@Override public String toString() { // Ensure that the key gets printed when containing objects are logged return toKey(); } }
@Override public PersistentEvent submit(WorkflowInstance workflowInstance, ExecutionDescription executionDescription, String executionId) { return new Submit(workflowInstance.toKey(), executionDescription, executionId); }
@Override public PersistentEvent halt(WorkflowInstance workflowInstance) { return new PersistentEvent("halt", workflowInstance.toKey()); } }
@Override public PersistentEvent triggerExecution(WorkflowInstance workflowInstance, Trigger trigger, TriggerParameters parameters) { return new TriggerExecution(workflowInstance.toKey(), Optional.of(trigger), Optional.of(parameters)); }
@Override public PersistentEvent info(WorkflowInstance workflowInstance, Message message) { return new Info(workflowInstance.toKey(), message); }
@Override public PersistentEvent dequeue(WorkflowInstance workflowInstance, Set<String> resourceIds) { return new Dequeue(workflowInstance.toKey(), Optional.of(resourceIds)); }
@Override public PersistentEvent submitted(WorkflowInstance workflowInstance, String executionId) { return new Submitted(workflowInstance.toKey(), executionId); }
@Override public PersistentEvent started(WorkflowInstance workflowInstance) { return new Started(workflowInstance.toKey()); }
@Override public PersistentEvent terminate(WorkflowInstance workflowInstance, Optional<Integer> exitCode) { return new Terminate(workflowInstance.toKey(), exitCode); }
@Override public PersistentEvent success(WorkflowInstance workflowInstance) { return new PersistentEvent("success", workflowInstance.toKey()); }
@Override public PersistentEvent timeout(WorkflowInstance workflowInstance) { return new PersistentEvent("timeout", workflowInstance.toKey()); }
static Key activeWorkflowInstanceKey(KeyFactory keyFactory, WorkflowInstance workflowInstance) { final String name = workflowInstance.toKey(); return activeWorkflowInstanceKey(keyFactory, name); }
@Override public PersistentEvent created(WorkflowInstance workflowInstance, String executionId, String dockerImage) { return new Created(workflowInstance.toKey(), executionId, Optional.of(dockerImage)); }
@Override public PersistentEvent retry(WorkflowInstance workflowInstance) { return new PersistentEvent("retry", workflowInstance.toKey()); }
@Override public PersistentEvent stop(WorkflowInstance workflowInstance) { return new PersistentEvent("stop", workflowInstance.toKey()); }
@Override public PersistentEvent timeTrigger(WorkflowInstance workflowInstance) { return new PersistentEvent("timeTrigger", workflowInstance.toKey()); }
@Override public PersistentEvent runError(WorkflowInstance workflowInstance, String message) { return new RunError(workflowInstance.toKey(), message); }
@Override public PersistentEvent retryAfter(WorkflowInstance workflowInstance, long delayMillis) { return new RetryAfter(workflowInstance.toKey(), delayMillis); }
SortedSet<SequenceEvent> readEvents(WorkflowInstance workflowInstance) throws IOException { try (final Table eventsTable = connection.getTable(EVENTS_TABLE_NAME)) { final Scan scan = new Scan() .setRowPrefixFilter(Bytes.toBytes(workflowInstance.toKey() + '#')); final SortedSet<SequenceEvent> set = newSortedEventSet(); for (Result result : eventsTable.getScanner(scan)) { set.add(parseEventResult(result)); } return set; } }
void writeEvent(SequenceEvent sequenceEvent) throws IOException { storeWithRetries(() -> { try (final Table eventsTable = connection.getTable(EVENTS_TABLE_NAME)) { final String workflowInstanceKey = sequenceEvent.event().workflowInstance().toKey(); final String keyString = String.format("%s#%08d", workflowInstanceKey, sequenceEvent.counter()); final byte[] key = Bytes.toBytes(keyString); final Put put = new Put(key, sequenceEvent.timestamp()); final byte[] eventBytes = serialize(sequenceEvent.event()).toByteArray(); put.addColumn(EVENT_CF, EVENT_QUALIFIER, eventBytes); eventsTable.put(put); } }); }