ivandika3 commented on code in PR #8542:
URL: https://github.com/apache/ozone/pull/8542#discussion_r3464858031
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CommandDispatcher.java:
##########
@@ -82,26 +81,26 @@ public CommandHandler getDeleteBlocksCommandHandler() {
return handlerMap.get(Type.deleteBlocksCommand);
}
- public ClosePipelineCommandHandler getClosePipelineCommandHandler() {
- return (ClosePipelineCommandHandler)
handlerMap.get(Type.closePipelineCommand);
- }
-
/**
* Dispatch the command to the correct handler.
*
* @param command - SCM Command.
*/
public void handle(SCMCommand<?> command) {
- Objects.requireNonNull(command, "command == null");
+ Preconditions.checkNotNull(command);
CommandHandler handler = handlerMap.get(command.getType());
if (handler != null) {
commandHandlerMetrics.increaseCommandCount(command.getType());
try {
handler.handle(command, container, context, connectionManager);
} catch (Exception ex) {
+ context.updateCommandStatus(command.getId(),
+ status -> status.setStatus(CommandStatus.Status.FAILED));
LOG.error("Exception while handle command, ", ex);
}
} else {
+ context.updateCommandStatus(command.getId(),
+ status -> status.setStatus(CommandStatus.Status.FAILED));
Review Comment:
This is a general review for most of the failed command, is it easier to
throw exception and let the `updateCommandStatus` to be done in the catch
block? This would make it less error-prone for other command handler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]