• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #175

pending completion
#175

push

github-actions

web-flow
Worker / Build Id versioning (#1786)

Implement new worker build id based versioning feature

236 of 236 new or added lines in 24 files covered. (100.0%)

18343 of 23697 relevant lines covered (77.41%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.16
/temporal-sdk/src/main/java/io/temporal/worker/WorkerOptions.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.worker;
22

23
import static java.lang.Double.compare;
24

25
import com.google.common.base.Preconditions;
26
import io.temporal.common.Experimental;
27
import java.time.Duration;
28
import java.util.Objects;
29
import javax.annotation.Nonnull;
30
import javax.annotation.Nullable;
31

32
public final class WorkerOptions {
33

34
  public static Builder newBuilder() {
35
    return new Builder();
1✔
36
  }
37

38
  public static Builder newBuilder(WorkerOptions options) {
39
    return new Builder(options);
1✔
40
  }
41

42
  public static WorkerOptions getDefaultInstance() {
43
    return DEFAULT_INSTANCE;
1✔
44
  }
45

46
  static final Duration DEFAULT_STICKY_SCHEDULE_TO_START_TIMEOUT = Duration.ofSeconds(5);
1✔
47

48
  private static final WorkerOptions DEFAULT_INSTANCE;
49

50
  static {
51
    DEFAULT_INSTANCE = WorkerOptions.newBuilder().validateAndBuildWithDefaults();
1✔
52
  }
1✔
53

54
  public static final class Builder {
55

56
    private static final int DEFAULT_MAX_CONCURRENT_WORKFLOW_TASK_POLLERS = 5;
57
    private static final int DEFAULT_MAX_CONCURRENT_ACTIVITY_TASK_POLLERS = 5;
58
    private static final int DEFAULT_MAX_CONCURRENT_WORKFLOW_TASK_EXECUTION_SIZE = 200;
59
    private static final int DEFAULT_MAX_CONCURRENT_ACTIVITY_EXECUTION_SIZE = 200;
60
    private static final int DEFAULT_MAX_CONCURRENT_LOCAL_ACTIVITY_EXECUTION_SIZE = 200;
61
    private static final long DEFAULT_DEADLOCK_DETECTION_TIMEOUT = 1000;
62
    private static final Duration DEFAULT_MAX_HEARTBEAT_THROTTLE_INTERVAL = Duration.ofSeconds(60);
1✔
63
    private static final Duration DEFAULT_DEFAULT_HEARTBEAT_THROTTLE_INTERVAL =
1✔
64
        Duration.ofSeconds(30);
1✔
65

66
    private double maxWorkerActivitiesPerSecond;
67
    private int maxConcurrentActivityExecutionSize;
68
    private int maxConcurrentWorkflowTaskExecutionSize;
69
    private int maxConcurrentLocalActivityExecutionSize;
70
    private double maxTaskQueueActivitiesPerSecond;
71
    private int maxConcurrentWorkflowTaskPollers;
72
    private int maxConcurrentActivityTaskPollers;
73
    private boolean localActivityWorkerOnly;
74
    private long defaultDeadlockDetectionTimeout;
75
    private Duration maxHeartbeatThrottleInterval;
76
    private Duration defaultHeartbeatThrottleInterval;
77
    private Duration stickyQueueScheduleToStartTimeout;
78
    private boolean disableEagerExecution;
79
    private String buildId;
80
    private boolean useBuildIdForVersioning;
81

82
    private Builder() {}
83

84
    private Builder(WorkerOptions o) {
1✔
85
      if (o == null) {
1✔
86
        return;
1✔
87
      }
88
      this.maxWorkerActivitiesPerSecond = o.maxWorkerActivitiesPerSecond;
1✔
89
      this.maxConcurrentActivityExecutionSize = o.maxConcurrentActivityExecutionSize;
1✔
90
      this.maxConcurrentWorkflowTaskExecutionSize = o.maxConcurrentWorkflowTaskExecutionSize;
1✔
91
      this.maxConcurrentLocalActivityExecutionSize = o.maxConcurrentLocalActivityExecutionSize;
1✔
92
      this.maxTaskQueueActivitiesPerSecond = o.maxTaskQueueActivitiesPerSecond;
1✔
93
      this.maxConcurrentWorkflowTaskPollers = o.maxConcurrentWorkflowTaskPollers;
1✔
94
      this.maxConcurrentActivityTaskPollers = o.maxConcurrentActivityTaskPollers;
1✔
95
      this.localActivityWorkerOnly = o.localActivityWorkerOnly;
1✔
96
      this.defaultDeadlockDetectionTimeout = o.defaultDeadlockDetectionTimeout;
1✔
97
      this.maxHeartbeatThrottleInterval = o.maxHeartbeatThrottleInterval;
1✔
98
      this.defaultHeartbeatThrottleInterval = o.defaultHeartbeatThrottleInterval;
1✔
99
      this.stickyQueueScheduleToStartTimeout = o.stickyQueueScheduleToStartTimeout;
1✔
100
      this.disableEagerExecution = o.disableEagerExecution;
1✔
101
      this.useBuildIdForVersioning = o.useBuildIdForVersioning;
1✔
102
      this.buildId = o.buildId;
1✔
103
    }
1✔
104

105
    /**
106
     * @param maxWorkerActivitiesPerSecond Maximum number of activities started per second by this
107
     *     worker. Default is 0 which means unlimited.
108
     * @return {@code this}
109
     *     <p>If worker is not fully loaded while tasks are backing up on the service consider
110
     *     increasing {@link #setMaxConcurrentActivityTaskPollers(int)}.
111
     *     <p>Note that this is a per worker limit. Use {@link
112
     *     #setMaxTaskQueueActivitiesPerSecond(double)} to set per task queue limit across multiple
113
     *     workers.
114
     */
115
    public Builder setMaxWorkerActivitiesPerSecond(double maxWorkerActivitiesPerSecond) {
116
      if (maxWorkerActivitiesPerSecond < 0) {
1✔
117
        throw new IllegalArgumentException(
×
118
            "Negative maxWorkerActivitiesPerSecond value: " + maxWorkerActivitiesPerSecond);
119
      }
120
      this.maxWorkerActivitiesPerSecond = maxWorkerActivitiesPerSecond;
1✔
121
      return this;
1✔
122
    }
123

124
    /**
125
     * @param maxConcurrentActivityExecutionSize Maximum number of activities executed in parallel.
126
     *     Default is 200, which is chosen if set to zero.
127
     * @return {@code this}
128
     */
129
    public Builder setMaxConcurrentActivityExecutionSize(int maxConcurrentActivityExecutionSize) {
130
      if (maxConcurrentActivityExecutionSize < 0) {
1✔
131
        throw new IllegalArgumentException(
×
132
            "Negative maxConcurrentActivityExecutionSize value: "
133
                + maxConcurrentActivityExecutionSize);
134
      }
135
      this.maxConcurrentActivityExecutionSize = maxConcurrentActivityExecutionSize;
1✔
136
      return this;
1✔
137
    }
138

139
    /**
140
     * @param maxConcurrentWorkflowTaskExecutionSize Maximum number of simultaneously executed
141
     *     workflow tasks. Default is 200, which is chosen if set to zero.
142
     * @return {@code this}
143
     *     <p>Note that this is not related to the total number of open workflows which do not need
144
     *     to be loaded in a worker when they are not making state transitions.
145
     */
146
    public Builder setMaxConcurrentWorkflowTaskExecutionSize(
147
        int maxConcurrentWorkflowTaskExecutionSize) {
148
      if (maxConcurrentWorkflowTaskExecutionSize < 0) {
1✔
149
        throw new IllegalArgumentException(
×
150
            "Negative maxConcurrentWorkflowTaskExecutionSize value: "
151
                + maxConcurrentWorkflowTaskExecutionSize);
152
      }
153
      this.maxConcurrentWorkflowTaskExecutionSize = maxConcurrentWorkflowTaskExecutionSize;
1✔
154
      return this;
1✔
155
    }
156

157
    /**
158
     * @param maxConcurrentLocalActivityExecutionSize Maximum number of local activities executed in
159
     *     parallel. Default is 200, which is chosen if set to zero.
160
     * @return {@code this}
161
     */
162
    public Builder setMaxConcurrentLocalActivityExecutionSize(
163
        int maxConcurrentLocalActivityExecutionSize) {
164
      if (maxConcurrentLocalActivityExecutionSize < 0) {
1✔
165
        throw new IllegalArgumentException(
×
166
            "Negative maxConcurrentLocalActivityExecutionSize value: "
167
                + maxConcurrentLocalActivityExecutionSize);
168
      }
169
      this.maxConcurrentLocalActivityExecutionSize = maxConcurrentLocalActivityExecutionSize;
1✔
170
      return this;
1✔
171
    }
172

173
    /**
174
     * Optional: Sets the rate limiting on number of activities that can be executed per second.
175
     * This is managed by the server and controls activities per second for the entire task queue
176
     * across all the workers. Notice that the number is represented in double, so that you can set
177
     * it to less than 1 if needed. For example, set the number to 0.1 means you want your activity
178
     * to be executed once every 10 seconds. This can be used to protect down stream services from
179
     * flooding. The zero value of this uses the default value. Default is unlimited.
180
     */
181
    public Builder setMaxTaskQueueActivitiesPerSecond(double maxTaskQueueActivitiesPerSecond) {
182
      this.maxTaskQueueActivitiesPerSecond = maxTaskQueueActivitiesPerSecond;
1✔
183
      return this;
1✔
184
    }
185

186
    /**
187
     * Sets the maximum number of simultaneous long poll requests to the Temporal Server to retrieve
188
     * workflow tasks. Changing this value will affect the rate at which the worker is able to
189
     * consume tasks from a task queue.
190
     *
191
     * <p>Due to internal logic where pollers alternate between sticky and non-sticky queues, this
192
     * value cannot be 1 and will be adjusted to 2 if set to that value.
193
     *
194
     * <p>Default is 5.
195
     */
196
    public Builder setMaxConcurrentWorkflowTaskPollers(int maxConcurrentWorkflowTaskPollers) {
197
      this.maxConcurrentWorkflowTaskPollers = maxConcurrentWorkflowTaskPollers;
1✔
198
      return this;
1✔
199
    }
200

201
    /**
202
     * Number of simultaneous poll requests on workflow task queue. Note that the majority of the
203
     * workflow tasks will be using host local task queue due to caching. So try incrementing {@link
204
     * WorkerFactoryOptions.Builder#setWorkflowHostLocalPollThreadCount(int)} before this one.
205
     *
206
     * <p>Default is 5.
207
     *
208
     * @deprecated Use {@link #setMaxConcurrentWorkflowTaskPollers}
209
     */
210
    @Deprecated
211
    public Builder setWorkflowPollThreadCount(int workflowPollThreadCount) {
212
      return setMaxConcurrentWorkflowTaskPollers(workflowPollThreadCount);
×
213
    }
214

215
    /**
216
     * Number of simultaneous poll requests on activity task queue. Consider incrementing if the
217
     * worker is not throttled due to `MaxActivitiesPerSecond` or
218
     * `MaxConcurrentActivityExecutionSize` options and still cannot keep up with the request rate.
219
     *
220
     * <p>Default is 5.
221
     */
222
    public Builder setMaxConcurrentActivityTaskPollers(int maxConcurrentActivityTaskPollers) {
223
      this.maxConcurrentActivityTaskPollers = maxConcurrentActivityTaskPollers;
1✔
224
      return this;
1✔
225
    }
226

227
    /**
228
     * Number of simultaneous poll requests on activity task queue. Consider incrementing if the
229
     * worker is not throttled due to `MaxActivitiesPerSecond` or
230
     * `MaxConcurrentActivityExecutionSize` options and still cannot keep up with the request rate.
231
     *
232
     * <p>Default is 5.
233
     *
234
     * @deprecated Use {@link #setMaxConcurrentActivityTaskPollers}
235
     */
236
    @Deprecated
237
    public Builder setActivityPollThreadCount(int activityPollThreadCount) {
238
      return setMaxConcurrentActivityTaskPollers(activityPollThreadCount);
×
239
    }
240

241
    /**
242
     * If set to true worker would only handle workflow tasks and local activities. Non-local
243
     * activities will not be executed by this worker.
244
     *
245
     * <p>Default is false.
246
     */
247
    public Builder setLocalActivityWorkerOnly(boolean localActivityWorkerOnly) {
248
      this.localActivityWorkerOnly = localActivityWorkerOnly;
1✔
249
      return this;
1✔
250
    }
251

252
    /**
253
     * @param defaultDeadlockDetectionTimeoutMs time period in ms that will be used to detect
254
     *     workflows deadlock. Default is 1000ms, which is chosen if set to zero.
255
     *     <p>Specifies an amount of time in milliseconds that workflow tasks are allowed to execute
256
     *     without interruption. If workflow task runs longer than specified interval without
257
     *     yielding (like calling an Activity), it will fail automatically.
258
     * @return {@code this}
259
     * @see io.temporal.internal.sync.PotentialDeadlockException
260
     */
261
    public Builder setDefaultDeadlockDetectionTimeout(long defaultDeadlockDetectionTimeoutMs) {
262
      if (defaultDeadlockDetectionTimeoutMs < 0) {
1✔
263
        throw new IllegalArgumentException(
×
264
            "Negative defaultDeadlockDetectionTimeout value: " + defaultDeadlockDetectionTimeoutMs);
265
      }
266
      this.defaultDeadlockDetectionTimeout = defaultDeadlockDetectionTimeoutMs;
1✔
267
      return this;
1✔
268
    }
269

270
    /**
271
     * @param interval the maximum amount of time between sending each pending heartbeat to the
272
     *     server. Regardless of heartbeat timeout, no pending heartbeat will wait longer than this
273
     *     amount of time to send. Default is 60s, which is chosen if set to null or 0.
274
     * @return {@code this}
275
     */
276
    public Builder setMaxHeartbeatThrottleInterval(@Nullable Duration interval) {
277
      Preconditions.checkArgument(
×
278
          interval == null || !interval.isNegative(),
×
279
          "Negative maxHeartbeatThrottleInterval value: %s",
280
          interval);
281
      this.maxHeartbeatThrottleInterval = interval;
×
282
      return this;
×
283
    }
284

285
    /**
286
     * @param interval the default amount of time between sending each pending heartbeat to the
287
     *     server. This is used if the ActivityOptions do not provide a HeartbeatTimeout. Otherwise,
288
     *     the interval becomes a value a bit smaller than the given HeartbeatTimeout. Default is
289
     *     30s, which is chosen if set to null or 0.
290
     * @return {@code this}
291
     */
292
    public Builder setDefaultHeartbeatThrottleInterval(@Nullable Duration interval) {
293
      Preconditions.checkArgument(
×
294
          interval == null || !interval.isNegative(),
×
295
          "Negative defaultHeartbeatThrottleInterval value: %s",
296
          interval);
297
      this.defaultHeartbeatThrottleInterval = interval;
×
298
      return this;
×
299
    }
300

301
    /**
302
     * Timeout for a workflow task routed to the "sticky worker" - host that has the workflow
303
     * instance cached in memory. Once it times out, then it can be picked up by any worker.
304
     *
305
     * <p>Default value is 5 seconds.
306
     */
307
    public Builder setStickyQueueScheduleToStartTimeout(Duration timeout) {
308
      this.stickyQueueScheduleToStartTimeout = timeout;
1✔
309
      return this;
1✔
310
    }
311

312
    /**
313
     * Disable eager activities. If set to true, eager execution will not be requested for
314
     * activities requested from workflows bound to this Worker.
315
     *
316
     * <p>Eager activity execution means the server returns requested eager activities directly from
317
     * the workflow task back to this worker which is faster than non-eager which may be dispatched
318
     * to a separate worker.
319
     *
320
     * <p>Defaults to false, meaning that eager activity execution is permitted
321
     */
322
    public Builder setDisableEagerExecution(boolean disableEagerExecution) {
323
      this.disableEagerExecution = disableEagerExecution;
×
324
      return this;
×
325
    }
326

327
    /**
328
     * Opts the worker in to the Build-ID-based versioning feature. This ensures that the worker
329
     * will only receive tasks which it is compatible with. For more information see: TODO: Doc link
330
     *
331
     * <p>Defaults to false
332
     */
333
    @Experimental
334
    public Builder setUseBuildIdForVersioning(boolean useBuildIdForVersioning) {
335
      this.useBuildIdForVersioning = useBuildIdForVersioning;
1✔
336
      return this;
1✔
337
    }
338

339
    /**
340
     * Set a unique identifier for this worker. The identifier should be stable with respect to the
341
     * code the worker uses for workflows, activities, and interceptors. For more information see:
342
     * TODO: Doc link
343
     *
344
     * <p>A Build Id must be set if {@link #setUseBuildIdForVersioning(boolean)} is set true.
345
     */
346
    @Experimental
347
    public Builder setBuildId(String buildId) {
348
      this.buildId = buildId;
1✔
349
      return this;
1✔
350
    }
351

352
    public WorkerOptions build() {
353
      return new WorkerOptions(
1✔
354
          maxWorkerActivitiesPerSecond,
355
          maxConcurrentActivityExecutionSize,
356
          maxConcurrentWorkflowTaskExecutionSize,
357
          maxConcurrentLocalActivityExecutionSize,
358
          maxTaskQueueActivitiesPerSecond,
359
          maxConcurrentWorkflowTaskPollers,
360
          maxConcurrentActivityTaskPollers,
361
          localActivityWorkerOnly,
362
          defaultDeadlockDetectionTimeout,
363
          maxHeartbeatThrottleInterval,
364
          defaultHeartbeatThrottleInterval,
365
          stickyQueueScheduleToStartTimeout,
366
          disableEagerExecution,
367
          useBuildIdForVersioning,
368
          buildId);
369
    }
370

371
    public WorkerOptions validateAndBuildWithDefaults() {
372
      Preconditions.checkState(
1✔
373
          maxWorkerActivitiesPerSecond >= 0, "negative maxActivitiesPerSecond");
374
      Preconditions.checkState(
1✔
375
          maxConcurrentActivityExecutionSize >= 0, "negative maxConcurrentActivityExecutionSize");
376
      Preconditions.checkState(
1✔
377
          maxConcurrentWorkflowTaskExecutionSize >= 0,
378
          "negative maxConcurrentWorkflowTaskExecutionSize");
379
      Preconditions.checkState(
1✔
380
          maxConcurrentLocalActivityExecutionSize >= 0,
381
          "negative maxConcurrentLocalActivityExecutionSize");
382
      Preconditions.checkState(
1✔
383
          maxTaskQueueActivitiesPerSecond >= 0, "negative taskQueueActivitiesPerSecond");
384
      Preconditions.checkState(
1✔
385
          maxConcurrentWorkflowTaskPollers >= 0, "negative maxConcurrentWorkflowTaskPollers");
386
      Preconditions.checkState(
1✔
387
          maxConcurrentActivityTaskPollers >= 0, "negative maxConcurrentActivityTaskPollers");
388
      Preconditions.checkState(
1✔
389
          defaultDeadlockDetectionTimeout >= 0, "negative defaultDeadlockDetectionTimeout");
390
      Preconditions.checkState(
1✔
391
          stickyQueueScheduleToStartTimeout == null
392
              || !stickyQueueScheduleToStartTimeout.isNegative(),
1✔
393
          "negative stickyQueueScheduleToStartTimeout");
394
      if (useBuildIdForVersioning) {
1✔
395
        Preconditions.checkState(
1✔
396
            buildId != null && !buildId.isEmpty(),
1✔
397
            "buildId must be set non-empty if useBuildIdForVersioning is set true");
398
      }
399

400
      return new WorkerOptions(
1✔
401
          maxWorkerActivitiesPerSecond,
402
          maxConcurrentActivityExecutionSize == 0
1✔
403
              ? DEFAULT_MAX_CONCURRENT_ACTIVITY_EXECUTION_SIZE
1✔
404
              : maxConcurrentActivityExecutionSize,
1✔
405
          maxConcurrentWorkflowTaskExecutionSize == 0
1✔
406
              ? DEFAULT_MAX_CONCURRENT_WORKFLOW_TASK_EXECUTION_SIZE
1✔
407
              : maxConcurrentWorkflowTaskExecutionSize,
1✔
408
          maxConcurrentLocalActivityExecutionSize == 0
1✔
409
              ? DEFAULT_MAX_CONCURRENT_LOCAL_ACTIVITY_EXECUTION_SIZE
1✔
410
              : maxConcurrentLocalActivityExecutionSize,
1✔
411
          maxTaskQueueActivitiesPerSecond,
412
          maxConcurrentWorkflowTaskPollers == 0
1✔
413
              ? DEFAULT_MAX_CONCURRENT_WORKFLOW_TASK_POLLERS
1✔
414
              : maxConcurrentWorkflowTaskPollers,
1✔
415
          maxConcurrentActivityTaskPollers == 0
1✔
416
              ? DEFAULT_MAX_CONCURRENT_ACTIVITY_TASK_POLLERS
1✔
417
              : maxConcurrentActivityTaskPollers,
1✔
418
          localActivityWorkerOnly,
419
          defaultDeadlockDetectionTimeout == 0
1✔
420
              ? DEFAULT_DEADLOCK_DETECTION_TIMEOUT
1✔
421
              : defaultDeadlockDetectionTimeout,
1✔
422
          maxHeartbeatThrottleInterval == null || maxHeartbeatThrottleInterval.isZero()
1✔
423
              ? DEFAULT_MAX_HEARTBEAT_THROTTLE_INTERVAL
1✔
424
              : maxHeartbeatThrottleInterval,
1✔
425
          defaultHeartbeatThrottleInterval == null || defaultHeartbeatThrottleInterval.isZero()
1✔
426
              ? DEFAULT_DEFAULT_HEARTBEAT_THROTTLE_INTERVAL
1✔
427
              : defaultHeartbeatThrottleInterval,
1✔
428
          stickyQueueScheduleToStartTimeout == null
1✔
429
              ? DEFAULT_STICKY_SCHEDULE_TO_START_TIMEOUT
1✔
430
              : stickyQueueScheduleToStartTimeout,
1✔
431
          disableEagerExecution,
432
          useBuildIdForVersioning,
433
          buildId);
434
    }
435
  }
436

437
  private final double maxWorkerActivitiesPerSecond;
438
  private final int maxConcurrentActivityExecutionSize;
439
  private final int maxConcurrentWorkflowTaskExecutionSize;
440
  private final int maxConcurrentLocalActivityExecutionSize;
441
  private final double maxTaskQueueActivitiesPerSecond;
442
  private final int maxConcurrentWorkflowTaskPollers;
443
  private final int maxConcurrentActivityTaskPollers;
444
  private final boolean localActivityWorkerOnly;
445
  private final long defaultDeadlockDetectionTimeout;
446
  private final Duration maxHeartbeatThrottleInterval;
447
  private final Duration defaultHeartbeatThrottleInterval;
448
  private final @Nonnull Duration stickyQueueScheduleToStartTimeout;
449
  private final boolean disableEagerExecution;
450
  private final boolean useBuildIdForVersioning;
451
  private final String buildId;
452

453
  private WorkerOptions(
454
      double maxWorkerActivitiesPerSecond,
455
      int maxConcurrentActivityExecutionSize,
456
      int maxConcurrentWorkflowExecutionSize,
457
      int maxConcurrentLocalActivityExecutionSize,
458
      double maxTaskQueueActivitiesPerSecond,
459
      int workflowPollThreadCount,
460
      int activityPollThreadCount,
461
      boolean localActivityWorkerOnly,
462
      long defaultDeadlockDetectionTimeout,
463
      Duration maxHeartbeatThrottleInterval,
464
      Duration defaultHeartbeatThrottleInterval,
465
      @Nonnull Duration stickyQueueScheduleToStartTimeout,
466
      boolean disableEagerExecution,
467
      boolean useBuildIdForVersioning,
468
      String buildId) {
1✔
469
    this.maxWorkerActivitiesPerSecond = maxWorkerActivitiesPerSecond;
1✔
470
    this.maxConcurrentActivityExecutionSize = maxConcurrentActivityExecutionSize;
1✔
471
    this.maxConcurrentWorkflowTaskExecutionSize = maxConcurrentWorkflowExecutionSize;
1✔
472
    this.maxConcurrentLocalActivityExecutionSize = maxConcurrentLocalActivityExecutionSize;
1✔
473
    this.maxTaskQueueActivitiesPerSecond = maxTaskQueueActivitiesPerSecond;
1✔
474
    this.maxConcurrentWorkflowTaskPollers = workflowPollThreadCount;
1✔
475
    this.maxConcurrentActivityTaskPollers = activityPollThreadCount;
1✔
476
    this.localActivityWorkerOnly = localActivityWorkerOnly;
1✔
477
    this.defaultDeadlockDetectionTimeout = defaultDeadlockDetectionTimeout;
1✔
478
    this.maxHeartbeatThrottleInterval = maxHeartbeatThrottleInterval;
1✔
479
    this.defaultHeartbeatThrottleInterval = defaultHeartbeatThrottleInterval;
1✔
480
    this.stickyQueueScheduleToStartTimeout = stickyQueueScheduleToStartTimeout;
1✔
481
    this.disableEagerExecution = disableEagerExecution;
1✔
482
    this.useBuildIdForVersioning = useBuildIdForVersioning;
1✔
483
    this.buildId = buildId;
1✔
484
  }
1✔
485

486
  public double getMaxWorkerActivitiesPerSecond() {
487
    return maxWorkerActivitiesPerSecond;
1✔
488
  }
489

490
  public int getMaxConcurrentActivityExecutionSize() {
491
    return maxConcurrentActivityExecutionSize;
1✔
492
  }
493

494
  public int getMaxConcurrentWorkflowTaskExecutionSize() {
495
    return maxConcurrentWorkflowTaskExecutionSize;
1✔
496
  }
497

498
  public int getMaxConcurrentLocalActivityExecutionSize() {
499
    return maxConcurrentLocalActivityExecutionSize;
1✔
500
  }
501

502
  public double getMaxTaskQueueActivitiesPerSecond() {
503
    return maxTaskQueueActivitiesPerSecond;
1✔
504
  }
505

506
  /**
507
   * @deprecated use {@link #getMaxConcurrentWorkflowTaskPollers}
508
   */
509
  @Deprecated
510
  public int getWorkflowPollThreadCount() {
511
    return getMaxConcurrentWorkflowTaskPollers();
×
512
  }
513

514
  public int getMaxConcurrentWorkflowTaskPollers() {
515
    return maxConcurrentWorkflowTaskPollers;
1✔
516
  }
517

518
  /**
519
   * @deprecated use {@link #getMaxConcurrentActivityTaskPollers}
520
   */
521
  @Deprecated
522
  public int getActivityPollThreadCount() {
523
    return getMaxConcurrentActivityTaskPollers();
×
524
  }
525

526
  public int getMaxConcurrentActivityTaskPollers() {
527
    return maxConcurrentActivityTaskPollers;
1✔
528
  }
529

530
  public long getDefaultDeadlockDetectionTimeout() {
531
    return defaultDeadlockDetectionTimeout;
1✔
532
  }
533

534
  public boolean isLocalActivityWorkerOnly() {
535
    return localActivityWorkerOnly;
1✔
536
  }
537

538
  public Duration getMaxHeartbeatThrottleInterval() {
539
    return maxHeartbeatThrottleInterval;
1✔
540
  }
541

542
  public Duration getDefaultHeartbeatThrottleInterval() {
543
    return defaultHeartbeatThrottleInterval;
1✔
544
  }
545

546
  @Nonnull
547
  public Duration getStickyQueueScheduleToStartTimeout() {
548
    return stickyQueueScheduleToStartTimeout;
1✔
549
  }
550

551
  public boolean isEagerExecutionDisabled() {
552
    return disableEagerExecution;
1✔
553
  }
554

555
  public boolean isUsingBuildIdForVersioning() {
556
    return useBuildIdForVersioning;
1✔
557
  }
558

559
  public String getBuildId() {
560
    return buildId;
1✔
561
  }
562

563
  @Override
564
  public boolean equals(Object o) {
565
    if (this == o) return true;
×
566
    if (o == null || getClass() != o.getClass()) return false;
×
567
    WorkerOptions that = (WorkerOptions) o;
×
568
    return compare(that.maxWorkerActivitiesPerSecond, maxWorkerActivitiesPerSecond) == 0
×
569
        && maxConcurrentActivityExecutionSize == that.maxConcurrentActivityExecutionSize
570
        && maxConcurrentWorkflowTaskExecutionSize == that.maxConcurrentWorkflowTaskExecutionSize
571
        && maxConcurrentLocalActivityExecutionSize == that.maxConcurrentLocalActivityExecutionSize
572
        && compare(that.maxTaskQueueActivitiesPerSecond, maxTaskQueueActivitiesPerSecond) == 0
×
573
        && maxConcurrentWorkflowTaskPollers == that.maxConcurrentWorkflowTaskPollers
574
        && maxConcurrentActivityTaskPollers == that.maxConcurrentActivityTaskPollers
575
        && localActivityWorkerOnly == that.localActivityWorkerOnly
576
        && defaultDeadlockDetectionTimeout == that.defaultDeadlockDetectionTimeout
577
        && Objects.equals(maxHeartbeatThrottleInterval, that.maxHeartbeatThrottleInterval)
×
578
        && Objects.equals(defaultHeartbeatThrottleInterval, that.defaultHeartbeatThrottleInterval)
×
579
        && Objects.equals(stickyQueueScheduleToStartTimeout, that.stickyQueueScheduleToStartTimeout)
×
580
        && disableEagerExecution == that.disableEagerExecution
581
        && useBuildIdForVersioning == that.useBuildIdForVersioning
582
        && buildId.equals(that.buildId);
×
583
  }
584

585
  @Override
586
  public int hashCode() {
587
    return Objects.hash(
×
588
        maxWorkerActivitiesPerSecond,
×
589
        maxConcurrentActivityExecutionSize,
×
590
        maxConcurrentWorkflowTaskExecutionSize,
×
591
        maxConcurrentLocalActivityExecutionSize,
×
592
        maxTaskQueueActivitiesPerSecond,
×
593
        maxConcurrentWorkflowTaskPollers,
×
594
        maxConcurrentActivityTaskPollers,
×
595
        localActivityWorkerOnly,
×
596
        defaultDeadlockDetectionTimeout,
×
597
        maxHeartbeatThrottleInterval,
598
        defaultHeartbeatThrottleInterval,
599
        stickyQueueScheduleToStartTimeout,
600
        disableEagerExecution,
×
601
        useBuildIdForVersioning,
×
602
        buildId);
603
  }
604

605
  @Override
606
  public String toString() {
607
    return "WorkerOptions{"
×
608
        + "maxWorkerActivitiesPerSecond="
609
        + maxWorkerActivitiesPerSecond
610
        + ", maxConcurrentActivityExecutionSize="
611
        + maxConcurrentActivityExecutionSize
612
        + ", maxConcurrentWorkflowTaskExecutionSize="
613
        + maxConcurrentWorkflowTaskExecutionSize
614
        + ", maxConcurrentLocalActivityExecutionSize="
615
        + maxConcurrentLocalActivityExecutionSize
616
        + ", maxTaskQueueActivitiesPerSecond="
617
        + maxTaskQueueActivitiesPerSecond
618
        + ", maxConcurrentWorkflowTaskPollers="
619
        + maxConcurrentWorkflowTaskPollers
620
        + ", maxConcurrentActivityTaskPollers="
621
        + maxConcurrentActivityTaskPollers
622
        + ", localActivityWorkerOnly="
623
        + localActivityWorkerOnly
624
        + ", defaultDeadlockDetectionTimeout="
625
        + defaultDeadlockDetectionTimeout
626
        + ", maxHeartbeatThrottleInterval="
627
        + maxHeartbeatThrottleInterval
628
        + ", defaultHeartbeatThrottleInterval="
629
        + defaultHeartbeatThrottleInterval
630
        + ", stickyQueueScheduleToStartTimeout="
631
        + stickyQueueScheduleToStartTimeout
632
        + ", disableEagerExecution="
633
        + disableEagerExecution
634
        + ", useBuildIdForVersioning="
635
        + useBuildIdForVersioning
636
        + ", buildId='"
637
        + buildId
638
        + '}';
639
  }
640
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc