ferenc-csaky commented on code in PR #851:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/851#discussion_r1668491036
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java:
##########
@@ -263,14 +268,24 @@ protected SocketAddress
getSocketAddress(RestClusterClient<String> clusterClient
}
@Override
- public Collection<JobStatusMessage> listJobs(Configuration conf) throws
Exception {
+ public Optional<JobStatusMessage> getJobStatus(Configuration conf, JobID
jobId)
+ throws Exception {
try (var clusterClient = getClusterClient(conf)) {
return clusterClient
.sendRequest(
JobsOverviewHeaders.getInstance(),
EmptyMessageParameters.getInstance(),
EmptyRequestBody.getInstance())
- .thenApply(JobStatusUtils::toJobStatusMessage)
+ .thenApply(
+ mjd -> {
+ if (mjd.getJobs() == null) {
+ return Optional.<JobStatusMessage>empty();
+ }
+ return mjd.getJobs().stream()
+ .filter(jd ->
jd.getJobId().equals(jobId))
+ .findAny()
+
.map(JobStatusUtils::toJobStatusMessage);
+ })
Review Comment:
nit: Possibility of eliminate the null-check and do it in 1 command:
```java
.thenApply(
mjd ->
Optional.ofNullable(mjd.getJobs())
.orElse(Collections.emptyList())
.stream()
.filter(jd -> jd.getJobId().equals(jobId))
.findAny()
.map(JobStatusUtils::toJobStatusMessage))
```
--
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]