Пример #1
0
 /// <summary>
 /// Initializes a new instance of the CloudPool class.
 /// </summary>
 /// <param name="id">A string that uniquely identifies the pool within
 /// the account.</param>
 /// <param name="displayName">The display name for the pool.</param>
 /// <param name="url">The URL of the pool.</param>
 /// <param name="eTag">The ETag of the pool.</param>
 /// <param name="lastModified">The last modified time of the
 /// pool.</param>
 /// <param name="creationTime">The creation time of the pool.</param>
 /// <param name="state">The current state of the pool.</param>
 /// <param name="stateTransitionTime">The time at which the pool
 /// entered its current state.</param>
 /// <param name="allocationState">Whether the pool is resizing.</param>
 /// <param name="allocationStateTransitionTime">The time at which the
 /// pool entered its current allocation state.</param>
 /// <param name="vmSize">The size of virtual machines in the pool. All
 /// virtual machines in a pool are the same size.</param>
 /// <param name="cloudServiceConfiguration">The cloud service
 /// configuration for the pool.</param>
 /// <param name="virtualMachineConfiguration">The virtual machine
 /// configuration for the pool.</param>
 /// <param name="resizeTimeout">The timeout for allocation of compute
 /// nodes to the pool.</param>
 /// <param name="resizeError">Details of any error encountered while
 /// performing the last resize on the pool.</param>
 /// <param name="currentDedicated">The number of compute nodes
 /// currently in the pool.</param>
 /// <param name="targetDedicated">The desired number of compute nodes
 /// in the pool.</param>
 /// <param name="enableAutoScale">Whether the pool size should
 /// automatically adjust over time.</param>
 /// <param name="autoScaleFormula">A formula for the desired number of
 /// compute nodes in the pool.</param>
 /// <param name="autoScaleEvaluationInterval">A time interval for the
 /// desired AutoScale evaluation period in the pool.</param>
 /// <param name="autoScaleRun">The results and errors from the last
 /// execution of the autoscale formula.</param>
 /// <param name="enableInterNodeCommunication">Whether the pool
 /// permits direct communication between nodes.</param>
 /// <param name="networkConfiguration">The network configuration for
 /// the pool.</param>
 /// <param name="startTask">A task specified to run on each compute
 /// node as it joins the pool.</param>
 /// <param name="certificateReferences">The list of certificates to be
 /// installed on each compute node in the pool.</param>
 /// <param name="applicationPackageReferences">The list of application
 /// packages to be installed on each compute node in the pool.</param>
 /// <param name="maxTasksPerNode">The maximum number of tasks that can
 /// run concurrently on a single compute node in the pool.</param>
 /// <param name="taskSchedulingPolicy">How the Batch service
 /// distributes tasks between compute nodes in the pool.</param>
 /// <param name="metadata">A list of name-value pairs associated with
 /// the pool as metadata.</param>
 /// <param name="stats">Utilization and resource usage statistics for
 /// the entire lifetime of the pool.</param>
 public CloudPool(string id = default(string), string displayName = default(string), string url = default(string), string eTag = default(string), System.DateTime?lastModified = default(System.DateTime?), System.DateTime?creationTime = default(System.DateTime?), PoolState?state = default(PoolState?), System.DateTime?stateTransitionTime = default(System.DateTime?), AllocationState?allocationState = default(AllocationState?), System.DateTime?allocationStateTransitionTime = default(System.DateTime?), string vmSize = default(string), CloudServiceConfiguration cloudServiceConfiguration = default(CloudServiceConfiguration), VirtualMachineConfiguration virtualMachineConfiguration = default(VirtualMachineConfiguration), System.TimeSpan?resizeTimeout = default(System.TimeSpan?), ResizeError resizeError = default(ResizeError), int?currentDedicated = default(int?), int?targetDedicated = default(int?), bool?enableAutoScale = default(bool?), string autoScaleFormula = default(string), System.TimeSpan?autoScaleEvaluationInterval = default(System.TimeSpan?), AutoScaleRun autoScaleRun = default(AutoScaleRun), bool?enableInterNodeCommunication = default(bool?), NetworkConfiguration networkConfiguration = default(NetworkConfiguration), StartTask startTask = default(StartTask), System.Collections.Generic.IList <CertificateReference> certificateReferences = default(System.Collections.Generic.IList <CertificateReference>), System.Collections.Generic.IList <ApplicationPackageReference> applicationPackageReferences = default(System.Collections.Generic.IList <ApplicationPackageReference>), int?maxTasksPerNode = default(int?), TaskSchedulingPolicy taskSchedulingPolicy = default(TaskSchedulingPolicy), System.Collections.Generic.IList <MetadataItem> metadata = default(System.Collections.Generic.IList <MetadataItem>), PoolStatistics stats = default(PoolStatistics))
 {
     Id                            = id;
     DisplayName                   = displayName;
     Url                           = url;
     ETag                          = eTag;
     LastModified                  = lastModified;
     CreationTime                  = creationTime;
     State                         = state;
     StateTransitionTime           = stateTransitionTime;
     AllocationState               = allocationState;
     AllocationStateTransitionTime = allocationStateTransitionTime;
     VmSize                        = vmSize;
     CloudServiceConfiguration     = cloudServiceConfiguration;
     VirtualMachineConfiguration   = virtualMachineConfiguration;
     ResizeTimeout                 = resizeTimeout;
     ResizeError                   = resizeError;
     CurrentDedicated              = currentDedicated;
     TargetDedicated               = targetDedicated;
     EnableAutoScale               = enableAutoScale;
     AutoScaleFormula              = autoScaleFormula;
     AutoScaleEvaluationInterval   = autoScaleEvaluationInterval;
     AutoScaleRun                  = autoScaleRun;
     EnableInterNodeCommunication  = enableInterNodeCommunication;
     NetworkConfiguration          = networkConfiguration;
     StartTask                     = startTask;
     CertificateReferences         = certificateReferences;
     ApplicationPackageReferences  = applicationPackageReferences;
     MaxTasksPerNode               = maxTasksPerNode;
     TaskSchedulingPolicy          = taskSchedulingPolicy;
     Metadata                      = metadata;
     Stats                         = stats;
 }
