コード例 #1
0
        new internal static unsafe MonitoredRollingApplicationUpgradePolicyDescription FromNative(IntPtr policyPtr)
        {
            if (policyPtr == IntPtr.Zero)
            {
                return(null);
            }

            var castedPtr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION *)policyPtr;

            var monitoringPolicy = new MonitoredRollingApplicationUpgradePolicyDescription();

            if (castedPtr->Reserved != IntPtr.Zero)
            {
                var castedEx1Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX1 *)castedPtr->Reserved;
                if (castedEx1Ptr->MonitoringPolicy != IntPtr.Zero)
                {
                    monitoringPolicy.MonitoringPolicy = RollingUpgradeMonitoringPolicy.FromNative(castedEx1Ptr->MonitoringPolicy);
                }

                if (castedEx1Ptr->HealthPolicy != IntPtr.Zero)
                {
                    monitoringPolicy.HealthPolicy = ApplicationHealthPolicy.FromNative(castedEx1Ptr->HealthPolicy);
                }
            }

            monitoringPolicy.FromNativeHelper(policyPtr);

            return(monitoringPolicy);
        }
        new internal static unsafe MonitoredRollingFabricUpgradePolicyDescription FromNative(IntPtr policyPtr)
        {
            if (policyPtr == IntPtr.Zero)
            {
                return(null);
            }

            var castedPtr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION *)policyPtr;

            var monitoringPolicy = new MonitoredRollingFabricUpgradePolicyDescription();

            if (castedPtr->Reserved != IntPtr.Zero)
            {
                var castedEx1Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX1 *)castedPtr->Reserved;
                if (castedEx1Ptr->MonitoringPolicy != IntPtr.Zero)
                {
                    monitoringPolicy.MonitoringPolicy = RollingUpgradeMonitoringPolicy.FromNative(castedEx1Ptr->MonitoringPolicy);
                }

                if (castedEx1Ptr->HealthPolicy != IntPtr.Zero)
                {
                    monitoringPolicy.HealthPolicy = ClusterHealthPolicy.FromNative(castedEx1Ptr->HealthPolicy);
                }

                if (castedEx1Ptr->Reserved != IntPtr.Zero)
                {
                    var castedEx2Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX2 *)castedEx1Ptr->Reserved;
                    monitoringPolicy.EnableDeltaHealthEvaluation = NativeTypes.FromBOOLEAN(castedEx2Ptr->EnableDeltaHealthEvaluation);

                    if (castedEx2Ptr->UpgradeHealthPolicy != IntPtr.Zero)
                    {
                        monitoringPolicy.UpgradeHealthPolicy = ClusterUpgradeHealthPolicy.FromNative(castedEx2Ptr->UpgradeHealthPolicy);
                    }

                    if (castedEx2Ptr->Reserved != IntPtr.Zero)
                    {
                        var castedEx3Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX3 *)castedEx2Ptr->Reserved;

                        if (castedEx3Ptr->ApplicationHealthPolicyMap != IntPtr.Zero)
                        {
                            monitoringPolicy.ApplicationHealthPolicyMap.FromNative(castedEx3Ptr->ApplicationHealthPolicyMap);
                        }
                    }
                }
            }

            monitoringPolicy.FromNativeHelper(policyPtr);

            return(monitoringPolicy);
        }
コード例 #3
0
 // For unit tests
 internal static bool AreEqual(RollingUpgradeMonitoringPolicy left, RollingUpgradeMonitoringPolicy right)
 {
     if (left != null && right != null)
     {
         return
             (left.FailureAction == right.FailureAction &&
              left.HealthCheckWaitDuration == right.HealthCheckWaitDuration &&
              left.HealthCheckStableDuration == right.HealthCheckStableDuration &&
              left.HealthCheckRetryTimeout == right.HealthCheckRetryTimeout &&
              left.UpgradeTimeout == right.UpgradeTimeout &&
              left.UpgradeDomainTimeout == right.UpgradeDomainTimeout);
     }
     else
     {
         return(left == null && right == null);
     }
 }
