예제 #1
0
        private void AddDomainIds(FabricNodeType fabricNode)
        {
            string nodeUpgradeDomain = fabricNode.UpgradeDomain;
            string nodeFaultDomain   = fabricNode.FaultDomain;

            List <SettingsTypeSectionParameter> parameters = new List <SettingsTypeSectionParameter>();

            if (!string.IsNullOrEmpty(nodeUpgradeDomain))
            {
                parameters.Add(new SettingsTypeSectionParameter()
                {
                    Name = Constants.ParameterNames.UpgradeDomainId, Value = nodeUpgradeDomain, MustOverride = false
                });
            }
            if (!string.IsNullOrEmpty(nodeFaultDomain))
            {
                parameters.Add(new SettingsTypeSectionParameter()
                {
                    Name = Constants.ParameterNames.NodeFaultDomainId, Value = nodeFaultDomain, MustOverride = false
                });
            }
            if (parameters.Count > 0)
            {
                this.Settings.Add(new SettingsTypeSection()
                {
                    Name = Constants.SectionNames.NodeDomainIds, Parameter = parameters.ToArray()
                });
            }
        }
예제 #2
0
 public NodeSettings(FabricNodeType fabricNode, ClusterManifestTypeNodeType nodeType, DeploymentFolders deploymentFolders, bool isScaleMin, FabricEndpointsType endpoints)
 {
     this.Settings              = new List <SettingsTypeSection>();
     this.NodeName              = fabricNode.NodeName;
     this.IPAddressOrFQDN       = fabricNode.IPAddressOrFQDN;
     this.DeploymentFoldersInfo = deploymentFolders;
     AddFabricNodeSection(fabricNode, endpoints, nodeType, isScaleMin);
     AddDomainIds(fabricNode);
     AddNodeProperties(nodeType);
 }
예제 #3
0
 private NodeDescription ToNodeDescription(FabricNodeType node)
 {
     return(new NodeDescription()
     {
         NodeName = node.NodeName,
         NodeTypeRef = node.NodeTypeRef,
         IPAddress = node.IPAddressOrFQDN,
         FaultDomain = node.FaultDomain,
         UpgradeDomain = node.UpgradeDomain
     });
 }
예제 #4
0
        List <NodeSettings> GetNodeSettings(int nodeCount, int start, bool addAppPorts, string ipAddressOrFQDN)
        {
            List <NodeSettings> nodes = new List <NodeSettings>();
            int leasedriverPort       = BaseLeaseDriverPort + start;
            int appPortStart          = BaseAppStartport + start * AppPortRange;
            int appPortEnd            = appPortStart + AppPortRange;
            int httpGatewayPort       = BaseHttpGatewayport + start;
            int httpAppGatewayPort    = BaseHttpAppGatewayport + start;

            for (int i = 0; i < nodeCount; i++)
            {
                string         nodeName   = string.Format(NodeNameTemplate, i + start);
                FabricNodeType fabricNode = new FabricNodeType()
                {
                    NodeName = nodeName, IPAddressOrFQDN = ipAddressOrFQDN, NodeTypeRef = "Test"
                };
                var endpoints = new FabricEndpointsType()
                {
                    LeaseDriverEndpoint = new InternalEndpointType()
                    {
                        Port = string.Format("{0}", leasedriverPort)
                    },
                    ClientConnectionEndpoint = new InputEndpointType {
                        Port = "3999"
                    },
                    ClusterConnectionEndpoint = new InternalEndpointType()
                    {
                        Port = "3998"
                    },
                    HttpGatewayEndpoint = new InputEndpointType {
                        Port = string.Format("{0}", httpGatewayPort)
                    },
                    HttpApplicationGatewayEndpoint = new InputEndpointType {
                        Port = string.Format("{0}", httpAppGatewayPort)
                    },
                    ApplicationEndpoints = addAppPorts ?
                                           new FabricEndpointsTypeApplicationEndpoints()
                    {
                        StartPort = appPortStart,
                        EndPort   = appPortEnd
                    }
                            : null
                };
                ClusterManifestTypeNodeType type    = new ClusterManifestTypeNodeType();
                DeploymentFolders           folders = new DeploymentFolders("", null, FabricDeploymentSpecification.Create(), nodeName, new Versions("", "", "", ""), false);
                NodeSettings setting = new NodeSettings(fabricNode, type, folders, true, endpoints);
                nodes.Add(setting);
                leasedriverPort++;
                appPortStart += AppPortRange;
                appPortEnd   += AppPortRange;
            }
            return(nodes);
        }
