@Test public void testListJobRequestDefaults() { JobClusterManagerProto.ListJobsRequest listJobsRequest2 = JobRouteUtils.createListJobsRequest(new HashMap<>(), Optional.empty(), true); assertEquals(false, listJobsRequest2.getCriteria().getLimit().isPresent()); assertEquals(false, listJobsRequest2.getCriteria().getJobState().isPresent()); assertEquals(0, listJobsRequest2.getCriteria().getStageNumberList().size()); assertEquals(0, listJobsRequest2.getCriteria().getWorkerIndexList().size()); assertEquals(0, listJobsRequest2.getCriteria().getWorkerNumberList().size()); assertEquals(0, listJobsRequest2.getCriteria().getWorkerStateList().size()); assertEquals(true, listJobsRequest2.getCriteria().getActiveOnly().get()); assertEquals(0, listJobsRequest2.getCriteria().getMatchingLabels().size()); assertEquals(false, listJobsRequest2.getCriteria().getLabelsOperand().isPresent()); assertEquals(false, listJobsRequest2.getCriteria().getMatchingRegex().isPresent()); }
public static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params, final Optional<String> regex, final boolean activeOnlyDefault) { if(params == null) { if (regex.isPresent()) { return new JobClusterManagerProto.ListJobsRequest(regex.get()); } else { return new JobClusterManagerProto.ListJobsRequest(); } } final Optional<Integer> limit = paramValueAsInt(params, QUERY_PARAM_LIMIT); final Optional<JobState.MetaState> jobState = paramValue(params, QUERY_PARAM_JOB_STATE).map(p -> JobState.MetaState.valueOf(p)); final List<Integer> stageNumber = paramValuesAsInt(params, QUERY_PARAM_STAGE_NUM); final List<Integer> workerIndex = paramValuesAsInt(params, QUERY_PARAM_WORKER_INDEX); final List<Integer> workerNumber = paramValuesAsInt(params, QUERY_PARAM_WORKER_NUM); final List<WorkerState.MetaState> workerState = paramValuesAsMetaState(params, QUERY_PARAM_WORKER_STATE); final Optional<Boolean> activeOnly = Optional.of(paramValueAsBool(params, QUERY_PARAM_ACTIVE_ONLY).orElse(activeOnlyDefault)); final Optional<String> labelsQuery = paramValue(params, QUERY_PARAM_LABELS_QUERY); final Optional<String> labelsOperand = paramValue(params, QUERY_PARAM_LABELS_OPERAND); return new JobClusterManagerProto.ListJobsRequest(new JobClusterManagerProto.ListJobCriteria(limit, jobState, stageNumber, workerIndex, workerNumber, workerState, activeOnly, regex, labelsQuery, labelsOperand)); }
JobRouteUtils { public static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params, final Optional<String> regex, final boolean activeOnlyDefault) { if(params == null) { if (regex.isPresent()) { return new JobClusterManagerProto.ListJobsRequest(regex.get()); } else { return new JobClusterManagerProto.ListJobsRequest(); } } final Optional<Integer> limit = paramValueAsInt(params, QUERY_PARAM_LIMIT); final Optional<JobState.MetaState> jobState = paramValue(params, QUERY_PARAM_JOB_STATE).map(p -> JobState.MetaState.valueOf(p)); final List<Integer> stageNumber = paramValuesAsInt(params, QUERY_PARAM_STAGE_NUM); final List<Integer> workerIndex = paramValuesAsInt(params, QUERY_PARAM_WORKER_INDEX); final List<Integer> workerNumber = paramValuesAsInt(params, QUERY_PARAM_WORKER_NUM); final List<WorkerState.MetaState> workerState = paramValuesAsMetaState(params, QUERY_PARAM_WORKER_STATE); final Optional<Boolean> activeOnly = Optional.of(paramValueAsBool(params, QUERY_PARAM_ACTIVE_ONLY).orElse(activeOnlyDefault)); final Optional<String> labelsQuery = paramValue(params, QUERY_PARAM_LABELS_QUERY); final Optional<String> labelsOperand = paramValue(params, QUERY_PARAM_LABELS_OPERAND); return new JobClusterManagerProto.ListJobsRequest(new JobClusterManagerProto.ListJobCriteria(limit, jobState, stageNumber, workerIndex, workerNumber, workerState, activeOnly, regex, labelsQuery, labelsOperand)); } }
JobRouteUtils { public static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params, final Optional<String> regex, final boolean activeOnlyDefault) { if(params == null) { if (regex.isPresent()) { return new JobClusterManagerProto.ListJobsRequest(regex.get()); } else { return new JobClusterManagerProto.ListJobsRequest(); } } final Optional<Integer> limit = paramValueAsInt(params, QUERY_PARAM_LIMIT); final Optional<JobState.MetaState> jobState = paramValue(params, QUERY_PARAM_JOB_STATE).map(p -> JobState.MetaState.valueOf(p)); final List<Integer> stageNumber = paramValuesAsInt(params, QUERY_PARAM_STAGE_NUM); final List<Integer> workerIndex = paramValuesAsInt(params, QUERY_PARAM_WORKER_INDEX); final List<Integer> workerNumber = paramValuesAsInt(params, QUERY_PARAM_WORKER_NUM); final List<WorkerState.MetaState> workerState = paramValuesAsMetaState(params, QUERY_PARAM_WORKER_STATE); final Optional<Boolean> activeOnly = Optional.of(paramValueAsBool(params, QUERY_PARAM_ACTIVE_ONLY).orElse(activeOnlyDefault)); final Optional<String> labelsQuery = paramValue(params, QUERY_PARAM_LABELS_QUERY); final Optional<String> labelsOperand = paramValue(params, QUERY_PARAM_LABELS_OPERAND); return new JobClusterManagerProto.ListJobsRequest(new JobClusterManagerProto.ListJobCriteria(limit, jobState, stageNumber, workerIndex, workerNumber, workerState, activeOnly, regex, labelsQuery, labelsOperand)); }  }
JobRouteUtils { public static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params, final Optional<String> regex, final boolean activeOnlyDefault) { if(params == null) { if (regex.isPresent()) { return new JobClusterManagerProto.ListJobsRequest(regex.get()); } else { return new JobClusterManagerProto.ListJobsRequest(); } } final Optional<Integer> limit = paramValueAsInt(params, QUERY_PARAM_LIMIT); final Optional<JobState.MetaState> jobState = paramValue(params, QUERY_PARAM_JOB_STATE).map(p -> JobState.MetaState.valueOf(p)); final List<Integer> stageNumber = paramValuesAsInt(params, QUERY_PARAM_STAGE_NUM); final List<Integer> workerIndex = paramValuesAsInt(params, QUERY_PARAM_WORKER_INDEX); final List<Integer> workerNumber = paramValuesAsInt(params, QUERY_PARAM_WORKER_NUM); final List<WorkerState.MetaState> workerState = paramValuesAsMetaState(params, QUERY_PARAM_WORKER_STATE); final Optional<Boolean> activeOnly = Optional.of(paramValueAsBool(params, QUERY_PARAM_ACTIVE_ONLY).orElse(activeOnlyDefault)); final Optional<String> labelsQuery = paramValue(params, QUERY_PARAM_LABELS_QUERY); final Optional<String> labelsOperand = paramValue(params, QUERY_PARAM_LABELS_OPERAND); return new JobClusterManagerProto.ListJobsRequest(new JobClusterManagerProto.ListJobCriteria(limit, jobState, stageNumber, workerIndex, workerNumber, workerState, activeOnly, regex, labelsQuery, labelsOperand)); }  static WorkerEvent createWorkerStatusRequest(final PostJobStatusRequest req); static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params,
                                                                               final Optional<String> regex,
                                                                               final boolean activeOnlyDefault); static JobClusterManagerProto.ListJobIdsRequest createListJobIdsRequest(final Map<String, List<String>> params, final Optional<String> regex,
                                                                                   final boolean activeOnlyDefault); }
