Skip to content

Commit 868c392

Browse files
authored
Linting (#780)
1 parent 5f6022a commit 868c392

File tree

6 files changed

+62
-51
lines changed

6 files changed

+62
-51
lines changed

src/main/java/com/uber/cadence/activity/Activity.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,19 @@
163163
* }
164164
* </code></pre>
165165
*
166-
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to recording the
167-
* {@link Activity#getTaskToken()} in an external system (or prior to another thread calling it) may not be noticed
168-
* until the "long" timeout occurs. This can be resolved by having another system call
169-
* {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[], Object)} while that external action is
170-
* running, but there is currently no way to mitigate this issue without these heartbeats. For in-process-only async
171-
* completion, relying on heartbeating is safe and reliable because these heartbeats should occur as long as the
172-
* process / background thread is still running.
173-
*
174-
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection, consider emulating a
175-
* long activity via a signal channel instead: you can start a short-lived activity and wait for a "saved to external
176-
* system" signal, retrying as necessary, and then wait for an "external system finished" signal containing the final
177-
* result.
166+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to
167+
* recording the {@link Activity#getTaskToken()} in an external system (or prior to another thread
168+
* calling it) may not be noticed until the "long" timeout occurs. This can be resolved by having
169+
* another system call {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[],
170+
* Object)} while that external action is running, but there is currently no way to mitigate this
171+
* issue without these heartbeats. For in-process-only async completion, relying on heartbeating is
172+
* safe and reliable because these heartbeats should occur as long as the process / background
173+
* thread is still running.
174+
*
175+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection,
176+
* consider emulating a long activity via a signal channel instead: you can start a short-lived
177+
* activity and wait for a "saved to external system" signal, retrying as necessary, and then wait
178+
* for an "external system finished" signal containing the final result.
178179
*
179180
* <h3>Activity Heartbeating</h3>
180181
*
@@ -214,23 +215,23 @@
214215
public final class Activity {
215216

216217
/**
217-
* If this method is called during an activity execution then activity will not complete
218-
* when its method returns. It is expected to be completed asynchronously using {@link
218+
* If this method is called during an activity execution then activity will not complete when its
219+
* method returns. It is expected to be completed asynchronously using {@link
219220
* com.uber.cadence.client.ActivityCompletionClient}.
220221
*
221-
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to recording the
222-
* {@link Activity#getTaskToken()} in an external system (or prior to another thread calling it) may not be noticed
223-
* until the "long" timeout occurs.
224-
* This can be resolved by having another system call
225-
* {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[], Object)} while that external action is
226-
* running, but there is currently no way to mitigate this issue without these heartbeats. For in-process-only async
227-
* completion, relying on heartbeating is safe and reliable because these heartbeats should occur as long as the
228-
* process / background thread is still running.
222+
* <p>Caution: since using this sometimes implies "long" timeouts, activity-worker losses prior to
223+
* recording the {@link Activity#getTaskToken()} in an external system (or prior to another thread
224+
* calling it) may not be noticed until the "long" timeout occurs. This can be resolved by having
225+
* another system call {@link com.uber.cadence.client.ActivityCompletionClient#heartbeat(byte[],
226+
* Object)} while that external action is running, but there is currently no way to mitigate this
227+
* issue without these heartbeats. For in-process-only async completion, relying on heartbeating
228+
* is safe and reliable because these heartbeats should occur as long as the process / background
229+
* thread is still running.
229230
*
230-
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection, consider emulating a
231-
* long activity via a signal channel instead: you can start a short-lived activity and wait for a "saved to external
232-
* system" signal, retrying as necessary, and then wait for an "external system finished" signal containing the final
233-
* result.
231+
* <p>If you cannot heartbeat and cannot tolerate this kind of delayed-activity-loss detection,
232+
* consider emulating a long activity via a signal channel instead: you can start a short-lived
233+
* activity and wait for a "saved to external system" signal, retrying as necessary, and then wait
234+
* for an "external system finished" signal containing the final result.
234235
*/
235236
public static void doNotCompleteOnReturn() {
236237
ActivityInternal.doNotCompleteOnReturn();

src/main/java/com/uber/cadence/internal/sync/ActivityInvocationHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ protected Function<Object[], Object> getActivityFunc(
6666
if (activityOptionsOverride == null) {
6767
stub = ActivityStubImpl.newInstance(mergedOptions, activityExecutor);
6868
} else {
69-
ActivityOptions mergedOverrideOptions = ActivityOptions.merge(activityMethod, methodRetry, activityOptionsOverride);
69+
ActivityOptions mergedOverrideOptions =
70+
ActivityOptions.merge(activityMethod, methodRetry, activityOptionsOverride);
7071
stub = ActivityStubImpl.newInstance(mergedOverrideOptions, activityExecutor);
7172
}
7273

src/main/java/com/uber/cadence/internal/worker/ActivityPollTask.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
package com.uber.cadence.internal.worker;
1919

20+
import static com.uber.cadence.internal.metrics.MetricsTagValue.INTERNAL_SERVICE_ERROR;
21+
import static com.uber.cadence.internal.metrics.MetricsTagValue.SERVICE_BUSY;
22+
2023
import com.google.common.collect.ImmutableMap;
2124
import com.uber.cadence.InternalServiceError;
2225
import com.uber.cadence.PollForActivityTaskRequest;
@@ -32,9 +35,6 @@
3235
import org.slf4j.Logger;
3336
import org.slf4j.LoggerFactory;
3437

35-
import static com.uber.cadence.internal.metrics.MetricsTagValue.INTERNAL_SERVICE_ERROR;
36-
import static com.uber.cadence.internal.metrics.MetricsTagValue.SERVICE_BUSY;
37-
3838
final class ActivityPollTask extends ActivityPollTaskBase {
3939

4040
private static final Logger log = LoggerFactory.getLogger(ActivityPollTask.class);
@@ -72,17 +72,20 @@ protected PollForActivityTaskResponse pollTask() throws TException {
7272
try {
7373
result = service.PollForActivityTask(pollRequest);
7474
} catch (InternalServiceError e) {
75-
options.getMetricsScope()
76-
.tagged(ImmutableMap.of(MetricsTag.CAUSE, INTERNAL_SERVICE_ERROR))
77-
.counter(MetricsType.ACTIVITY_POLL_TRANSIENT_FAILED_COUNTER).inc(1);
75+
options
76+
.getMetricsScope()
77+
.tagged(ImmutableMap.of(MetricsTag.CAUSE, INTERNAL_SERVICE_ERROR))
78+
.counter(MetricsType.ACTIVITY_POLL_TRANSIENT_FAILED_COUNTER)
79+
.inc(1);
7880
throw e;
7981
} catch (ServiceBusyError e) {
80-
options.getMetricsScope()
81-
.tagged(ImmutableMap.of(MetricsTag.CAUSE, SERVICE_BUSY))
82-
.counter(MetricsType.ACTIVITY_POLL_TRANSIENT_FAILED_COUNTER).inc(1);
82+
options
83+
.getMetricsScope()
84+
.tagged(ImmutableMap.of(MetricsTag.CAUSE, SERVICE_BUSY))
85+
.counter(MetricsType.ACTIVITY_POLL_TRANSIENT_FAILED_COUNTER)
86+
.inc(1);
8387
throw e;
84-
}
85-
catch (TException e) {
88+
} catch (TException e) {
8689
options.getMetricsScope().counter(MetricsType.ACTIVITY_POLL_FAILED_COUNTER).inc(1);
8790
throw e;
8891
}

src/main/java/com/uber/cadence/internal/worker/WorkflowPollTask.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
package com.uber.cadence.internal.worker;
1919

20+
import static com.uber.cadence.internal.metrics.MetricsTagValue.INTERNAL_SERVICE_ERROR;
21+
import static com.uber.cadence.internal.metrics.MetricsTagValue.SERVICE_BUSY;
22+
2023
import com.uber.cadence.InternalServiceError;
2124
import com.uber.cadence.PollForDecisionTaskRequest;
2225
import com.uber.cadence.PollForDecisionTaskResponse;
@@ -30,15 +33,11 @@
3033
import com.uber.m3.tally.Stopwatch;
3134
import com.uber.m3.util.Duration;
3235
import com.uber.m3.util.ImmutableMap;
33-
3436
import java.util.Objects;
3537
import org.apache.thrift.TException;
3638
import org.slf4j.Logger;
3739
import org.slf4j.LoggerFactory;
3840

39-
import static com.uber.cadence.internal.metrics.MetricsTagValue.INTERNAL_SERVICE_ERROR;
40-
import static com.uber.cadence.internal.metrics.MetricsTagValue.SERVICE_BUSY;
41-
4241
final class WorkflowPollTask implements Poller.PollTask<PollForDecisionTaskResponse> {
4342

4443
private static final Logger log = LoggerFactory.getLogger(WorkflowWorker.class);
@@ -83,13 +82,15 @@ public PollForDecisionTaskResponse poll() throws TException {
8382
result = service.PollForDecisionTask(pollRequest);
8483
} catch (InternalServiceError e) {
8584
metricScope
86-
.tagged(ImmutableMap.of(MetricsTag.CAUSE, INTERNAL_SERVICE_ERROR))
87-
.counter(MetricsType.DECISION_POLL_TRANSIENT_FAILED_COUNTER).inc(1);
85+
.tagged(ImmutableMap.of(MetricsTag.CAUSE, INTERNAL_SERVICE_ERROR))
86+
.counter(MetricsType.DECISION_POLL_TRANSIENT_FAILED_COUNTER)
87+
.inc(1);
8888
throw e;
8989
} catch (ServiceBusyError e) {
9090
metricScope
91-
.tagged(ImmutableMap.of(MetricsTag.CAUSE, SERVICE_BUSY))
92-
.counter(MetricsType.DECISION_POLL_TRANSIENT_FAILED_COUNTER).inc(1);
91+
.tagged(ImmutableMap.of(MetricsTag.CAUSE, SERVICE_BUSY))
92+
.counter(MetricsType.DECISION_POLL_TRANSIENT_FAILED_COUNTER)
93+
.inc(1);
9394
throw e;
9495
} catch (TException e) {
9596
metricScope.counter(MetricsType.DECISION_POLL_FAILED_COUNTER).inc(1);

src/main/java/com/uber/cadence/worker/WorkflowImplementationOptions.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,19 @@ public Builder setNonDeterministicWorkflowPolicy(
4646
/**
4747
* Set overrides for a specific workflow implementation for activity options.
4848
*
49-
* @param activityOptionOverrides a map where the key is the activity name and the value is the activity
50-
* options that should override existing activity configuration that comes from @ActivityMethod annotation.
49+
* @param activityOptionOverrides a map where the key is the activity name and the value is the
50+
* activity options that should override existing activity configuration that comes
51+
* from @ActivityMethod annotation.
5152
*/
52-
public Builder setActivityOptionOverrides(Map<String, ActivityOptions> activityOptionOverrides) {
53+
public Builder setActivityOptionOverrides(
54+
Map<String, ActivityOptions> activityOptionOverrides) {
5355
this.activityOptionOverrides = activityOptionOverrides;
5456
return this;
5557
}
5658

5759
public WorkflowImplementationOptions build() {
58-
return new WorkflowImplementationOptions(nonDeterministicWorkflowPolicy, activityOptionOverrides);
60+
return new WorkflowImplementationOptions(
61+
nonDeterministicWorkflowPolicy, activityOptionOverrides);
5962
}
6063
}
6164

src/test/java/com/uber/cadence/workflow/WorkflowTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6339,7 +6339,9 @@ public void testActivityDoesntTimeoutWhenTimeoutsAreLonger() throws Exception {
63396339
.build());
63406340

63416341
startWorkerFor(
6342-
new WorkflowImplementationOptions.Builder().setActivityOptionOverrides(activityOptionsMap).build(),
6342+
new WorkflowImplementationOptions.Builder()
6343+
.setActivityOptionOverrides(activityOptionsMap)
6344+
.build(),
63436345
TestWorkflowActivityOptionOverride.class);
63446346

63456347
TestWorkflow1 workflowStub =

0 commit comments

Comments
 (0)