Пример #2
0
        public void GetPoolResizeError()
        {
            var autoScaleRunError = new Models.AutoScaleRunError
            {
                Code    = "InsufficientSampleData",
                Message = "Autoscale evaluation failed due to insufficient sample data",
                Values  = new List <Models.NameValuePair>
                {
                    new Models.NameValuePair
                    {
                        Name  = "Message",
                        Value = "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%"
                    }
                }
            };

            var autoScaleError = new Models.AutoScaleRun {
                Error = autoScaleRunError
            };

            BatchSharedKeyCredentials credentials = ClientUnitTestCommon.CreateDummySharedKeyCredential();

            using (BatchClient client = BatchClient.Open(credentials))
            {
                Protocol.RequestInterceptor interceptor = new Protocol.RequestInterceptor(baseRequest =>
                {
                    var request = (Protocol.BatchRequest <Models.PoolGetOptions, AzureOperationResponse <Models.CloudPool, Models.PoolGetHeaders> >)baseRequest;

                    request.ServiceRequestFunc = async(token) =>
                    {
                        var response = new AzureOperationResponse <Models.CloudPool, Models.PoolGetHeaders>
                        {
                            Body = new Models.CloudPool
                            {
                                DisplayName      = "batch-test",
                                AutoScaleFormula = "$RunningTasks.GetSample(10 * TimeInterval_Second, 0 * TimeInterval_Second, 100);",
                                AutoScaleRun     = autoScaleError,
                                EnableAutoScale  = true,
                            }
                        };

                        var task = Task.FromResult(response);
                        return(await task);
                    };
                });

                var pool = client.PoolOperations.GetPool("batch-test", additionalBehaviors: new List <BatchClientBehavior> {
                    interceptor
                });

                Assert.Equal("batch-test", pool.DisplayName);
                Assert.Equal(pool.AutoScaleEnabled, true);
                Assert.Equal(pool.AutoScaleRun.Error.Code, "InsufficientSampleData");
                Assert.Equal(pool.AutoScaleRun.Error.Message, "Autoscale evaluation failed due to insufficient sample data");
                Assert.Equal(pool.AutoScaleRun.Error.Values.First().Name, "Message");
                Assert.Equal(pool.AutoScaleRun.Error.Values.First().Value, "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%");
            }
        }
