Search in sources :

Example 1 with JobIdInfo

use of io.mantisrx.master.api.akka.route.proto.JobClusterProtoAdapter.JobIdInfo in project mantis by Netflix.

the class JobClusterActor method onJobIdList.

@Override
public void onJobIdList(final ListJobIdsRequest request) {
    if (logger.isTraceEnabled()) {
        logger.trace("Entering JCA:onJobIdList");
    }
    final ActorRef sender = getSender();
    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 matching jobs for given labels exit
        if (jobIdsFilteredByLabelsSet.isEmpty()) {
            sender.tell(new ListJobIdsResponse(request.requestId, SUCCESS, "No JobIds match given Label criterion", new ArrayList<>()), sender);
            if (logger.isTraceEnabled()) {
                logger.trace("Exit JCA:onJobIdList");
            }
            return;
        }
    }
    // Found jobs matching labels or no labels criterion given.
    List<JobIdInfo> jobIdList;
    // Apply additional filtering to non terminal jobs
    jobIdList = getFilteredNonTerminalJobIdList(request.filters, jobIdsFilteredByLabelsSet);
    if (!request.getCriteria().getActiveOnly().orElse(true)) {
        jobIdList.addAll(getFilteredTerminalJobIdList(request.filters, jobIdsFilteredByLabelsSet));
    }
    sender.tell(new ListJobIdsResponse(request.requestId, SUCCESS, "", jobIdList), sender);
    if (logger.isTraceEnabled()) {
        logger.trace("Exit JCA:onJobIdList");
    }
}
Also used : JobIdInfo(io.mantisrx.master.api.akka.route.proto.JobClusterProtoAdapter.JobIdInfo) ActorRef(akka.actor.ActorRef) ArrayList(java.util.ArrayList) ListJobIdsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsResponse) JobId(io.mantisrx.server.master.domain.JobId) HashSet(java.util.HashSet)

Aggregations

ActorRef (akka.actor.ActorRef)1 JobIdInfo (io.mantisrx.master.api.akka.route.proto.JobClusterProtoAdapter.JobIdInfo)1 ListJobIdsResponse (io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsResponse)1 JobId (io.mantisrx.server.master.domain.JobId)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1