Skip to content

Commit 5372038

Browse files
authored
refactor: cloud execution DTO using long as id (#931)
1 parent 8548e78 commit 5372038

20 files changed

Lines changed: 79 additions & 77 deletions

File tree

cloud/flamingock-cloud-api/src/main/java/io/flamingock/cloud/api/response/ExecutionDetailResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class ExecutionDetailResponse {
2323

24-
private String executionId;
24+
private Long executionId;
2525
private long environmentId;
2626
private long serviceId;
2727
private String runnerId;
@@ -32,7 +32,7 @@ public class ExecutionDetailResponse {
3232
public ExecutionDetailResponse() {
3333
}
3434

35-
public ExecutionDetailResponse(String executionId, long environmentId, long serviceId, String runnerId,
35+
public ExecutionDetailResponse(Long executionId, long environmentId, long serviceId, String runnerId,
3636
Instant startedAt, ClientSubmissionRequest clientSubmission, PipelineResponse pipeline) {
3737
this.executionId = executionId;
3838
this.environmentId = environmentId;
@@ -43,8 +43,8 @@ public ExecutionDetailResponse(String executionId, long environmentId, long serv
4343
this.pipeline = pipeline;
4444
}
4545

46-
public String getExecutionId() { return executionId; }
47-
public void setExecutionId(String executionId) { this.executionId = executionId; }
46+
public Long getExecutionId() { return executionId; }
47+
public void setExecutionId(Long executionId) { this.executionId = executionId; }
4848

4949
public long getEnvironmentId() { return environmentId; }
5050
public void setEnvironmentId(long environmentId) { this.environmentId = environmentId; }

cloud/flamingock-cloud-api/src/main/java/io/flamingock/cloud/api/response/ExecutionPlanResponse.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class ExecutionPlanResponse {
2424

25-
private String executionId;
25+
private Long executionId;
2626

2727
private CloudExecutionAction action;
2828

@@ -50,28 +50,28 @@ public ExecutionPlanResponse() {
5050
}
5151

5252
public ExecutionPlanResponse(CloudExecutionAction action,
53-
String executionId,
53+
Long executionId,
5454
LockInfoResponse lock) {
5555
this(action, executionId, lock, Collections.emptyList());
5656
}
5757

5858
public ExecutionPlanResponse(CloudExecutionAction action,
59-
String executionId,
59+
Long executionId,
6060
LockInfoResponse lock,
6161
List<StageResponse> stages) {
6262
this(action, executionId, lock, stages, false);
6363
}
6464

6565
public ExecutionPlanResponse(CloudExecutionAction action,
66-
String executionId,
66+
Long executionId,
6767
LockInfoResponse lock,
6868
List<StageResponse> stages,
6969
boolean synchronizedMarks) {
7070
this(action, executionId, lock, stages, null, synchronizedMarks);
7171
}
7272

7373
public ExecutionPlanResponse(CloudExecutionAction action,
74-
String executionId,
74+
Long executionId,
7575
LockInfoResponse lock,
7676
List<StageResponse> stages,
7777
PipelineResultResponse pipelineResult,
@@ -88,11 +88,11 @@ public void setAction(CloudExecutionAction action) {
8888
this.action = action;
8989
}
9090

91-
public String getExecutionId() {
91+
public Long getExecutionId() {
9292
return executionId;
9393
}
9494

95-
public void setExecutionId(String executionId) {
95+
public void setExecutionId(Long executionId) {
9696
this.executionId = executionId;
9797
}
9898

cloud/flamingock-cloud-api/src/main/java/io/flamingock/cloud/api/response/ExecutionSummaryResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
public class ExecutionSummaryResponse {
2121

22-
private String executionId;
22+
private Long executionId;
2323
private long environmentId;
2424
private long serviceId;
2525
private String runnerId;
@@ -28,16 +28,16 @@ public class ExecutionSummaryResponse {
2828
public ExecutionSummaryResponse() {
2929
}
3030

31-
public ExecutionSummaryResponse(String executionId, long environmentId, long serviceId, String runnerId, Instant startedAt) {
31+
public ExecutionSummaryResponse(Long executionId, long environmentId, long serviceId, String runnerId, Instant startedAt) {
3232
this.executionId = executionId;
3333
this.environmentId = environmentId;
3434
this.serviceId = serviceId;
3535
this.runnerId = runnerId;
3636
this.startedAt = startedAt;
3737
}
3838

39-
public String getExecutionId() { return executionId; }
40-
public void setExecutionId(String executionId) { this.executionId = executionId; }
39+
public Long getExecutionId() { return executionId; }
40+
public void setExecutionId(Long executionId) { this.executionId = executionId; }
4141

4242
public long getEnvironmentId() { return environmentId; }
4343
public void setEnvironmentId(long environmentId) { this.environmentId = environmentId; }

cloud/flamingock-cloud/src/main/java/io/flamingock/cloud/planner/CloudExecutionPlanner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ private ExecutionPlan buildNextExecutionPlan(List<AbstractLoadedStage> loadedSta
203203
ExecutionPlanResponse response,
204204
Lock lock) {
205205
return ExecutionPlan.newExecution(
206-
response.getExecutionId(),
206+
// The server identity is a Long (the executions PK). The shared core ExecutionPlan/AuditEntry keep a
207+
// String executionId (used by Community local audit stores too), so convert at the cloud boundary.
208+
String.valueOf(response.getExecutionId()),
207209
lock,
208210
CloudExecutionPlanMapper.getExecutableStages(response, loadedStages)
209211
);

cloud/flamingock-cloud/src/test/java/io/flamingock/cloud/planner/CloudExecutionPlanMapperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void shouldThrowManualInterventionOnStageValidate() {
185185
void shouldBuildAbortPlanFromAbortResponse() {
186186
List<AbstractLoadedStage> loadedStages = Arrays.asList(buildStage("stage-1", change1, change2));
187187
ExecutionPlanResponse response = new ExecutionPlanResponse(
188-
CloudExecutionAction.ABORT, "exec-1", null,
188+
CloudExecutionAction.ABORT, 1L, null,
189189
Arrays.asList(buildStageResponse("stage-1", 0,
190190
changeResponse(change1.getId(), CloudChangeAction.MANUAL_INTERVENTION),
191191
changeResponse(change2.getId(), CloudChangeAction.APPLY)))
@@ -372,7 +372,7 @@ private static DefaultLoadedStage buildStage(String name, AbstractLoadedChange..
372372
}
373373

374374
private static ExecutionPlanResponse buildResponse(StageResponse... stages) {
375-
return new ExecutionPlanResponse(CloudExecutionAction.EXECUTE, "exec-1", null, Arrays.asList(stages));
375+
return new ExecutionPlanResponse(CloudExecutionAction.EXECUTE, 1L, null, Arrays.asList(stages));
376376
}
377377

378378
private static StageResponse buildStageResponse(String name, int order, ChangeResponse... changes) {

cloud/flamingock-cloud/src/test/java/io/flamingock/cloud/planner/CloudExecutionPlannerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void shouldReturnAbortPlanWhenServerReturnsAbort() {
155155
CloudExecutionPlanner planner = buildPlanner(Collections.emptyList());
156156

157157
ExecutionPlanResponse response = new ExecutionPlanResponse(
158-
CloudExecutionAction.ABORT, "exec-1", null,
158+
CloudExecutionAction.ABORT, 1L, null,
159159
Collections.singletonList(new StageResponse("stage-1", 0,
160160
Collections.singletonList(new ChangeResponse(change1.getId(), CloudChangeAction.MANUAL_INTERVENTION))))
161161
);
@@ -178,7 +178,7 @@ void shouldReturnAbortPlanWhenServerReturnsAbortWithNoMIChanges() {
178178
CloudExecutionPlanner planner = buildPlanner(Collections.emptyList());
179179

180180
ExecutionPlanResponse response = new ExecutionPlanResponse(
181-
CloudExecutionAction.ABORT, "exec-1", null,
181+
CloudExecutionAction.ABORT, 1L, null,
182182
Collections.singletonList(new StageResponse("stage-1", 0,
183183
Collections.singletonList(new ChangeResponse(change1.getId(), CloudChangeAction.APPLY))))
184184
);
@@ -208,7 +208,7 @@ void shouldIncludeAuditMarksInExecutionRequest() {
208208
CloudExecutionPlanner planner = buildPlanner(Arrays.asList(marker1, marker2));
209209

210210
ExecutionPlanResponse response = new ExecutionPlanResponse(
211-
CloudExecutionAction.CONTINUE, "exec-1", null,
211+
CloudExecutionAction.CONTINUE, 1L, null,
212212
Collections.singletonList(new StageResponse("stage-1", 0, Arrays.asList(
213213
new ChangeResponse(change1.getId(), CloudChangeAction.SKIP),
214214
new ChangeResponse(change2.getId(), CloudChangeAction.APPLY))))
@@ -238,7 +238,7 @@ void shouldSendNoneStatusWhenNoMarks() {
238238
CloudExecutionPlanner planner = buildPlanner(Collections.emptyList());
239239

240240
ExecutionPlanResponse response = new ExecutionPlanResponse(
241-
CloudExecutionAction.CONTINUE, "exec-1", null,
241+
CloudExecutionAction.CONTINUE, 1L, null,
242242
Collections.singletonList(new StageResponse("stage-1", 0,
243243
Collections.singletonList(new ChangeResponse(change1.getId(), CloudChangeAction.SKIP))))
244244
);
@@ -352,7 +352,7 @@ void shouldNotClearNewMarksWrittenAfterRequest() {
352352

353353
private ExecutionPlanResponse buildSyncResponse(CloudExecutionAction action, boolean synchronizedMarks) {
354354
ExecutionPlanResponse response = new ExecutionPlanResponse(
355-
action, "exec-1", null,
355+
action, 1L, null,
356356
Collections.singletonList(new StageResponse("stage-1", 0,
357357
Arrays.asList(
358358
new ChangeResponse(change1.getId(), CloudChangeAction.SKIP),
@@ -396,7 +396,7 @@ void continueWithPipelineResultWritesVerdict() {
396396
Collections.emptyList())
397397
));
398398
ExecutionPlanResponse response = new ExecutionPlanResponse(
399-
CloudExecutionAction.CONTINUE, "exec-1", null, Collections.emptyList(),
399+
CloudExecutionAction.CONTINUE, 1L, null, Collections.emptyList(),
400400
pipelineResult, false);
401401
when(client.createExecution(any(), any(), anyLong())).thenReturn(response);
402402

@@ -440,7 +440,7 @@ void executeWithPipelineResultUpgradesAlreadyAppliedRecords() {
440440
lockInfo.setAcquisitionId("acq-1");
441441
lockInfo.setAcquiredForMillis(60000L);
442442
ExecutionPlanResponse response = new ExecutionPlanResponse(
443-
CloudExecutionAction.EXECUTE, "exec-1", lockInfo,
443+
CloudExecutionAction.EXECUTE, 1L, lockInfo,
444444
Collections.singletonList(new StageResponse("stage-1", 0,
445445
Collections.singletonList(
446446
new ChangeResponse(change2.getId(), CloudChangeAction.APPLY)))),
@@ -477,7 +477,7 @@ void abortLeavesPipelineRunUntouched() {
477477
// ABORT carries no pipelineResult — validate() doesn't require it, and the planner
478478
// must not attempt to apply one (NPE-guard).
479479
ExecutionPlanResponse response = new ExecutionPlanResponse(
480-
CloudExecutionAction.ABORT, "exec-1", null,
480+
CloudExecutionAction.ABORT, 1L, null,
481481
Collections.singletonList(new StageResponse("stage-1", 0,
482482
Collections.singletonList(
483483
new ChangeResponse(change1.getId(), CloudChangeAction.APPLY))))

cloud/flamingock-cloud/src/test/java/io/flamingock/core/cloud/CloudAuditPersistenceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void afterEach() {
134134
@DisplayName("Should run successfully happy path")
135135
void happyPath() {
136136
//GIVEN
137-
String executionId = "execution-1";
137+
long executionId = 1L;
138138
mockRunnerServer
139139
.addSimpleStageExecutionPlan(executionId, "changes", auditEntryExpectations)
140140
.addExecutionWithAllChangesRequestResponse(executionId)
@@ -157,7 +157,7 @@ void shouldPerformRightCallsWhenAwaitExecuteContinue() {
157157
try (MockedConstruction<ThreadSleeper> lockThreadSleeperConstructors = Mockito.mockConstruction(ThreadSleeper.class)) {
158158

159159

160-
String executionId = "execution-1";
160+
long executionId = 1L;
161161
mockRunnerServer
162162
.addSimpleStageExecutionPlan(executionId, "changes", auditEntryExpectations)
163163
.addExecutionAwaitRequestResponse(executionId)
@@ -185,7 +185,7 @@ void shouldPerformRightCallsWhenAwaitExecuteContinue() {
185185
void shouldWaitAndEventuallyAbort() {
186186
///GIVEN
187187
String acquisitionId = UUID.randomUUID().toString();
188-
String executionId = "execution-1";
188+
long executionId = 1L;
189189
mockRunnerServer
190190
.addSimpleStageExecutionPlan(executionId, "changes", auditEntryExpectations)
191191
.addExecutionAwaitRequestResponse(executionId, 5000L, acquisitionId)
@@ -218,7 +218,7 @@ void shouldWaitAndEventuallyAbort() {
218218
@DisplayName("Should wait and retry when lock is initially blocked eventually released")
219219
void shouldWaitAndRetry() {
220220
//GIVEN
221-
String executionId = "execution-1";
221+
long executionId = 1L;
222222
String acquisitionId = UUID.randomUUID().toString();
223223
mockRunnerServer
224224
.addSimpleStageExecutionPlan(executionId, "changes", auditEntryExpectations)
@@ -243,7 +243,7 @@ void shouldWaitAndRetry() {
243243
@DisplayName("Should continue and not run anything if server returns CONTINUE at first")
244244
void shouldContinue() {
245245
mockRunnerServer
246-
.addSimpleStageExecutionPlan("execution-1", "changes", auditEntryExpectations)
246+
.addSimpleStageExecutionPlan(1L, "changes", auditEntryExpectations)
247247
.addExecutionContinueRequestResponse()
248248
.start();
249249

cloud/flamingock-cloud/src/test/java/io/flamingock/core/cloud/CloudTransactionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void afterEach() {
124124
@DisplayName("Should run successfully happy path")
125125
void happyPath() {
126126
//GIVEN
127-
String executionId = "execution-1";
127+
long executionId = 1L;
128128
mockRunnerServer
129129
.addSimpleStageExecutionPlan(executionId, "changes", auditEntries)
130130
.addExecutionWithAllChangesRequestResponse(executionId)

core/target-systems/flamingock-couchbase-targetsystem/src/test/java/io/flamingock/targetsystem/couchbase/CouchbaseTargetSystemTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void afterEach() throws Exception {
142142
@Test
143143
@DisplayName("Should follow the targetSystem lifecycle")
144144
void happyPath() {
145-
String executionId = "execution-1";
145+
long executionId = 1L;
146146
String stageName = "stage-1";
147147

148148
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(
@@ -191,7 +191,7 @@ void happyPath() {
191191
@Test
192192
@DisplayName("Should rollback the ongoing deletion when a change fails")
193193
void failedChanges() {
194-
String executionId = "execution-1";
194+
long executionId = 1L;
195195
String stageName = "stage-1";
196196

197197
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(
@@ -246,7 +246,7 @@ void failedChanges() {
246246
@Disabled("adapt when adding cloud support")
247247
@DisplayName("Should send ongoing change in execution when is present in local database")
248248
void shouldSendOngoingChangeInExecutionPlan() {
249-
String executionId = "execution-1";
249+
long executionId = 1L;
250250
String stageName = "stage-1";
251251

252252
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(

core/target-systems/flamingock-dynamodb-targetsystem/src/test/java/io/flamingock/targetsystem/dynamodb/DynamoDBCloudTargetSystemTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void afterEach() throws Exception {
122122
@Test
123123
@DisplayName("Should follow the transactioner lifecycle")
124124
void happyPath() {
125-
String executionId = "execution-1";
125+
long executionId = 1L;
126126
String stageName = "stage-1";
127127

128128
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(
@@ -178,7 +178,7 @@ void happyPath() {
178178
@Test
179179
@DisplayName("Should rollback the ongoing deletion when a change fails")
180180
void failedChanges() {
181-
String executionId = "execution-1";
181+
long executionId = 1L;
182182
String stageName = "stage-1";
183183

184184
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(
@@ -238,7 +238,7 @@ void failedChanges() {
238238
@Disabled("adapt when adding cloud support")
239239
@DisplayName("Should send ongoing change in execution when is present in local database")
240240
void shouldSendOngoingChangeInExecutionPlan() {
241-
String executionId = "execution-1";
241+
long executionId = 1L;
242242
String stageName = "stage-1";
243243

244244
PrototypeClientSubmission prototypeClientSubmission = new PrototypeClientSubmission(

0 commit comments

Comments
 (0)