Exemplo n.º 1
0
        protected override ClusterManifestTypeInfrastructure OnSortInfrastructure(ClusterManifestTypeInfrastructure infrastructure)
        {
            var infra = (ClusterManifestTypeInfrastructureWindowsServer)infrastructure.Item;

            infra.NodeList = infra.NodeList.OrderBy(node => node.NodeName).ToArray();
            return(infrastructure);
        }
Exemplo n.º 2
0
        protected override void UpdateEndpointPortsForScaleMin(ClusterManifestTypeInfrastructure infrastructure, ClusterManifestTypeNodeType[] nodeTypes, List <NodeTypeDescription> targetNodeTypes)
        {
            var infra = (ClusterManifestTypeInfrastructureWindowsServer)infrastructure.Item;

            if (!infra.IsScaleMin)
            {
                return;
            }

            if (targetNodeTypes[0].ClusterConnectionEndpointPort != 0)
            {
                return;
            }

            var clusterConnectionEndpointPort = int.Parse(nodeTypes[0].Endpoints.ClusterConnectionEndpoint.Port);
            var serviceConnectionEndpointPort = int.Parse(nodeTypes[0].Endpoints.ServiceConnectionEndpoint.Port);
            var leaseDriverEndpointPort       = int.Parse(nodeTypes[0].Endpoints.ServiceConnectionEndpoint.Port);

            for (int i = 1; i < nodeTypes.Length; i++)
            {
                clusterConnectionEndpointPort = clusterConnectionEndpointPort + 2;
                serviceConnectionEndpointPort = serviceConnectionEndpointPort + 2;
                leaseDriverEndpointPort       = leaseDriverEndpointPort + 2;

                nodeTypes[i].Endpoints.ClusterConnectionEndpoint.Port = clusterConnectionEndpointPort.ToString(CultureInfo.InvariantCulture);
                nodeTypes[i].Endpoints.LeaseDriverEndpoint.Port       = leaseDriverEndpointPort.ToString(CultureInfo.InvariantCulture);
                nodeTypes[i].Endpoints.ServiceConnectionEndpoint.Port = serviceConnectionEndpointPort.ToString(CultureInfo.InvariantCulture);
            }
        }
Exemplo n.º 3
0
 private static void VerifyAreEqual(ClusterManifestTypeInfrastructure infra1, ClusterManifestTypeInfrastructure infra2)
 {
     Assert.AreEqual(infra1.Item.GetType(), infra2.Item.GetType());
     if (infra1.Item is ClusterManifestTypeInfrastructureWindowsServer)
     {
         var infrastructure1 = infra1.Item as ClusterManifestTypeInfrastructureWindowsServer;
         var infrastructure2 = infra2.Item as ClusterManifestTypeInfrastructureWindowsServer;
         VerifyAreEqual(infrastructure1, infrastructure2);
     }
 }
        public AzureInfrastructure(ClusterManifestTypeInfrastructure cmInfrastructure, InfrastructureNodeType[] inputInfrastructureNodes, Dictionary <string, ClusterManifestTypeNodeType> nameToNodeTypeMap)
        {
            ReleaseAssert.AssertIfNull(cmInfrastructure, "cmInfrastructure");
            ReleaseAssert.AssertIfNull(nameToNodeTypeMap, "nameToNodeTypeMap");

            this.votes = new List <SettingsTypeSectionParameter>();
            this.seedNodeClientConnectionAddresses = new List <SettingsTypeSectionParameter>();
            this.voteMappings = new Dictionary <string, string>();
            this.nodes        = new List <InfrastructureNodeType>();

            TopologyProvider.TopologyProviderType topologyProviderType = TopologyProvider.GetTopologyProviderTypeFromClusterManifestTypeInfrastructure(cmInfrastructure);

            if (topologyProviderType == TopologyProvider.TopologyProviderType.ServiceRuntimeTopologyProvider)
            {
                this.InitializeFromServiceRuntimeTopologyProvider(cmInfrastructure.Item as ClusterManifestTypeInfrastructureWindowsAzure, inputInfrastructureNodes, nameToNodeTypeMap);
            }
            else if (topologyProviderType == TopologyProvider.TopologyProviderType.StaticTopologyProvider)
            {
                this.InitializeFromStaticTopologyProvider(cmInfrastructure.Item as ClusterManifestTypeInfrastructureWindowsAzureStaticTopology, inputInfrastructureNodes, nameToNodeTypeMap);
            }
        }
Exemplo n.º 5
0
        public static Infrastructure Create(ClusterManifestTypeInfrastructure cmInfrastructure, InfrastructureNodeType[] infrastructureNodes, ClusterManifestTypeNodeType[] nodeTypes)
        {
            Dictionary <string, ClusterManifestTypeNodeType> nameToNodeTypeMap = new Dictionary <string, ClusterManifestTypeNodeType>();

            foreach (var nodeType in nodeTypes)
            {
                try
                {
                    nameToNodeTypeMap.Add(nodeType.Name, nodeType);
                }
                catch (ArgumentException)
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Node type name {0} is duplicate", nodeType.Name));
                }
            }
