This is an automated email from the ASF dual-hosted git repository.
wiener pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 793a362 updated flinkruntime jobstatus checks
new f65b27c Merge pull request #33 from mfaizanse/dev
793a362 is described below
commit 793a362366e0b4d425ed04c2b626091d7bdbf057
Author: Muhammad Faizan <[email protected]>
AuthorDate: Tue Mar 23 11:02:55 2021 +0100
updated flinkruntime jobstatus checks
---
.../streampipes/wrapper/flink/FlinkRuntime.java | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git
a/streampipes-wrapper-flink/src/main/java/org/apache/streampipes/wrapper/flink/FlinkRuntime.java
b/streampipes-wrapper-flink/src/main/java/org/apache/streampipes/wrapper/flink/FlinkRuntime.java
index c0ed59e..d806033 100644
---
a/streampipes-wrapper-flink/src/main/java/org/apache/streampipes/wrapper/flink/FlinkRuntime.java
+++
b/streampipes-wrapper-flink/src/main/java/org/apache/streampipes/wrapper/flink/FlinkRuntime.java
@@ -235,7 +235,8 @@ public abstract class FlinkRuntime<RP extends
RuntimeParams<B, I, RC>, B extends
Thread.sleep(1000);
Optional<JobStatusMessage> statusMessageOpt =
getJobStatus(bindingParams.getGraph().getElementId());
- if (statusMessageOpt.isPresent()) {
+ if (statusMessageOpt.isPresent()
+ &&
statusMessageOpt.get().getJobState().name().equals("RUNNING")) {
isDeployed = true;
}
@@ -262,7 +263,12 @@ public abstract class FlinkRuntime<RP extends
RuntimeParams<B, I, RC>, B extends
Optional<JobStatusMessage> jobStatusMessage =
getJobStatus(bindingParams.getGraph().getElementId());
if (jobStatusMessage.isPresent()) {
- restClient.cancel(jobStatusMessage.get().getJobId());
+ String jobStatusStr = jobStatusMessage.get().getJobState().name();
+ // Cancel the job if running
+ if (jobStatusStr.equals("RUNNING")) {
+ restClient.cancel(jobStatusMessage.get().getJobId());
+ }
+ // else ignore, because job is already discarded
} else {
throw new SpRuntimeException("Could not stop Flink Job");
}
@@ -296,9 +302,19 @@ public abstract class FlinkRuntime<RP extends
RuntimeParams<B, I, RC>, B extends
try {
RestClusterClient<String> restClient = getRestClient();
CompletableFuture<Collection<JobStatusMessage>> jobs =
restClient.listJobs();
+ Collection<JobStatusMessage> jobsFound = jobs.get();
+
+ // First, find a job with Running status
+ Optional<JobStatusMessage> job = jobsFound.stream()
+ .filter(j -> j.getJobName().equals(jobName) &&
j.getJobState().name().equals("RUNNING")).findFirst();
+ if (job.isPresent()) {
+ return job;
+ }
+
+ // Otherwise return job with any other status
return jobs.get()
.stream()
- .filter(j -> j.getJobName().equals(jobName) &&
j.getJobState().name().equals("RUNNING")).findFirst();
+ .filter(j -> j.getJobName().equals(jobName)).findFirst();
} catch (Exception e) {
e.printStackTrace();