コード例 #4
0
        internal static unsafe RollingUpgradeMonitoringPolicy FromNative(IntPtr nativePolicyPtr)
        {
            if (nativePolicyPtr == IntPtr.Zero)
            {
                return(null);
            }

            var managedPolicy = new RollingUpgradeMonitoringPolicy();
            var nativePolicy  = (NativeTypes.FABRIC_ROLLING_UPGRADE_MONITORING_POLICY *)nativePolicyPtr;

            managedPolicy.FailureAction           = (UpgradeFailureAction)nativePolicy->FailureAction;
            managedPolicy.HealthCheckWaitDuration = FromNativeTimeInSeconds(nativePolicy->HealthCheckWaitDurationInSeconds);
            managedPolicy.HealthCheckRetryTimeout = FromNativeTimeInSeconds(nativePolicy->HealthCheckRetryTimeoutInSeconds);
            managedPolicy.UpgradeTimeout          = FromNativeTimeInSeconds(nativePolicy->UpgradeTimeoutInSeconds);
            managedPolicy.UpgradeDomainTimeout    = FromNativeTimeInSeconds(nativePolicy->UpgradeDomainTimeoutInSeconds);

            if (nativePolicy->Reserved != IntPtr.Zero)
            {
                var ex1Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_MONITORING_POLICY_EX1 *)nativePolicy->Reserved;
                managedPolicy.HealthCheckStableDuration = FromNativeTimeInSeconds(ex1Ptr->HealthCheckStableDurationInSeconds);
            }

            return(managedPolicy);
        }
コード例 #5
0
        internal UInt32 FromUpdateDescription(UpgradeUpdateDescriptionBase updateDescription)
        {
            UInt32 flags = 0;

            var monitoringPolicy = new RollingUpgradeMonitoringPolicy();

            if (updateDescription.UpgradeMode.HasValue)
            {
                flags           |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_UPGRADE_MODE;
                this.UpgradeMode = updateDescription.UpgradeMode.Value;
            }

            if (updateDescription.ForceRestart.HasValue)
            {
                flags            |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_FORCE_RESTART;
                this.ForceRestart = updateDescription.ForceRestart.Value;
            }

            if (updateDescription.UpgradeReplicaSetCheckTimeout.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_REPLICA_SET_CHECK_TIMEOUT;
                this.UpgradeReplicaSetCheckTimeout = updateDescription.UpgradeReplicaSetCheckTimeout.Value;
            }

            if (updateDescription.FailureAction.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_FAILURE_ACTION;
                monitoringPolicy.FailureAction = updateDescription.FailureAction.Value;
            }

            if (updateDescription.HealthCheckWaitDuration.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_HEALTH_CHECK_WAIT;
                monitoringPolicy.HealthCheckWaitDuration = updateDescription.HealthCheckWaitDuration.Value;
            }

            if (updateDescription.HealthCheckStableDuration.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_HEALTH_CHECK_STABLE;
                monitoringPolicy.HealthCheckStableDuration = updateDescription.HealthCheckStableDuration.Value;
            }

            if (updateDescription.HealthCheckRetryTimeout.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_HEALTH_CHECK_RETRY;
                monitoringPolicy.HealthCheckRetryTimeout = updateDescription.HealthCheckRetryTimeout.Value;
            }

            if (updateDescription.UpgradeTimeout.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_UPGRADE_TIMEOUT;
                monitoringPolicy.UpgradeTimeout = updateDescription.UpgradeTimeout.Value;
            }

            if (updateDescription.UpgradeDomainTimeout.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_UPGRADE_DOMAIN_TIMEOUT;
                monitoringPolicy.UpgradeDomainTimeout = updateDescription.UpgradeDomainTimeout.Value;
            }

            // Flags will determine whether any values are actually used
            //
            this.MonitoringPolicy = monitoringPolicy;

            return(flags);
        }