コード例 #1
0
            public bool ProcessLatestNode(PaasNodeStatusInfo latestNode)
            {
                ReleaseAssert.AssertIfNot(
                    this.Node.NodeName.Equals(latestNode.NodeName), "Existing NodeName {0} does not match new name {1}",
                    this.Node.NodeName,
                    latestNode.NodeName);

                if (!this.Node.Equals(latestNode))
                {
                    var oldNode = this.Node;

                    this.Node = latestNode;
                    this.Node.IntentionInstance++;
                    this.IsProcessedByWRP = false;

                    Trace.WriteInfo(
                        TraceType,
                        "Updating NodeStatus. Old: {0}, Updated: {1}",
                        oldNode,
                        this.Node);

                    return(true);
                }

                return(false);
            }
コード例 #2
0
        public async Task EnableNodeAsync(PaasNodeStatusInfo nodeToEnable, TimeSpan timeout, CancellationToken cancellationToken)
        {
            Trace.WriteInfo(TraceType, "Calling ActivateNode for {0}", nodeToEnable.NodeName);

            var timeoutHelper = new TimeoutHelper(timeout, Constants.MaxOperationTimeout);

            await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync(
                () => this.FabricClient.ClusterManager.ActivateNodeAsync(
                    nodeToEnable.NodeName,
                    timeoutHelper.GetOperationTimeout(),
                    cancellationToken),
                timeoutHelper.GetOperationTimeout(),
                cancellationToken);
        }
コード例 #3
0
        private bool ProcessNodeQueryInternal(List <UpgradeServiceNodeState> currentUpgradeServiceNodeStates, NodeList queryNodes)
        {
            if (queryNodes == null)
            {
                return(false);
            }

            bool shouldUpdate = false;

            foreach (var queryNode in queryNodes)
            {
                var latestNodeStatusInfo = new PaasNodeStatusInfo(queryNode);

                var matchingUpgradeServiceNodeState = currentUpgradeServiceNodeStates.FirstOrDefault(
                    nodeState => nodeState.Node.NodeName.Equals(latestNodeStatusInfo.NodeName));
                if (matchingUpgradeServiceNodeState == null)
                {
                    Trace.WriteInfo(
                        TraceType,
                        "{0} is added newly in NodeStatus",
                        latestNodeStatusInfo);

                    // New node in the query.
                    // Add it to the nodeStates so that it will be reported to WRP
                    // This is done to handle proper fuctioning of FabricUS even after data loss
                    currentUpgradeServiceNodeStates.Add(new UpgradeServiceNodeState(latestNodeStatusInfo));
                    shouldUpdate = true;
                    continue;
                }

                if (matchingUpgradeServiceNodeState.ProcessLatestNode(latestNodeStatusInfo))
                {
                    shouldUpdate = true;
                }
            }

            return(shouldUpdate);
        }
