Exemplo n.º 1
0
        private static void GetPorts(
            NodeSettings setting,
            out string leaseDriverPort,
            out string applicationPortRange,
            out string httpGatewayPort,
            out string httpAppGatewayPort,
            out string dynamicPortRange)
        {
            SettingsTypeSection fabricNodeSection = setting.Settings.FirstOrDefault(section => section.Name.Equals(Constants.SectionNames.FabricNode, StringComparison.OrdinalIgnoreCase));
            var leaseDriverPortParameter          = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.LeaseAgentAddress, StringComparison.OrdinalIgnoreCase));

            leaseDriverPort = leaseDriverPortParameter.Value;

            httpGatewayPort = null;
            var httpGatewayPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.HttpGatewayListenAddress, StringComparison.OrdinalIgnoreCase));

            if (httpGatewayPortParameter != null)
            {
                httpGatewayPort = httpGatewayPortParameter.Value;
            }

            httpAppGatewayPort = null;
            var httpAppGatewayPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.HttpApplicationGatewayListenAddress, StringComparison.OrdinalIgnoreCase));

            if (httpAppGatewayPortParameter != null)
            {
                httpAppGatewayPort = httpAppGatewayPortParameter.Value;
            }

            var startApplicationPortParamter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.StartApplicationPortRange, StringComparison.OrdinalIgnoreCase));
            var endApplicationPortParamter   = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.EndApplicationPortRange, StringComparison.OrdinalIgnoreCase));

            if (startApplicationPortParamter != null && endApplicationPortParamter != null)
            {
                applicationPortRange = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}-{1}",
                    startApplicationPortParamter.Value,
                    endApplicationPortParamter.Value);
            }
            else
            {
                applicationPortRange = null;
            }

            var startDynamicPortParamter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.StartDynamicPortRange, StringComparison.OrdinalIgnoreCase));
            var endDynamicnPortParamter  = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.EndDynamicPortRange, StringComparison.OrdinalIgnoreCase));

            if (startDynamicPortParamter != null && endDynamicnPortParamter != null)
            {
                dynamicPortRange = string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}-{1}",
                    startDynamicPortParamter.Value,
                    endDynamicnPortParamter.Value);
            }
            else
            {
                dynamicPortRange = null;
            }
        }
Exemplo n.º 2
0
        private static void GetPorts2(
            NodeSettings setting,
            out string clientConnectionPort,
            out string serviceConnectionPort,
            out string clusterConnectionPort,
            out string clusterManagerReplicatorPort,
            out string repairManagerReplicatorPort,
            out string namingReplicatorPort,
            out string failoverManagerReplicatorPort,
            out string imageStoreServiceReplicatorPort,
            out string upgradeServiceReplicatorPort)
        {
            SettingsTypeSection fabricNodeSection = setting.Settings.FirstOrDefault(section => section.Name.Equals(Constants.SectionNames.FabricNode, StringComparison.OrdinalIgnoreCase));

            var clientConnectionPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.ClientConnectionAddress, StringComparison.OrdinalIgnoreCase));

            clientConnectionPort = clientConnectionPortParameter.Value;

            var serviceConnectionPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.RuntimeServiceAddress, StringComparison.OrdinalIgnoreCase));

            serviceConnectionPort = serviceConnectionPortParameter.Value;

            var clusterConnectionPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.NodeAddress, StringComparison.OrdinalIgnoreCase));

            clusterConnectionPort = clusterConnectionPortParameter.Value;

            clusterManagerReplicatorPort = null;
            var clusterManagerReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.ClusterManagerReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (clusterManagerReplicatorPortParameter != null)
            {
                clusterManagerReplicatorPort = clusterManagerReplicatorPortParameter.Value;
            }

            repairManagerReplicatorPort = null;
            var repairManagerReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.RepairManagerReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (repairManagerReplicatorPortParameter != null)
            {
                repairManagerReplicatorPort = repairManagerReplicatorPortParameter.Value;
            }

            namingReplicatorPort = null;
            var namingReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.NamingReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (namingReplicatorPortParameter != null)
            {
                namingReplicatorPort = namingReplicatorPortParameter.Value;
            }

            failoverManagerReplicatorPort = null;
            var failoverManagerReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.FailoverManagerReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (failoverManagerReplicatorPortParameter != null)
            {
                failoverManagerReplicatorPort = failoverManagerReplicatorPortParameter.Value;
            }

            imageStoreServiceReplicatorPort = null;
            var imageStoreServiceReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.ImageStoreServiceReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (imageStoreServiceReplicatorPortParameter != null)
            {
                imageStoreServiceReplicatorPort = imageStoreServiceReplicatorPortParameter.Value;
            }

            upgradeServiceReplicatorPort = null;
            var upgradeServiceReplicatorPortParameter = fabricNodeSection.Parameter.FirstOrDefault(parameter => parameter.Name.Equals(FabricValidatorConstants.ParameterNames.UpgradeServiceReplicatorAddress, StringComparison.OrdinalIgnoreCase));

            if (upgradeServiceReplicatorPortParameter != null)
            {
                upgradeServiceReplicatorPort = upgradeServiceReplicatorPortParameter.Value;
            }
        }
