|
| 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.history; |
| 22 | + |
| 23 | +import com.fasterxml.jackson.annotation.JsonFormat; |
| 24 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 25 | +import java.time.Duration; |
| 26 | +import javax.annotation.Nullable; |
| 27 | + |
| 28 | +/** |
| 29 | + * See <a |
| 30 | + * href="https://github.com/temporalio/sdk-core/blob/master/protos/local/temporal/sdk/core/external_data/external_data.proto#L12">Core |
| 31 | + * Data Structure</a> |
| 32 | + */ |
| 33 | +public class LocalActivityMarkerMetadata { |
| 34 | + // The time the LA was originally scheduled (wall clock time). This is used to track |
| 35 | + // schedule-to-close timeouts when timer-based backoffs are used. |
| 36 | + @JsonProperty(value = "firstSkd") |
| 37 | + private long originalScheduledTimestamp; |
| 38 | + |
| 39 | + // The number of attempts at execution before we recorded this result. Typically starts at 1, |
| 40 | + // but it is possible to start at a higher number when backing off using a timer. |
| 41 | + @JsonProperty(value = "atpt") |
| 42 | + private int attempt; |
| 43 | + |
| 44 | + // If set, this local activity conceptually is retrying after the specified backoff. |
| 45 | + // Implementation wise, they are really two different LA machines, but with the same type & input. |
| 46 | + // The retry starts with an attempt number > 1. |
| 47 | + @Nullable |
| 48 | + @JsonFormat(shape = JsonFormat.Shape.NUMBER_INT) |
| 49 | + @JsonProperty(value = "backoff") |
| 50 | + private Duration backoff; |
| 51 | + |
| 52 | + public LocalActivityMarkerMetadata() {} |
| 53 | + |
| 54 | + public LocalActivityMarkerMetadata(int attempt, long originalScheduledTimestamp) { |
| 55 | + this.attempt = attempt; |
| 56 | + this.originalScheduledTimestamp = originalScheduledTimestamp; |
| 57 | + } |
| 58 | + |
| 59 | + public long getOriginalScheduledTimestamp() { |
| 60 | + return originalScheduledTimestamp; |
| 61 | + } |
| 62 | + |
| 63 | + public void setOriginalScheduledTimestamp(long originalScheduledTimestamp) { |
| 64 | + this.originalScheduledTimestamp = originalScheduledTimestamp; |
| 65 | + } |
| 66 | + |
| 67 | + public int getAttempt() { |
| 68 | + return attempt; |
| 69 | + } |
| 70 | + |
| 71 | + public void setAttempt(int attempt) { |
| 72 | + this.attempt = attempt; |
| 73 | + } |
| 74 | + |
| 75 | + @Nullable |
| 76 | + public Duration getBackoff() { |
| 77 | + return backoff; |
| 78 | + } |
| 79 | + |
| 80 | + public void setBackoff(@Nullable Duration backoff) { |
| 81 | + this.backoff = backoff; |
| 82 | + } |
| 83 | +} |
0 commit comments