flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request #4734: [FLINK-7652] [flip6] Port CurrentJobIdsHandler to ...
Date Tue, 10 Oct 2017 13:02:45 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4734#discussion_r143716493
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
---
    @@ -242,6 +248,86 @@ public void start() throws Exception {
     	}
     
     	@Override
    +	public CompletableFuture<JobStatusesWithIdsOverview> requestJobIdsOverview(@RpcTimeout
Time timeout) {
    +		final int numJobs = jobManagerRunners.size();
    +
    +		ArrayList<CompletableFuture<Tuple2<JobID, JobStatus>>> jobStatuses
= new ArrayList<>(numJobs);
    +		for (Map.Entry<JobID, JobManagerRunner> jobManagerRunnerEntry : jobManagerRunners.entrySet())
{
    +			CompletableFuture<JobStatus> jobStatusFuture =
    +				jobManagerRunnerEntry.getValue().getJobManagerGateway().requestJobStatus(timeout);
    +
    +			jobStatuses.add(jobStatusFuture.thenApply(jobStatus -> Tuple2.of(jobManagerRunnerEntry.getKey(),
jobStatus)));
    +		}
    +
    +		CompletableFuture<Collection<Tuple2<JobID, JobStatus>>> combinedJobStatusesFuture
= FutureUtils.combineAll(jobStatuses);
    +
    +		return combinedJobStatusesFuture.thenApply(
    +			jobStatusesWithIds -> {
    +				List<JobID> jobsCreated = new LinkedList<>();
    +				List<JobID> jobsRunning = new LinkedList<>();
    +				List<JobID> jobsFinished = new LinkedList<>();
    +				List<JobID> jobsCancelling = new LinkedList<>();
    +				List<JobID> jobsCancelled = new LinkedList<>();
    +				List<JobID> jobsFailing = new LinkedList<>();
    +				List<JobID> jobsFailed = new LinkedList<>();
    +				List<JobID> jobsRestarting = new LinkedList<>();
    +				List<JobID> jobsSuspended = new LinkedList<>();
    +				List<JobID> jobsReconciling = new LinkedList<>();
    --- End diff --
    
    Not entirely sure, but I think that `ArrayList` would be better here. Even though we will
most likely only add few elements per list, a linked list is probably a bit slower since `LinkedList`
uses some more complex internal data structures.


---

Mime
View raw message