sarvekshayr commented on code in PR #8929:
URL: https://github.com/apache/ozone/pull/8929#discussion_r2268690332
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ContainerStateVerifier.java:
##########
@@ -99,11 +99,17 @@ public BlockVerificationResult verifyBlock(DatanodeDetails
datanode, OmKeyLocati
private boolean areContainerAndReplicasInGoodState(ContainerDataProto.State
replicaState,
HddsProtos.LifeCycleState containerState) {
- return (replicaState != ContainerDataProto.State.UNHEALTHY &&
- replicaState != ContainerDataProto.State.INVALID &&
- replicaState != ContainerDataProto.State.DELETED &&
- containerState != HddsProtos.LifeCycleState.DELETING &&
- containerState != HddsProtos.LifeCycleState.DELETED);
+ boolean replicaInGoodState = (replicaState ==
ContainerDataProto.State.OPEN ||
+ replicaState == ContainerDataProto.State.CLOSING ||
+ replicaState == ContainerDataProto.State.QUASI_CLOSED ||
+ replicaState == ContainerDataProto.State.CLOSED);
+
+ boolean containerInGoodState = (containerState ==
HddsProtos.LifeCycleState.OPEN ||
+ containerState == HddsProtos.LifeCycleState.CLOSING ||
+ containerState == HddsProtos.LifeCycleState.QUASI_CLOSED ||
+ containerState == HddsProtos.LifeCycleState.CLOSED);
+
+ return replicaInGoodState && containerInGoodState;
Review Comment:
Thanks for the improvement @Gargi-jais11.
Instead of multiple `==` checks, define an EnumSet of “good” states for
replicas and containers, and use `contains()` for the check. This approach
makes the code cleaner and easier to extend if new states are added.
```
Set<ContainerDataProto.State> GOOD_REPLICA_STATES = EnumSet.of(...)
Set<HddsProtos.LifeCycleState> GOOD_CONTAINER_STATES = EnumSet.of(...)
boolean areContainerAndReplicasInGoodState(ContainerDataProto.State
replicaState, HddsProtos.LifeCycleState containerState) {
return GOOD_REPLICA_STATES.contains(replicaState) &&
GOOD_CONTAINER_STATES.contains(containerState);
}
```
--
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]