ivandika3 commented on code in PR #10525:
URL: https://github.com/apache/ozone/pull/10525#discussion_r3478722490
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java:
##########
@@ -404,23 +404,30 @@ public void updateContainerStateWithSequenceId(final
HddsProtos.ContainerID cont
LOG.warn("Container sequenceId is {} greater than the leader
container sequenceId {}",
containerInfo.getSequenceId(), sequenceId);
}
-
- final LifeCycleState oldState = containerInfo.getState();
- final LifeCycleState newState = stateMachine.getNextState(
- oldState, event);
- if (newState.getNumber() > oldState.getNumber()) {
- ExecutionUtil.create(() -> {
- containers.updateState(id, oldState, newState);
- transactionBuffer.addToBuffer(containerStore, id,
- containers.getContainerInfo(id));
- }).onException(() -> {
- containers.updateState(id, newState, oldState);
- ContainerInfo currentInfo = containers.getContainerInfo(id);
- transactionBuffer.addToBuffer(containerStore, id, currentInfo);
-
- }).execute();
- containerStateChangeActions.getOrDefault(event, info -> { })
- .accept(containerInfo);
+
+ try {
+ final LifeCycleState oldState = containerInfo.getState();
+ final LifeCycleState newState = stateMachine.getNextState(
+ oldState, event);
+
+ if (newState.getNumber() > oldState.getNumber()) {
+ ExecutionUtil.create(() -> {
+ containers.updateState(id, oldState, newState);
+ transactionBuffer.addToBuffer(containerStore, id,
+ containers.getContainerInfo(id));
+ }).onException(() -> {
+ containers.updateState(id, newState, oldState);
+ ContainerInfo currentInfo = containers.getContainerInfo(id);
+ transactionBuffer.addToBuffer(containerStore, id, currentInfo);
+
+ }).execute();
+ containerStateChangeActions.getOrDefault(event, info -> { })
+ .accept(containerInfo);
+ }
+ } catch (InvalidStateTransitionException ex) {
+ LOG.warn("Ignoring invalid container state transition for container
{} " +
+ "for event {} at state {}",
+ id, event, containerInfo.getState(), ex);
Review Comment:
Thanks, moved the catch outside and remove the inner try block.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java:
##########
@@ -404,23 +404,30 @@ public void updateContainerStateWithSequenceId(final
HddsProtos.ContainerID cont
LOG.warn("Container sequenceId is {} greater than the leader
container sequenceId {}",
containerInfo.getSequenceId(), sequenceId);
}
-
- final LifeCycleState oldState = containerInfo.getState();
- final LifeCycleState newState = stateMachine.getNextState(
- oldState, event);
- if (newState.getNumber() > oldState.getNumber()) {
- ExecutionUtil.create(() -> {
- containers.updateState(id, oldState, newState);
- transactionBuffer.addToBuffer(containerStore, id,
- containers.getContainerInfo(id));
- }).onException(() -> {
- containers.updateState(id, newState, oldState);
- ContainerInfo currentInfo = containers.getContainerInfo(id);
- transactionBuffer.addToBuffer(containerStore, id, currentInfo);
-
- }).execute();
- containerStateChangeActions.getOrDefault(event, info -> { })
- .accept(containerInfo);
+
+ try {
+ final LifeCycleState oldState = containerInfo.getState();
+ final LifeCycleState newState = stateMachine.getNextState(
+ oldState, event);
+
+ if (newState.getNumber() > oldState.getNumber()) {
+ ExecutionUtil.create(() -> {
+ containers.updateState(id, oldState, newState);
+ transactionBuffer.addToBuffer(containerStore, id,
+ containers.getContainerInfo(id));
+ }).onException(() -> {
+ containers.updateState(id, newState, oldState);
+ ContainerInfo currentInfo = containers.getContainerInfo(id);
+ transactionBuffer.addToBuffer(containerStore, id, currentInfo);
+
+ }).execute();
+ containerStateChangeActions.getOrDefault(event, info -> { })
+ .accept(containerInfo);
+ }
+ } catch (InvalidStateTransitionException ex) {
+ LOG.warn("Ignoring invalid container state transition for container
{} " +
+ "for event {} at state {}",
+ id, event, containerInfo.getState(), ex);
Review Comment:
Thanks @szetszwo , moved the catch outside and remove the inner try block.
--
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]