예제 #5
0
 private static void VerifyAreEqual(ClusterManifestTypeInfrastructureWindowsServer infrastructure1, ClusterManifestTypeInfrastructureWindowsServer infrastructure2)
 {
     Assert.AreEqual(infrastructure1.IsScaleMin, infrastructure2.IsScaleMin, "Infrastructure.IsScaleMin");
     Assert.AreEqual(infrastructure1.NodeList.Length, infrastructure2.NodeList.Length, "Infrastructure.NodeList.Length");
     for (int i = 0; i < infrastructure1.NodeList.Length; i++)
     {
         FabricNodeType node1 = infrastructure1.NodeList[i];
         FabricNodeType node2 = infrastructure2.NodeList[i];
         Assert.AreEqual(node1.FaultDomain, node2.FaultDomain, string.Format(CultureInfo.InvariantCulture, "Infrastrucuture.NodeList[{0}]", i));
         Assert.AreEqual(node1.IPAddressOrFQDN, node2.IPAddressOrFQDN, string.Format(CultureInfo.InvariantCulture, "Infrastructure.NodeList[{0}].IPAddressOrFQDNL", i));
         Assert.AreEqual(node1.IsSeedNode, node2.IsSeedNode, string.Format("Infrastructure.NodeList[{0}].IsSeedNode", i));
         Assert.AreEqual(node1.NodeName, node2.NodeName, string.Format("Infrastructure.NodeList[{0}].NodeName", i));
         Assert.AreEqual(node1.NodeTypeRef, node2.NodeTypeRef, string.Format("Infrastructure.NodeList[{0}].NodeTypeRef", i));
         Assert.AreEqual(node1.UpgradeDomain, node2.UpgradeDomain, string.Format("Infrastructure.NodeList[{0}].UpgradeDomain", i));
     }
 }
예제 #6
0
 public InfrastructureNode(FabricNodeType node, FabricEndpointsType endpoints, CertificatesType certificates)
 {
     FabricNode       = node;
     NodeEndpoints    = endpoints;
     NodeCertificates = certificates;
 }
