Exemplo n.º 1
0
        protected void NewCluster(string clusterConfigurationFilePath, string fabricPackageSourcePath, bool noCleanupOnFailure, bool force, int maxPercentFailedNodes, uint timeoutInSeconds)
        {
            this.ChangeCurrentDirectoryToSession();
            clusterConfigurationFilePath = this.GetAbsolutePath(clusterConfigurationFilePath);
            fabricPackageSourcePath      = this.GetAbsolutePath(fabricPackageSourcePath);

            ClusterCreationOptions creationOptions = ClusterCreationOptions.None;

            if (noCleanupOnFailure)
            {
                creationOptions |= ClusterCreationOptions.OptOutCleanupOnFailure;
            }

            if (force)
            {
                creationOptions |= ClusterCreationOptions.Force;
            }

            TimeSpan?timeout = null;

            if (timeoutInSeconds > 0)
            {
                timeout = TimeSpan.FromSeconds(timeoutInSeconds);
            }

            try
            {
                this.WriteObject(StringResources.Info_CreatingServiceFabricCluster);
                this.WriteObject(StringResources.Info_CreatingServiceFabricClusterDebugDetails);
                DeploymentManager.CreateClusterAsync(
                    clusterConfigurationFilePath,
                    fabricPackageSourcePath,
                    creationOptions,
                    maxPercentFailedNodes,
                    timeout).Wait();

                var standAloneModel = StandAloneInstallerJsonModelBase.GetJsonConfigFromFile(clusterConfigurationFilePath);
                var node            = standAloneModel.Nodes[0];
                var nodeType        = standAloneModel.GetUserConfig().NodeTypes.Find(type => type.Name == node.NodeTypeRef);
                this.WriteObject(string.Format(StringResources.Info_CreateServiceFabricClusterSucceeded, node.IPAddress, nodeType.ClientConnectionEndpointPort));
            }
            catch (Exception exception)
            {
                this.WriteObject(StringResources.Error_CreateServiceFabricClusterFailed);
                this.WriteObject(exception.InnerException != null ? exception.InnerException.Message : exception.Message);
                this.ThrowTerminatingError(
                    exception,
                    Constants.NewNodeConfigurationErrorId,
                    null);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a Service Fabric cluster based on an input JSON configuration file and Service Fabric runtime package CAB file.
 /// </summary>
 /// <param name="clusterConfigPath">Specifies the path to the JSON cluster configuration file where you define the cluster nodes & configuration settings. Templates are provided in the Standalone deployment package.</param>
 /// <param name="fabricRuntimePackagePath">Specifies the path to Service Fabric runtime package CAB file.</param>
 /// <param name="creationOptions">Options for cluster creation.</param>
 /// <param name="maxPercentFailedNodes">Maximum percentage of nodes allowed to fail during cluster creation. If more than this percentage of nodes fail, the cluster creation will fail and roll back. Default value is 0 percent.</param>
 /// <param name="timeout">Timeout for cluster creation. Default value null means there is no timeout for the creation process.</param>
 public static async Task CreateClusterAsync(
     string clusterConfigPath,
     string fabricRuntimePackagePath,
     ClusterCreationOptions creationOptions = ClusterCreationOptions.None,
     int maxPercentFailedNodes = 0,
     TimeSpan?timeout          = null)
 {
     await DeploymentManagerInternal.CreateClusterAsyncInternal(
         clusterConfigPath,
         null,
         null,
         true,
         FabricPackageType.XCopyPackage,
         fabricRuntimePackagePath,
         null,
         creationOptions,
         maxPercentFailedNodes,
         timeout).ConfigureAwait(false);
 }