use of io.mantisrx.shaded.com.google.common.collect.Lists in project mantis by Netflix.
the class JobClusterActor method onJobList.
@Override
public void onJobList(final ListJobsRequest request) {
if (logger.isDebugEnabled()) {
logger.info("Entering JCA:onJobList");
}
final ActorRef sender = getSender();
final ActorRef self = getSelf();
Set<JobId> jobIdsFilteredByLabelsSet = new HashSet<>();
// If labels criterion is given prefilter by labels
if (!request.getCriteria().getMatchingLabels().isEmpty()) {
jobIdsFilteredByLabelsSet = jobManager.getJobsMatchingLabels(request.getCriteria().getMatchingLabels(), request.getCriteria().getLabelsOperand());
// Found no jobs matching labels exit
if (jobIdsFilteredByLabelsSet.isEmpty()) {
if (logger.isTraceEnabled()) {
logger.trace("Exit JCA:onJobList {}", jobIdsFilteredByLabelsSet.size());
}
sender.tell(new ListJobsResponse(request.requestId, SUCCESS, "", new ArrayList<>()), self);
return;
}
}
// Found jobs matching labels or no labels criterion given.
// Apply additional criterion to both active and completed jobs
getFilteredNonTerminalJobList(request.getCriteria(), jobIdsFilteredByLabelsSet).mergeWith(getFilteredTerminalJobList(request.getCriteria(), jobIdsFilteredByLabelsSet)).collect(() -> Lists.<MantisJobMetadataView>newArrayList(), List::add).doOnNext(resultList -> {
if (logger.isTraceEnabled()) {
logger.trace("Exit JCA:onJobList {}", resultList.size());
}
sender.tell(new ListJobsResponse(request.requestId, SUCCESS, "", resultList), self);
}).subscribe();
}
Aggregations