-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODSOURMAN-1195 Save job execution progress in batches (#908)
- Loading branch information
1 parent
e29f875
commit 92ee1c2
Showing
17 changed files
with
826 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...nager-server/src/main/java/org/folio/services/progress/BatchableJobExecutionProgress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.folio.services.progress; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.folio.dataimport.util.OkapiConnectionParams; | ||
import org.folio.rest.jaxrs.model.JobExecutionProgress; | ||
|
||
/** | ||
* Class that enforces the presence of tenant ID and Job execution ID. These values must be present for appropriate batch | ||
* processing. | ||
*/ | ||
public class BatchableJobExecutionProgress { | ||
private final JobExecutionProgress jobExecutionProgress; | ||
private final OkapiConnectionParams params; | ||
|
||
public BatchableJobExecutionProgress(OkapiConnectionParams params, JobExecutionProgress jobExecutionProgress) { | ||
if (params == null || StringUtils.isBlank(params.getTenantId())) { | ||
throw new IllegalArgumentException("Tenant ID must be set in Okapi connection parameters"); | ||
} | ||
if (jobExecutionProgress == null || StringUtils.isBlank(jobExecutionProgress.getJobExecutionId())) { | ||
throw new IllegalArgumentException("job execution id must be set on JobExecutionProgress object"); | ||
} | ||
this.params = params; | ||
this.jobExecutionProgress = jobExecutionProgress; | ||
} | ||
|
||
public JobExecutionProgress getJobExecutionProgress() { | ||
return jobExecutionProgress; | ||
} | ||
|
||
public OkapiConnectionParams getParams() { | ||
return params; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...-server/src/main/java/org/folio/services/progress/BatchableJobExecutionProgressCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.folio.services.progress; | ||
|
||
import io.vertx.core.buffer.Buffer; | ||
import io.vertx.core.eventbus.MessageCodec; | ||
|
||
/** | ||
* Codec that won't cause any serialization/deserialization. It should only be used locally, exception will be thrown if | ||
* message need to be sent over the wire for a clustered event bus. | ||
*/ | ||
public class BatchableJobExecutionProgressCodec implements MessageCodec<BatchableJobExecutionProgress, BatchableJobExecutionProgress> { | ||
@Override | ||
public void encodeToWire(Buffer buffer, BatchableJobExecutionProgress progress) { | ||
throw new UnsupportedOperationException(progress.toString()); | ||
} | ||
|
||
@Override | ||
public BatchableJobExecutionProgress decodeFromWire(int pos, Buffer buffer) { | ||
throw new UnsupportedOperationException(buffer.toString()); | ||
} | ||
|
||
@Override | ||
public BatchableJobExecutionProgress transform(BatchableJobExecutionProgress progress) { | ||
return progress; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return BatchableJobExecutionProgressCodec.class.getSimpleName(); | ||
} | ||
|
||
@Override | ||
public byte systemCodecID() { | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...rd-manager-server/src/main/java/org/folio/services/progress/JobExecutionProgressUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.folio.services.progress; | ||
|
||
import io.vertx.core.Vertx; | ||
import io.vertx.core.eventbus.DeliveryOptions; | ||
import io.vertx.core.eventbus.MessageProducer; | ||
|
||
public class JobExecutionProgressUtil { | ||
|
||
public static final String BATCH_JOB_PROGRESS_ADDRESS = "batchJobProgress"; | ||
|
||
private JobExecutionProgressUtil() {} | ||
|
||
/** | ||
* Creates a message producer that will enqueue {@link BatchableJobExecutionProgress} objects | ||
* to be processed asynchronously. Messages are only processed locally. | ||
*/ | ||
public static MessageProducer<BatchableJobExecutionProgress> getBatchJobProgressProducer(Vertx vertx) { | ||
return vertx.eventBus().sender(BATCH_JOB_PROGRESS_ADDRESS, new DeliveryOptions() | ||
.setCodecName(BatchableJobExecutionProgressCodec.class.getSimpleName()) | ||
.setLocalOnly(true)); | ||
} | ||
|
||
/** | ||
* Register needed message codecs for job execution progress processing | ||
*/ | ||
public static void registerCodecs(Vertx vertx) { | ||
vertx.eventBus().registerCodec(new BatchableJobExecutionProgressCodec()); | ||
} | ||
|
||
} |
Oops, something went wrong.