Skip to content

Commit f7eabe4

Browse files
DHFPROD-2501: If 'uris'is null and job is stopped return the response immediately (#2481)
* If 'uris' is null and job is stopped return the response immediately * 'stepStatus' contains the prefixes not the other way around
1 parent 2a76450 commit f7eabe4

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/step/impl/QueryStepRunner.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,26 @@ private RunStepResponse runHarmonizer(RunStepResponse runStepResponse, Collectio
309309
listener.onStatusChange(runStepResponse.getJobId(), 0, JobStatus.RUNNING_PREFIX + step, 0,0, "starting step execution");
310310
});
311311

312-
if ( !isStopped.get() && (uris == null || uris.size() == 0 )) {
312+
if (uris == null || uris.size() == 0) {
313+
JsonNode jobDoc = null;
314+
final String stepStatus;
315+
if(isStopped.get()) {
316+
stepStatus = JobStatus.CANCELED_PREFIX + step;
317+
}
318+
else {
319+
stepStatus = JobStatus.COMPLETED_PREFIX + step;
320+
}
321+
313322
stepStatusListeners.forEach((StepStatusListener listener) -> {
314-
listener.onStatusChange(runStepResponse.getJobId(), 100, JobStatus.COMPLETED_PREFIX + step, 0, 0, "collector returned 0 items");
323+
listener.onStatusChange(runStepResponse.getJobId(), 100, stepStatus, 0, 0,
324+
(stepStatus.contains(JobStatus.COMPLETED_PREFIX) ? "collector returned 0 items" : "job was stopped"));
315325
});
316326
stepFinishedListeners.forEach((StepFinishedListener::onStepFinished));
317327
runStepResponse.setCounts(0,0,0,0,0);
318-
runStepResponse.withStatus(JobStatus.COMPLETED_PREFIX + step);
319-
JsonNode jobDoc = null;
328+
runStepResponse.withStatus(stepStatus);
329+
320330
try {
321-
jobDoc = jobDocManager.postJobs(jobId, JobStatus.COMPLETED_PREFIX + step, step, step, runStepResponse);
331+
jobDoc = jobDocManager.postJobs(jobId, stepStatus, step, stepStatus.contains(JobStatus.COMPLETED_PREFIX) ? step : null, runStepResponse);
322332
}
323333
catch (Exception e) {
324334
throw e;

marklogic-data-hub/src/main/java/com/marklogic/hub/step/impl/WriteStepRunner.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,16 +396,27 @@ private RunStepResponse runIngester(RunStepResponse runStepResponse, Collection<
396396
stepStatusListeners.forEach((StepStatusListener listener) -> {
397397
listener.onStatusChange(runStepResponse.getJobId(), 0, JobStatus.RUNNING_PREFIX + step, 0, 0, "starting step execution");
398398
});
399-
if ( !isStopped.get() && (uris == null || uris.size() == 0 )) {
399+
400+
if (uris == null || uris.size() == 0 ) {
401+
JsonNode jobDoc = null;
402+
final String stepStatus;
403+
if(isStopped.get()) {
404+
stepStatus = JobStatus.CANCELED_PREFIX + step;
405+
}
406+
else {
407+
stepStatus = JobStatus.COMPLETED_PREFIX + step;
408+
}
409+
400410
stepStatusListeners.forEach((StepStatusListener listener) -> {
401-
listener.onStatusChange(runStepResponse.getJobId(), 100, JobStatus.COMPLETED_PREFIX + step, 0, 0, "provided file path returned 0 items");
411+
listener.onStatusChange(runStepResponse.getJobId(), 100, stepStatus, 0, 0,
412+
(stepStatus.contains(JobStatus.COMPLETED_PREFIX) ? "provided file path returned 0 items" : "job was stopped"));
402413
});
403414
stepFinishedListeners.forEach((StepFinishedListener::onStepFinished));
404415
runStepResponse.setCounts(0,0,0,0,0);
405-
runStepResponse.withStatus(JobStatus.COMPLETED_PREFIX + step);
406-
JsonNode jobDoc;
416+
runStepResponse.withStatus(stepStatus);
417+
407418
try {
408-
jobDoc = jobDocManager.postJobs(jobId, JobStatus.COMPLETED_PREFIX + step, step, step, runStepResponse);
419+
jobDoc = jobDocManager.postJobs(jobId, stepStatus, step, stepStatus.contains(JobStatus.COMPLETED_PREFIX) ? step : null, runStepResponse);
409420
}
410421
catch (Exception e) {
411422
throw e;

0 commit comments

Comments
 (0)