public void write(List<? extends T> items) throws Exception { // Block until expecting <= throttle limit while (localState.getExpecting() > throttleLimit) { getNextResult(); } if (!items.isEmpty()) { ChunkRequest<T> request = localState.getRequest(items); if (logger.isDebugEnabled()) { logger.debug("Dispatching chunk: " + request); } messagingGateway.send(new GenericMessage<>(request)); localState.incrementExpected(); } }
public Collection<StepContribution> getStepContributions() { List<StepContribution> contributions = new ArrayList<>(); for (ChunkResponse response : localState.pollChunkResponses()) { StepContribution contribution = response.getStepContribution(); if (logger.isDebugEnabled()) { logger.debug("Applying: " + response); } contributions.add(contribution); } return contributions; }
Assert.state(jobInstanceId.equals(localState.getJobId()), "Message contained wrong job instance id [" + jobInstanceId + "] should have been [" + localState.getJobId() + "]."); if (payload.isRedelivered()) { logger + "from workers have been sent, the business state " + "is probably inconsistent, and the step will fail."); localState.incrementRedelivered(); localState.pushResponse(payload); localState.incrementActual(); if (!payload.isSuccessful()) { throw new AsynchronousFailureException("Failure or interrupt detected in handler: "
return ExitStatus.EXECUTING; long expecting = localState.getExpecting(); boolean timedOut; try { + localState.getExpecting()); return ExitStatus.FAILED.addExitDescription("Timed out waiting for " + localState.getExpecting() + " backlog at end of step");
/** * Wait until all the results that are in the pipeline come back to the reply channel. * * @return true if successfully received a result, false if timed out */ private boolean waitForResults() throws AsynchronousFailureException { int count = 0; int maxCount = maxWaitTimeouts; Throwable failure = null; logger.info("Waiting for " + localState.getExpecting() + " results"); while (localState.getExpecting() > 0 && count++ < maxCount) { try { getNextResult(); } catch (Throwable t) { logger.error("Detected error in remote result. Trying to recover " + localState.getExpecting() + " outstanding results before completing.", t); failure = t; } } if (failure != null) { throw wrapIfNecessary(failure); } return count < maxCount; }
public <T> ChunkRequest<T> getRequest(List<? extends T> items) { return new ChunkRequest<>(current.incrementAndGet(), items, getJobId(), createStepContribution()); }
public void open(ExecutionContext executionContext) throws ItemStreamException { if (executionContext.containsKey(EXPECTED)) { localState.open(executionContext.getInt(EXPECTED), executionContext.getInt(ACTUAL)); if (!waitForResults()) { throw new ItemStreamException("Timed out waiting for back log on open"); } } }