void addActiveExecutableReference(final ExecutionReference reference) throws ExecutorManagerException { final String INSERT = "INSERT INTO active_executing_flows " + "(exec_id, update_time) values (?,?)"; try { this.dbOperator.update(INSERT, reference.getExecId(), reference.getUpdateTime()); } catch (final SQLException e) { throw new ExecutorManagerException( "Error updating active flow reference " + reference.getExecId(), e); } }
/** * Wraps BoundedQueue Take method to have a corresponding update in queuedFlowMap lookup table */ public Pair<ExecutionReference, ExecutableFlow> fetchHead() throws InterruptedException { final Pair<ExecutionReference, ExecutableFlow> pair = this.queuedFlowList.take(); if (pair != null && pair.getFirst() != null) { this.queuedFlowMap.remove(pair.getFirst().getExecId()); } return pair; }
/** * Empties queue by dequeuing all the elements */ public void clear() { for (final Pair<ExecutionReference, ExecutableFlow> pair : this.queuedFlowMap.values()) { dequeue(pair.getFirst().getExecId()); } } }
@Override public void addActiveExecutableReference(final ExecutionReference ref) throws ExecutorManagerException { this.refs.put(ref.getExecId(), ref); }
private List<Integer> getRunningFlowsHelper(final int projectId, final String flowId, final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) { final List<Integer> executionIds = new ArrayList<>(); for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) { if (ref.getSecond().getFlowId().equals(flowId) && ref.getSecond().getProjectId() == projectId) { executionIds.add(ref.getFirst().getExecId()); } } return executionIds; }
private List<Integer> getRunningFlowsHelper(final int projectId, final String flowId, final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) { final List<Integer> executionIds = new ArrayList<>(); for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) { if (ref.getSecond().getFlowId().equals(flowId) && ref.getSecond().getProjectId() == projectId) { executionIds.add(ref.getFirst().getExecId()); } } return executionIds; }
Map<String, Object> callWithReferenceByUser(final ExecutionReference ref, final String action, final String user, final Pair<String, String>... params) throws ExecutorManagerException { final Executor executor = ref.getExecutor().get(); return callWithExecutionId(executor.getHost(), executor.getPort(), action, ref.getExecId(), user, params); }
Map<String, Object> callWithReference(final ExecutionReference ref, final String action, final Pair<String, String>... params) throws ExecutorManagerException { final Executor executor = ref.getExecutor().get(); return callWithExecutionId(executor.getHost(), executor.getPort(), action, ref.getExecId(), null, params); }
@Test public void testDequeue() throws IOException, ExecutorManagerException { final QueuedExecutions queue = new QueuedExecutions(5); final List<Pair<ExecutionReference, ExecutableFlow>> dataList = getDummyData(); queue.enqueueAll(dataList); queue.dequeue(dataList.get(0).getFirst().getExecId()); Assert.assertEquals(queue.size(), 1); Assert.assertTrue(queue.getAllEntries().contains(dataList.get(1))); }
@Test public void testGetFlow() throws IOException, ExecutorManagerException, InterruptedException { final QueuedExecutions queue = new QueuedExecutions(2); final List<Pair<ExecutionReference, ExecutableFlow>> dataList = getDummyData(); queue.enqueueAll(dataList); for (final Pair<ExecutionReference, ExecutableFlow> pair : dataList) { Assert.assertEquals(pair.getSecond(), queue.getFlow(pair.getFirst().getExecId())); } }
@Test public void testGetReferences() throws IOException, ExecutorManagerException, InterruptedException { final QueuedExecutions queue = new QueuedExecutions(2); final List<Pair<ExecutionReference, ExecutableFlow>> dataList = getDummyData(); queue.enqueueAll(dataList); for (final Pair<ExecutionReference, ExecutableFlow> pair : dataList) { Assert.assertEquals(pair.getFirst(), queue.getReference(pair.getFirst().getExecId())); } } }
@Test public void testHasExecution() throws IOException, ExecutorManagerException, InterruptedException { final QueuedExecutions queue = new QueuedExecutions(2); final List<Pair<ExecutionReference, ExecutableFlow>> dataList = getDummyData(); queue.enqueueAll(dataList); for (final Pair<ExecutionReference, ExecutableFlow> pair : dataList) { Assert.assertTrue(queue.hasExecution(pair.getFirst().getExecId())); } Assert.assertFalse(queue.hasExecution(5)); Assert.assertFalse(queue.hasExecution(7)); Assert.assertFalse(queue.hasExecution(15)); }
/** * Wraps BoundedQueue Take method to have a corresponding update in queuedFlowMap lookup table */ public Pair<ExecutionReference, ExecutableFlow> fetchHead() throws InterruptedException { final Pair<ExecutionReference, ExecutableFlow> pair = this.queuedFlowList.take(); if (pair != null && pair.getFirst() != null) { this.queuedFlowMap.remove(pair.getFirst().getExecId()); } return pair; }
@Override public List<Integer> getRunningFlows(int projectId, String flowId) { ArrayList<Integer> executionIds = new ArrayList<Integer>(); for (Pair<ExecutionReference, ExecutableFlow> ref : runningFlows.values()) { if (ref.getSecond().getFlowId().equals(flowId) && ref.getSecond().getProjectId() == projectId) { executionIds.add(ref.getFirst().getExecId()); } } return executionIds; }
private List<Integer> getRunningFlowsHelper(final int projectId, final String flowId, final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) { final List<Integer> executionIds = new ArrayList<>(); for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) { if (ref.getSecond().getFlowId().equals(flowId) && ref.getSecond().getProjectId() == projectId) { executionIds.add(ref.getFirst().getExecId()); } } return executionIds; }
Map<String, Object> callWithReferenceByUser(final ExecutionReference ref, final String action, final String user, final Pair<String, String>... params) throws ExecutorManagerException { final Executor executor = ref.getExecutor().get(); return callWithExecutionId(executor.getHost(), executor.getPort(), action, ref.getExecId(), user, params); }
Map<String, Object> callWithReference(final ExecutionReference ref, final String action, final Pair<String, String>... params) throws ExecutorManagerException { final Executor executor = ref.getExecutor().get(); return callWithExecutionId(executor.getHost(), executor.getPort(), action, ref.getExecId(), null, params); }
private Map<String, Object> callExecutorServer(ExecutionReference ref, String action, Pair<String,String> ... params) throws ExecutorManagerException { try { return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), null, params); } catch (IOException e) { throw new ExecutorManagerException(e); } }
private Map<String, Object> callExecutorServer(ExecutionReference ref, String action, String user) throws ExecutorManagerException { try { return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), user, (Pair<String,String>[])null); } catch (IOException e) { throw new ExecutorManagerException(e); } }
private Map<String, Object> callExecutorServer(ExecutionReference ref, String action, String user, Pair<String,String> ... params) throws ExecutorManagerException { try { return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), user, params); } catch (IOException e) { throw new ExecutorManagerException(e); } }