@Override public List<Executor> fetchActiveExecutors() throws ExecutorManagerException { final List<Executor> activeExecutors = new ArrayList<>(); for (final Executor executor : this.executors) { if (executor.isActive()) { activeExecutors.add(executor); } } return activeExecutors; }
@Test public void testExecutorActivation() throws Exception { final Executor executor = this.executorDao.addExecutor("localhost1", 12345); assertThat(executor.isActive()).isFalse(); executor.setActive(true); this.executorDao.updateExecutor(executor); final Executor fetchedExecutor = this.executorDao.fetchExecutor(executor.getId()); assertThat(fetchedExecutor.isActive()).isTrue(); } }
public void updateExecutor(final Executor executor) throws ExecutorManagerException { final String UPDATE = "UPDATE executors SET host=?, port=?, active=? where id=?"; try { final int rows = this.dbOperator.update(UPDATE, executor.getHost(), executor.getPort(), executor.isActive(), executor.getId()); if (rows == 0) { throw new ExecutorManagerException("No executor with id :" + executor.getId()); } } catch (final SQLException e) { throw new ExecutorManagerException("Error inactivating executor " + executor.getId(), e); } }
if (executor == null) { executor = this.executorLoader.addExecutor(executorHost, executorPort); } else if (!executor.isActive()) { executor.setActive(true); this.executorLoader.updateExecutor(executor);
public void updateExecutor(final Executor executor) throws ExecutorManagerException { final String UPDATE = "UPDATE executors SET host=?, port=?, active=? where id=?"; try { final int rows = this.dbOperator.update(UPDATE, executor.getHost(), executor.getPort(), executor.isActive(), executor.getId()); if (rows == 0) { throw new ExecutorManagerException("No executor with id :" + executor.getId()); } } catch (final SQLException e) { throw new ExecutorManagerException("Error inactivating executor " + executor.getId(), e); } }