@@ -83,9 +83,7 @@ public static final class Builder {
83
83
private String buildId ;
84
84
private boolean useBuildIdForVersioning ;
85
85
private Duration stickyTaskQueueDrainTimeout ;
86
- private SlotSupplier <WorkflowSlotInfo > workflowSlotSupplier ;
87
- private SlotSupplier <ActivitySlotInfo > activitySlotSupplier ;
88
- private SlotSupplier <LocalActivitySlotInfo > localActivitySlotSupplier ;
86
+ private WorkerTuner workerTuner ;
89
87
private String identity ;
90
88
91
89
private Builder () {}
@@ -98,9 +96,7 @@ private Builder(WorkerOptions o) {
98
96
this .maxConcurrentActivityExecutionSize = o .maxConcurrentActivityExecutionSize ;
99
97
this .maxConcurrentWorkflowTaskExecutionSize = o .maxConcurrentWorkflowTaskExecutionSize ;
100
98
this .maxConcurrentLocalActivityExecutionSize = o .maxConcurrentLocalActivityExecutionSize ;
101
- this .workflowSlotSupplier = o .workflowSlotSupplier ;
102
- this .activitySlotSupplier = o .activitySlotSupplier ;
103
- this .localActivitySlotSupplier = o .localActivitySlotSupplier ;
99
+ this .workerTuner = o .workerTuner ;
104
100
this .maxTaskQueueActivitiesPerSecond = o .maxTaskQueueActivitiesPerSecond ;
105
101
this .maxConcurrentWorkflowTaskPollers = o .maxConcurrentWorkflowTaskPollers ;
106
102
this .maxConcurrentActivityTaskPollers = o .maxConcurrentActivityTaskPollers ;
@@ -138,8 +134,7 @@ public Builder setMaxWorkerActivitiesPerSecond(double maxWorkerActivitiesPerSeco
138
134
* @param maxConcurrentActivityExecutionSize Maximum number of activities executed in parallel.
139
135
* Default is 200, which is chosen if set to zero.
140
136
* @return {@code this}
141
- * <p>Note setting is mutually exclusive with {@link
142
- * #setActivitySlotSupplier(SlotSupplier)}.
137
+ * <p>Note setting is mutually exclusive with {@link #setWorkerTuner(WorkerTuner)}
143
138
*/
144
139
public Builder setMaxConcurrentActivityExecutionSize (int maxConcurrentActivityExecutionSize ) {
145
140
if (maxConcurrentActivityExecutionSize < 0 ) {
@@ -157,7 +152,7 @@ public Builder setMaxConcurrentActivityExecutionSize(int maxConcurrentActivityEx
157
152
* @return {@code this}
158
153
* <p>Note that this is not related to the total number of open workflows which do not need
159
154
* to be loaded in a worker when they are not making state transitions.
160
- * <p>Note setting is mutually exclusive with {@link #setWorkflowSlotSupplier(SlotSupplier )}
155
+ * <p>Note setting is mutually exclusive with {@link #setWorkerTuner(WorkerTuner )}
161
156
*/
162
157
public Builder setMaxConcurrentWorkflowTaskExecutionSize (
163
158
int maxConcurrentWorkflowTaskExecutionSize ) {
@@ -174,8 +169,7 @@ public Builder setMaxConcurrentWorkflowTaskExecutionSize(
174
169
* @param maxConcurrentLocalActivityExecutionSize Maximum number of local activities executed in
175
170
* parallel. Default is 200, which is chosen if set to zero.
176
171
* @return {@code this}
177
- * <p>Note setting is mutually exclusive with {@link
178
- * #setLocalActivitySlotSupplier(SlotSupplier)}
172
+ * <p>Note setting is mutually exclusive with {@link #setWorkerTuner(WorkerTuner)}
179
173
*/
180
174
public Builder setMaxConcurrentLocalActivityExecutionSize (
181
175
int maxConcurrentLocalActivityExecutionSize ) {
@@ -384,37 +378,13 @@ public Builder setStickyTaskQueueDrainTimeout(Duration stickyTaskQueueDrainTimeo
384
378
}
385
379
386
380
/**
387
- * Set the {@link SlotSupplier} for workflow tasks.
388
- *
389
- * <p>Note that this setting is mutually exclusive with {@link
390
- * #setMaxConcurrentWorkflowTaskExecutionSize(int)}.
391
- */
392
- @ Experimental
393
- public void setWorkflowSlotSupplier (SlotSupplier <WorkflowSlotInfo > workflowSlotSupplier ) {
394
- this .workflowSlotSupplier = workflowSlotSupplier ;
395
- }
396
-
397
- /**
398
- * Set the {@link SlotSupplier} for activity tasks.
399
- *
400
- * <p>Note that this setting is mutually exclusive with {@link
401
- * #setMaxConcurrentActivityExecutionSize(int)}.
402
- */
403
- @ Experimental
404
- public void setActivitySlotSupplier (SlotSupplier <ActivitySlotInfo > activitySlotSupplier ) {
405
- this .activitySlotSupplier = activitySlotSupplier ;
406
- }
407
-
408
- /**
409
- * Set the {@link SlotSupplier} for local activity tasks.
410
- *
411
- * <p>Note that this setting is mutually exclusive with {@link
412
- * #setMaxConcurrentLocalActivityExecutionSize(int)}.
381
+ * Set a {@link WorkerTuner} to determine how slots will be allocated for different types of
382
+ * tasks.
413
383
*/
414
384
@ Experimental
415
- public void setLocalActivitySlotSupplier (
416
- SlotSupplier < LocalActivitySlotInfo > localActivitySlotSupplier ) {
417
- this . localActivitySlotSupplier = localActivitySlotSupplier ;
385
+ public Builder setWorkerTuner ( WorkerTuner workerTuner ) {
386
+ this . workerTuner = workerTuner ;
387
+ return this ;
418
388
}
419
389
420
390
/** Override identity of the worker primary specified in a WorkflowClient options. */
@@ -429,9 +399,7 @@ public WorkerOptions build() {
429
399
maxConcurrentActivityExecutionSize ,
430
400
maxConcurrentWorkflowTaskExecutionSize ,
431
401
maxConcurrentLocalActivityExecutionSize ,
432
- workflowSlotSupplier ,
433
- activitySlotSupplier ,
434
- localActivitySlotSupplier ,
402
+ workerTuner ,
435
403
maxTaskQueueActivitiesPerSecond ,
436
404
maxConcurrentWorkflowTaskPollers ,
437
405
maxConcurrentActivityTaskPollers ,
@@ -458,20 +426,20 @@ public WorkerOptions validateAndBuildWithDefaults() {
458
426
Preconditions .checkState (
459
427
maxConcurrentLocalActivityExecutionSize >= 0 ,
460
428
"negative maxConcurrentLocalActivityExecutionSize" );
461
- if (activitySlotSupplier != null ) {
429
+ if (workerTuner != null ) {
462
430
Preconditions .checkState (
463
431
maxConcurrentActivityExecutionSize == 0 ,
464
- "maxConcurrentActivityExecutionSize must not be set if activitySlotSupplier is set" );
432
+ "maxConcurrentActivityExecutionSize must not be set if workerTuner is set" );
465
433
}
466
- if (workflowSlotSupplier != null ) {
434
+ if (workerTuner != null ) {
467
435
Preconditions .checkState (
468
436
maxConcurrentWorkflowTaskExecutionSize == 0 ,
469
- "maxConcurrentWorkflowTaskExecutionSize must not be set if workflowSlotSupplier is set" );
437
+ "maxConcurrentWorkflowTaskExecutionSize must not be set if workerTuner is set" );
470
438
}
471
- if (localActivitySlotSupplier != null ) {
439
+ if (workerTuner != null ) {
472
440
Preconditions .checkState (
473
441
maxConcurrentLocalActivityExecutionSize == 0 ,
474
- "maxConcurrentLocalActivityExecutionSize must not be set if localActivitySlotSupplier is set" );
442
+ "maxConcurrentLocalActivityExecutionSize must not be set if workerTuner is set" );
475
443
}
476
444
Preconditions .checkState (
477
445
maxTaskQueueActivitiesPerSecond >= 0 , "negative taskQueueActivitiesPerSecond" );
@@ -505,9 +473,7 @@ public WorkerOptions validateAndBuildWithDefaults() {
505
473
maxConcurrentLocalActivityExecutionSize == 0
506
474
? DEFAULT_MAX_CONCURRENT_LOCAL_ACTIVITY_EXECUTION_SIZE
507
475
: maxConcurrentLocalActivityExecutionSize ,
508
- workflowSlotSupplier ,
509
- activitySlotSupplier ,
510
- localActivitySlotSupplier ,
476
+ workerTuner ,
511
477
maxTaskQueueActivitiesPerSecond ,
512
478
maxConcurrentWorkflowTaskPollers == 0
513
479
? DEFAULT_MAX_CONCURRENT_WORKFLOW_TASK_POLLERS
@@ -542,9 +508,7 @@ public WorkerOptions validateAndBuildWithDefaults() {
542
508
private final int maxConcurrentActivityExecutionSize ;
543
509
private final int maxConcurrentWorkflowTaskExecutionSize ;
544
510
private final int maxConcurrentLocalActivityExecutionSize ;
545
- private final SlotSupplier <WorkflowSlotInfo > workflowSlotSupplier ;
546
- private final SlotSupplier <ActivitySlotInfo > activitySlotSupplier ;
547
- private final SlotSupplier <LocalActivitySlotInfo > localActivitySlotSupplier ;
511
+ private final WorkerTuner workerTuner ;
548
512
private final double maxTaskQueueActivitiesPerSecond ;
549
513
private final int maxConcurrentWorkflowTaskPollers ;
550
514
private final int maxConcurrentActivityTaskPollers ;
@@ -564,9 +528,7 @@ private WorkerOptions(
564
528
int maxConcurrentActivityExecutionSize ,
565
529
int maxConcurrentWorkflowTaskExecutionSize ,
566
530
int maxConcurrentLocalActivityExecutionSize ,
567
- SlotSupplier <WorkflowSlotInfo > workflowSlotSupplier ,
568
- SlotSupplier <ActivitySlotInfo > activitySlotSupplier ,
569
- SlotSupplier <LocalActivitySlotInfo > localActivitySlotSupplier ,
531
+ WorkerTuner workerTuner ,
570
532
double maxTaskQueueActivitiesPerSecond ,
571
533
int workflowPollThreadCount ,
572
534
int activityPollThreadCount ,
@@ -584,9 +546,7 @@ private WorkerOptions(
584
546
this .maxConcurrentActivityExecutionSize = maxConcurrentActivityExecutionSize ;
585
547
this .maxConcurrentWorkflowTaskExecutionSize = maxConcurrentWorkflowTaskExecutionSize ;
586
548
this .maxConcurrentLocalActivityExecutionSize = maxConcurrentLocalActivityExecutionSize ;
587
- this .workflowSlotSupplier = workflowSlotSupplier ;
588
- this .activitySlotSupplier = activitySlotSupplier ;
589
- this .localActivitySlotSupplier = localActivitySlotSupplier ;
549
+ this .workerTuner = workerTuner ;
590
550
this .maxTaskQueueActivitiesPerSecond = maxTaskQueueActivitiesPerSecond ;
591
551
this .maxConcurrentWorkflowTaskPollers = workflowPollThreadCount ;
592
552
this .maxConcurrentActivityTaskPollers = activityPollThreadCount ;
@@ -683,16 +643,8 @@ public Duration getStickyTaskQueueDrainTimeout() {
683
643
return stickyTaskQueueDrainTimeout ;
684
644
}
685
645
686
- public SlotSupplier <WorkflowSlotInfo > getWorkflowSlotSupplier () {
687
- return workflowSlotSupplier ;
688
- }
689
-
690
- public SlotSupplier <ActivitySlotInfo > getActivitySlotSupplier () {
691
- return activitySlotSupplier ;
692
- }
693
-
694
- public SlotSupplier <LocalActivitySlotInfo > getLocalActivitySlotSupplier () {
695
- return localActivitySlotSupplier ;
646
+ public WorkerTuner getWorkerTuner () {
647
+ return workerTuner ;
696
648
}
697
649
698
650
@ Nullable
@@ -716,9 +668,7 @@ && compare(maxTaskQueueActivitiesPerSecond, that.maxTaskQueueActivitiesPerSecond
716
668
&& defaultDeadlockDetectionTimeout == that .defaultDeadlockDetectionTimeout
717
669
&& disableEagerExecution == that .disableEagerExecution
718
670
&& useBuildIdForVersioning == that .useBuildIdForVersioning
719
- && Objects .equals (workflowSlotSupplier , that .workflowSlotSupplier )
720
- && Objects .equals (activitySlotSupplier , that .activitySlotSupplier )
721
- && Objects .equals (localActivitySlotSupplier , that .localActivitySlotSupplier )
671
+ && Objects .equals (workerTuner , that .workerTuner )
722
672
&& Objects .equals (maxHeartbeatThrottleInterval , that .maxHeartbeatThrottleInterval )
723
673
&& Objects .equals (defaultHeartbeatThrottleInterval , that .defaultHeartbeatThrottleInterval )
724
674
&& Objects .equals (stickyQueueScheduleToStartTimeout , that .stickyQueueScheduleToStartTimeout )
@@ -734,9 +684,7 @@ public int hashCode() {
734
684
maxConcurrentActivityExecutionSize ,
735
685
maxConcurrentWorkflowTaskExecutionSize ,
736
686
maxConcurrentLocalActivityExecutionSize ,
737
- workflowSlotSupplier ,
738
- activitySlotSupplier ,
739
- localActivitySlotSupplier ,
687
+ workerTuner ,
740
688
maxTaskQueueActivitiesPerSecond ,
741
689
maxConcurrentWorkflowTaskPollers ,
742
690
maxConcurrentActivityTaskPollers ,
@@ -763,12 +711,8 @@ public String toString() {
763
711
+ maxConcurrentWorkflowTaskExecutionSize
764
712
+ ", maxConcurrentLocalActivityExecutionSize="
765
713
+ maxConcurrentLocalActivityExecutionSize
766
- + ", workflowSlotSupplier="
767
- + workflowSlotSupplier
768
- + ", activitySlotSupplier="
769
- + activitySlotSupplier
770
- + ", localActivitySlotSupplier="
771
- + localActivitySlotSupplier
714
+ + ", workerTuner="
715
+ + workerTuner
772
716
+ ", maxTaskQueueActivitiesPerSecond="
773
717
+ maxTaskQueueActivitiesPerSecond
774
718
+ ", maxConcurrentWorkflowTaskPollers="
0 commit comments