Esempio n. 1
0
 private static unsafe ReplicaHealth FromNative(NativeTypes.FABRIC_REPLICA_HEALTH *nativeHealth)
 {
     if (nativeHealth->Kind == NativeTypes.FABRIC_SERVICE_KIND.FABRIC_SERVICE_KIND_STATELESS)
     {
         return(StatelessServiceInstanceHealth.FromNative((NativeTypes.FABRIC_STATELESS_SERVICE_INSTANCE_HEALTH *)nativeHealth->Value));
     }
     else if (nativeHealth->Kind == NativeTypes.FABRIC_SERVICE_KIND.FABRIC_SERVICE_KIND_STATEFUL)
     {
         return(StatefulServiceReplicaHealth.FromNative((NativeTypes.FABRIC_STATEFUL_SERVICE_REPLICA_HEALTH *)nativeHealth->Value));
     }
     else
     {
         AppTrace.TraceSource.WriteError("ReplicaHealth.FromNative", "Unknown service kind: {0}", nativeHealth->Kind);
         ReleaseAssert.Failfast(string.Format(CultureInfo.CurrentCulture, StringResources.Error_ServiceKindInvalid_Formatted, nativeHealth->Kind));
         return(null);
     }
 }
Esempio n. 2
0
        internal static unsafe StatefulServiceReplicaHealth FromNative(NativeTypes.FABRIC_STATEFUL_SERVICE_REPLICA_HEALTH *nativeHealth)
        {
            var managedHealth = new StatefulServiceReplicaHealth();

            managedHealth.AggregatedHealthState = (HealthState)nativeHealth->AggregatedHealthState;
            managedHealth.HealthEvents          = HealthEvent.FromNativeList(nativeHealth->HealthEvents);
            managedHealth.PartitionId           = nativeHealth->PartitionId;
            managedHealth.Id = nativeHealth->ReplicaId;

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

            return(managedHealth);
        }