Ejemplo n.º 1
0
        internal static unsafe ComposeDeploymentUpgradeProgress CreateFromNative(
            NativeClient.IFabricComposeDeploymentUpgradeProgressResult nativeResult)
        {
            ComposeDeploymentUpgradeProgress result = new ComposeDeploymentUpgradeProgress();
            IntPtr upgradeProgressPtr = nativeResult.get_UpgradeProgress();

            if (upgradeProgressPtr != IntPtr.Zero)
            {
                var castedUpgradeProgressPtr = (NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_PROGRESS *)upgradeProgressPtr;

                result.ApplicationName = NativeTypes.FromNativeUri(castedUpgradeProgressPtr->ApplicationName);
                result.DeploymentName  = NativeTypes.FromNativeString(castedUpgradeProgressPtr->DeploymentName);

                // Upgrade policy
                if (castedUpgradeProgressPtr->UpgradePolicyDescription != IntPtr.Zero)
                {
                    RollingUpgradePolicyDescription policy = null;

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

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

                    result.UpgradePolicyDescription = policy;
                }

                result.TargetApplicationTypeVersion = NativeTypes.FromNativeString(castedUpgradeProgressPtr->TargetApplicationTypeVersion);

                switch (castedUpgradeProgressPtr->UpgradeState)
                {
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_PROVISIONING_TARGET:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_ROLLING_FORWARD_IN_PROGRESS:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_ROLLING_FORWARD_PENDING:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_UNPROVISIONING_CURRENT:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_ROLLING_FORWARD_COMPLETED:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_ROLLING_BACK_IN_PROGRESS:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_UNPROVISIONING_TARGET:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_ROLLING_BACK_COMPLETED:
                case NativeTypes.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE.FABRIC_COMPOSE_DEPLOYMENT_UPGRADE_STATE_FAILED:
                    result.UpgradeState = (ComposeDeploymentUpgradeState)castedUpgradeProgressPtr->UpgradeState;
                    break;

                default:
                    result.UpgradeState = ComposeDeploymentUpgradeState.Invalid;
                    break;
                }

                result.NextUpgradeDomain = NativeTypes.FromNativeString(castedUpgradeProgressPtr->NextUpgradeDomain);
                if (castedUpgradeProgressPtr->UpgradeDomains != IntPtr.Zero)
                {
                    var  upgradeDomainsPtr = (NativeTypes.FABRIC_UPGRADE_DOMAIN_STATUS_DESCRIPTION_LIST *)castedUpgradeProgressPtr->UpgradeDomains;
                    uint count             = upgradeDomainsPtr->Count;
                    result.UpgradeDomains = Interop.InteropHelpers.UpgradeDomainHelper.CreateUpgradeDomainsFromNative(count, upgradeDomainsPtr->Items);
                }

                result.UpgradeDuration = TimeSpan.FromSeconds(castedUpgradeProgressPtr->UpgradeDurationInSeconds);
                result.CurrentUpgradeDomainDuration    = TimeSpan.FromSeconds(castedUpgradeProgressPtr->CurrentUpgradeDomainDurationInSeconds);
                result.ApplicationUnhealthyEvaluations = HealthEvaluation.FromNativeList(castedUpgradeProgressPtr->ApplicationUnhealthyEvaluations);
                result.CurrentUpgradeDomainProgress    = UpgradeDomainProgress.FromNative(castedUpgradeProgressPtr->CurrentUpgradeDomainProgress);
                result.StartTimestampUtc   = NativeTypes.FromNullableNativeFILETIME(castedUpgradeProgressPtr->StartTimestampUtc);
                result.FailureTimestampUtc = NativeTypes.FromNullableNativeFILETIME(castedUpgradeProgressPtr->FailureTimestampUtc);

                if (result.FailureTimestampUtc.HasValue)
                {
                    switch (castedUpgradeProgressPtr->FailureReason)
                    {
                    case NativeTypes.FABRIC_UPGRADE_FAILURE_REASON.FABRIC_UPGRADE_FAILURE_REASON_INTERRUPTED:
                    case NativeTypes.FABRIC_UPGRADE_FAILURE_REASON.FABRIC_UPGRADE_FAILURE_REASON_HEALTH_CHECK:
                    case NativeTypes.FABRIC_UPGRADE_FAILURE_REASON.FABRIC_UPGRADE_FAILURE_REASON_UPGRADE_DOMAIN_TIMEOUT:
                    case NativeTypes.FABRIC_UPGRADE_FAILURE_REASON.FABRIC_UPGRADE_FAILURE_REASON_OVERALL_UPGRADE_TIMEOUT:
                    case NativeTypes.FABRIC_UPGRADE_FAILURE_REASON.FABRIC_UPGRADE_FAILURE_REASON_PROCESSING_FAILURE:
                        result.FailureReason = (UpgradeFailureReason)castedUpgradeProgressPtr->FailureReason;
                        break;

                    default:
                        result.FailureReason = UpgradeFailureReason.None;
                        break;
                    }

                    result.UpgradeDomainProgressAtFailure = UpgradeDomainProgress.FromNative(castedUpgradeProgressPtr->UpgradeDomainProgressAtFailure);
                }

                result.ApplicationUpgradeStatusDetails = NativeTypes.FromNativeString(castedUpgradeProgressPtr->ApplicationUpgradeStatusDetails);
                result.UpgradeStatusDetails            = NativeTypes.FromNativeString(castedUpgradeProgressPtr->UpgradeStatusDetails);
            }

            return(result);
        }
 private ComposeDeploymentUpgradeProgress GetComposeDeploymentUpgradeProgressEndWrapper(NativeCommon.IFabricAsyncOperationContext context)
 {
     return(ComposeDeploymentUpgradeProgress.CreateFromNative(this.internalNativeApplicationClient.EndGetComposeDeploymentUpgradeProgress(context)));
 }