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);
        }
        internal IntPtr ToNative(PinCollection pinCollection)
        {
            UInt32 flags = 0;

            var policyDescription = new MonitoredRollingFabricUpgradePolicyDescription();

            flags = policyDescription.FromUpdateDescription(this);

            if (this.HealthPolicy != null)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_HEALTH_POLICY;
                policyDescription.HealthPolicy = this.HealthPolicy;
            }

            if (this.EnableDeltaHealthEvaluation.HasValue)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_ENABLE_DELTAS;
                policyDescription.EnableDeltaHealthEvaluation = this.EnableDeltaHealthEvaluation.Value;
            }

            if (this.UpgradeHealthPolicy != null)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_UPGRADE_HEALTH_POLICY;
                policyDescription.UpgradeHealthPolicy = this.UpgradeHealthPolicy;
            }

            if (this.ApplicationHealthPolicyMap != null)
            {
                flags |= (UInt32)NativeTypes.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS.FABRIC_ROLLING_UPGRADE_UPDATE_FLAGS_UPGRADE_APPLICATION_HEALTH_POLICY_MAP;
                policyDescription.ApplicationHealthPolicyMap = this.ApplicationHealthPolicyMap;
            }

            var nativeDescription = new NativeTypes.FABRIC_UPGRADE_UPDATE_DESCRIPTION();

            nativeDescription.UpgradeKind = NativeTypes.FABRIC_UPGRADE_KIND.FABRIC_UPGRADE_KIND_ROLLING;
            nativeDescription.UpdateFlags = flags;
            nativeDescription.UpgradePolicyDescription = policyDescription.ToNative(pinCollection);

            return(pinCollection.AddBlittable(nativeDescription));
        }
Ejemplo n.º 3
0
        internal static unsafe FabricUpgradeDescription FromNative(IntPtr descriptionPtr)
        {
            if (descriptionPtr == IntPtr.Zero)
            {
                return(null);
            }

            var castedPtr = (NativeTypes.FABRIC_UPGRADE_DESCRIPTION *)descriptionPtr;

            var description = new FabricUpgradeDescription();

            description.TargetCodeVersion = NativeTypes.FromNativeString(castedPtr->CodeVersion);

            description.TargetConfigVersion = NativeTypes.FromNativeString(castedPtr->ConfigVersion);

            if (castedPtr->UpgradeKind == NativeTypes.FABRIC_UPGRADE_KIND.FABRIC_UPGRADE_KIND_ROLLING &&
                castedPtr->UpgradePolicyDescription != IntPtr.Zero)
            {
                RollingUpgradePolicyDescription policy = null;

                var castedPolicyPtr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION *)castedPtr->UpgradePolicyDescription;

                if (castedPolicyPtr->RollingUpgradeMode == NativeTypes.FABRIC_ROLLING_UPGRADE_MODE.FABRIC_ROLLING_UPGRADE_MODE_MONITORED)
                {
                    policy = MonitoredRollingFabricUpgradePolicyDescription.FromNative(castedPtr->UpgradePolicyDescription);
                }
                else
                {
                    policy = RollingUpgradePolicyDescription.FromNative(castedPtr->UpgradePolicyDescription);
                }

                description.UpgradePolicyDescription = policy;
            }

            return(description);
        }