internal static unsafe PartitionHealthState FromNative(NativeTypes.FABRIC_PARTITION_HEALTH_STATE nativeState)
        {
            var partitionHealthState = new PartitionHealthState();

            partitionHealthState.PartitionId           = nativeState.PartitionId;
            partitionHealthState.AggregatedHealthState = (HealthState)nativeState.AggregatedHealthState;

            return(partitionHealthState);
        }
Example #2
0
        private static unsafe ServiceHealth FromNative(NativeTypes.FABRIC_SERVICE_HEALTH *nativeHealth)
        {
            var managedHealth = new ServiceHealth();

            managedHealth.AggregatedHealthState = (HealthState)nativeHealth->AggregatedHealthState;
            managedHealth.HealthEvents          = HealthEvent.FromNativeList(nativeHealth->HealthEvents);
            managedHealth.ServiceName           = NativeTypes.FromNativeUri(nativeHealth->ServiceName);
            managedHealth.PartitionHealthStates = PartitionHealthState.FromNativeList(nativeHealth->PartitionHealthStates);

            if (nativeHealth->Reserved != IntPtr.Zero)
            {
                var nativeHealthEx1 = (NativeTypes.FABRIC_SERVICE_HEALTH_EX1 *)nativeHealth->Reserved;
                managedHealth.UnhealthyEvaluations = HealthEvaluation.FromNativeList(nativeHealthEx1->UnhealthyEvaluations);

                if (nativeHealthEx1->Reserved != IntPtr.Zero)
                {
                    var nativeHealthEx2 = (NativeTypes.FABRIC_SERVICE_HEALTH_EX2 *)nativeHealthEx1->Reserved;
                    managedHealth.HealthStatistics = HealthStatistics.CreateFromNative(nativeHealthEx2->HealthStatistics);
                }
            }

            return(managedHealth);
        }