#if DotNetCoreClrLinux
            if (cmInfrastructure.Item is ClusterManifestTypeInfrastructureLinux)
#else
            if (cmInfrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer)
#endif
            {
                return(new ServerInfrastructure(cmInfrastructure, infrastructureNodes, nameToNodeTypeMap));
            }
            else if (cmInfrastructure.Item is ClusterManifestTypeInfrastructureWindowsAzure)
            {
                return(new AzureInfrastructure(cmInfrastructure, infrastructureNodes, nameToNodeTypeMap));
            }
            else if (cmInfrastructure.Item is ClusterManifestTypeInfrastructureWindowsAzureStaticTopology)
            {
                return(new AzureInfrastructure(cmInfrastructure, infrastructureNodes, nameToNodeTypeMap, GetDynamicTopologyKindIntValue()));
            }
            else if (cmInfrastructure.Item is ClusterManifestTypeInfrastructurePaaS)
            {
                return(new PaasInfrastructure(cmInfrastructure, infrastructureNodes, nameToNodeTypeMap));
            }
            else
            {
                return(null);
            }
        }
 protected override ClusterManifestTypeInfrastructure OnSortInfrastructure(ClusterManifestTypeInfrastructure infrastructure)
 {
     return(infrastructure);
 }
Exemplo n.º 7
0
 public FabricValidatorAzure(ClusterManifestType clusterManifest, List <InfrastructureNodeType> infrastructureInformation, WindowsFabricSettings windowsFabricSettings)
     : base(clusterManifest, infrastructureInformation, windowsFabricSettings)
 {
     this.infrastructure = clusterManifest.Infrastructure;
     this.IsScaleMin     = infrastructureInformation != null && FabricValidatorUtility.IsNodeListScaleMin(this.infrastructureInformation);
 }
Exemplo n.º 8
0
        public static TopologyProviderType GetTopologyProviderTypeFromClusterManifestTypeInfrastructure(ClusterManifestTypeInfrastructure clusterManifestTypeInfrastructure)
        {
            if (clusterManifestTypeInfrastructure == null || clusterManifestTypeInfrastructure.Item == null)
            {
                return(TopologyProviderType.NotApplicable);
            }

            if (clusterManifestTypeInfrastructure.Item is ClusterManifestTypeInfrastructureWindowsAzure)
            {
                return(TopologyProviderType.ServiceRuntimeTopologyProvider);
            }

            if (clusterManifestTypeInfrastructure.Item is ClusterManifestTypeInfrastructureWindowsAzureStaticTopology)
            {
                return(TopologyProviderType.StaticTopologyProvider);
            }

            return(TopologyProviderType.NotApplicable);
        }
 protected virtual void UpdateEndpointPortsForScaleMin(ClusterManifestTypeInfrastructure infrastructure, ClusterManifestTypeNodeType[] nodeTypes, List <NodeTypeDescription> targetNodeType)
 {
 }
Exemplo n.º 10
0
 protected abstract ClusterManifestTypeInfrastructure OnSortInfrastructure(ClusterManifestTypeInfrastructure infrastructure);
Exemplo n.º 11
0
        public PaasInfrastructure(ClusterManifestTypeInfrastructure cmInfrastructure, InfrastructureNodeType[] infrastructureNodes, Dictionary <string, ClusterManifestTypeNodeType> nameToNodeTypeMap)
        {
            this.votes = new List <SettingsTypeSectionParameter>();
            this.nodes = new List <InfrastructureNodeType>();
            this.seedNodeClientConnectionAddresses = new List <SettingsTypeSectionParameter>();

            ClusterManifestTypeInfrastructurePaaS infrastructure = cmInfrastructure.Item as ClusterManifestTypeInfrastructurePaaS;
            Dictionary <string, string>           roleToTypeMap  = new Dictionary <string, string>();

            foreach (var role in infrastructure.Roles)
            {
                try
                {
                    roleToTypeMap.Add(role.RoleName, role.NodeTypeRef);
                }
                catch (ArgumentException)
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Role name {0} is duplicate", role.RoleName));
                }
            }

            foreach (var nodeInfo in infrastructureNodes)
            {
                ClusterManifestTypeNodeType nodeType = null;
                if (!nameToNodeTypeMap.TryGetValue(nodeInfo.NodeTypeRef, out nodeType) || nodeType == null)
                {
                    continue;
                }

                var node = (new InfrastructureNodeType()
                {
                    Certificates = nodeType.Certificates,
                    Endpoints = nodeType.Endpoints,
                    FaultDomain = nodeInfo.FaultDomain,
                    IPAddressOrFQDN = nodeInfo.IPAddressOrFQDN,
                    IsSeedNode = nodeInfo.IsSeedNode,
                    NodeName = nodeInfo.NodeName,
                    NodeTypeRef = nodeInfo.NodeTypeRef,
                    RoleOrTierName = nodeInfo.NodeTypeRef,
                    UpgradeDomain = nodeInfo.UpgradeDomain
                });

                this.nodes.Add(node);

                if (node.IsSeedNode)
                {
                    string key = node.NodeName;
                    string clientConnectionAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", node.IPAddressOrFQDN, node.Endpoints.ClientConnectionEndpoint.Port);
                    this.seedNodeClientConnectionAddresses.Add(new SettingsTypeSectionParameter()
                    {
                        Name = key, Value = clientConnectionAddress, MustOverride = false
                    });
                    FabricValidator.TraceSource.WriteNoise(FabricValidatorUtility.TraceTag, "Seed Nodes {0}-{1} added", key, clientConnectionAddress);
                }
            }

            foreach (var vote in infrastructure.Votes)
            {
                string key = vote.NodeName;
                string connectionAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", vote.IPAddressOrFQDN, vote.Port);
                string value             = string.Format(CultureInfo.InvariantCulture, "{0},{1}", "SeedNode", connectionAddress);
                this.votes.Add(new SettingsTypeSectionParameter()
                {
                    Name = key, Value = value, MustOverride = false
                });
                FabricValidator.TraceSource.WriteNoise(FabricValidatorUtility.TraceTag, "Vote {0}-{1} added", key, value);
            }
        }