コード例 #4
0
        private async Task <IOperationStatus> BuildStatusAsync(ClusterOperationDescription description, IOperationContext context, ClusterErrorDetails errorDetails)
        {
            var upgradeProgressTask = this.fabricClientWrapper.GetFabricUpgradeProgressAsync(Constants.MaxOperationTimeout, context.CancellationToken);

            var nodeListQueryTask = this.fabricClientWrapper.GetNodeListAsync(Constants.MaxOperationTimeout, context.CancellationToken);

            // Only query for system services when WRP needs to adjust the replica set size
            Task <Dictionary <string, ServiceRuntimeDescription> > systemServiceSizeQueryTask = null;

            if (description != null &&
                description.SystemServiceDescriptionsToSet != null &&
                description.SystemServiceDescriptionsToSet.Any())
            {
                systemServiceSizeQueryTask =
                    this.fabricClientWrapper.GetSystemServiceRuntimeDescriptionsAsync(Constants.MaxOperationTimeout, context.CancellationToken);
            }

            await Task.WhenAll(
                nodeListQueryTask,
                upgradeProgressTask,
                systemServiceSizeQueryTask ?? Task.FromResult <Dictionary <string, ServiceRuntimeDescription> >(null));

            FabricUpgradeProgress currentUpgradeProgress = GetResultFromTask(upgradeProgressTask);
            NodeList nodeList = FilterPrimaryNodeTypesStatus(GetResultFromTask(nodeListQueryTask), description?.PrimaryNodeTypes);
            Dictionary <string, ServiceRuntimeDescription> systemServicesRuntimeDescriptions = GetResultFromTask(systemServiceSizeQueryTask);

            List <PaasNodeStatusInfo> nodesDisabled = null;
            List <PaasNodeStatusInfo> nodesEnabled  = null;

            if (description != null &&
                nodeList != null)
            {
                Trace.WriteNoise(TraceType, "BuildStatusAsync: Begin this.nodeStatusManager.ProcessNodeQuery.");
                await this.nodeStatusManager.ProcessNodeQuery(nodeList, Constants.KvsCommitTimeout, context.CancellationToken);

                Trace.WriteNoise(TraceType, "BuildStatusAsync: End this.nodeStatusManager.ProcessNodeQuery.");

                // Send back the list of nodes that are disabled
                if (description.NodesToDisabled != null)
                {
                    nodesDisabled = new List <PaasNodeStatusInfo>();

                    // Send back the Instance# for the requested disabled nodes
                    foreach (var nodeToDisable in description.NodesToDisabled)
                    {
                        var matchingNodeStatus =
                            nodeList.FirstOrDefault(
                                node =>
                                string.Equals(node.NodeName, nodeToDisable.NodeName,
                                              StringComparison.OrdinalIgnoreCase));
                        if (matchingNodeStatus != null && matchingNodeStatus.NodeStatus == NodeStatus.Disabled)
                        {
                            var nodeDisabled = new PaasNodeStatusInfo(nodeToDisable)
                            {
                                NodeState = NodeState.Disabled
                            };

                            nodesDisabled.Add(nodeDisabled);

                            Trace.WriteInfo(TraceType, "BuildStatusAsync: Node has been successfully disabled. {0}", nodeDisabled);
                        }
                    }
                }

                // Send back the list of nodes that are Enabled
                if (description.NodesToEnabled != null)
                {
                    nodesEnabled = new List <PaasNodeStatusInfo>();

                    // Send back the Instance# for the requested up nodes
                    foreach (var nodeToEnable in description.NodesToEnabled)
                    {
                        var matchingNodeStatus =
                            nodeList.FirstOrDefault(
                                node =>
                                string.Equals(node.NodeName, nodeToEnable.NodeName,
                                              StringComparison.OrdinalIgnoreCase));

                        // Since a node can be enabled and can still be down, we infer enabled status instead.
                        if (matchingNodeStatus != null &&
                            (matchingNodeStatus.NodeStatus != NodeStatus.Disabling) &&
                            (matchingNodeStatus.NodeStatus != NodeStatus.Disabled) &&
                            (matchingNodeStatus.NodeStatus != NodeStatus.Enabling))
                        {
                            var nodeEnabled = new PaasNodeStatusInfo(nodeToEnable);
                            nodeEnabled.NodeState = NodeState.Enabled;

                            nodesEnabled.Add(nodeEnabled);

                            Trace.WriteInfo(TraceType, "BuildStatusAsync: Node has been successfully enabled. {0}", nodeEnabled);
                        }
                    }
                }
            }

            Trace.WriteNoise(TraceType, "BuildStatusAsync: Begin this.nodeStatusManager.GetNodeStates.");
            var nodesStatus = await this.nodeStatusManager.GetNodeStates(Constants.KvsCommitTimeout, context.CancellationToken);

            Trace.WriteNoise(TraceType, "BuildStatusAsync: End this.nodeStatusManager.GetNodeStates.");

            var status = new ClusterOperationStatus(description)
            {
                DisabledNodes             = nodesDisabled,
                EnabledNodes              = nodesEnabled,
                NodesStatus               = nodesStatus,
                SystemServiceDescriptions = systemServicesRuntimeDescriptions,
            };

            if (currentUpgradeProgress != null)
            {
                status.Progress = JObject.FromObject(currentUpgradeProgress, this.serializer);
            }

            if (errorDetails != null)
            {
                status.ErrorDetails = JObject.FromObject(errorDetails, this.serializer);
            }

            return(status);
        }
コード例 #5
0
 public UpgradeServiceNodeState(PaasNodeStatusInfo node)
 {
     this.IsProcessedByWRP       = false;
     this.Node                   = node;
     this.Node.IntentionInstance = DateTime.Now.Ticks;
 }