if (alreadyExists != null) {
throw new IllegalStateException("Action is already perfomed for execution=#" + scheduleExecutionId);
}
// Execute action
ActionResult actionResult;
try {
actionResult = actionExecutor.execute(actionDefinition, scheduleExecutionId, address);
if (actionResult == null) {
String message = String.format("Action result is null for execution=#[%d] and node=[%s]",
scheduleExecutionId, address);
throw new NullPointerException(message);
}
} finally {
executionTracker.remove(scheduleExecutionId);
}
// Marshall execution result
byte[] actionResultData = actionResultMarshaller.marshall(actionResult);
// Compose the result record
ActionAgentResult actionAgentResult = new ActionAgentResult();
actionAgentResult.setSucceed(actionResult.isSucceed());
actionAgentResult.setData(actionResultData);
return actionAgentResult;
}