Search in sources :

Example 1 with Lists

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();
}
Also used : JobId(io.mantisrx.server.master.domain.JobId) Terminated(akka.actor.Terminated) Optional.of(java.util.Optional.of) MantisJobStore(io.mantisrx.server.master.persistence.MantisJobStore) Action1(rx.functions.Action1) TriggerOperator(com.netflix.fenzo.triggers.TriggerOperator) GetLastSubmittedJobIdStreamResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLastSubmittedJobIdStreamResponse) JobActor(io.mantisrx.master.jobcluster.job.JobActor) ListArchivedWorkersRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListArchivedWorkersRequest) ActorRef(akka.actor.ActorRef) UpdateJobClusterLabelsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterLabelsResponse) UpdateJobClusterArtifactResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterArtifactResponse) Duration(java.time.Duration) Map(java.util.Map) CronPolicy(io.mantisrx.server.master.domain.IJobClusterDefinition.CronPolicy) Schedulers(rx.schedulers.Schedulers) Metrics(io.mantisrx.common.metrics.Metrics) Preconditions(com.netflix.spectator.impl.Preconditions) DisableJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterResponse) ListCompletedJobsInClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListCompletedJobsInClusterResponse) JobDefinition(io.mantisrx.server.master.domain.JobDefinition) Set(java.util.Set) ListCompletedJobsInClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListCompletedJobsInClusterRequest) ScaleStageRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ScaleStageRequest) JobStartedEvent(io.mantisrx.master.jobcluster.proto.JobClusterProto.JobStartedEvent) SubmitJobRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobRequest) CompletionStage(java.util.concurrent.CompletionStage) UpdateJobClusterWorkerMigrationStrategyRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyRequest) TriggerNotFoundException(com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException) JobHelper(io.mantisrx.master.jobcluster.job.JobHelper) ListJobIdsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsRequest) BehaviorSubject(rx.subjects.BehaviorSubject) ListWorkersRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListWorkersRequest) GetJobDefinitionUpdatedFromJobActorRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDefinitionUpdatedFromJobActorRequest) Optional.empty(java.util.Optional.empty) SERVER_ERROR(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.SERVER_ERROR) CronTrigger(com.netflix.fenzo.triggers.CronTrigger) MetricsRegistry(io.mantisrx.common.metrics.MetricsRegistry) JobConstraints(io.mantisrx.runtime.JobConstraints) LabelUtils(com.mantisrx.common.utils.LabelUtils) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ListJobIdsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobIdsResponse) SupervisorStrategy(akka.actor.SupervisorStrategy) JobClusterDefinitionImpl(io.mantisrx.server.master.domain.JobClusterDefinitionImpl) WorkerEvent(io.mantisrx.server.master.scheduler.WorkerEvent) GetLastSubmittedJobIdStreamRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLastSubmittedJobIdStreamRequest) Label(io.mantisrx.common.Label) EnableJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.EnableJobClusterRequest) GetJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterRequest) UpdateJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterRequest) MANTIS_MASTER_USER(io.mantisrx.master.StringConstants.MANTIS_MASTER_USER) CLIENT_ERROR_NOT_FOUND(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.CLIENT_ERROR_NOT_FOUND) UpdateJobClusterWorkerMigrationStrategyResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterWorkerMigrationStrategyResponse) CompletedJob(io.mantisrx.server.master.domain.JobClusterDefinitionImpl.CompletedJob) IMantisJobMetadata(io.mantisrx.master.jobcluster.job.IMantisJobMetadata) KillJobResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.KillJobResponse) SchedulerException(com.netflix.fenzo.triggers.exceptions.SchedulerException) IMantisWorkerMetadata(io.mantisrx.master.jobcluster.job.worker.IMantisWorkerMetadata) ListJobsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobsResponse) EnableJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.EnableJobClusterResponse) IJobClusterDefinition(io.mantisrx.server.master.domain.IJobClusterDefinition) JobState(io.mantisrx.master.jobcluster.job.JobState) GetJobSchedInfoRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobSchedInfoRequest) LoggerFactory(org.slf4j.LoggerFactory) GaugeCallback(io.mantisrx.common.metrics.spectator.GaugeCallback) StageSchedulingInfo(io.mantisrx.runtime.descriptor.StageSchedulingInfo) JobCompletedReason(io.mantisrx.server.core.JobCompletedReason) InvalidJobRequest(io.mantisrx.server.master.InvalidJobRequest) MantisScheduler(io.mantisrx.server.master.scheduler.MantisScheduler) ListJobsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobsRequest) CLIENT_ERROR(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.CLIENT_ERROR) GetJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobClusterResponse) JobClusterProto(io.mantisrx.master.jobcluster.proto.JobClusterProto) GetLatestJobDiscoveryInfoResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLatestJobDiscoveryInfoResponse) GetJobDetailsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsResponse) BasicTag(com.netflix.spectator.api.BasicTag) JobProto(io.mantisrx.master.jobcluster.proto.JobProto) ResubmitWorkerResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ResubmitWorkerResponse) ConstraintsEvaluators(io.mantisrx.server.master.ConstraintsEvaluators) DisableJobClusterRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DisableJobClusterRequest) ResubmitWorkerRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ResubmitWorkerRequest) GetJobDefinitionUpdatedFromJobActorResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDefinitionUpdatedFromJobActorResponse) UpdateJobClusterLabelsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterLabelsRequest) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SLA(io.mantisrx.server.master.domain.SLA) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) GetJobSchedInfoResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobSchedInfoResponse) Objects(java.util.Objects) List(java.util.List) PatternsCS.ask(akka.pattern.PatternsCS.ask) GetJobDetailsRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetJobDetailsRequest) SubmitJobResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.SubmitJobResponse) ConfigurationProvider(io.mantisrx.server.master.config.ConfigurationProvider) Optional(java.util.Optional) Props(akka.actor.Props) UpdateJobClusterSLARequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLARequest) MantisJobMetadataView(io.mantisrx.master.jobcluster.job.MantisJobMetadataView) ScaleStageResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ScaleStageResponse) UpdateJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterResponse) JobIdInfo(io.mantisrx.master.api.akka.route.proto.JobClusterProtoAdapter.JobIdInfo) KillJobRequest(io.mantisrx.master.jobcluster.proto.JobClusterProto.KillJobRequest) ListArchivedWorkersResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListArchivedWorkersResponse) MantisJobMetadataImpl(io.mantisrx.master.jobcluster.job.MantisJobMetadataImpl) JobSla(io.mantisrx.runtime.JobSla) HashMap(java.util.HashMap) UpdateJobClusterSLAResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterSLAResponse) MantisActorSupervisorStrategy(io.mantisrx.master.akka.MantisActorSupervisorStrategy) ConcurrentMap(java.util.concurrent.ConcurrentMap) Observable(rx.Observable) HashSet(java.util.HashSet) LifecycleEventsProto(io.mantisrx.master.events.LifecycleEventsProto) DeleteJobClusterResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.DeleteJobClusterResponse) ListWorkersResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListWorkersResponse) AbstractActorWithTimers(akka.actor.AbstractActorWithTimers) JobClusterAlreadyExistsException(io.mantisrx.server.master.persistence.exceptions.JobClusterAlreadyExistsException) Counter(io.mantisrx.common.metrics.Counter) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Optional.ofNullable(java.util.Optional.ofNullable) ListJobCriteria(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobCriteria) GetLatestJobDiscoveryInfoRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.GetLatestJobDiscoveryInfoRequest) JobClusterConfig(io.mantisrx.server.master.domain.JobClusterConfig) SUCCESS(io.mantisrx.master.jobcluster.proto.BaseResponse.ResponseCode.SUCCESS) JobClusterManagerProto(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto) Lists(io.mantisrx.shaded.com.google.common.collect.Lists) UpdateJobClusterArtifactRequest(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.UpdateJobClusterArtifactRequest) Collections(java.util.Collections) LifecycleEventPublisher(io.mantisrx.master.events.LifecycleEventPublisher) JobClustersManagerInitializeResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.JobClustersManagerInitializeResponse) MetricGroupId(io.mantisrx.common.metrics.spectator.MetricGroupId) ActorRef(akka.actor.ActorRef) ArrayList(java.util.ArrayList) ListJobsResponse(io.mantisrx.master.jobcluster.proto.JobClusterManagerProto.ListJobsResponse) ArrayList(java.util.ArrayList) List(java.util.List) JobId(io.mantisrx.server.master.domain.JobId) HashSet(java.util.HashSet)

