public DeploymentParameters(bool setBinRoot) { DeploymentSpecification = FabricDeploymentSpecification.Create(); DeleteTargetFile = false; if (setBinRoot) { try { this.FabricBinRoot = FabricEnvironment.GetBinRoot(); } catch (Exception) { } } }
/// <summary> /// Automatically infers node name on the machine and finds resource /// under path [dataRoot]\[inferredNodeName]\[desiredResourceSubPath] or returns null. /// </summary> /// <param name="dataRoot"></param> /// <param name="resoucePathRetrievalMethod">Delegate used to retrieve file path pattern.</param> /// <returns></returns> internal static string GetNodeResourcePath(string dataRoot, DeploymentSpecificationResourceDelegate resoucePathRetrievalMethod) { if (string.IsNullOrEmpty(dataRoot)) { throw new ArgumentNullException("dataRoot"); } FabricDeploymentSpecification deploymentSpecification = FabricDeploymentSpecification.Create(); deploymentSpecification.SetDataRoot(dataRoot); string resourcePath = null; TimeSpan retryInterval = TimeSpan.FromSeconds(5); int retryCount = 5; Type[] exceptionTypes = { typeof(UnauthorizedAccessException) }; Helpers.PerformWithRetry(() => { string[] dataRootDirectories = Directory.GetDirectories(dataRoot, "*", SearchOption.TopDirectoryOnly); foreach (string dir in dataRootDirectories) { string nodeName = Path.GetFileName(dir); string tmpPath = resoucePathRetrievalMethod(deploymentSpecification, nodeName); if (File.Exists(tmpPath)) { resourcePath = tmpPath; break; } } }, exceptionTypes, retryInterval, retryCount); return(resourcePath); }
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); }
public static string GetInstalledBinaryDirectory(string installationFolder, string service) { return(FabricDeploymentSpecification.Create().GetInstalledBinaryFolder(installationFolder, service)); }
public DeploymentFolders(string fabricInstallationFolder, SettingsOverridesTypeSection[] fabricSettings, FabricDeploymentSpecification deploymentSpecification, string nodeName, Versions versions, bool isScaleMin) { this.nodeName = nodeName; this.versions = versions; this.installationFolder = fabricInstallationFolder; this.IsCodeDeploymentNeeded = isScaleMin; this.DataRoot = deploymentSpecification.GetDataRoot(); this.deploymentSpecification = deploymentSpecification; this.DeploymentRoot = this.deploymentSpecification.GetNodeFolder(nodeName); this.DataDeploymentDirectory = this.deploymentSpecification.GetDataDeploymentFolder(nodeName); this.WorkFolder = this.deploymentSpecification.GetWorkFolder(nodeName); this.CurrentClusterManifestFile = this.deploymentSpecification.GetCurrentClusterManifestFile(nodeName); this.CurrentFabricPackageFile = this.deploymentSpecification.GetCurrentFabricPackageFile(nodeName); this.InfrastructureManfiestFile = this.deploymentSpecification.GetInfrastructureManfiestFile(nodeName); this.ConfigDeploymentDirectory = this.deploymentSpecification.GetConfigurationDeploymentFolder(nodeName, versions.ConfigVersion); this.ApplicationDeploymentFolder = GetApplicationDeploymentFolder(fabricSettings, isScaleMin); }
internal static bool StartCollection(SettingsOverridesTypeSection[] fabricSettings, FabricDeploymentSpecification deploymentSpecification) { if (!StopDataCollector()) { return(false); } if (!DeleteDataCollector()) { return(false); } var samplingInterval = PerformanceCounterCommon.DefaultSamplingInterval; HashSet <string> counters = null; int maxFileSizeInMB = PerformanceCounterCommon.MaxPerformanceCountersBinaryFileSizeInMB; var newFileCreationInterval = PerformanceCounterCommon.NewPerfCounterBinaryFileCreationInterval; string outputFolderPath = deploymentSpecification.GetPerformanceCountersBinaryFolder(); string outputFileNamePrefix = CounterFileNamePrefix; bool includeMachineNameInOuputFile = false; bool enableCircularTraceSession = FabricEnvironment.GetEnableCircularTraceSession(); SettingsOverridesTypeSection manifestSection = fabricSettings.FirstOrDefault(section => section.Name.Equals(Constants.SectionNames.PerformanceCounterLocalStore, StringComparison.OrdinalIgnoreCase)); if (manifestSection != null) { var isEnabledParameter = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(System.Fabric.FabricValidatorConstants.ParameterNames.IsEnabled, StringComparison.OrdinalIgnoreCase)); if (isEnabledParameter != null) { bool isEnabled = bool.Parse(isEnabledParameter.Value); if (!isEnabled) { DeployerTrace.WriteInfo( "Performance counter collection is not enabled because parameter {0} in section {1} is set to false.", System.Fabric.FabricValidatorConstants.ParameterNames.IsEnabled, Constants.SectionNames.PerformanceCounterLocalStore); return(true); } } var samplingIntervalSecondsParameter = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(Constants.ParameterNames.SamplingIntervalInSeconds, StringComparison.OrdinalIgnoreCase)); if (samplingIntervalSecondsParameter != null) { samplingInterval = TimeSpan.FromSeconds(int.Parse(samplingIntervalSecondsParameter.Value, CultureInfo.InvariantCulture)); } var countersParameter = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(System.Fabric.FabricValidatorConstants.ParameterNames.Counters, StringComparison.OrdinalIgnoreCase)); if (countersParameter != null) { PerformanceCounterCommon.ParseCounterList(countersParameter.Value, out counters); } var maxFileSizeInMBParameter = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(Constants.ParameterNames.MaxCounterBinaryFileSizeInMB, StringComparison.OrdinalIgnoreCase)); if (maxFileSizeInMBParameter != null) { maxFileSizeInMB = int.Parse(maxFileSizeInMBParameter.Value, CultureInfo.InvariantCulture); } var newFileCreationIntervalMinutesParameter = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(System.Fabric.FabricValidatorConstants.ParameterNames.NewCounterBinaryFileCreationIntervalMinutes, StringComparison.OrdinalIgnoreCase)); if (newFileCreationIntervalMinutesParameter != null) { newFileCreationInterval = TimeSpan.FromMinutes(int.Parse(newFileCreationIntervalMinutesParameter.Value, CultureInfo.InvariantCulture)); } var testOnlyCounterFilePath = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(System.Fabric.FabricValidatorConstants.ParameterNames.TestOnlyCounterFilePath, StringComparison.OrdinalIgnoreCase)); if (testOnlyCounterFilePath != null) { outputFolderPath = testOnlyCounterFilePath.Value; } var testOnlyCounterFileNamePrefix = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(System.Fabric.FabricValidatorConstants.ParameterNames.TestOnlyCounterFileNamePrefix, StringComparison.OrdinalIgnoreCase)); if (testOnlyCounterFileNamePrefix != null) { outputFileNamePrefix = testOnlyCounterFileNamePrefix.Value; } var testOnlyIncludeMachineNameInCounterFileName = manifestSection.Parameter.FirstOrDefault(param => param.Name.Equals(Constants.ParameterNames.TestOnlyIncludeMachineNameInCounterFileName, StringComparison.OrdinalIgnoreCase)); if (testOnlyIncludeMachineNameInCounterFileName != null) { includeMachineNameInOuputFile = bool.Parse(testOnlyIncludeMachineNameInCounterFileName.Value); } } if (counters == null) { PerformanceCounterCommon.ParseCounterList(PerformanceCounterCommon.LabelDefault, out counters); } DeployerTrace.WriteInfo("Performance counter sampling interval: {0} seconds.", samplingInterval); if (!StartCollectionForCounterSet( counters, outputFolderPath, outputFileNamePrefix, includeMachineNameInOuputFile, (int)samplingInterval.TotalSeconds, maxFileSizeInMB, (int)newFileCreationInterval.TotalMinutes, enableCircularTraceSession)) { return(false); } return(true); }