/** * Like {@link #receive(Event)} but ignoring the {@link IsClosedException} exception. * * @param event The event to receive */ default void receiveIgnoreClosed(Event event) { try { receive(event); } catch (IsClosedException isClosedException) { LOG.info("Ignored event, state receiver closed", isClosedException); } }
state.workflowInstance(), getExecDescription(workflowInstance, state.data()), createExecutionId()); try { stateManager.receive(submitEvent); } catch (IsClosedException isClosedException) { LOG.warn("Could not send 'submit' event", isClosedException); try { LOG.error("Failed to retrieve execution description for " + state.workflowInstance(), e); stateManager.receive(Event.runError(state.workflowInstance(), e.getMessage())); } catch (IsClosedException isClosedException) { LOG.warn("Failed to send 'runError' event", isClosedException);
stateManager.receive(submitted, state.counter()); } catch (IsClosedException isClosedException) { LOG.warn("Could not emit 'submitted' event", isClosedException); LOG.error(msg, e); stateManager.receive(Event.runError(state.workflowInstance(), e.getMessage()), state.counter() + 1); } catch (IsClosedException isClosedException) {
/** * Like {@link #receive(Event)} but ignoring the {@link IsClosedException} exception. * * @param event The event to receive * @param counter The state counter upon which the event must act upon */ default void receiveIgnoreClosed(Event event, long counter) { try { receive(event, counter); } catch (IsClosedException isClosedException) { LOG.info("Ignored event, state receiver closed", isClosedException); } }
@VisibleForTesting CompletionStage<Void> receive(Event event) throws IsClosedException { return stateManager.receive(event); }
private StatusType eventInjectorHelper(Event event) { try { stateManager.receive(event).toCompletableFuture().get(); } catch (IsClosedException | InterruptedException e) { return INTERNAL_SERVER_ERROR.withReasonPhrase(e.getMessage()); } catch (ExecutionException e) { if (e.getCause() instanceof IllegalArgumentException || e.getCause() instanceof IllegalStateException) { return BAD_REQUEST.withReasonPhrase(e.getCause().getMessage()); } else { return INTERNAL_SERVER_ERROR.withReasonPhrase(e.getMessage()); } } return OK; }
private void emitPodEvents(Pod pod, RunState runState) { final List<Event> events = translate(runState.workflowInstance(), runState, pod, stats); for (int i = 0; i < events.size(); ++i) { final Event event = events.get(i); if (event.accept(new PullImageErrorMatcher())) { stats.recordPullImageError(); } if (EventUtil.name(event).equals("started")) { runState.data().executionId().ifPresent(stats::recordRunning); } try { // TODO: spoofing counter values like this can give unexpected results, e.g. if we emit two events here the // first one might be discarded and the second one accepted. stateManager.receive(event, runState.counter() + i); } catch (IsClosedException isClosedException) { LOG.warn("Could not receive kubernetes event", isClosedException); throw new RuntimeException(isClosedException); } } }