@Override public List<ExecutableFlow> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<ExecutableFlow> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data != null) { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); execFlows.add(exFlow); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
@Override public List<ExecutableFlow> handle( final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<ExecutableFlow> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data != null) { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); execFlows.add(exFlow); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
@Override public List<Pair<ExecutionReference, ExecutableFlow>> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<Pair<ExecutionReference, ExecutableFlow>> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data == null) { logger.error("Found a flow with empty data blob exec_id: " + id); } else { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); final ExecutionReference ref = new ExecutionReference(id); execFlows.add(new Pair<>(ref, exFlow)); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
private static Pair<ExecutionReference, ExecutableFlow> getExecutableFlowHelper( final ResultSet rs) throws SQLException { final int id = rs.getInt("exec_id"); final int encodingType = rs.getInt("enc_type"); final byte[] data = rs.getBytes("flow_data"); if (data == null) { logger.warn("Execution id " + id + " has flow_data = null. To clean up, update status to " + "FAILED manually, eg. " + "SET status = " + Status.FAILED.getNumVal() + " WHERE id = " + id); } else { final EncodingType encType = EncodingType.fromInteger(encodingType); final ExecutableFlow exFlow; try { exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } return getPairWithExecutorInfo(rs, exFlow); } return null; }
@Override public ExecutableFlow fetchExecutableFlow(final int execId) throws ExecutorManagerException { final ExecutableFlow flow = this.flows.get(execId); return ExecutableFlow.createExecutableFlowFromObject(flow.toObject()); }
@Override public void uploadExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { // Clone the flow node to mimick how it would be saved in DB. // If we would keep a handle to the original flow node, we would also see any changes made after // this method was called. We must only store a snapshot of the current state. // Also to avoid modifying statuses of the original job nodes in this.updateExecutableFlow() final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject(flow.toObject()); this.flows.put(flow.getExecutionId(), exFlow); this.flowUpdateCount++; }
@Test public void testExecutorFlowJson() throws Exception { final Flow flow = this.project.getFlow("jobe"); Assert.assertNotNull(flow); final ExecutableFlow exFlow = new ExecutableFlow(this.project, flow); final Object obj = exFlow.toObject(); final String exFlowJSON = JSONUtils.toJSON(obj); final Map<String, Object> flowObjMap = (Map<String, Object>) JSONUtils.parseJSONFromString(exFlowJSON); final ExecutableFlow parsedExFlow = ExecutableFlow.createExecutableFlowFromObject(flowObjMap); testEquals(exFlow, parsedExFlow); }
ExecutableFlow.createExecutableFlowFromObject(flowObjMap); testEquals(exFlow, parsedExFlow);
(Map<String, Object>) JSONUtils.parseJSONFromString(exFlowJSON); final ExecutableFlow copyFlow = ExecutableFlow.createExecutableFlowFromObject(flowObjMap);
@Override public List<ExecutableFlow> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<ExecutableFlow> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data != null) { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); execFlows.add(exFlow); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
@Override public List<ExecutableFlow> handle( final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<ExecutableFlow> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data != null) { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); execFlows.add(exFlow); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
private void handleAjaxSubmitFlow(HttpServletRequest req, HashMap<String, Object> respMap, int execid) { try{ String execFlowJson = getParam(req, ExecutorManagerAdapter.INFO_EXEC_FLOW_JSON); ExecutableFlow exflow = ExecutableFlow.createExecutableFlowFromObject(JSONUtils.parseJSONFromString(execFlowJson)); String user = getParam(req, ExecutorManagerAdapter.INFO_USER_ID); executorManager.submitExecutableFlow(exflow, user); respMap.put(ExecutorManagerAdapter.INFO_EXEC_ID, exflow.getExecutionId()); } catch (Exception e) { e.printStackTrace(); respMap.put(ExecutorManagerAdapter.INFO_ERROR, e); } }
@Override public List<Pair<ExecutionReference, ExecutableFlow>> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<Pair<ExecutionReference, ExecutableFlow>> execFlows = new ArrayList<>(); do { final int id = rs.getInt(1); final int encodingType = rs.getInt(2); final byte[] data = rs.getBytes(3); if (data == null) { logger.error("Found a flow with empty data blob exec_id: " + id); } else { final EncodingType encType = EncodingType.fromInteger(encodingType); try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); final ExecutionReference ref = new ExecutionReference(id); execFlows.add(new Pair<>(ref, exFlow)); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } } } while (rs.next()); return execFlows; } }
ExecutableFlow.createExecutableFlowFromObject(flowObj); execFlows.add(exFlow);
try { final ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); final Executor executor;
ExecutableFlow.createExecutableFlowFromObject(flowObj); ExecutionReference ref = new ExecutionReference(id, host, port); ref.setUpdateTime(updateTime);