@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++; }
private void mockResultWithData() throws Exception { final ExecutableFlow flow = TestUtils.createTestExecutableFlow("exectest1", "exec1"); final String json = JSONUtils.toJSON(flow.toObject()); final byte[] data = json.getBytes("UTF-8"); mockExecution(EncodingType.PLAIN.getNumVal(), data); }
private void updateExecutableFlow(final ExecutableFlow flow, final EncodingType encType) throws ExecutorManagerException { final String UPDATE_EXECUTABLE_FLOW_DATA = "UPDATE execution_flows " + "SET status=?,update_time=?,start_time=?,end_time=?,enc_type=?,flow_data=? " + "WHERE exec_id=?"; final String json = JSONUtils.toJSON(flow.toObject()); byte[] data = null; try { final byte[] stringData = json.getBytes("UTF-8"); data = stringData; // Todo kunkun-tang: use a common method to transform stringData to data. if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } } catch (final IOException e) { throw new ExecutorManagerException("Error encoding the execution flow."); } try { this.dbOperator.update(UPDATE_EXECUTABLE_FLOW_DATA, flow.getStatus() .getNumVal(), flow.getUpdateTime(), flow.getStartTime(), flow .getEndTime(), encType.getNumVal(), data, flow.getExecutionId()); } catch (final SQLException e) { throw new ExecutorManagerException("Error updating flow.", e); } }
@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); }
exFlow.setExecutionOptions(options); final Object obj = exFlow.toObject(); final String exFlowJSON = JSONUtils.toJSON(obj); final Map<String, Object> flowObjMap =
final Object obj = exFlow.toObject(); final String exFlowJSON = JSONUtils.toJSON(obj); final Map<String, Object> flowObjMap =
QueryRunner runner = new QueryRunner(); String json = JSONUtils.toJSON(flow.toObject()); byte[] data = null; try {
private void updateExecutableFlow(final ExecutableFlow flow, final EncodingType encType) throws ExecutorManagerException { final String UPDATE_EXECUTABLE_FLOW_DATA = "UPDATE execution_flows " + "SET status=?,update_time=?,start_time=?,end_time=?,enc_type=?,flow_data=? " + "WHERE exec_id=?"; final String json = JSONUtils.toJSON(flow.toObject()); byte[] data = null; try { final byte[] stringData = json.getBytes("UTF-8"); data = stringData; // Todo kunkun-tang: use a common method to transform stringData to data. if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } } catch (final IOException e) { throw new ExecutorManagerException("Error encoding the execution flow."); } try { this.dbOperator.update(UPDATE_EXECUTABLE_FLOW_DATA, flow.getStatus() .getNumVal(), flow.getUpdateTime(), flow.getStartTime(), flow .getEndTime(), encType.getNumVal(), data, flow.getExecutionId()); } catch (final SQLException e) { throw new ExecutorManagerException("Error updating flow.", e); } }