Exemplo n.º 3
0
        protected override void OnExecuteOperation(DeploymentParameters parameters, ClusterManifestType clusterManifest, Infrastructure infrastructure)
        {
            this.manifest        = clusterManifest;
            this.infrastructure  = infrastructure;
            this.parameters      = parameters;
            this.fabricValidator = new FabricValidatorWrapper(parameters, manifest, infrastructure);
            fabricValidator.ValidateAndEnsureDefaultImageStore();
            this.nodeSettings = GetNodeSettings();

            // creating a ClusterSettings without Unreliable Transport settings
            var clusterSettingsNoUnreliableTransport = new ClusterSettings(this.manifest.FabricSettings, GetVotes(), GetSeedNodes(), manifest.Certificates != null ? this.manifest.Certificates.SecretsCertificate : null);

            clusterSettingsNoUnreliableTransport.Settings.RemoveAll(x => x.Name == FabricValidatorConstants.SectionNames.UnreliableTransport);

            var clusterSettings = new ClusterSettings(this.manifest.FabricSettings, GetVotes(), GetSeedNodes(), manifest.Certificates != null ? this.manifest.Certificates.SecretsCertificate : null);

            this.UpdateClusterSettings(clusterSettingsNoUnreliableTransport);
            var fabricHostSettings  = InitializeFabricHostSettings(clusterSettingsNoUnreliableTransport, nodeSettings);
            var servicesToBeEnabled = GetServicesToBeEnabled();

            for (int i = 0; i < nodeSettings.Count; i++)
            {
                NodeSettings   nodeSetting          = nodeSettings[i];
                List <string>  servicesToBeDeployed = GetServicesToBeDeployed(i);
                DeploymentNode node = new DeploymentNode(nodeSetting, clusterSettings, infrastructure, servicesToBeDeployed.ToArray(), servicesToBeEnabled.ToArray(), this.manifest);

                if (string.IsNullOrEmpty(parameters.NodeName) || parameters.NodeName.Equals(nodeSetting.NodeName, StringComparison.OrdinalIgnoreCase))
                {
                    if (parameters.Operation == DeploymentOperations.Update || parameters.Operation == DeploymentOperations.UpdateInstanceId)
                    {
                        node.UpgradeDeployment();
                    }
                    else if (parameters.Operation == DeploymentOperations.Create)
                    {
                        node.CreateDeployment();  //update infrastructure manifest
                    }
                }

                //  Gateway service activation is managed by Fabric.exe, and so its settings shouldn't be written to FabricHostSettings.xml
                fabricHostSettings.AddRange(node.GetHostedServices().FindAll(
                                                delegate(SettingsTypeSection section)
                {
                    string hostedServiceName = string.Format(
                        CultureInfo.InvariantCulture,
                        Constants.SectionNames.HostSettingsSectionPattern,
                        nodeSetting.NodeName,
                        Constants.HttpGatewayService);

                    return(section.Name != hostedServiceName);
                }));
            }

            WriteFabricHostSettingsFile(parameters.DeploymentSpecification.GetDataRoot(), new SettingsType()
            {
                Section = fabricHostSettings.ToArray()
            }, parameters.MachineName);

            var currentType = this as CreateorUpdateOperation;

            if (currentType != null)
            {
                base.OnExecuteOperation(parameters, clusterManifest, infrastructure);
            }
        }