/// <summary> /// Initializes a new instance of the CloudJob class. /// </summary> /// <param name="id">A string that uniquely identifies the Job within /// the Account.</param> /// <param name="displayName">The display name for the Job.</param> /// <param name="usesTaskDependencies">Whether Tasks in the Job can /// define dependencies on each other. The default is false.</param> /// <param name="url">The URL of the Job.</param> /// <param name="eTag">The ETag of the Job.</param> /// <param name="lastModified">The last modified time of the /// Job.</param> /// <param name="creationTime">The creation time of the Job.</param> /// <param name="state">The current state of the Job.</param> /// <param name="stateTransitionTime">The time at which the Job entered /// its current state.</param> /// <param name="previousState">The previous state of the Job.</param> /// <param name="previousStateTransitionTime">The time at which the Job /// entered its previous state.</param> /// <param name="priority">The priority of the Job.</param> /// <param name="maxParallelTasks">The maximum number of tasks that can /// be executed in parallel for the job.</param> /// <param name="constraints">The execution constraints for the /// Job.</param> /// <param name="jobManagerTask">Details of a Job Manager Task to be /// launched when the Job is started.</param> /// <param name="jobPreparationTask">The Job Preparation Task.</param> /// <param name="jobReleaseTask">The Job Release Task.</param> /// <param name="commonEnvironmentSettings">The list of common /// environment variable settings. These environment variables are set /// for all Tasks in the Job (including the Job Manager, Job /// Preparation and Job Release Tasks).</param> /// <param name="poolInfo">The Pool settings associated with the /// Job.</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all Tasks in the Job are in the completed /// state.</param> /// <param name="onTaskFailure">The action the Batch service should /// take when any Task in the Job fails.</param> /// <param name="networkConfiguration">The network configuration for /// the Job.</param> /// <param name="metadata">A list of name-value pairs associated with /// the Job as metadata.</param> /// <param name="executionInfo">The execution information for the /// Job.</param> /// <param name="stats">Resource usage statistics for the entire /// lifetime of the Job.</param> public CloudJob(string id = default(string), string displayName = default(string), bool?usesTaskDependencies = default(bool?), string url = default(string), string eTag = default(string), System.DateTime?lastModified = default(System.DateTime?), System.DateTime?creationTime = default(System.DateTime?), JobState?state = default(JobState?), System.DateTime?stateTransitionTime = default(System.DateTime?), JobState?previousState = default(JobState?), System.DateTime?previousStateTransitionTime = default(System.DateTime?), int?priority = default(int?), int?maxParallelTasks = default(int?), JobConstraints constraints = default(JobConstraints), JobManagerTask jobManagerTask = default(JobManagerTask), JobPreparationTask jobPreparationTask = default(JobPreparationTask), JobReleaseTask jobReleaseTask = default(JobReleaseTask), IList <EnvironmentSetting> commonEnvironmentSettings = default(IList <EnvironmentSetting>), PoolInformation poolInfo = default(PoolInformation), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?), OnTaskFailure?onTaskFailure = default(OnTaskFailure?), JobNetworkConfiguration networkConfiguration = default(JobNetworkConfiguration), IList <MetadataItem> metadata = default(IList <MetadataItem>), JobExecutionInformation executionInfo = default(JobExecutionInformation), JobStatistics stats = default(JobStatistics)) { Id = id; DisplayName = displayName; UsesTaskDependencies = usesTaskDependencies; Url = url; ETag = eTag; LastModified = lastModified; CreationTime = creationTime; State = state; StateTransitionTime = stateTransitionTime; PreviousState = previousState; PreviousStateTransitionTime = previousStateTransitionTime; Priority = priority; MaxParallelTasks = maxParallelTasks; Constraints = constraints; JobManagerTask = jobManagerTask; JobPreparationTask = jobPreparationTask; JobReleaseTask = jobReleaseTask; CommonEnvironmentSettings = commonEnvironmentSettings; PoolInfo = poolInfo; OnAllTasksComplete = onAllTasksComplete; OnTaskFailure = onTaskFailure; NetworkConfiguration = networkConfiguration; Metadata = metadata; ExecutionInfo = executionInfo; Stats = stats; CustomInit(); }
/// <summary> /// Commits all pending changes to this <see cref="CloudJob" /> to the Azure Batch service. /// </summary> /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param> /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> /// <remarks> /// <para> /// Updates an existing <see cref="CloudJob"/> on the Batch service by replacing its properties with the properties of this <see cref="CloudJob"/> which have been changed. /// Unchanged properties are ignored. /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refresh"/>, <see cref="JobOperations.GetJob"/>, /// or <see cref="JobOperations.ListJobs"/>) are applied. /// Properties which are explicitly set to null will cause an exception because the Batch service does not support partial updates which set a property to null. /// If you need to set a property to null, use <see cref="Commit"/>. /// </para> /// <para>This operation runs asynchronously.</para> /// </remarks> public async Task CommitChangesAsync( IEnumerable <BatchClientBehavior> additionalBehaviors = null, CancellationToken cancellationToken = default(CancellationToken)) { UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); // first forbid actions during patch this.propertyContainer.IsReadOnly = true; // craft the behavior manager for this call BehaviorManager behaveMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); Models.MetadataItem[] modelMetadata = this.propertyContainer.MetadataProperty. GetTransportObjectIfChanged <MetadataItem, Models.MetadataItem>(); Models.JobConstraints modelJobConstraints = this.propertyContainer.ConstraintsProperty. GetTransportObjectIfChanged <JobConstraints, Models.JobConstraints>(); Models.PoolInformation modelPoolInformation = this.propertyContainer.PoolInformationProperty. GetTransportObjectIfChanged <PoolInformation, Models.PoolInformation>(); int?priority = this.propertyContainer.PriorityProperty.GetIfChangedOrNull(); Task asyncTask = this.parentBatchClient.ProtocolLayer.PatchJob( this.Id, priority, UtilitiesInternal.MapNullableEnum <Common.OnAllTasksComplete, Models.OnAllTasksComplete>(this.OnAllTasksComplete), modelPoolInformation, modelJobConstraints, modelMetadata, behaveMgr, cancellationToken); await asyncTask.ConfigureAwait(continueOnCapturedContext : false); }
/// <summary> /// Initializes a new instance of the JobUpdateParameter class. /// </summary> /// <param name="poolInfo">The pool on which the Batch service runs /// the job's tasks.</param> /// <param name="priority">The priority of the job.</param> /// <param name="constraints">The execution constraints for the /// job.</param> /// <param name="metadata">A list of name-value pairs associated with /// the job as metadata.</param> /// <param name="onAllTasksComplete">Specifies an action the Batch /// service should take when all tasks in the job are in the /// completed state. Possible values include: 'noAction', /// 'terminateJob'</param> public JobUpdateParameter(PoolInformation poolInfo, int?priority = default(int?), JobConstraints constraints = default(JobConstraints), System.Collections.Generic.IList <MetadataItem> metadata = default(System.Collections.Generic.IList <MetadataItem>), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?)) { Priority = priority; Constraints = constraints; PoolInfo = poolInfo; Metadata = metadata; OnAllTasksComplete = onAllTasksComplete; }
/// <summary> /// Initializes a new instance of the JobPatchParameter class. /// </summary> /// <param name="priority">The priority of the job.</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all tasks in the job are in the completed /// state.</param> /// <param name="constraints">The execution constraints for the /// job.</param> /// <param name="poolInfo">The pool on which the Batch service runs the /// job's tasks.</param> /// <param name="metadata">A list of name-value pairs associated with /// the job as metadata.</param> public JobPatchParameter(int?priority = default(int?), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?), JobConstraints constraints = default(JobConstraints), PoolInformation poolInfo = default(PoolInformation), IList <MetadataItem> metadata = default(IList <MetadataItem>)) { Priority = priority; OnAllTasksComplete = onAllTasksComplete; Constraints = constraints; PoolInfo = poolInfo; Metadata = metadata; CustomInit(); }
public PropertyContainer(Models.PoolInformation protocolObject) : base(BindingState.Bound) { this.AutoPoolSpecificationProperty = this.CreatePropertyAccessor( UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.AutoPoolSpecification, o => new AutoPoolSpecification(o)), "AutoPoolSpecification", BindingAccess.Read | BindingAccess.Write); this.PoolIdProperty = this.CreatePropertyAccessor( protocolObject.PoolId, "PoolId", BindingAccess.Read | BindingAccess.Write); }
/// <summary> /// Initializes a new instance of the JobUpdateParameter class. /// </summary> /// <param name="poolInfo">The Pool on which the Batch service runs the /// Job's Tasks.</param> /// <param name="priority">The priority of the Job.</param> /// <param name="maxParallelTasks">The maximum number of tasks that can /// be executed in parallel for the job.</param> /// <param name="allowTaskPreemption">Whether Tasks in this job can be /// preempted by other high priority jobs</param> /// <param name="constraints">The execution constraints for the /// Job.</param> /// <param name="metadata">A list of name-value pairs associated with /// the Job as metadata.</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all Tasks in the Job are in the completed /// state.</param> public JobUpdateParameter(PoolInformation poolInfo, int?priority = default(int?), int?maxParallelTasks = default(int?), bool?allowTaskPreemption = default(bool?), JobConstraints constraints = default(JobConstraints), IList <MetadataItem> metadata = default(IList <MetadataItem>), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?)) { Priority = priority; MaxParallelTasks = maxParallelTasks; AllowTaskPreemption = allowTaskPreemption; Constraints = constraints; PoolInfo = poolInfo; Metadata = metadata; OnAllTasksComplete = onAllTasksComplete; CustomInit(); }
/// <summary> /// Initializes a new instance of the JobSpecification class. /// </summary> /// <param name="poolInfo">The pool on which the Batch service runs /// the tasks of jobs created under this schedule.</param> /// <param name="priority">The priority of jobs created under this /// schedule.</param> /// <param name="displayName">The display name for jobs created under /// this schedule.</param> /// <param name="usesTaskDependencies">The flag that determines if /// this job will use tasks with dependencies.</param> /// <param name="constraints">The execution constraints for jobs /// created under this schedule.</param> /// <param name="jobManagerTask">The details of a Job Manager task to /// be launched when a job is started under this schedule.</param> /// <param name="jobPreparationTask">The Job Preparation task for jobs /// created under this schedule.</param> /// <param name="jobReleaseTask">The Job Release task for jobs created /// under this schedule.</param> /// <param name="commonEnvironmentSettings">A list of common /// environment variable settings. These environment variables are /// set for all tasks in jobs created under this schedule (including /// the Job Manager, Job Preparation and Job Release tasks).</param> /// <param name="metadata">A list of name-value pairs associated with /// each job created under this schedule as metadata.</param> public JobSpecification(PoolInformation poolInfo, int?priority = default(int?), string displayName = default(string), bool?usesTaskDependencies = default(bool?), JobConstraints constraints = default(JobConstraints), JobManagerTask jobManagerTask = default(JobManagerTask), JobPreparationTask jobPreparationTask = default(JobPreparationTask), JobReleaseTask jobReleaseTask = default(JobReleaseTask), System.Collections.Generic.IList <EnvironmentSetting> commonEnvironmentSettings = default(System.Collections.Generic.IList <EnvironmentSetting>), System.Collections.Generic.IList <MetadataItem> metadata = default(System.Collections.Generic.IList <MetadataItem>)) { Priority = priority; DisplayName = displayName; UsesTaskDependencies = usesTaskDependencies; Constraints = constraints; JobManagerTask = jobManagerTask; JobPreparationTask = jobPreparationTask; JobReleaseTask = jobReleaseTask; CommonEnvironmentSettings = commonEnvironmentSettings; PoolInfo = poolInfo; Metadata = metadata; }
/// <summary> /// Initializes a new instance of the JobAddParameter class. /// </summary> /// <param name="id">A string that uniquely identifies the job within /// the account.</param> /// <param name="poolInfo">The pool on which the Batch service runs /// the job's tasks.</param> /// <param name="displayName">The display name for the job.</param> /// <param name="priority">The priority of the job.</param> /// <param name="constraints">The execution constraints for the /// job.</param> /// <param name="jobManagerTask">Details of a Job Manager task to be /// launched when the job is started.</param> /// <param name="jobPreparationTask">The Job Preparation task.</param> /// <param name="jobReleaseTask">The Job Release task.</param> /// <param name="commonEnvironmentSettings">The list of common /// environment variable settings. These environment variables are /// set for all tasks in the job (including the Job Manager, Job /// Preparation and Job Release tasks).</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all tasks in the job are in the completed state. /// Possible values include: 'noAction', 'terminateJob'</param> /// <param name="onTaskFailure">The action the Batch service should /// take when any task in the job fails. A task is considered to have /// failed if it completes with a non-zero exit code and has /// exhausted its retry count, or if it had a scheduling error. /// Possible values include: 'noAction', /// 'performExitOptionsJobAction'</param> /// <param name="metadata">A list of name-value pairs associated with /// the job as metadata.</param> /// <param name="usesTaskDependencies">The flag that determines if /// this job will use tasks with dependencies.</param> public JobAddParameter(string id, PoolInformation poolInfo, string displayName = default(string), int?priority = default(int?), JobConstraints constraints = default(JobConstraints), JobManagerTask jobManagerTask = default(JobManagerTask), JobPreparationTask jobPreparationTask = default(JobPreparationTask), JobReleaseTask jobReleaseTask = default(JobReleaseTask), System.Collections.Generic.IList <EnvironmentSetting> commonEnvironmentSettings = default(System.Collections.Generic.IList <EnvironmentSetting>), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?), OnTaskFailure?onTaskFailure = default(OnTaskFailure?), System.Collections.Generic.IList <MetadataItem> metadata = default(System.Collections.Generic.IList <MetadataItem>), bool?usesTaskDependencies = default(bool?)) { Id = id; DisplayName = displayName; Priority = priority; Constraints = constraints; JobManagerTask = jobManagerTask; JobPreparationTask = jobPreparationTask; JobReleaseTask = jobReleaseTask; CommonEnvironmentSettings = commonEnvironmentSettings; PoolInfo = poolInfo; OnAllTasksComplete = onAllTasksComplete; OnTaskFailure = onTaskFailure; Metadata = metadata; UsesTaskDependencies = usesTaskDependencies; }
/// <summary> /// Initializes a new instance of the JobSpecification class. /// </summary> /// <param name="poolInfo">The Pool on which the Batch service runs the /// Tasks of Jobs created under this schedule.</param> /// <param name="priority">The priority of Jobs created under this /// schedule.</param> /// <param name="displayName">The display name for Jobs created under /// this schedule.</param> /// <param name="usesTaskDependencies">Whether Tasks in the Job can /// define dependencies on each other. The default is false.</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all Tasks in a Job created under this schedule are /// in the completed state.</param> /// <param name="onTaskFailure">The action the Batch service should /// take when any Task fails in a Job created under this schedule. A /// Task is considered to have failed if it have failed if has a /// failureInfo. A failureInfo is set if the Task completes with a /// non-zero exit code after exhausting its retry count, or if there /// was an error starting the Task, for example due to a resource file /// download error.</param> /// <param name="networkConfiguration">The network configuration for /// the Job.</param> /// <param name="constraints">The execution constraints for Jobs /// created under this schedule.</param> /// <param name="jobManagerTask">The details of a Job Manager Task to /// be launched when a Job is started under this schedule.</param> /// <param name="jobPreparationTask">The Job Preparation Task for Jobs /// created under this schedule.</param> /// <param name="jobReleaseTask">The Job Release Task for Jobs created /// under this schedule.</param> /// <param name="commonEnvironmentSettings">A list of common /// environment variable settings. These environment variables are set /// for all Tasks in Jobs created under this schedule (including the /// Job Manager, Job Preparation and Job Release Tasks).</param> /// <param name="metadata">A list of name-value pairs associated with /// each Job created under this schedule as metadata.</param> public JobSpecification(PoolInformation poolInfo, int?priority = default(int?), string displayName = default(string), bool?usesTaskDependencies = default(bool?), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?), OnTaskFailure?onTaskFailure = default(OnTaskFailure?), JobNetworkConfiguration networkConfiguration = default(JobNetworkConfiguration), JobConstraints constraints = default(JobConstraints), JobManagerTask jobManagerTask = default(JobManagerTask), JobPreparationTask jobPreparationTask = default(JobPreparationTask), JobReleaseTask jobReleaseTask = default(JobReleaseTask), IList <EnvironmentSetting> commonEnvironmentSettings = default(IList <EnvironmentSetting>), IList <MetadataItem> metadata = default(IList <MetadataItem>)) { Priority = priority; DisplayName = displayName; UsesTaskDependencies = usesTaskDependencies; OnAllTasksComplete = onAllTasksComplete; OnTaskFailure = onTaskFailure; NetworkConfiguration = networkConfiguration; Constraints = constraints; JobManagerTask = jobManagerTask; JobPreparationTask = jobPreparationTask; JobReleaseTask = jobReleaseTask; CommonEnvironmentSettings = commonEnvironmentSettings; PoolInfo = poolInfo; Metadata = metadata; CustomInit(); }
/// <summary> /// Initializes a new instance of the JobAddParameter class. /// </summary> /// <param name="id">A string that uniquely identifies the Job within /// the Account.</param> /// <param name="poolInfo">The Pool on which the Batch service runs the /// Job's Tasks.</param> /// <param name="displayName">The display name for the Job.</param> /// <param name="priority">The priority of the Job.</param> /// <param name="maxParallelTasks">The maximum number of tasks that can /// be executed in parallel for the job.</param> /// <param name="allowTaskPreemption">Whether Tasks in this job can be /// preempted by other high priority jobs</param> /// <param name="constraints">The execution constraints for the /// Job.</param> /// <param name="jobManagerTask">Details of a Job Manager Task to be /// launched when the Job is started.</param> /// <param name="jobPreparationTask">The Job Preparation Task.</param> /// <param name="jobReleaseTask">The Job Release Task.</param> /// <param name="commonEnvironmentSettings">The list of common /// environment variable settings. These environment variables are set /// for all Tasks in the Job (including the Job Manager, Job /// Preparation and Job Release Tasks).</param> /// <param name="onAllTasksComplete">The action the Batch service /// should take when all Tasks in the Job are in the completed /// state.</param> /// <param name="onTaskFailure">The action the Batch service should /// take when any Task in the Job fails.</param> /// <param name="metadata">A list of name-value pairs associated with /// the Job as metadata.</param> /// <param name="usesTaskDependencies">Whether Tasks in the Job can /// define dependencies on each other. The default is false.</param> /// <param name="networkConfiguration">The network configuration for /// the Job.</param> public JobAddParameter(string id, PoolInformation poolInfo, string displayName = default(string), int?priority = default(int?), int?maxParallelTasks = default(int?), bool?allowTaskPreemption = default(bool?), JobConstraints constraints = default(JobConstraints), JobManagerTask jobManagerTask = default(JobManagerTask), JobPreparationTask jobPreparationTask = default(JobPreparationTask), JobReleaseTask jobReleaseTask = default(JobReleaseTask), IList <EnvironmentSetting> commonEnvironmentSettings = default(IList <EnvironmentSetting>), OnAllTasksComplete?onAllTasksComplete = default(OnAllTasksComplete?), OnTaskFailure?onTaskFailure = default(OnTaskFailure?), IList <MetadataItem> metadata = default(IList <MetadataItem>), bool?usesTaskDependencies = default(bool?), JobNetworkConfiguration networkConfiguration = default(JobNetworkConfiguration)) { Id = id; DisplayName = displayName; Priority = priority; MaxParallelTasks = maxParallelTasks; AllowTaskPreemption = allowTaskPreemption; Constraints = constraints; JobManagerTask = jobManagerTask; JobPreparationTask = jobPreparationTask; JobReleaseTask = jobReleaseTask; CommonEnvironmentSettings = commonEnvironmentSettings; PoolInfo = poolInfo; OnAllTasksComplete = onAllTasksComplete; OnTaskFailure = onTaskFailure; Metadata = metadata; UsesTaskDependencies = usesTaskDependencies; NetworkConfiguration = networkConfiguration; CustomInit(); }
/// <summary> /// Commits this <see cref="CloudJob" /> to the Azure Batch service. /// </summary> /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are applied to the Batch service request after the <see cref="CustomBehaviors"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param> /// <returns>A <see cref="Task"/> that represents the asynchronous operation.</returns> /// <remarks> /// <para>If the <see cref="CloudJob"/> already exists on the Batch service, its properties are replaced by the properties of this <see cref="CloudJob"/>.</para> /// <para>The commit operation runs asynchronously.</para> /// </remarks> public async Task CommitAsync( IEnumerable <BatchClientBehavior> additionalBehaviors = null, CancellationToken cancellationToken = default) { // first forbid actions during commit this.propertyContainer.IsReadOnly = true; // craft the behavior manager for this call BehaviorManager behaveMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); // hold the tpl task for the server call Task asyncTask; if (BindingState.Unbound == this.propertyContainer.BindingState) // unbound commit { // take all property changes and create a job Models.JobAddParameter protoJob = this.GetTransportObject(); asyncTask = parentBatchClient.ProtocolLayer.AddJob(protoJob, behaveMgr, cancellationToken); } else { Models.MetadataItem[] modelMetadata = UtilitiesInternal.ConvertToProtocolArray(this.Metadata); Models.JobConstraints modelJobConstraints = UtilitiesInternal.CreateObjectWithNullCheck(this.Constraints, item => item.GetTransportObject()); Models.PoolInformation modelPoolInformation = UtilitiesInternal.CreateObjectWithNullCheck(this.PoolInformation, item => item.GetTransportObject()); asyncTask = this.parentBatchClient.ProtocolLayer.UpdateJob( Id, Priority, UtilitiesInternal.MapNullableEnum <Common.OnAllTasksComplete, Models.OnAllTasksComplete>(this.OnAllTasksComplete), modelPoolInformation, modelJobConstraints, MaxParallelTasks, AllowTaskPreemption, modelMetadata, behaveMgr, cancellationToken); } await asyncTask.ConfigureAwait(continueOnCapturedContext : false); }
/// <summary> /// Initializes a new instance of the JobSpecification class. /// </summary> public JobSpecification() { PoolInfo = new PoolInformation(); CustomInit(); }
/// <summary> /// Initializes a new instance of the JobAddParameter class. /// </summary> public JobAddParameter() { PoolInfo = new PoolInformation(); CustomInit(); }