/// <summary> /// Overload this method to allow different seed node types. /// TODO: refactor to combine the two methods /// </summary> /// <param name="security"></param> /// <param name="existingClusterManifest"></param> /// <param name="nodeTypes"></param> /// <param name="currentFabricSettingsMetadata"></param> /// <param name="clusterManifestVersion"></param> /// <returns></returns> private ClusterManifestType UpdateClusterManifest( Security security, ClusterManifestType existingClusterManifest, IEnumerable <ClusterManifestTypeNodeType> nodeTypes, FabricSettingsMetadata currentFabricSettingsMetadata, string clusterManifestVersion, CertificateDescription thumbprintFileStoreCert, List <string> thumbprintWhiteList, ServerCertificateCommonNames commonNameFileStoreCert, Dictionary <string, string> commonNameWhiteList, List <NodeDescription> existingSeedNodes) { FabricSettingsGeneratorBase fabricSettingsGenerator = this.CreateFabricSettingsGenerator( this.TargetCsmConfig, this.TargetWrpConfig, this.ClusterManifestGeneratorSettings, currentFabricSettingsMetadata, existingClusterManifest); var fabricSettings = fabricSettingsGenerator.GenerateFabricSettings( security, thumbprintFileStoreCert, thumbprintWhiteList, commonNameFileStoreCert, commonNameWhiteList); var primaryNodesTypes = this.TargetCsmConfig.NodeTypes.Where(nodeType => nodeType.IsPrimary); var updatedCluterManifest = new ClusterManifestType { FabricSettings = fabricSettings, Infrastructure = this.OnGetInfrastructure(this.Topology, existingSeedNodes, nodeTypes), NodeTypes = nodeTypes.ToArray(), Name = StringConstants.ClusterManifestName, Version = clusterManifestVersion, Description = GeneratedCluterManifestDescription }; this.SortClusterManifest(updatedCluterManifest); return(updatedCluterManifest); }
public ClusterManifestType GenerateClusterManifest() { var primaryNodesTypes = this.TargetCsmConfig.NodeTypes.Where(nodeType => nodeType.IsPrimary); var seedNodes = this.GetSeedNodes( this.TargetCsmConfig.ReliabilityLevel, this.TargetCsmConfig.TotalPrimaryNodeTypeNodeCount, primaryNodesTypes, this.TargetCsmConfig.IsVMSS); if (seedNodes == null) { return(null); } FabricSettingsGeneratorBase fabricSettingsGenerator = this.CreateFabricSettingsGenerator( this.TargetCsmConfig, this.TargetWrpConfig, this.ClusterManifestGeneratorSettings, null /*currentFabricSettingsMetadata*/, null /*existingClusterManifest*/); var fabricSettings = fabricSettingsGenerator.GenerateFabricSettings(this.TargetCsmConfig.Security); var nodeTypes = this.GetNodeTypes(this.TargetCsmConfig.NodeTypes, this.TargetCsmConfig.Security).ToArray(); var infrastructure = this.OnGetInfrastructure(this.Topology, seedNodes, nodeTypes); this.UpdateEndpointPortsForScaleMin(infrastructure, nodeTypes, this.TargetCsmConfig.NodeTypes); var clusterManifest = new ClusterManifestType { FabricSettings = fabricSettings, Infrastructure = infrastructure, NodeTypes = nodeTypes, Name = this.TargetCsmConfig.ClusterName, Version = this.VersionGenerator.GetNextClusterManifestVersion(), Description = GeneratedCluterManifestDescription }; this.SortClusterManifest(clusterManifest); return(clusterManifest); }
protected ClusterManifestType UpdateClusterManifest( Security security, ClusterManifestType existingClusterManifest, List <PaaSVoteType> seedNodes, IEnumerable <ClusterManifestTypeNodeType> nodeTypes, IEnumerable <PaaSRoleType> roles, FabricSettingsMetadata currentFabricSettingsMetadata, string clusterManifestVersion) { FabricSettingsGeneratorBase fabricSettingsGenerator = this.CreateFabricSettingsGenerator( this.TargetCsmConfig, this.TargetWrpConfig, this.ClusterManifestGeneratorSettings, currentFabricSettingsMetadata, existingClusterManifest); var fabricSettings = fabricSettingsGenerator.GenerateFabricSettings(security); var updatedCluterManifest = new ClusterManifestType { FabricSettings = fabricSettings, Infrastructure = new ClusterManifestTypeInfrastructure() { Item = new ClusterManifestTypeInfrastructurePaaS() { Roles = roles.ToArray(), Votes = seedNodes.ToArray() } }, NodeTypes = nodeTypes.ToArray(), Name = StringConstants.ClusterManifestName, Version = clusterManifestVersion, Description = GeneratedCluterManifestDescription }; this.SortClusterManifest(updatedCluterManifest); return(updatedCluterManifest); }
protected ClusterManifestType UpdateClusterManifest( Security security, ClusterManifestType existingClusterManifest, List <FabricNodeType> seedNodes, NodeDescription seedNodeChanged, List <NodeDescription> nonSeedNodeChanged, bool isSeedNodeToAdd, IEnumerable <ClusterManifestTypeNodeType> nodeTypes, FabricSettingsMetadata currentFabricSettingsMetadata, string clusterManifestVersion) { FabricSettingsGeneratorBase fabricSettingsGenerator = this.CreateFabricSettingsGenerator( this.TargetCsmConfig, this.TargetWrpConfig, this.ClusterManifestGeneratorSettings, currentFabricSettingsMetadata, existingClusterManifest); var originalNodeList = ((ClusterManifestTypeInfrastructureWindowsServer)existingClusterManifest.Infrastructure.Item).NodeList; List <FabricNodeType> nodelist = new List <FabricNodeType>(); foreach (var n in originalNodeList) { nodelist.Add(new FabricNodeType { FaultDomain = n.FaultDomain, IPAddressOrFQDN = n.IPAddressOrFQDN, IsSeedNode = n.IsSeedNode, NodeName = n.NodeName, NodeTypeRef = n.NodeTypeRef, UpgradeDomain = n.UpgradeDomain }); } var fabricSettings = fabricSettingsGenerator.GenerateFabricSettings(security, nodelist.Count()); if (isSeedNodeToAdd) { var hasNodeListAlreadyContainedThisSeedNode = originalNodeList.Select(node => node.NodeName).Contains(seedNodeChanged.NodeName); if (!hasNodeListAlreadyContainedThisSeedNode) { nodelist.Add(seedNodeChanged.ToFabricNodeType()); } if (nonSeedNodeChanged.Count > 0) { foreach (var nonSeedNodeAdded in nonSeedNodeChanged) { nodelist.Add(nonSeedNodeAdded.ToFabricNodeType()); } } } else { nodelist.Where(n => n.NodeName.Equals(seedNodeChanged.NodeName)).FirstOrDefault().IsSeedNode = false; if (nonSeedNodeChanged.Count > 0) { foreach (var nonSeedNodeRemoved in nonSeedNodeChanged) { nodelist = nodelist.Where(n => !nonSeedNodeRemoved.NodeName.Equals(n.NodeName)).ToList(); } } } // Set ExpectedNodeDeactivationDuration section in FailoverManager to 2 days. Deactivating node in seed node removal // could take a lot of intermediate seed node changing upgrades. This is to prevent deactivate node timeout. // TODO Chrissie: When the seed node removal causing the intermediate seed node shift bug is fixed, remove this parameter from add node scenario. var failoverManagerSettings = fabricSettings.FirstOrDefault(setting => setting.Name.Equals(StringConstants.SectionName.FailoverManager, StringComparison.OrdinalIgnoreCase)); TimeSpan totalSeconds = TimeSpan.FromSeconds(120 * 60 * 24); double defaultNodeDeactivationDuration = totalSeconds.TotalSeconds; var expectedNodeDeactivationDurationParameter = failoverManagerSettings.Parameter.FirstOrDefault( param => param.Name.Equals(StringConstants.ParameterName.ExpectedNodeDeactivationDuration, StringComparison.OrdinalIgnoreCase)); if (expectedNodeDeactivationDurationParameter != null) { expectedNodeDeactivationDurationParameter.Value = defaultNodeDeactivationDuration.ToString(); } else { int originalParamCount = failoverManagerSettings.Parameter.Count(); SettingsOverridesTypeSectionParameter[] newFailoverManagerSection = new SettingsOverridesTypeSectionParameter[originalParamCount + 1]; Array.Copy(failoverManagerSettings.Parameter, newFailoverManagerSection, originalParamCount); newFailoverManagerSection[originalParamCount] = new SettingsOverridesTypeSectionParameter() { Name = StringConstants.ParameterName.ExpectedNodeDeactivationDuration, Value = defaultNodeDeactivationDuration.ToString() }; failoverManagerSettings.Parameter = newFailoverManagerSection; } var seedNodeNames = seedNodes.Select(item => item.NodeName); foreach (var node in nodelist) { node.IsSeedNode = seedNodeNames.Contains(node.NodeName); } var updatedCluterManifest = new ClusterManifestType { FabricSettings = fabricSettings, Infrastructure = new ClusterManifestTypeInfrastructure() { Item = new ClusterManifestTypeInfrastructureWindowsServer() { NodeList = nodelist.ToArray() } }, NodeTypes = nodeTypes.ToArray(), Name = StringConstants.ClusterManifestName, Version = clusterManifestVersion, Description = GeneratedCluterManifestDescription }; this.SortClusterManifest(updatedCluterManifest); return(updatedCluterManifest); }