@Override public Set<String> getAllActiveExecutorServerHosts() { // Includes non primary server/hosts HashSet<String> ports = new HashSet<String>(); ports.add(executorHost + ":" + executorPort); for(Pair<ExecutionReference, ExecutableFlow> running: runningFlows.values()) { ExecutionReference ref = running.getFirst(); ports.add(ref.getHost() + ":" + ref.getPort()); } return ports; }
private Map<ConnectionInfo, List<ExecutableFlow>> getFlowToExecutorMap() { HashMap<ConnectionInfo, List<ExecutableFlow>> exFlowMap = new HashMap<ConnectionInfo, List<ExecutableFlow>>(); ConnectionInfo lastPort = new ConnectionInfo(executorHost, executorPort); for (Pair<ExecutionReference, ExecutableFlow> runningFlow: runningFlows.values()) { ExecutionReference ref = runningFlow.getFirst(); ExecutableFlow flow = runningFlow.getSecond(); // We can set the next check time to prevent the checking of certain flows. if (ref.getNextCheckTime() >= System.currentTimeMillis()) { continue; } // Just a silly way to reduce object creation construction of objects since it's most likely that the values will be the same. if (!lastPort.isEqual(ref.getHost(), ref.getPort())) { lastPort = new ConnectionInfo(ref.getHost(), ref.getPort()); } List<ExecutableFlow> flows = exFlowMap.get(lastPort); if (flows == null) { flows = new ArrayList<ExecutableFlow>(); exFlowMap.put(lastPort, flows); } flows.add(flow); } return exFlowMap; }
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) throws ExecutorManagerException { try { return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), null, (Pair<String,String>[])null); } 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); } }
@Override public void addActiveExecutableReference(ExecutionReference reference) throws ExecutorManagerException { final String INSERT = "INSERT INTO active_executing_flows " + "(exec_id, host, port, update_time) values (?,?,?,?)"; QueryRunner runner = createQueryRunner(); try { runner.update( INSERT, reference.getExecId(), reference.getHost(), reference.getPort(), reference.getUpdateTime()); } catch (SQLException e) { throw new ExecutorManagerException( "Error updating active flow reference " + reference.getExecId(), e); } }