Exemplo n.º 12
0
        public ServerInfrastructure(ClusterManifestTypeInfrastructure cmInfrastructure, InfrastructureNodeType[] infrastructureNodes, Dictionary <string, ClusterManifestTypeNodeType> nameToNodeTypeMap)
        {
            this.votes = new List <SettingsTypeSectionParameter>();
            this.seedNodeClientConnectionAddresses = new List <SettingsTypeSectionParameter>();
            this.nodes = new List <InfrastructureNodeType>();
#if DotNetCoreClrLinux
            var infrastructure = cmInfrastructure.Item as ClusterManifestTypeInfrastructureLinux;
#else
            var infrastructure = cmInfrastructure.Item as ClusterManifestTypeInfrastructureWindowsServer;
#endif

            foreach (var nodeInfo in infrastructure.NodeList)
            {
                if (!nameToNodeTypeMap.ContainsKey(nodeInfo.NodeTypeRef))
                {
                    throw new ArgumentException(
                              string.Format(CultureInfo.InvariantCulture, "Node {0} has NodeType {1}, which is not present in node types definition", nodeInfo.NodeName, nodeInfo.NodeTypeRef));
                }

                var nodeType = nameToNodeTypeMap[nodeInfo.NodeTypeRef];
                var node     = (new InfrastructureNodeType()
                {
                    Certificates = nodeType.Certificates,
                    Endpoints = nodeType.Endpoints,
                    FaultDomain = nodeInfo.FaultDomain,
                    IPAddressOrFQDN = Helpers.isIPV6AddressAndNoBracket(nodeInfo.IPAddressOrFQDN) ?
                                      Helpers.AddBracketsAroundIPV6(nodeInfo.IPAddressOrFQDN) : nodeInfo.IPAddressOrFQDN,
                    IsSeedNode = nodeInfo.IsSeedNode,
                    NodeName = nodeInfo.NodeName,
                    NodeTypeRef = nodeInfo.NodeTypeRef,
                    RoleOrTierName = nodeInfo.NodeTypeRef,
                    UpgradeDomain = nodeInfo.UpgradeDomain
                });
                this.nodes.Add(node);
                if (node.IsSeedNode)
                {
                    string key = node.NodeName;
                    string connectionAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", node.IPAddressOrFQDN, node.Endpoints.ClusterConnectionEndpoint.Port);
                    string value             = string.Format(CultureInfo.InvariantCulture, "{0},{1}", "SeedNode", connectionAddress);
                    this.votes.Add(new SettingsTypeSectionParameter()
                    {
                        Name = key, Value = value, MustOverride = false
                    });
                    FabricValidator.TraceSource.WriteNoise(FabricValidatorUtility.TraceTag, "Vote {0}-{1} added", key, value);

                    string clientConnectionAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", node.IPAddressOrFQDN, node.Endpoints.ClientConnectionEndpoint.Port);
                    this.seedNodeClientConnectionAddresses.Add(new SettingsTypeSectionParameter()
                    {
                        Name = key, Value = clientConnectionAddress, MustOverride = false
                    });
                    FabricValidator.TraceSource.WriteNoise(FabricValidatorUtility.TraceTag, "Seed Nodes {0}-{1} added", key, clientConnectionAddress);
                }
            }

            if (infrastructureNodes != null)
            {
                foreach (var infraNode in infrastructureNodes)
                {
                    /* If the current machine node name is present in the infrastructure manifest but not present in the cluster manifest, then
                     * it should be added back to this.nodes */
                    if (this.nodes.Find(node => infraNode.NodeName == node.NodeName) == null &&
                        NetworkApiHelper.IsNodeForThisMachine(infraNode))
                    {
                        this.nodes.Add(infraNode);
                    }
                }
            }

            this.isScaleMin = infrastructure.IsScaleMin;
        }