-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathSynchronousJobMetadata.java
147 lines (125 loc) · 4.27 KB
/
SynchronousJobMetadata.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
145
146
147
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.server.scheduler;
import io.airbyte.commons.temporal.JobMetadata;
import io.airbyte.config.JobConfig.ConfigType;
import java.nio.file.Path;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
public class SynchronousJobMetadata {
private final UUID id;
private final ConfigType configType;
private final UUID configId;
private final long createdAt;
private final long endedAt;
private final boolean succeeded;
private final boolean connectorConfigurationUpdated;
private final Path logPath;
public static SynchronousJobMetadata fromJobMetadata(final JobMetadata jobMetadata,
final UUID id,
final ConfigType configType,
final UUID configId,
final boolean connectorConfigurationUpdated,
final long createdAt,
final long endedAt) {
return new SynchronousJobMetadata(
id,
configType,
configId,
createdAt,
endedAt,
jobMetadata.isSucceeded(),
connectorConfigurationUpdated,
jobMetadata.getLogPath());
}
public SynchronousJobMetadata(final UUID id,
final ConfigType configType,
final UUID configId,
final long createdAt,
final long endedAt,
final boolean succeeded,
final boolean connectorConfigurationUpdated,
final Path logPath) {
this.id = id;
this.configType = configType;
this.configId = configId;
this.createdAt = createdAt;
this.endedAt = endedAt;
this.succeeded = succeeded;
this.connectorConfigurationUpdated = connectorConfigurationUpdated;
this.logPath = logPath;
}
public UUID getId() {
return id;
}
public ConfigType getConfigType() {
return configType;
}
public Optional<UUID> getConfigId() {
return Optional.ofNullable(configId);
}
public long getCreatedAt() {
return createdAt;
}
public long getEndedAt() {
return endedAt;
}
public boolean isSucceeded() {
return succeeded;
}
public boolean isConnectorConfigurationUpdated() {
return connectorConfigurationUpdated;
}
public Path getLogPath() {
return logPath;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final SynchronousJobMetadata that = (SynchronousJobMetadata) o;
return createdAt == that.createdAt && endedAt == that.endedAt && succeeded == that.succeeded
&& connectorConfigurationUpdated == that.connectorConfigurationUpdated && Objects.equals(id, that.id)
&& configType == that.configType && Objects.equals(configId, that.configId) && Objects.equals(logPath, that.logPath);
}
@Override
public int hashCode() {
return Objects.hash(id, configType, configId, createdAt, endedAt, succeeded, connectorConfigurationUpdated, logPath);
}
@Override
public String toString() {
return "SynchronousJobMetadata{" +
"id=" + id +
", configType=" + configType +
", configId=" + configId +
", createdAt=" + createdAt +
", endedAt=" + endedAt +
", succeeded=" + succeeded +
", connectorConfigurationUpdated=" + connectorConfigurationUpdated +
", logPath=" + logPath +
'}';
}
public static SynchronousJobMetadata mock(final ConfigType configType) {
final long now = Instant.now().toEpochMilli();
final UUID configId = null;
final boolean succeeded = true;
final boolean connectorConfigurationUpdated = false;
final Path logPath = null;
return new SynchronousJobMetadata(
UUID.randomUUID(),
configType,
configId,
now,
now,
succeeded,
connectorConfigurationUpdated,
logPath);
}
}