public Payload createPayload(Execution execution) { return createPayload(execution, false); }
private Execution extractExecution(ExecutionMessage executionMessage) { return executionMessageConverter.extractExecution(executionMessage.getPayload()); }
public Payload createPayload(Execution execution, boolean setContainsSensitiveData) { Payload payload = new Payload(objToBytes(execution)); if(setContainsSensitiveData || checkContainsSensitiveData(execution)) { setSensitive(payload); } return payload; }
private void addErrorMessage(ExecutionMessage message) { String group = message.getWorkerGroup(); Execution execution = converter.extractExecution(message.getPayload()); execution.getSystemContext().setNoWorkerInGroup(group); Payload payload = converter.createPayload(execution); message.setPayload(payload); }
public boolean containsSensitiveData(Payload payload) { return isSensitive(payload); }
public <T> T extractExecution(Payload payload) { return objFromBytes(payload.getData()); }
private byte[] objToBytes(Object obj){ ObjectOutputStream oos = null; try { ByteArrayOutputStream bout = new ByteArrayOutputStream(SIZE); initPayloadMetaData(bout); BufferedOutputStream bos = new BufferedOutputStream(bout); oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); return bout.toByteArray(); } catch(IOException ex) { throw new RuntimeException("Failed to serialize execution plan. Error: ", ex); } finally { IOUtils.closeQuietly(oos); } }
execution = converter.extractExecution(executionMessage.getPayload()); executionMessage.setPayload(converter.createPayload(execution)); //this is done since we could get here from InBuffer shortcut - so no payload... and for FAILED message we need to set the payload
public boolean containsSensitiveData(Payload payload) { return isSensitive(payload); }
public <T> T extractExecution(Payload payload) { return objFromBytes(payload.getData()); }
private byte[] objToBytes(Object obj){ ObjectOutputStream oos = null; try { ByteArrayOutputStream bout = new ByteArrayOutputStream(SIZE); initPayloadMetaData(bout); BufferedOutputStream bos = new BufferedOutputStream(bout); oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); return bout.toByteArray(); } catch(IOException ex) { throw new RuntimeException("Failed to serialize execution plan. Error: ", ex); } finally { IOUtils.closeQuietly(oos); } }
public Payload createPayload(Execution execution) { return createPayload(execution, false); }
@Override public SystemContext extractSystemContext(byte[] executionObjectSerialized) { Execution execution = executionMessageConverter.extractExecution(new Payload(executionObjectSerialized)); return execution.getSystemContext(); }
public Payload createPayload(Execution execution, boolean setContainsSensitiveData) { Payload payload = new Payload(objToBytes(execution)); if(setContainsSensitiveData || checkContainsSensitiveData(execution)) { setSensitive(payload); } return payload; }
@Override public ExecutionMessage convert(Execution execution) { return new ExecutionMessage(execution.getExecutionId().toString(), converter.createPayload(execution)); } };
@Override public SystemContext extractSystemContext(byte[] executionObjectSerialized) { Execution execution = executionMessageConverter.extractExecution(new Payload(executionObjectSerialized)); return execution.getSystemContext(); }
private ExecutionMessage createExecutionMessage(Execution execution) { Payload payload = executionMessageConverter.createPayload(execution); return new ExecutionMessage(ExecutionMessage.EMPTY_EXEC_STATE_ID, ExecutionMessage.EMPTY_WORKER, WorkerNode.DEFAULT_WORKER_GROUPS[0], String.valueOf(execution.getExecutionId()), ExecStatus.PENDING, //start new run also in PENDING payload, 0); } }
@Override public Long reTrigger(SystemContext newSystemContext, byte[] executionObj) { Execution execution = executionMessageConverter.extractExecution(new Payload(executionObj)); //We must refresh the system context with the new one in order to re-trigger execution.getSystemContext().clear(); execution.getSystemContext().putAll(newSystemContext); //generate new execution id Long newExecutionId = idGenerator.next(); execution.getSystemContext().setExecutionId(newExecutionId); execution.setExecutionId(newExecutionId); // create execution record in ExecutionSummary table executionStateService.createParentExecution(execution.getExecutionId()); // create execution message ExecutionMessage message = createExecutionMessage(execution); queueDispatcher.dispatch(Collections.singletonList(message)); return newExecutionId; }
@Override public ExecutionMessage convert(Execution execution) { return new ExecutionMessage(execution.getExecutionId().toString(), converter.createPayload(execution)); } };
@Override public Long reTrigger(SystemContext newSystemContext, byte[] executionObj) { Execution execution = executionMessageConverter.extractExecution(new Payload(executionObj)); //We must refresh the system context with the new one in order to re-trigger execution.getSystemContext().clear(); execution.getSystemContext().putAll(newSystemContext); //generate new execution id Long newExecutionId = idGenerator.next(); execution.getSystemContext().setExecutionId(newExecutionId); execution.setExecutionId(newExecutionId); // create execution record in ExecutionSummary table executionStateService.createParentExecution(execution.getExecutionId()); // create execution message ExecutionMessage message = createExecutionMessage(execution); queueDispatcher.dispatch(Collections.singletonList(message)); return newExecutionId; }