예제 #7
0
        private void RemoveLogicalDirectoriesIfExist(string fabricDataRoot, string machineName)
        {
            if (machineName == null)
            {
                machineName = "";
            }

            ClusterManifestType clusterManifest = null;

            var clusterManifestLocation = Helpers.GetCurrentClusterManifestPath(fabricDataRoot);

            if (clusterManifestLocation == null)
            {
                clusterManifestLocation = Directory.EnumerateFiles(
                    fabricDataRoot,
                    "clusterManifest.xml",
                    SearchOption.AllDirectories).FirstOrDefault();
            }

            if (clusterManifestLocation != null)
            {
                clusterManifest = XMLHelper.ReadClusterManifest(clusterManifestLocation);
            }
            else
            {
                DeployerTrace.WriteWarning(string.Format(StringResources.Warning_clusterManifestFileMissingInDataRoot, fabricDataRoot, machineName));
            }

            if (clusterManifest != null)
            {
                InfrastructureInformationType infrastructure = null;
                FabricNodeType[] nodeList;

                if ((clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer &&
                     ((ClusterManifestTypeInfrastructureWindowsServer)clusterManifest.Infrastructure.Item).IsScaleMin) ||
                    (clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureLinux &&
                     ((ClusterManifestTypeInfrastructureLinux)clusterManifest.Infrastructure.Item).IsScaleMin))
                {
                    DeployerTrace.WriteInfo(string.Format("Checking to remove logicalDirectories for one box scale min deployment. Machine name: {0}.", machineName));

                    // Get all the nodes on this IP's LogicalDirectories and remove the all directoies.
                    nodeList = clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer ?
                               ((ClusterManifestTypeInfrastructureWindowsServer)clusterManifest.Infrastructure.Item).NodeList :
                               ((ClusterManifestTypeInfrastructureLinux)clusterManifest.Infrastructure.Item).NodeList;

                    RemoveLogicalDirectoies(clusterManifest, nodeList, machineName);
                }
                else if (clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructurePaaS) // PaaS doesn't support scale min.
                {
                    var infrastructureManifestLocation = Helpers.GetInfrastructureManifestPath(fabricDataRoot);
                    if (infrastructureManifestLocation == null)
                    {
                        DeployerTrace.WriteWarning(string.Format(StringResources.Warning_infrastructureManifestFileMissingInDataRoot, fabricDataRoot, machineName));
                        return;
                    }

                    infrastructure = XMLHelper.ReadInfrastructureManifest(infrastructureManifestLocation);

                    // Get all the nodes on this IP's LogicalDirectories and remove the all directories.
                    var len = infrastructure.NodeList.Length;
                    nodeList = new FabricNodeType[len];
                    for (var i = 0; i < len; i++)
                    {
                        FabricNodeType fabricNode = new FabricNodeType()
                        {
                            NodeName        = infrastructure.NodeList[i].NodeName,
                            FaultDomain     = infrastructure.NodeList[i].FaultDomain,
                            IPAddressOrFQDN = infrastructure.NodeList[i].IPAddressOrFQDN,
                            IsSeedNode      = infrastructure.NodeList[i].IsSeedNode,
                            NodeTypeRef     = infrastructure.NodeList[i].NodeTypeRef,
                            UpgradeDomain   = infrastructure.NodeList[i].UpgradeDomain
                        };

                        nodeList[i] = fabricNode;
                    }

                    RemoveLogicalDirectoies(clusterManifest, nodeList, machineName);
                }
                else if (clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer ||
                         clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureLinux)
                {
                    nodeList = clusterManifest.Infrastructure.Item is ClusterManifestTypeInfrastructureWindowsServer ?
                               ((ClusterManifestTypeInfrastructureWindowsServer)clusterManifest.Infrastructure.Item).NodeList :
                               ((ClusterManifestTypeInfrastructureLinux)clusterManifest.Infrastructure.Item).NodeList;
                    if (!string.IsNullOrEmpty(machineName)) //For cab deployment
                    {
                        DeployerTrace.WriteInfo(string.Format("Checking to remove logicalDirectories for WindowsServer/Linux deployment with cab. Machine name: {0}.", machineName));
                        RemoveLogicalDirectoies(clusterManifest, nodeList, machineName);
                    }
                    else
                    {
                        DeployerTrace.WriteInfo(string.Format("Checking to remove logicalDirectories for WindowsServer/Linux deployment with MSI. Machine name: {0}.", machineName));
                        foreach (var node in nodeList)
                        {
                            InfrastructureNodeType infraNode = new InfrastructureNodeType()
                            {
                                NodeName        = node.NodeName,
                                NodeTypeRef     = node.NodeTypeRef,
                                IPAddressOrFQDN = node.IPAddressOrFQDN,
                                IsSeedNode      = node.IsSeedNode,
                                FaultDomain     = node.FaultDomain,
                                UpgradeDomain   = node.UpgradeDomain
                            };

                            bool isNodeForThisMachine = NetworkApiHelper.IsNodeForThisMachine(infraNode);
                            if (isNodeForThisMachine)
                            {
                                FabricNodeType[] fabricNodes = new FabricNodeType[1];
                                FabricNodeType   fabricNode  = new FabricNodeType()
                                {
                                    NodeName        = node.NodeName,
                                    FaultDomain     = node.FaultDomain,
                                    IPAddressOrFQDN = node.IPAddressOrFQDN,
                                    IsSeedNode      = node.IsSeedNode,
                                    NodeTypeRef     = node.NodeTypeRef,
                                    UpgradeDomain   = node.UpgradeDomain
                                };

                                fabricNodes[0] = fabricNode;
                                RemoveLogicalDirectoies(clusterManifest, fabricNodes, machineName);
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
        private void InitializeInfrastructureSettings(
            int nNodeTypes,
            bool isScaleMin,
            bool isLogicalDirectories,
            int[] nNodes,
            int[] nSeedNodes,
            int[] nFaultDomains,
            int[] nUpgradDomains,
            InfrastructureType infrastructureType)
        {
            this.nodeTypes = new ClusterManifestTypeNodeType[nNodeTypes];
            int totalNodes = 0;

            for (int i = 0; i < nNodeTypes; i++)
            {
                totalNodes += nNodes[i];
            }
            this.nodes      = new FabricNodeType[totalNodes];
            this.infraNodes = new InfrastructureNodeType[totalNodes];
            int nodeIndex = 0;

            for (int i = 0; i < nNodeTypes; i++)
            {
                int    clientConnectionPort  = 19000 + i;
                int    leaseDriverPort       = 19000 + nNodeTypes + i;
                int    clusterConnectionPort = 19000 + 2 * nNodeTypes + i;
                int    httpGatewayPort       = 19000 + 3 * nNodeTypes + i;
                int    serviceConnectionPort = 19000 + 4 * nNodeTypes + i;
                int    startAppPort          = 30000 + 1000 * i + 1;
                int    endAppPort            = 30000 + 1000 * (i + 1);
                string host                   = isScaleMin ? "localhost" : System.Net.Dns.GetHostName();
                string roleOrTierName         = GetRoleOrTiername(i);
                string faultDomain            = string.Format(CultureInfo.InvariantCulture, "fd:/Rack{0}", i % nFaultDomains[i]);
                string upgradeDomain          = string.Format(CultureInfo.InvariantCulture, "MYUD{0}", i % nUpgradDomains[i]);
                FabricEndpointsType endpoints = new FabricEndpointsType()
                {
                    ApplicationEndpoints = new FabricEndpointsTypeApplicationEndpoints()
                    {
                        StartPort = startAppPort, EndPort = endAppPort
                    },
                    LeaseDriverEndpoint = new InternalEndpointType()
                    {
                        Port = leaseDriverPort.ToString(CultureInfo.InvariantCulture)
                    },
                    ClusterConnectionEndpoint = new InternalEndpointType()
                    {
                        Port = clusterConnectionPort.ToString(CultureInfo.InvariantCulture)
                    },
                    ClientConnectionEndpoint = new InputEndpointType()
                    {
                        Port = clientConnectionPort.ToString(CultureInfo.InvariantCulture)
                    },
                    HttpGatewayEndpoint = new InputEndpointType()
                    {
                        Port = httpGatewayPort.ToString(CultureInfo.InvariantCulture)
                    },
                    ServiceConnectionEndpoint = new InternalEndpointType()
                    {
                        Port = serviceConnectionPort.ToString(CultureInfo.InvariantCulture)
                    }
                };

                for (int j = 0; j < nNodes[i]; j++)
                {
                    bool           isSeedNode = j < nSeedNodes[i];
                    string         nodeName   = string.Format(CultureInfo.InvariantCulture, "{0}.Node.{1}", roleOrTierName, j);
                    FabricNodeType node       = new FabricNodeType()
                    {
                        NodeName = nodeName, FaultDomain = faultDomain, IPAddressOrFQDN = host, IsSeedNode = isSeedNode, NodeTypeRef = roleOrTierName, UpgradeDomain = upgradeDomain
                    };
                    InfrastructureNodeType infraNode = new InfrastructureNodeType()
                    {
                        NodeName = nodeName, FaultDomain = faultDomain, IPAddressOrFQDN = host, IsSeedNode = isSeedNode, NodeTypeRef = roleOrTierName, UpgradeDomain = upgradeDomain, RoleOrTierName = roleOrTierName, Certificates = null, Endpoints = endpoints
                    };
                    this.nodes[nodeIndex]      = node;
                    this.infraNodes[nodeIndex] = infraNode;
                    nodeIndex++;
                }
                nodeTypes[i] = new ClusterManifestTypeNodeType();
                nodeTypes[i].Certificates = null;
                if (infrastructureType == InfrastructureType.WindowsServer || infrastructureType == InfrastructureType.VMM || infrastructureType == InfrastructureType.PaaS)
                {
                    nodeTypes[i].Endpoints = endpoints;
                }

                nodeTypes[i].Name = roleOrTierName;
            }

            if (isLogicalDirectories)
            {
                nodeTypes[0].LogicalDirectories    = new LogicalDirectoryType[5];
                nodeTypes[0].LogicalDirectories[0] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "0",
                    MappedTo             = TestUtility.LogicalDirectoriesApplicationCheckPointFilesDir,
                    Context = LogicalDirectoryTypeContext.node
                };

                nodeTypes[0].LogicalDirectories[1] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "1",
                    MappedTo             = TestUtility.LogicalDirectoriesLogDir,
                    Context = LogicalDirectoryTypeContext.node
                };
                nodeTypes[0].LogicalDirectories[2] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "2",
                    MappedTo             = TestUtility.LogicalDirectoriesBackupDir,
                    Context = LogicalDirectoryTypeContext.application
                };
                nodeTypes[0].LogicalDirectories[3] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "3",
                    MappedTo             = TestUtility.LogicalDirectoriesUserDefined1Dir
                };
                nodeTypes[0].LogicalDirectories[4] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "4",
                    MappedTo             = TestUtility.LogicalDirectoriesUserDefined2Dir,
                    Context = LogicalDirectoryTypeContext.node
                };

                nodeTypes[1].LogicalDirectories    = new LogicalDirectoryType[5];
                nodeTypes[1].LogicalDirectories[0] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "0",
                    MappedTo             = TestUtility.LogicalDirectoriesApplicationCheckPointFilesDir2,
                    Context = LogicalDirectoryTypeContext.application
                };

                nodeTypes[1].LogicalDirectories[1] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "1",
                    MappedTo             = TestUtility.LogicalDirectoriesLogDir2,
                    Context = LogicalDirectoryTypeContext.application
                };
                nodeTypes[1].LogicalDirectories[2] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "2",
                    MappedTo             = TestUtility.LogicalDirectoriesBackupDir2,
                    Context = LogicalDirectoryTypeContext.node
                };
                nodeTypes[1].LogicalDirectories[3] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "3",
                    MappedTo             = TestUtility.LogicalDirectoriesUserDefined1Dir2,
                    Context = LogicalDirectoryTypeContext.application
                };
                nodeTypes[1].LogicalDirectories[4] = new LogicalDirectoryType
                {
                    LogicalDirectoryName = "4",
                    MappedTo             = TestUtility.LogicalDirectoriesUserDefined2Dir2,
                    Context = LogicalDirectoryTypeContext.application
                };
            }
        }
