Hisoka-X commented on code in PR #2413:
URL:
https://github.com/apache/incubator-seatunnel/pull/2413#discussion_r949764046
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/operation/DeployTaskOperation.java:
##########
@@ -40,9 +40,9 @@ public DeployTaskOperation(@NonNull Data
taskImmutableInformation) {
}
@Override
- protected NonCompletableFuture<?> doRun() throws Exception {
- SeaTunnelServer server = getService();
- return
server.getTaskExecutionService().deployTask(taskImmutableInformation);
+ protected PassiveCompletableFuture<?> doRun() throws Exception {
+ TaskExecutionService taskExecutionService = getService();
Review Comment:
Does `TaskExecutionService` is an hazelcast service? Can use `getService()`
to get it?
##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/JobProxy.java:
##########
@@ -47,10 +51,37 @@ public long getJobId() {
@Override
public void submitJob() throws ExecutionException, InterruptedException {
- ClientMessage request = SeaTunnelSubmitJobCodec.encodeRequest(
+ ClientMessage request =
SeaTunnelSubmitJobCodec.encodeRequest(jobImmutableInformation.getJobId(),
seaTunnelHazelcastClient.getSerializationService().toData(jobImmutableInformation));
- NonCompletableFuture<Void> submitJobFuture =
+ PassiveCompletableFuture<Void> submitJobFuture =
seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(request);
submitJobFuture.get();
}
+
+ @Override
+ public void waitForJobComplete() {
+ PassiveCompletableFuture<JobStatus> jobFuture =
+ seaTunnelHazelcastClient.requestOnMasterAndGetCompletableFuture(
+
SeaTunnelWaitForJobCompleteCodec.encodeRequest(jobImmutableInformation.getJobId()),
+ response -> {
+ return
JobStatus.values()[SeaTunnelWaitForJobCompleteCodec.decodeResponse(response)];
+ });
+
+ jobFuture.whenComplete((v, t) -> {
Review Comment:
Did we can't show log in client at now?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
/**
* call by client to submit job
*/
- @SuppressWarnings("checkstyle:MagicNumber")
- public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+ public PassiveCompletableFuture<Void> submitJob(long jobId, Data
jobImmutableInformation) {
CompletableFuture<Void> voidCompletableFuture = new
CompletableFuture<>();
JobMaster jobMaster = new JobMaster(jobImmutableInformation,
this.nodeEngine, executorService);
executorService.submit(() -> {
try {
jobMaster.init();
- jobMaster.run();
+ runningJobMasterMap.put(jobId, jobMaster);
} catch (Throwable e) {
- LOGGER.severe("submit job error: " + e.getMessage());
+ LOGGER.severe(String.format("submit job %s error %s ", jobId,
ExceptionUtils.getMessage(e)));
voidCompletableFuture.completeExceptionally(e);
} finally {
// We specify that when init is complete, the submitJob is
complete
voidCompletableFuture.complete(null);
}
- //jobMaster.run();
+
+ try {
+ jobMaster.run();
+ } finally {
+ runningJobMasterMap.remove(jobId);
+ }
});
- return new NonCompletableFuture<>(voidCompletableFuture);
+ return new PassiveCompletableFuture(voidCompletableFuture);
+ }
+
+ public PassiveCompletableFuture<JobStatus> waitForJobComplete(long jobId) {
+ JobMaster runningJobMaster = runningJobMasterMap.get(jobId);
+ if (runningJobMaster == null) {
Review Comment:
If `runningJobMaster` failed, but `runningJobMasterMap.remove(jobId)`
already executed. The job status will be FINISHED not FAILED. This is a mistake.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServer.java:
##########
@@ -116,23 +122,39 @@ public LiveOperationRegistry getLiveOperationRegistry() {
/**
* call by client to submit job
*/
- @SuppressWarnings("checkstyle:MagicNumber")
- public NonCompletableFuture<Void> submitJob(Data jobImmutableInformation) {
+ public PassiveCompletableFuture<Void> submitJob(long jobId, Data
jobImmutableInformation) {
CompletableFuture<Void> voidCompletableFuture = new
CompletableFuture<>();
JobMaster jobMaster = new JobMaster(jobImmutableInformation,
this.nodeEngine, executorService);
executorService.submit(() -> {
try {
jobMaster.init();
- jobMaster.run();
+ runningJobMasterMap.put(jobId, jobMaster);
} catch (Throwable e) {
- LOGGER.severe("submit job error: " + e.getMessage());
+ LOGGER.severe(String.format("submit job %s error %s ", jobId,
ExceptionUtils.getMessage(e)));
voidCompletableFuture.completeExceptionally(e);
} finally {
// We specify that when init is complete, the submitJob is
complete
voidCompletableFuture.complete(null);
}
- //jobMaster.run();
+
+ try {
+ jobMaster.run();
Review Comment:
If `jobMaster.run()` throw an exception, how handle it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]