JobRouteUtils { public static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params, final Optional<String> regex, final boolean activeOnlyDefault) { if(params == null) { if (regex.isPresent()) { return new JobClusterManagerProto.ListJobsRequest(regex.get()); } else { return new JobClusterManagerProto.ListJobsRequest(); } } final Optional<Integer> limit = paramValueAsInt(params, QUERY_PARAM_LIMIT); final Optional<JobState.MetaState> jobState = paramValue(params, QUERY_PARAM_JOB_STATE).map(p -> JobState.MetaState.valueOf(p)); final List<Integer> stageNumber = paramValuesAsInt(params, QUERY_PARAM_STAGE_NUM); final List<Integer> workerIndex = paramValuesAsInt(params, QUERY_PARAM_WORKER_INDEX); final List<Integer> workerNumber = paramValuesAsInt(params, QUERY_PARAM_WORKER_NUM); final List<WorkerState.MetaState> workerState = paramValuesAsMetaState(params, QUERY_PARAM_WORKER_STATE); final Optional<Boolean> activeOnly = Optional.of(paramValueAsBool(params, QUERY_PARAM_ACTIVE_ONLY).orElse(activeOnlyDefault)); final Optional<String> labelsQuery = paramValue(params, QUERY_PARAM_LABELS_QUERY); final Optional<String> labelsOperand = paramValue(params, QUERY_PARAM_LABELS_OPERAND); return new JobClusterManagerProto.ListJobsRequest(new JobClusterManagerProto.ListJobCriteria(limit, jobState, stageNumber, workerIndex, workerNumber, workerState, activeOnly, regex, labelsQuery, labelsOperand)); }  static WorkerEvent createWorkerStatusRequest(final PostJobStatusRequest req); static JobClusterManagerProto.ListJobsRequest createListJobsRequest(final Map<String, List<String>> params,
                                                                               final Optional<String> regex,
                                                                               final boolean activeOnlyDefault); static JobClusterManagerProto.ListJobIdsRequest createListJobIdsRequest(final Map<String, List<String>> params, final Optional<String> regex,
                                                                                   final boolean activeOnlyDefault); static final String QUERY_PARAM_LIMIT; static final String QUERY_PARAM_JOB_STATE; static final String QUERY_PARAM_STAGE_NUM; static final String QUERY_PARAM_WORKER_INDEX; static final String QUERY_PARAM_WORKER_NUM; static final String QUERY_PARAM_WORKER_STATE; static final String QUERY_PARAM_ACTIVE_ONLY; static final String QUERY_PARAM_LABELS_QUERY; static final String QUERY_PARAM_LABELS_OPERAND; }