private boolean isRecoveryCheckpoint(Execution nextStepExecution) { //Here we check if we need to go to queue to persist - we can do it with shortcut to InBuffer!!!!!!!! if (!isRecoveryDisabled && nextStepExecution.getSystemContext().containsKey(TempConstants.IS_RECOVERY_CHECKPOINT)) { //clean key nextStepExecution.getSystemContext().remove(TempConstants.IS_RECOVERY_CHECKPOINT); //set current step to finished executionMessage.setStatus(ExecStatus.FINISHED); executionMessage.incMsgSeqId(); executionMessage.setPayload(null); ExecutionMessage inProgressMessage = createInProgressExecutionMessage(nextStepExecution); ExecutionMessage[] executionMessagesToSend = new ExecutionMessage[]{executionMessage, inProgressMessage}; //for the outBuffer ExecutionMessage inProgressMessageForInBuffer = (ExecutionMessage) inProgressMessage.clone(); inProgressMessageForInBuffer.setPayload(null); //we do not need the payload for the inBuffer shortcut try { //The order is important!!!!! outBuffer.put(executionMessagesToSend); inBuffer.addExecutionMessage(inProgressMessageForInBuffer); } catch (InterruptedException e) { logger.warn("Thread was interrupted! Exiting the execution... ", e); return true; //exiting... in shutdown... } return true; } else { return false; } }
private boolean shouldChangeWorkerGroup(Execution nextStepExecution) { //Here we check if we can continue to run in current thread - depends on the group if (nextStepExecution.getSystemContext().containsKey(TempConstants.SHOULD_CHECK_GROUP)) { //take care of worker group id String groupName = nextStepExecution.getGroupName(); //clean key nextStepExecution.getSystemContext().remove(TempConstants.SHOULD_CHECK_GROUP); boolean canRunInThisWorker = groupName== null || //does not really matter on what worker to run workerConfigurationService.isMemberOf(groupName) || //this worker is member of the group isStickyToThisWorker(groupName); //next step should run in this worker because of "sticky worker" feature if(!canRunInThisWorker){ //set current step to finished executionMessage.setStatus(ExecStatus.FINISHED); executionMessage.incMsgSeqId(); executionMessage.setPayload(null); ExecutionMessage pendingMessage = createPendingExecutionMessage(nextStepExecution); ExecutionMessage[] executionMessagesToSend = new ExecutionMessage[]{executionMessage, pendingMessage};//Messages that we will send to OutBuffer try { outBuffer.put(executionMessagesToSend); } catch (InterruptedException e) { logger.warn("Thread was interrupted! Exiting the execution... ", e); return true; } return true; } } return false; }