Пример #3
0
        public void GetPoolResizeError()
        {
            var autoScaleRunError = new AutoScaleRunError
            {
                Code    = "InsufficientSampleData",
                Message = "Autoscale evaluation failed due to insufficient sample data",
                Values  = new List <NameValuePair>
                {
                    new NameValuePair
                    {
                        Name  = "Message",
                        Value = "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%"
                    }
                }
            };

            var autoScaleError = new AutoScaleRun {
                Error = autoScaleRunError
            };

            using (var client = FakeBatchClient.ConnectWithFakeCredentials(ClientUnitTestCommon.DummyBaseUrl))
            {
                client.FakeProtocolLayer.GetPoolHandler = (skipToken, behaviors) => Task.FromResult(
                    new AzureOperationResponse <ProxyModels.CloudPool, ProxyModels.PoolGetHeaders>
                {
                    Body = new ProxyModels.CloudPool
                    {
                        DisplayName      = "batch-test",
                        AutoScaleFormula = "$RunningTasks.GetSample(10 * TimeInterval_Second, 0 * TimeInterval_Second, 100);",
                        AutoScaleRun     = autoScaleError,
                        EnableAutoScale  = true,
                    }
                });

                var pool = client.PoolOperations.GetPool("batch-test");

                Assert.Equal("batch-test", pool.DisplayName);
                Assert.Equal(pool.AutoScaleEnabled, true);
                Assert.Equal(pool.AutoScaleRun.Error.Code, "InsufficientSampleData");
                Assert.Equal(pool.AutoScaleRun.Error.Message, "Autoscale evaluation failed due to insufficient sample data");
                Assert.Equal(pool.AutoScaleRun.Error.Values.First().Name, "Message");
                Assert.Equal(pool.AutoScaleRun.Error.Values.First().Value, "Line 1, Col 24: Insufficient data from data set: $RunningTasks wanted 100%, received 0%");
            }
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the CloudPool class.
 /// </summary>
 /// <param name="id">A string that uniquely identifies the Pool within
 /// the Account.</param>
 /// <param name="displayName">The display name for the Pool.</param>
 /// <param name="url">The URL of the Pool.</param>
 /// <param name="eTag">The ETag of the Pool.</param>
 /// <param name="lastModified">The last modified time of the
 /// Pool.</param>
 /// <param name="creationTime">The creation time of the Pool.</param>
 /// <param name="state">The current state of the Pool.</param>
 /// <param name="stateTransitionTime">The time at which the Pool
 /// entered its current state.</param>
 /// <param name="allocationState">Whether the Pool is resizing.</param>
 /// <param name="allocationStateTransitionTime">The time at which the
 /// Pool entered its current allocation state.</param>
 /// <param name="vmSize">The size of virtual machines in the Pool. All
 /// virtual machines in a Pool are the same size.</param>
 /// <param name="cloudServiceConfiguration">The cloud service
 /// configuration for the Pool.</param>
 /// <param name="virtualMachineConfiguration">The virtual machine
 /// configuration for the Pool.</param>
 /// <param name="resizeTimeout">The timeout for allocation of Compute
 /// Nodes to the Pool.</param>
 /// <param name="resizeErrors">A list of errors encountered while
 /// performing the last resize on the Pool.</param>
 /// <param name="currentDedicatedNodes">The number of dedicated Compute
 /// Nodes currently in the Pool.</param>
 /// <param name="currentLowPriorityNodes">The number of low-priority
 /// Compute Nodes currently in the Pool.</param>
 /// <param name="targetDedicatedNodes">The desired number of dedicated
 /// Compute Nodes in the Pool.</param>
 /// <param name="targetLowPriorityNodes">The desired number of
 /// low-priority Compute Nodes in the Pool.</param>
 /// <param name="enableAutoScale">Whether the Pool size should
 /// automatically adjust over time.</param>
 /// <param name="autoScaleFormula">A formula for the desired number of
 /// Compute Nodes in the Pool.</param>
 /// <param name="autoScaleEvaluationInterval">The time interval at
 /// which to automatically adjust the Pool size according to the
 /// autoscale formula.</param>
 /// <param name="autoScaleRun">The results and errors from the last
 /// execution of the autoscale formula.</param>
 /// <param name="enableInterNodeCommunication">Whether the Pool permits
 /// direct communication between Compute Nodes.</param>
 /// <param name="networkConfiguration">The network configuration for
 /// the Pool.</param>
 /// <param name="startTask">A Task specified to run on each Compute
 /// Node as it joins the Pool.</param>
 /// <param name="certificateReferences">The list of Certificates to be
 /// installed on each Compute Node in the Pool.</param>
 /// <param name="applicationPackageReferences">The list of Packages to
 /// be installed on each Compute Node in the Pool.</param>
 /// <param name="applicationLicenses">The list of application licenses
 /// the Batch service will make available on each Compute Node in the
 /// Pool.</param>
 /// <param name="taskSlotsPerNode">The number of task slots that can be
 /// used to run concurrent tasks on a single compute node in the
 /// pool.</param>
 /// <param name="taskSchedulingPolicy">How Tasks are distributed across
 /// Compute Nodes in a Pool.</param>
 /// <param name="userAccounts">The list of user Accounts to be created
 /// on each Compute Node in the Pool.</param>
 /// <param name="metadata">A list of name-value pairs associated with
 /// the Pool as metadata.</param>
 /// <param name="stats">Utilization and resource usage statistics for
 /// the entire lifetime of the Pool.</param>
 /// <param name="mountConfiguration">A list of file systems to mount on
 /// each node in the pool.</param>
 /// <param name="identity">The identity of the Batch pool, if
 /// configured.</param>
 public CloudPool(string id = default(string), string displayName = default(string), string url = default(string), string eTag = default(string), System.DateTime?lastModified = default(System.DateTime?), System.DateTime?creationTime = default(System.DateTime?), PoolState?state = default(PoolState?), System.DateTime?stateTransitionTime = default(System.DateTime?), AllocationState?allocationState = default(AllocationState?), System.DateTime?allocationStateTransitionTime = default(System.DateTime?), string vmSize = default(string), CloudServiceConfiguration cloudServiceConfiguration = default(CloudServiceConfiguration), VirtualMachineConfiguration virtualMachineConfiguration = default(VirtualMachineConfiguration), System.TimeSpan?resizeTimeout = default(System.TimeSpan?), IList <ResizeError> resizeErrors = default(IList <ResizeError>), int?currentDedicatedNodes = default(int?), int?currentLowPriorityNodes = default(int?), int?targetDedicatedNodes = default(int?), int?targetLowPriorityNodes = default(int?), bool?enableAutoScale = default(bool?), string autoScaleFormula = default(string), System.TimeSpan?autoScaleEvaluationInterval = default(System.TimeSpan?), AutoScaleRun autoScaleRun = default(AutoScaleRun), bool?enableInterNodeCommunication = default(bool?), NetworkConfiguration networkConfiguration = default(NetworkConfiguration), StartTask startTask = default(StartTask), IList <CertificateReference> certificateReferences = default(IList <CertificateReference>), IList <ApplicationPackageReference> applicationPackageReferences = default(IList <ApplicationPackageReference>), IList <string> applicationLicenses = default(IList <string>), int?taskSlotsPerNode = default(int?), TaskSchedulingPolicy taskSchedulingPolicy = default(TaskSchedulingPolicy), IList <UserAccount> userAccounts = default(IList <UserAccount>), IList <MetadataItem> metadata = default(IList <MetadataItem>), PoolStatistics stats = default(PoolStatistics), IList <MountConfiguration> mountConfiguration = default(IList <MountConfiguration>), BatchPoolIdentity identity = default(BatchPoolIdentity))
 {
     Id                            = id;
     DisplayName                   = displayName;
     Url                           = url;
     ETag                          = eTag;
     LastModified                  = lastModified;
     CreationTime                  = creationTime;
     State                         = state;
     StateTransitionTime           = stateTransitionTime;
     AllocationState               = allocationState;
     AllocationStateTransitionTime = allocationStateTransitionTime;
     VmSize                        = vmSize;
     CloudServiceConfiguration     = cloudServiceConfiguration;
     VirtualMachineConfiguration   = virtualMachineConfiguration;
     ResizeTimeout                 = resizeTimeout;
     ResizeErrors                  = resizeErrors;
     CurrentDedicatedNodes         = currentDedicatedNodes;
     CurrentLowPriorityNodes       = currentLowPriorityNodes;
     TargetDedicatedNodes          = targetDedicatedNodes;
     TargetLowPriorityNodes        = targetLowPriorityNodes;
     EnableAutoScale               = enableAutoScale;
     AutoScaleFormula              = autoScaleFormula;
     AutoScaleEvaluationInterval   = autoScaleEvaluationInterval;
     AutoScaleRun                  = autoScaleRun;
     EnableInterNodeCommunication  = enableInterNodeCommunication;
     NetworkConfiguration          = networkConfiguration;
     StartTask                     = startTask;
     CertificateReferences         = certificateReferences;
     ApplicationPackageReferences  = applicationPackageReferences;
     ApplicationLicenses           = applicationLicenses;
     TaskSlotsPerNode              = taskSlotsPerNode;
     TaskSchedulingPolicy          = taskSchedulingPolicy;
     UserAccounts                  = userAccounts;
     Metadata                      = metadata;
     Stats                         = stats;
     MountConfiguration            = mountConfiguration;
     Identity                      = identity;
     CustomInit();
 }
Пример #5
0
 internal AutoScaleRun(Models.AutoScaleRun protocolObject)
 {
     this.error     = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.Error, o => new AutoScaleRunError(o).Freeze());
     this.results   = protocolObject.Results;
     this.timestamp = protocolObject.Timestamp;
 }