internal static ClusterNodeConfig GetTargetNodeConfigAddNode(StandAloneClusterTopology topology, long version)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating TargetNodeConfig");
            List <Microsoft.ServiceFabric.ClusterManagementCommon.NodeStatus> nodeStatus = new List <Microsoft.ServiceFabric.ClusterManagementCommon.NodeStatus>();

            foreach (var nodeName in topology.Nodes.Keys)
            {
                nodeStatus.Add(
                    new Microsoft.ServiceFabric.ClusterManagementCommon.NodeStatus
                {
                    NodeName  = nodeName,
                    NodeType  = topology.Nodes[nodeName].NodeTypeRef,
                    NodeState = NodeState.Enabled,
                    NodeDeactivationIntent = WrpNodeDeactivationIntent.Invalid,
                    InstanceId             = 0
                });
            }

            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Setting NodeStatus for nodes {0}", string.Join(", ", nodeStatus.Select(node => node.NodeName).ToArray()));
            return(new ClusterNodeConfig
            {
                Version = version + 1,
                NodesStatus = nodeStatus
            });
        }
示例#2
0
        internal StandAloneClusterTopology GetClusterTopology()
        {
            var clusterTopology = new StandAloneClusterTopology()
            {
                Nodes    = new Dictionary <string, NodeDescription>(),
                Machines = new List <string>()
            };

            foreach (var node in this.Nodes)
            {
                if (!clusterTopology.Nodes.Any(n => n.Key == node.NodeName))
                {
                    clusterTopology.Nodes.Add(node.NodeName, node.ConvertToInternal());
                }
                else
                {
                    throw new ValidationException(ClusterManagementErrorCode.NodeNameDuplicateDetected, StringResources.NodeNameDuplicateDetected);
                }
            }

            clusterTopology.Machines = clusterTopology.Nodes.Values.Select <NodeDescription, string>(nd => nd.IPAddress).Distinct().ToList();
            return(clusterTopology);
        }