logger.warn("Force CurrentState on Zk to be stateModel's CurrentState. partitionKey: "
+ partitionId + ", currentState: " + _stateModel.getCurrentState() + ", message: "
+ _message);
_currentStateDelta.setState(partitionId, State.from(_stateModel.getCurrentState()));
} else {
StateTransitionError error =
new StateTransitionError(ErrorType.INTERNAL, ErrorCode.ERROR, exception);
if (exception instanceof InterruptedException) {
if (_isTimeout) {
error = new StateTransitionError(ErrorType.INTERNAL, ErrorCode.TIMEOUT, exception);
} else {
// State transition interrupted but not caused by timeout. Keep the current
// state in this case
logger
.error("State transition interrupted but not timeout. Not updating state. Partition : "
+ _message.getPartitionId() + " MsgId : " + _message.getMessageId());
return;
}
}
_stateModel.rollbackOnError(_message, _notificationContext, error);
_currentStateDelta.setState(partitionId, State.from(HelixDefinedState.ERROR.toString()));
_stateModel.updateState(HelixDefinedState.ERROR.toString());
// if we have errors transit from ERROR state, disable the partition
if (_message.getTypedFromState().toString()
.equalsIgnoreCase(HelixDefinedState.ERROR.toString())) {
disablePartition();
}
}
}
try {
// Update the ZK current state of the node
PropertyKey key =
keyBuilder.currentState(instanceName, sessionId.stringify(), resource.stringify(),
bucketizer.getBucketName(partitionId.stringify()));
if (_message.getAttribute(Attributes.PARENT_MSG_ID) == null) {
// normal message
accessor.updateProperty(key, _currentStateDelta);
} else {
// sub-message of a batch message
ConcurrentHashMap<String, CurrentStateUpdate> csUpdateMap =
(ConcurrentHashMap<String, CurrentStateUpdate>) _notificationContext
.get(MapKey.CURRENT_STATE_UPDATE.toString());
csUpdateMap.put(partitionId.stringify(), new CurrentStateUpdate(key, _currentStateDelta));
}
} catch (Exception e) {
logger.error("Error when updating current-state ", e);
StateTransitionError error =
new StateTransitionError(ErrorType.FRAMEWORK, ErrorCode.ERROR, e);
_stateModel.rollbackOnError(_message, _notificationContext, error);
_statusUpdateUtil.logError(_message, HelixStateTransitionHandler.class, e,
"Error when update current-state ", accessor);
}
}