Ejemplo n.º 1
0
        /// <summary>
        /// Copies an application package to the given cluster's image store.
        /// This expects the cluster to have the ImageStore service running.
        /// </summary>
        /// <param name="cluster"></param>
        /// <param name="applicationPackagePath"></param>
        /// <param name="applicationTypeName"></param>
        /// <param name="applicationTypeVersion"></param>
        /// <returns></returns>
        public Task <string> CopyPackageToImageStoreAsync(
            string cluster, string applicationPackagePath, string applicationTypeName, string applicationTypeVersion, CancellationToken token)
        {
            FabricClient fabricClient = this.GetClient(cluster);

            FabricClient.ApplicationManagementClient applicationClient = fabricClient.ApplicationManager;

            string imagestorePath = applicationTypeName + "_" + applicationTypeVersion;

            try
            {
                applicationClient.CopyApplicationPackage("fabric:ImageStore", applicationPackagePath, imagestorePath);
            }
            catch (System.Reflection.TargetInvocationException e)
            {
                // CopyApplicationPackages uses MethodInvoke internally to upload.
                // If that throws, we get TargetInvocationException.
                // This will rethrow the actual inner exception for the caller.
                if (e.InnerException != null)
                {
                    throw e.InnerException;
                }

                throw;
            }

            return(Task.FromResult(imagestorePath));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers an application type.
        /// </summary>
        /// <param name="cluster"></param>
        /// <param name="imageStorePath"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public Task RegisterApplicationAsync(string cluster, string imageStorePath, CancellationToken token)
        {
            FabricClient fabricClient = this.GetClient(cluster);

            FabricClient.ApplicationManagementClient applicationClient = fabricClient.ApplicationManager;

            // TODO: Error handling
            return(applicationClient.ProvisionApplicationAsync(imageStorePath, this.writeOperationTimeout, token));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an instance of an application.
        /// </summary>
        /// <param name="cluster"></param>
        /// <param name="applicationInstanceName"></param>
        /// <param name="applicationTypeName"></param>
        /// <param name="applicationTypeVersion"></param>
        /// <returns></returns>
        public async Task CreateApplicationAsync(
            string cluster, string applicationInstanceName, string applicationTypeName, string applicationTypeVersion, CancellationToken token)
        {
            FabricClient fabricClient = this.GetClient(cluster);

            FabricClient.ApplicationManagementClient applicationClient = fabricClient.ApplicationManager;

            Uri appName = new Uri("fabric:/" + applicationInstanceName);

            if (await this.ApplicationExistsAsync(cluster, applicationInstanceName, token))
            {
                return;
            }

            ApplicationDescription appDescription = new ApplicationDescription(appName, applicationTypeName, applicationTypeVersion);

            await applicationClient.CreateApplicationAsync(appDescription, this.writeOperationTimeout, token);
        }