예제 #1
0
        public void DisableJobRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            DisableJobOption disableOption        = DisableJobOption.Terminate;
            DisableJobOption requestDisableOption = DisableJobOption.Requeue;

            cmdlet.Id = "testJob";
            cmdlet.DisableJobOption = disableOption;

            // Don't go to the service on a Disable CloudJob call
            Action <BatchRequest <CloudJobDisableParameters, CloudJobDisableResponse> > extractDisableOptionAction =
                (request) =>
            {
                requestDisableOption = request.TypedParameters.DisableJobOption;
            };
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(requestAction: extractDisableOptionAction);

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            cmdlet.ExecuteCmdlet();

            // Verify that the job disable option was properly set on the outgoing request
            Assert.Equal(disableOption, requestDisableOption);
        }
예제 #2
0
        internal static string ToSerializedValue(this DisableJobOption value)
        {
            switch (value)
            {
            case DisableJobOption.Requeue:
                return("requeue");

            case DisableJobOption.Terminate:
                return("terminate");

            case DisableJobOption.Wait:
                return("wait");
            }
            return(null);
        }
예제 #3
0
 /// <summary>
 /// Disable this job
 /// </summary>
 public async System.Threading.Tasks.Task DisableAsync(DisableJobOption option)
 {
     try
     {
         System.Threading.Tasks.Task asyncTask = this.Job.DisableAsync(option);
         AsyncOperationTracker.Instance.AddTrackedOperation(new AsyncOperationModel(
                                                                asyncTask,
                                                                new JobOperation(JobOperation.Disable, this.Job.Id)));
         await asyncTask;
         await this.RefreshAsync(ModelRefreshType.Basic, showTrackedOperation : false);
     }
     catch (Exception e)
     {
         Messenger.Default.Send <GenericDialogMessage>(new GenericDialogMessage(e.ToString()));
     }
 }
예제 #4
0
        public void DisableJobRequestTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            DisableJobOption disableOption        = DisableJobOption.Terminate;
            DisableJobOption requestDisableOption = DisableJobOption.Requeue;

            cmdlet.Id = "testJob";
            cmdlet.DisableJobOption = disableOption;

            // Don't go to the service on an Enable AutoScale call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest <CloudJobDisableParameters, CloudJobDisableResponse> request =
                    (BatchRequest <CloudJobDisableParameters, CloudJobDisableResponse>)baseRequest;

                // Grab the disable option off the outgoing request.
                requestDisableOption = request.TypedParameters.DisableJobOption;

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    CloudJobDisableResponse response    = new CloudJobDisableResponse();
                    Task <CloudJobDisableResponse> task = Task.FromResult(response);
                    return(task);
                };
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            cmdlet.ExecuteCmdlet();

            // Verify that the job disable option was properly set on the outgoing request
            Assert.Equal(disableOption, requestDisableOption);
        }
예제 #5
0
 /// <summary>
 /// Disable this job
 /// </summary>
 public async System.Threading.Tasks.Task DisableAsync(DisableJobOption option)
 {
     try
     {
         System.Threading.Tasks.Task asyncTask = this.Job.DisableAsync(option);
         AsyncOperationTracker.Instance.AddTrackedOperation(new AsyncOperationModel(
             asyncTask,
             new JobOperation(JobOperation.Disable, this.Job.Id)));
         await asyncTask;
         await this.RefreshAsync(ModelRefreshType.Basic, showTrackedOperation: false);
     }
     catch (Exception e)
     {
         Messenger.Default.Send<GenericDialogMessage>(new GenericDialogMessage(e.ToString()));
     }
 }
예제 #6
0
 /// <summary>
 /// Disables the specified job, preventing new tasks from running.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The id of the job to disable.
 /// </param>
 /// <param name='disableTasks'>
 /// What to do with active tasks associated with the job. Possible values
 /// include: 'requeue', 'terminate', 'wait'
 /// </param>
 /// <param name='jobDisableOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <JobDisableHeaders> DisableAsync(this IJobOperations operations, string jobId, DisableJobOption disableTasks, JobDisableOptions jobDisableOptions = default(JobDisableOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.DisableWithHttpMessagesAsync(jobId, disableTasks, jobDisableOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
예제 #7
0
 /// <summary>
 /// Disables the specified job, preventing new tasks from running.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The id of the job to disable.
 /// </param>
 /// <param name='disableTasks'>
 /// What to do with active tasks associated with the job. Possible values
 /// include: 'requeue', 'terminate', 'wait'
 /// </param>
 /// <param name='jobDisableOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobDisableHeaders Disable(this IJobOperations operations, string jobId, DisableJobOption disableTasks, JobDisableOptions jobDisableOptions = default(JobDisableOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IJobOperations)s).DisableAsync(jobId, disableTasks, jobDisableOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 public DisableJobParameters(BatchAccountContext context, string jobId, PSCloudJob job, DisableJobOption disableJobOption,
                             IEnumerable <BatchClientBehavior> additionalBehaviors = null)
     : base(context, jobId, job, additionalBehaviors)
 {
     this.DisableJobOption = disableJobOption;
 }
 public DisableJobParameters(BatchAccountContext context, string jobId, PSCloudJob job, DisableJobOption disableJobOption,
     IEnumerable<BatchClientBehavior> additionalBehaviors = null)
     : base(context, jobId, job, additionalBehaviors)
 {
     this.DisableJobOption = disableJobOption;
 }
예제 #10
0
 /// <summary>
 /// Disables the specified Job, preventing new Tasks from running.
 /// </summary>
 /// <remarks>
 /// The Batch Service immediately moves the Job to the disabling state. Batch
 /// then uses the disableTasks parameter to determine what to do with the
 /// currently running Tasks of the Job. The Job remains in the disabling state
 /// until the disable operation is completed and all Tasks have been dealt with
 /// according to the disableTasks option; the Job then moves to the disabled
 /// state. No new Tasks are started under the Job until it moves back to active
 /// state. If you try to disable a Job that is in any state other than active,
 /// disabling, or disabled, the request fails with status code 409.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The ID of the Job to disable.
 /// </param>
 /// <param name='disableTasks'>
 /// What to do with active Tasks associated with the Job. Possible values
 /// include: 'requeue', 'terminate', 'wait'
 /// </param>
 /// <param name='jobDisableOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static JobDisableHeaders Disable(this IJobOperations operations, string jobId, DisableJobOption disableTasks, JobDisableOptions jobDisableOptions = default(JobDisableOptions))
 {
     return(operations.DisableAsync(jobId, disableTasks, jobDisableOptions).GetAwaiter().GetResult());
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the JobDisableParameter class.
 /// </summary>
 /// <param name="disableTasks">What to do with active tasks associated
 /// with the job.</param>
 public JobDisableParameter(DisableJobOption disableTasks)
 {
     DisableTasks = disableTasks;
     CustomInit();
 }
 public JobDisableParameter(DisableJobOption disableTasks)
 {
     DisableTasks = disableTasks;
 }
 public static string ToSerialString(this DisableJobOption value) => value switch
 {