Aggregations

AbstractActorWithTimers (akka.actor.AbstractActorWithTimers)1 ActorRef (akka.actor.ActorRef)1 Props (akka.actor.Props)1 SupervisorStrategy (akka.actor.SupervisorStrategy)1 Terminated (akka.actor.Terminated)1 PatternsCS.ask (akka.pattern.PatternsCS.ask)1 LabelUtils (com.mantisrx.common.utils.LabelUtils)1 CronTrigger (com.netflix.fenzo.triggers.CronTrigger)1 TriggerOperator (com.netflix.fenzo.triggers.TriggerOperator)1 SchedulerException (com.netflix.fenzo.triggers.exceptions.SchedulerException)1 TriggerNotFoundException (com.netflix.fenzo.triggers.exceptions.TriggerNotFoundException)1 BasicTag (com.netflix.spectator.api.BasicTag)1 Preconditions (com.netflix.spectator.impl.Preconditions)1 Label (io.mantisrx.common.Label)1 Counter (io.mantisrx.common.metrics.Counter)1 Metrics (io.mantisrx.common.metrics.Metrics)1 MetricsRegistry (io.mantisrx.common.metrics.MetricsRegistry)1 GaugeCallback (io.mantisrx.common.metrics.spectator.GaugeCallback)1 MetricGroupId (io.mantisrx.common.metrics.spectator.MetricGroupId)1 MANTIS_MASTER_USER (io.mantisrx.master.StringConstants.MANTIS_MASTER_USER)1