@Test public void testGetRunningCount() { WorkerRegistryV2 workerRegistryV2 = new WorkerRegistryV2(); initRegistryWithWorkers(workerRegistryV2,"testGetRunningCount-1", 5); assertEquals(5, workerRegistryV2.getNumRunningWorkers()); }
@Override public int getNumRunningWorkers() { if(logger.isDebugEnabled()) { logger.debug("In getNumRunningWorkers"); } int cnt = jobToWorkerInfoMap.values().stream() .map(workerList -> workerList.stream() .filter(wm -> WorkerState.isRunningState(wm.getState())) .collect(Collectors.toList()) .size() ) .reduce(0,(a, b) -> a + b); if(logger.isDebugEnabled()) { logger.debug("Returning {} from getNumRunningWorkers", cnt); } return cnt; }
WorkerRegistryV2 implements WorkerRegistry, WorkerEventSubscriber { @Override public int getNumRunningWorkers() { if(logger.isDebugEnabled()) { logger.debug("In getNumRunningWorkers"); } int cnt = jobToWorkerInfoMap.values().stream() .map(workerList -> workerList.stream() .filter(wm -> WorkerState.isRunningState(wm.getState())) .collect(Collectors.toList()) .size() ) .reduce(0,(a, b) -> a + b); if(logger.isDebugEnabled()) { logger.debug("Returning {} from getNumRunningWorkers", cnt); } return cnt; } }
WorkerRegistryV2 implements WorkerRegistry, WorkerEventSubscriber { @Override public int getNumRunningWorkers() { if(logger.isDebugEnabled()) { logger.debug("In getNumRunningWorkers"); } int cnt = jobToWorkerInfoMap.values().stream() .map(workerList -> workerList.stream() .filter(wm -> WorkerState.isRunningState(wm.getState())) .collect(Collectors.toList()) .size() ) .reduce(0,(a, b) -> a + b); if(logger.isDebugEnabled()) { logger.debug("Returning {} from getNumRunningWorkers", cnt); } return cnt; } WorkerRegistryV2(); }
WorkerRegistryV2 implements WorkerRegistry, WorkerEventSubscriber { @Override public int getNumRunningWorkers() { if(logger.isDebugEnabled()) { logger.debug("In getNumRunningWorkers"); } int cnt = jobToWorkerInfoMap.values().stream() .map(workerList -> workerList.stream() .filter(wm -> WorkerState.isRunningState(wm.getState())) .collect(Collectors.toList()) .size() ) .reduce(0,(a, b) -> a + b); if(logger.isDebugEnabled()) { logger.debug("Returning {} from getNumRunningWorkers", cnt); } return cnt; } WorkerRegistryV2(); static Props props(); void clearState(); @Override int getNumRunningWorkers(); @Override Set<WorkerId> getAllRunningWorkers(); @Override Map<WorkerId, String> getAllRunningWorkerSlaveIdMappings(); @Override boolean isWorkerValid(WorkerId workerId); @Override Optional<Long> getAcceptedAt(WorkerId workerId); @Override void process(LifecycleEventsProto.WorkerListChangedEvent event); @Override void process(LifecycleEventsProto.JobStatusEvent statusEvent); }
WorkerRegistryV2 implements WorkerRegistry, WorkerEventSubscriber { @Override public int getNumRunningWorkers() { if(logger.isDebugEnabled()) { logger.debug("In getNumRunningWorkers"); } int cnt = jobToWorkerInfoMap.values().stream() .map(workerList -> workerList.stream() .filter(wm -> WorkerState.isRunningState(wm.getState())) .collect(Collectors.toList()) .size() ) .reduce(0,(a, b) -> a + b); if(logger.isDebugEnabled()) { logger.debug("Returning {} from getNumRunningWorkers", cnt); } return cnt; } WorkerRegistryV2(); static Props props(); void clearState(); @Override int getNumRunningWorkers(); @Override Set<WorkerId> getAllRunningWorkers(); @Override Map<WorkerId, String> getAllRunningWorkerSlaveIdMappings(); @Override boolean isWorkerValid(WorkerId workerId); @Override Optional<Long> getAcceptedAt(WorkerId workerId); @Override void process(LifecycleEventsProto.WorkerListChangedEvent event); @Override void process(LifecycleEventsProto.JobStatusEvent statusEvent); static final WorkerRegistryV2 INSTANCE; }