1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License.
3
4 package com.microsoft.azure.batch.interceptor;
5
6 import com.microsoft.azure.batch.BatchClientBehavior;
7
8 /**
9 * Stores options that configure the operation of methods on Batch client parallel operations.
10 */
11 public class BatchClientParallelOptions extends BatchClientBehavior {
12
13 private int maxDegreeOfParallelism;
14
15 /**
16 * Gets the maximum number of concurrent tasks enabled by this {@link BatchClientParallelOptions} instance.
17 *
18 * The default value is 1.
19 * @return The maximum number of concurrent tasks.
20 */
21 public int maxDegreeOfParallelism() {
22 return this.maxDegreeOfParallelism;
23 }
24
25 /**
26 * Sets the maximum number of concurrent tasks enabled by this {@link BatchClientParallelOptions} instance.
27 *
28 * @param maxDegreeOfParallelism the maximum number of concurrent tasks.
29 * @return The instance of {@link BatchClientParallelOptions}.
30 */
31 public BatchClientParallelOptions withMaxDegreeOfParallelism(int maxDegreeOfParallelism) {
32 if (maxDegreeOfParallelism > 0) {
33 this.maxDegreeOfParallelism = maxDegreeOfParallelism;
34 } else {
35 throw new IllegalArgumentException("maxDegreeOfParallelism");
36 }
37 return this;
38 }
39
40 /**
41 * Initializes a new instance of the {@link BatchClientParallelOptions} class with default values.
42 */
43 public BatchClientParallelOptions() {
44 this.maxDegreeOfParallelism = 1;
45 }
46
47 /**
48 * Initializes a new instance of the {@link BatchClientParallelOptions} class.
49 *
50 * @param maxDegreeOfParallelism the maximum number of concurrent tasks.
51 */
52 public BatchClientParallelOptions(int maxDegreeOfParallelism) {
53 this.maxDegreeOfParallelism = maxDegreeOfParallelism;
54 }
55
56 }