예제 #9
0
        private void AddFabricNodeSection(FabricNodeType fabricNode, FabricEndpointsType endpoints, ClusterManifestTypeNodeType nodeType, bool isScaleMin)
        {
            CertificatesType certificates = nodeType.Certificates;

            List <SettingsTypeSectionParameter> parameters = new List <SettingsTypeSectionParameter>();

            parameters.Add(new SettingsTypeSectionParameter()
            {
                Name = Constants.ParameterNames.InstanceName, Value = this.NodeName, MustOverride = false
            });

            if (Helpers.isIPV6AddressAndNoBracket(this.IPAddressOrFQDN))
            {
                parameters.Add(new SettingsTypeSectionParameter()
                {
                    Name = Constants.ParameterNames.IPAddressOrFQDN, Value = Helpers.AddBracketsAroundIPV6(this.IPAddressOrFQDN), MustOverride = false
                });
            }
            else
            {
                parameters.Add(new SettingsTypeSectionParameter()
                {
                    Name = Constants.ParameterNames.IPAddressOrFQDN, Value = this.IPAddressOrFQDN, MustOverride = false
                });
            }

            parameters.Add(new SettingsTypeSectionParameter()
            {
                Name = Constants.ParameterNames.WorkingDir, Value = this.DeploymentFoldersInfo.WorkFolder, MustOverride = false
            });
            parameters.Add(new SettingsTypeSectionParameter()
            {
                Name = Constants.ParameterNames.NodeVersion, Value = this.DeploymentFoldersInfo.versions.FabricInstanceVersion, MustOverride = false
            });
            parameters.Add(new SettingsTypeSectionParameter()
            {
                Name = Constants.ParameterNames.NodeType, Value = fabricNode.NodeTypeRef, MustOverride = false
            });
            parameters.Add(new SettingsTypeSectionParameter()
            {
                Name = Constants.ParameterNames.IsScaleMin, Value = isScaleMin.ToString(), MustOverride = false
            });

            //
            // Fill in any KTLLogger values from the NodeTypes
            //
            if (nodeType.KtlLoggerSettings != null)
            {
                if (nodeType.KtlLoggerSettings.SharedLogFilePath != null)
                {
                    parameters.Add(new SettingsTypeSectionParameter()
                    {
                        Name = Constants.ParameterNames.SharedLogFilePath, Value = nodeType.KtlLoggerSettings.SharedLogFilePath.Value, MustOverride = false
                    });
                }

                if (nodeType.KtlLoggerSettings.SharedLogFileId != null)
                {
                    parameters.Add(new SettingsTypeSectionParameter()
                    {
                        Name = Constants.ParameterNames.SharedLogFileId, Value = nodeType.KtlLoggerSettings.SharedLogFileId.Value, MustOverride = false
                    });
                }

                if (nodeType.KtlLoggerSettings.SharedLogFileSizeInMB != null)
                {
                    parameters.Add(new SettingsTypeSectionParameter()
                    {
                        Name = Constants.ParameterNames.SharedLogFileSizeInMB, Value = nodeType.KtlLoggerSettings.SharedLogFileSizeInMB.Value.ToString(), MustOverride = false
                    });
                }
            }

            AddEndpoints(parameters, endpoints);
            AddCertifcateInformation(parameters, certificates);
            this.Settings.Add(new SettingsTypeSection()
            {
                Name = Constants.SectionNames.FabricNode, Parameter = parameters.ToArray()
            });
        }