-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathAttempt.java
144 lines (123 loc) · 4.13 KB
/
Attempt.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.persistence.job.models;
import io.airbyte.config.AttemptFailureSummary;
import io.airbyte.config.AttemptSyncConfig;
import io.airbyte.config.JobOutput;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nullable;
public class Attempt {
private final int attemptNumber;
private final long jobId;
private final JobOutput output;
private final AttemptStatus status;
private final String processingTaskQueue;
private final AttemptFailureSummary failureSummary;
private final AttemptSyncConfig syncConfig;
private final Path logPath;
private final long updatedAtInSecond;
private final long createdAtInSecond;
private final Long endedAtInSecond;
public Attempt(final int attemptNumber,
final long jobId,
final Path logPath,
final @Nullable AttemptSyncConfig syncConfig,
final @Nullable JobOutput output,
final AttemptStatus status,
final String processingTaskQueue,
final @Nullable AttemptFailureSummary failureSummary,
final long createdAtInSecond,
final long updatedAtInSecond,
final @Nullable Long endedAtInSecond) {
this.attemptNumber = attemptNumber;
this.jobId = jobId;
this.syncConfig = syncConfig;
this.output = output;
this.status = status;
this.processingTaskQueue = processingTaskQueue;
this.failureSummary = failureSummary;
this.logPath = logPath;
this.updatedAtInSecond = updatedAtInSecond;
this.createdAtInSecond = createdAtInSecond;
this.endedAtInSecond = endedAtInSecond;
}
public int getAttemptNumber() {
return attemptNumber;
}
public long getJobId() {
return jobId;
}
public Optional<AttemptSyncConfig> getSyncConfig() {
return Optional.ofNullable(syncConfig);
}
public Optional<JobOutput> getOutput() {
return Optional.ofNullable(output);
}
public AttemptStatus getStatus() {
return status;
}
public String getProcessingTaskQueue() {
return processingTaskQueue;
}
public Optional<AttemptFailureSummary> getFailureSummary() {
return Optional.ofNullable(failureSummary);
}
public Path getLogPath() {
return logPath;
}
public Optional<Long> getEndedAtInSecond() {
return Optional.ofNullable(endedAtInSecond);
}
public long getCreatedAtInSecond() {
return createdAtInSecond;
}
public long getUpdatedAtInSecond() {
return updatedAtInSecond;
}
public static boolean isAttemptInTerminalState(final Attempt attempt) {
return AttemptStatus.TERMINAL_STATUSES.contains(attempt.getStatus());
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Attempt attempt = (Attempt) o;
return attemptNumber == attempt.attemptNumber &&
jobId == attempt.jobId &&
updatedAtInSecond == attempt.updatedAtInSecond &&
createdAtInSecond == attempt.createdAtInSecond &&
Objects.equals(syncConfig, attempt.syncConfig) &&
Objects.equals(output, attempt.output) &&
status == attempt.status &&
Objects.equals(failureSummary, attempt.failureSummary) &&
Objects.equals(logPath, attempt.logPath) &&
Objects.equals(endedAtInSecond, attempt.endedAtInSecond);
}
@Override
public int hashCode() {
return Objects.hash(attemptNumber, jobId, syncConfig, output, status, failureSummary, logPath, updatedAtInSecond, createdAtInSecond,
endedAtInSecond);
}
@Override
public String toString() {
return "Attempt{" +
"id=" + attemptNumber +
", jobId=" + jobId +
", syncConfig=" + syncConfig +
", output=" + output +
", status=" + status +
", failureSummary=" + failureSummary +
", logPath=" + logPath +
", updatedAtInSecond=" + updatedAtInSecond +
", createdAtInSecond=" + createdAtInSecond +
", endedAtInSecond=" + endedAtInSecond +
'}';
}
}