/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 */

package com.microsoft.azure.batch.protocol.models;

import org.joda.time.Period;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * The execution constraints for a Job.
 */
public class JobConstraints {
    /**
     * The maximum elapsed time that the Job may run, measured from the time
     * the Job is created.
     * If the Job does not complete within the time limit, the Batch service
     * terminates it and any Tasks that are still running. In this case, the
     * termination reason will be MaxWallClockTimeExpiry. If this property is
     * not specified, there is no time limit on how long the Job may run.
     */
    @JsonProperty(value = "maxWallClockTime")
    private Period maxWallClockTime;

    /**
     * The maximum number of times each Task may be retried. The Batch service
     * retries a Task if its exit code is nonzero.
     * Note that this value specifically controls the number of retries. The
     * Batch service will try each Task once, and may then retry up to this
     * limit. For example, if the maximum retry count is 3, Batch tries a Task
     * up to 4 times (one initial try and 3 retries). If the maximum retry
     * count is 0, the Batch service does not retry Tasks. If the maximum retry
     * count is -1, the Batch service retries Tasks without limit. The default
     * value is 0 (no retries).
     */
    @JsonProperty(value = "maxTaskRetryCount")
    private Integer maxTaskRetryCount;

    /**
     * Get if the Job does not complete within the time limit, the Batch service terminates it and any Tasks that are still running. In this case, the termination reason will be MaxWallClockTimeExpiry. If this property is not specified, there is no time limit on how long the Job may run.
     *
     * @return the maxWallClockTime value
     */
    public Period maxWallClockTime() {
        return this.maxWallClockTime;
    }

    /**
     * Set if the Job does not complete within the time limit, the Batch service terminates it and any Tasks that are still running. In this case, the termination reason will be MaxWallClockTimeExpiry. If this property is not specified, there is no time limit on how long the Job may run.
     *
     * @param maxWallClockTime the maxWallClockTime value to set
     * @return the JobConstraints object itself.
     */
    public JobConstraints withMaxWallClockTime(Period maxWallClockTime) {
        this.maxWallClockTime = maxWallClockTime;
        return this;
    }

    /**
     * Get note that this value specifically controls the number of retries. The Batch service will try each Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries a Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry Tasks. If the maximum retry count is -1, the Batch service retries Tasks without limit. The default value is 0 (no retries).
     *
     * @return the maxTaskRetryCount value
     */
    public Integer maxTaskRetryCount() {
        return this.maxTaskRetryCount;
    }

    /**
     * Set note that this value specifically controls the number of retries. The Batch service will try each Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries a Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry Tasks. If the maximum retry count is -1, the Batch service retries Tasks without limit. The default value is 0 (no retries).
     *
     * @param maxTaskRetryCount the maxTaskRetryCount value to set
     * @return the JobConstraints object itself.
     */
    public JobConstraints withMaxTaskRetryCount(Integer maxTaskRetryCount) {
        this.maxTaskRetryCount = maxTaskRetryCount;
        return this;
    }

}
