Esempio n. 1
0
 internal DeployedApplicationHealth(
     System.Fabric.Health.DeployedApplicationHealth health)
     : base(health)
 {
     this.ApplicationName = health.ApplicationName.OriginalString;
     this.NodeName        = health.NodeName;
     this.DeployedServicePackageHealthStates =
         health.DeployedServicePackageHealthStates
         .Select(state => new DeployedServicePackageHealthState(
                     state.ApplicationName.OriginalString,
                     state.ServiceManifestName,
                     state.NodeName,
                     state.AggregatedHealthState));
 }
        private static unsafe DeployedApplicationHealth FromNative(NativeTypes.FABRIC_DEPLOYED_APPLICATION_HEALTH *nativeHealth)
        {
            var managedHealth = new DeployedApplicationHealth();

            managedHealth.AggregatedHealthState = (HealthState)nativeHealth->AggregatedHealthState;
            managedHealth.HealthEvents          = HealthEvent.FromNativeList(nativeHealth->HealthEvents);
            managedHealth.ApplicationName       = NativeTypes.FromNativeUri(nativeHealth->ApplicationName);
            managedHealth.NodeName = NativeTypes.FromNativeString(nativeHealth->NodeName);
            managedHealth.DeployedServicePackageHealthStates = DeployedServicePackageHealthState.FromNativeList(nativeHealth->DeployedServicePackageHealthStates);

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

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

            return(managedHealth);
        }