@@ -14,58 +14,107 @@ public class ActorCreationOptions extends BaseTaskOptions {
14
14
public static final int NO_RESTART = 0 ;
15
15
public static final int INFINITE_RESTART = -1 ;
16
16
17
- public final String name ;
18
- public ActorLifetime lifetime ;
19
- public final int maxRestarts ;
20
- public final int maxTaskRetries ;
21
- public final List <String > jvmOptions ;
22
- public final int maxConcurrency ;
23
- public final PlacementGroup group ;
24
- public final int bundleIndex ;
25
- public final List <ConcurrencyGroup > concurrencyGroups ;
26
- public final String serializedRuntimeEnv ;
27
- public final String namespace ;
28
- public final int maxPendingCalls ;
29
- public final boolean isAsync ;
30
- public final boolean executeOutOfOrder ;
31
-
32
- private ActorCreationOptions (
33
- String name ,
34
- ActorLifetime lifetime ,
35
- Map <String , Double > resources ,
36
- int maxRestarts ,
37
- int maxTaskRetries ,
38
- List <String > jvmOptions ,
39
- int maxConcurrency ,
40
- PlacementGroup group ,
41
- int bundleIndex ,
42
- List <ConcurrencyGroup > concurrencyGroups ,
43
- String serializedRuntimeEnv ,
44
- String namespace ,
45
- int maxPendingCalls ,
46
- boolean isAsync ) {
47
- super (resources );
48
- this .name = name ;
49
- this .lifetime = lifetime ;
50
- this .maxRestarts = maxRestarts ;
51
- this .maxTaskRetries = maxTaskRetries ;
52
- this .jvmOptions = jvmOptions ;
53
- this .maxConcurrency = maxConcurrency ;
54
- this .group = group ;
55
- this .bundleIndex = bundleIndex ;
56
- this .concurrencyGroups = concurrencyGroups ;
57
- this .serializedRuntimeEnv = serializedRuntimeEnv ;
58
- this .namespace = namespace ;
59
- this .maxPendingCalls = maxPendingCalls ;
60
- this .isAsync = isAsync ;
61
- this .executeOutOfOrder = isAsync ;
17
+ private final String name ;
18
+ private final ActorLifetime lifetime ;
19
+ private final int maxRestarts ;
20
+ private final int maxTaskRetries ;
21
+ private final List <String > jvmOptions ;
22
+ private final int maxConcurrency ;
23
+ private final PlacementGroup group ;
24
+ private final int bundleIndex ;
25
+ private final List <ConcurrencyGroup > concurrencyGroups ;
26
+ private final String serializedRuntimeEnv ;
27
+ private final String namespace ;
28
+ private final int maxPendingCalls ;
29
+ private final boolean isAsync ;
30
+ private final boolean executeOutOfOrder ;
31
+
32
+ private ActorCreationOptions (Builder builder ) {
33
+ super (builder .resources );
34
+ this .name = builder .name ;
35
+ this .lifetime = builder .lifetime ;
36
+ this .maxRestarts = builder .maxRestarts ;
37
+ this .maxTaskRetries = builder .maxTaskRetries ;
38
+ this .jvmOptions =
39
+ builder .jvmOptions != null
40
+ ? java .util .Collections .unmodifiableList (builder .jvmOptions )
41
+ : null ;
42
+ this .maxConcurrency = builder .maxConcurrency ;
43
+ this .group = builder .group ;
44
+ this .bundleIndex = builder .bundleIndex ;
45
+ this .concurrencyGroups =
46
+ builder .concurrencyGroups != null
47
+ ? java .util .Collections .unmodifiableList (builder .concurrencyGroups )
48
+ : null ;
49
+ this .serializedRuntimeEnv =
50
+ builder .runtimeEnv != null ? builder .runtimeEnv .serializeToRuntimeEnvInfo () : "" ;
51
+ this .namespace = builder .namespace ;
52
+ this .maxPendingCalls = builder .maxPendingCalls ;
53
+ this .isAsync = builder .isAsync ;
54
+ this .executeOutOfOrder = builder .isAsync ;
55
+ }
56
+
57
+ public String getName () {
58
+ return name ;
59
+ }
60
+
61
+ public ActorLifetime getLifetime () {
62
+ return lifetime ;
63
+ }
64
+
65
+ public int getMaxRestarts () {
66
+ return maxRestarts ;
67
+ }
68
+
69
+ public int getMaxTaskRetries () {
70
+ return maxTaskRetries ;
71
+ }
72
+
73
+ public List <String > getJvmOptions () {
74
+ return jvmOptions ;
75
+ }
76
+
77
+ public int getMaxConcurrency () {
78
+ return maxConcurrency ;
79
+ }
80
+
81
+ public PlacementGroup getGroup () {
82
+ return group ;
83
+ }
84
+
85
+ public int getBundleIndex () {
86
+ return bundleIndex ;
87
+ }
88
+
89
+ public List <ConcurrencyGroup > getConcurrencyGroups () {
90
+ return concurrencyGroups ;
91
+ }
92
+
93
+ public String getSerializedRuntimeEnv () {
94
+ return serializedRuntimeEnv ;
95
+ }
96
+
97
+ public String getNamespace () {
98
+ return namespace ;
99
+ }
100
+
101
+ public int getMaxPendingCalls () {
102
+ return maxPendingCalls ;
103
+ }
104
+
105
+ public boolean isAsync () {
106
+ return isAsync ;
107
+ }
108
+
109
+ public boolean isExecuteOutOfOrder () {
110
+ return executeOutOfOrder ;
62
111
}
63
112
64
113
/** The inner class for building ActorCreationOptions. */
65
114
public static class Builder {
66
115
private String name ;
67
116
private ActorLifetime lifetime = null ;
68
- private Map <String , Double > resources = new HashMap <>();
117
+ private final Map <String , Double > resources = new HashMap <>();
69
118
private int maxRestarts = 0 ;
70
119
private int maxTaskRetries = 0 ;
71
120
private List <String > jvmOptions = new ArrayList <>();
@@ -223,24 +272,6 @@ public Builder setPlacementGroup(PlacementGroup group, int bundleIndex) {
223
272
return this ;
224
273
}
225
274
226
- public ActorCreationOptions build () {
227
- return new ActorCreationOptions (
228
- name ,
229
- lifetime ,
230
- resources ,
231
- maxRestarts ,
232
- maxTaskRetries ,
233
- jvmOptions ,
234
- maxConcurrency ,
235
- group ,
236
- bundleIndex ,
237
- concurrencyGroups ,
238
- runtimeEnv != null ? runtimeEnv .serializeToRuntimeEnvInfo () : "" ,
239
- namespace ,
240
- maxPendingCalls ,
241
- isAsync );
242
- }
243
-
244
275
/** Set the concurrency groups for this actor. */
245
276
public Builder setConcurrencyGroups (List <ConcurrencyGroup > concurrencyGroups ) {
246
277
this .concurrencyGroups = concurrencyGroups ;
@@ -256,5 +287,9 @@ public Builder setNamespace(String namespace) {
256
287
this .namespace = namespace ;
257
288
return this ;
258
289
}
290
+
291
+ public ActorCreationOptions build () {
292
+ return new ActorCreationOptions (this );
293
+ }
259
294
}
260
295
}
0 commit comments