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

temporalio / sdk-java / #207

06 Nov 2023 04:21PM CUT coverage: 77.277% (-0.008%) from 77.285%
#207

push

github

web-flow
Test continue as new with local activities (#1922)

Test continue as new with local activities

18728 of 24235 relevant lines covered (77.28%)

0.77 hits per line

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

96.3
/temporal-sdk/src/main/java/io/temporal/internal/statemachines/ExecuteLocalActivityParameters.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.internal.statemachines;
22

23
import io.temporal.api.common.v1.ActivityType;
24
import io.temporal.api.common.v1.Payloads;
25
import io.temporal.api.failure.v1.Failure;
26
import io.temporal.api.workflowservice.v1.PollActivityTaskQueueResponse;
27
import io.temporal.internal.common.ProtobufTimeUtils;
28
import io.temporal.workflow.Functions;
29
import io.temporal.workflow.Workflow;
30
import java.time.Duration;
31
import java.util.Objects;
32
import javax.annotation.Nonnull;
33
import javax.annotation.Nullable;
34

35
public class ExecuteLocalActivityParameters {
36

37
  // This builder doesn't have all the fields published yet (a specific attempt for example)
38
  // It contains only the fields known at the moment of scheduling from the workflow.
39
  // This template gets adjusted for each attempt.
40
  private final @Nonnull PollActivityTaskQueueResponse.Builder activityTaskBuilder;
41

42
  /**
43
   * This timestamp is a Workflow Time ({@link Workflow#currentTimeMillis()}) at the moment of
44
   * scheduling of the first attempt. Comes into play when localRetryThreshold is reached. This
45
   * mechanic requires reasonably synchronized worker clocks to work properly.
46
   */
47
  private final long originalScheduledTimestamp;
48

49
  private final @Nullable Failure previousLocalExecutionFailure;
50
  private final @Nonnull Duration localRetryThreshold;
51
  private final boolean doNotIncludeArgumentsIntoMarker;
52
  private final @Nullable Duration scheduleToStartTimeout;
53
  private @Nullable Functions.Proc onNewAttemptCallback;
54

55
  public ExecuteLocalActivityParameters(
56
      @Nonnull PollActivityTaskQueueResponse.Builder activityTaskBuilder,
57
      @Nullable Duration scheduleToStartTimeout,
58
      long originalScheduledTimestamp,
59
      @Nullable Failure previousLocalExecutionFailure,
60
      boolean doNotIncludeArgumentsIntoMarker,
61
      @Nonnull Duration localRetryThreshold) {
1✔
62
    this.activityTaskBuilder = Objects.requireNonNull(activityTaskBuilder, "activityTaskBuilder");
1✔
63
    this.scheduleToStartTimeout = scheduleToStartTimeout;
1✔
64
    this.originalScheduledTimestamp = originalScheduledTimestamp;
1✔
65
    this.previousLocalExecutionFailure = previousLocalExecutionFailure;
1✔
66
    this.doNotIncludeArgumentsIntoMarker = doNotIncludeArgumentsIntoMarker;
1✔
67
    this.localRetryThreshold = localRetryThreshold;
1✔
68
    this.onNewAttemptCallback = null;
1✔
69
  }
1✔
70

71
  public String getActivityId() {
72
    return activityTaskBuilder.getActivityId();
1✔
73
  }
74

75
  public ActivityType getActivityType() {
76
    return activityTaskBuilder.getActivityType();
1✔
77
  }
78

79
  public Payloads getInput() {
80
    return activityTaskBuilder.getInput();
1✔
81
  }
82

83
  public int getInitialAttempt() {
84
    return activityTaskBuilder.getAttempt();
1✔
85
  }
86

87
  /**
88
   * @return cloned version of the original activity task builder supplied to these parameters to be
89
   *     used as an attempt base
90
   */
91
  @Nonnull
92
  public PollActivityTaskQueueResponse.Builder cloneActivityTaskBuilder() {
93
    return activityTaskBuilder.clone();
1✔
94
  }
95

96
  @Nullable
97
  public Duration getScheduleToCloseTimeout() {
98
    if (activityTaskBuilder.hasScheduleToCloseTimeout()) {
1✔
99
      return ProtobufTimeUtils.toJavaDuration(activityTaskBuilder.getScheduleToCloseTimeout());
1✔
100
    } else {
101
      return null;
1✔
102
    }
103
  }
104

105
  public long getOriginalScheduledTimestamp() {
106
    return originalScheduledTimestamp;
1✔
107
  }
108

109
  @Nullable
110
  public Failure getPreviousLocalExecutionFailure() {
111
    return previousLocalExecutionFailure;
1✔
112
  }
113

114
  public boolean isDoNotIncludeArgumentsIntoMarker() {
115
    return doNotIncludeArgumentsIntoMarker;
1✔
116
  }
117

118
  @Nonnull
119
  public Duration getLocalRetryThreshold() {
120
    return localRetryThreshold;
1✔
121
  }
122

123
  @Nullable
124
  public Duration getScheduleToStartTimeout() {
125
    return scheduleToStartTimeout;
1✔
126
  }
127

128
  @Nonnull
129
  public Functions.Proc getOnNewAttemptCallback() {
130
    if (onNewAttemptCallback == null) {
1✔
131
      return () -> {};
×
132
    }
133
    return onNewAttemptCallback;
1✔
134
  }
135

136
  public void setOnNewAttemptCallback(@Nonnull Functions.Proc onNewAttemptCallback) {
137
    this.onNewAttemptCallback = onNewAttemptCallback;
1✔
138
  }
1✔
139
}
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