//[Fact]
        public void TestResizeCluster()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
                var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);

                var          resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
                const string dnsname       = "hdisdk-resizetest";

                var spec = GetClusterSpecHelpers.GetPaasClusterSpec();

                client.Clusters.Create(resourceGroup, dnsname, spec);

                var cluster = client.Clusters.Get(resourceGroup, dnsname);

                var resizeParams = new ClusterResizeParameters
                {
                    TargetInstanceCount = 2
                };

                client.Clusters.Resize(resourceGroup, dnsname, resizeParams);

                cluster = client.Clusters.Get(resourceGroup, dnsname);

                client.Clusters.Delete(resourceGroup, dnsname);
            }
        }
Example #2
0
        /// <summary>
        /// Resizes the specified HDInsight cluster.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// Required. The name of the resource group.
        /// </param>
        /// <param name='clusterName'>
        /// Required. The name of the cluster.
        /// </param>
        /// <param name='targetInstanceCount'>
        /// Required. The target instance count for the resize operation.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// The cluster long running operation response.
        /// </returns>
        public async Task <AzureOperationResponse> ResizeAsync(string resourceGroupName, string clusterName, int targetInstanceCount, CancellationToken cancellationToken)
        {
            var resizeParams = new ClusterResizeParameters {
                TargetInstanceCount = targetInstanceCount
            };

            return(await ResizeWithHttpMessagesAsync(resourceGroupName, clusterName, resizeParams, null, cancellationToken).ConfigureAwait(false));
        }
        public void ResizeWithMissingTargetInstanceCount(HDInsightManagementClient client, string resourceGroup, string dnsname)
        {
            var resizeParams = new ClusterResizeParameters();

            try
            {
                client.Clusters.Resize(resourceGroup, dnsname, resizeParams);
            }
            catch (CloudException ex)
            {
                Assert.Equal(ex.Response.StatusCode, HttpStatusCode.BadRequest);
            }
        }
Example #4
0
 /// <summary>
 /// Begins resizing the specified HDInsight cluster.
 /// </summary>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='targetInstanceCount'>
 /// Required. The target instance count for the resize operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// Cancellation token.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public async Task <HDInsightOperationResponse> BeginResizingAsync(string resourceGroupName, string clusterName, int targetInstanceCount,
                                                                   CancellationToken cancellationToken)
 {
     try
     {
         var resizeParams = new ClusterResizeParameters {
             TargetInstanceCount = targetInstanceCount
         };
         return(await BeginResizingAsync(resourceGroupName, clusterName, resizeParams, cancellationToken));
     }
     catch (Exception ex)
     {
         throw new CloudException(ex.Message);
     }
 }
        public void ResizeToSameInstanceCount(HDInsightManagementClient client, string resourceGroup, string dnsname)
        {
            var cluster = client.Clusters.Get(resourceGroup, dnsname);
            var role    = cluster.Cluster.Properties.ComputeProfile.Roles.FirstOrDefault(r => r.Name == "DataNode");

            Assert.NotNull(role);
            var targetInstanceCount = role.TargetInstanceCount;

            var resizeParams = new ClusterResizeParameters
            {
                TargetInstanceCount = targetInstanceCount
            };

            try
            {
                client.Clusters.Resize(resourceGroup, dnsname, resizeParams);
            }
            catch
            {
            }
        }
Example #6
0
 public SetAzureHDInsightClusterSizeCommand()
 {
     resizeParams = new ClusterResizeParameters();
 }
Example #7
0
 public virtual void ResizeCluster(string resourceGroupName, string clusterName, ClusterResizeParameters resizeParams)
 {
     HdInsightManagementClient.Clusters.Resize(resourceGroupName, clusterName, resizeParams);
 }
Example #8
0
 /// <summary>
 /// Resizes the specified HDInsight cluster to the specified size.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the cluster.
 /// </param>
 /// <param name='parameters'>
 /// The parameters for the resize operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task BeginResizeAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterResizeParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.BeginResizeWithHttpMessagesAsync(resourceGroupName, clusterName, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Example #9
0
 /// <summary>
 /// Resizes the specified HDInsight cluster to the specified size.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the cluster.
 /// </param>
 /// <param name='parameters'>
 /// The parameters for the resize operation.
 /// </param>
 public static void BeginResize(this IClustersOperations operations, string resourceGroupName, string clusterName, ClusterResizeParameters parameters)
 {
     operations.BeginResizeAsync(resourceGroupName, clusterName, parameters).GetAwaiter().GetResult();
 }
Example #10
0
 public virtual OperationResource ResizeCluster(string resourceGroupName, string clusterName, ClusterResizeParameters resizeParams)
 {
     return(HdInsightManagementClient.Clusters.Resize(resourceGroupName, clusterName, resizeParams));
 }
 /// <summary>
 /// Resizes the specified HDInsight cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='resizeParameters'>
 /// Required. The parameters for the resize operation.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static Task <HDInsightLongRunningOperationResponse> ResizeAsync(this IClusterOperations operations, string resourceGroupName, string clusterName, ClusterResizeParameters resizeParameters)
 {
     return(operations.ResizeAsync(resourceGroupName, clusterName, resizeParameters, CancellationToken.None));
 }
 /// <summary>
 /// Resizes the specified HDInsight cluster.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.HDInsight.IClusterOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='clusterName'>
 /// Required. The name of the cluster.
 /// </param>
 /// <param name='resizeParameters'>
 /// Required. The parameters for the resize operation.
 /// </param>
 /// <returns>
 /// The cluster long running operation response.
 /// </returns>
 public static HDInsightLongRunningOperationResponse Resize(this IClusterOperations operations, string resourceGroupName, string clusterName, ClusterResizeParameters resizeParameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IClusterOperations)s).ResizeAsync(resourceGroupName, clusterName, resizeParameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }