}
@Override
public HelixTaskResult handleMessage() {
NotificationContext context = _notificationContext;
Message message = _message;
synchronized (_stateModel) {
HelixTaskResult taskResult = new HelixTaskResult();
HelixManager manager = context.getManager();
HelixDataAccessor accessor = manager.getHelixDataAccessor();
_statusUpdateUtil.logInfo(message, HelixStateTransitionHandler.class,
"Message handling task begin execute", accessor);
message.setExecuteStartTimeStamp(new Date().getTime());
try {
preHandleMessage();
invoke(accessor, context, taskResult, message);
} catch (HelixStateMismatchException e) {
// Simply log error and return from here if State mismatch.
// The current state of the state model is intact.
taskResult.setSuccess(false);
taskResult.setMessage(e.toString());
taskResult.setException(e);
} catch (Exception e) {
String errorMessage =
"Exception while executing a state transition task " + message.getPartitionName();
logger.error(errorMessage, e);
if (e.getCause() != null && e.getCause() instanceof InterruptedException) {
e = (InterruptedException) e.getCause();
}
_statusUpdateUtil.logError(message, HelixStateTransitionHandler.class, e, errorMessage,
accessor);
taskResult.setSuccess(false);
taskResult.setMessage(e.toString());
taskResult.setException(e);
taskResult.setInterrupted(e instanceof InterruptedException);
}
// add task result to context for postHandling
context.add(MapKey.HELIX_TASK_RESULT.toString(), taskResult);
postHandleMessage();
return taskResult;
}
}