adoroszlai commented on code in PR #8390:
URL: https://github.com/apache/ozone/pull/8390#discussion_r2082913709
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SCMSafeModeManager.java:
##########
@@ -209,33 +163,27 @@ public synchronized void validateSafeModeExitRules(String
ruleName,
* the safemode state change.
* @param eventQueue
Review Comment:
```suggestion
```
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModeRuleFactory.java:
##########
@@ -117,4 +117,9 @@ public List<SafeModeExitRule<?>> getSafeModeRules() {
public List<SafeModeExitRule<?>> getPreCheckRules() {
return preCheckRules;
}
+
+ public <T extends SafeModeExitRule<?>> T getSafeModeRule(Class<T> ruleClass)
{
+ return safeModeRules.stream().filter(r ->
ruleClass.isAssignableFrom(r.getClass()))
+ .map(ruleClass::cast).findFirst().orElse(null);
Review Comment:
nit: wrap stream operations for readability
```suggestion
return safeModeRules.stream()
.filter(r -> ruleClass.isAssignableFrom(r.getClass()))
.map(ruleClass::cast)
.findFirst()
.orElse(null);
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestSCMSafeModeWithPipelineRules.java:
##########
@@ -116,14 +116,15 @@ void testScmSafeMode() throws Exception {
// Ceil(0.1 * 2) is 1, as one pipeline is healthy pipeline rule is
// satisfied
- GenericTestUtils.waitFor(() ->
- scmSafeModeManager.getHealthyPipelineSafeModeRule()
+ GenericTestUtils.waitFor(() -> SafeModeRuleFactory.getInstance()
+ .getSafeModeRule(HealthyPipelineSafeModeRule.class)
.validate(), 1000, 60000);
Review Comment:
nit: it would be nice to move `getSafeModeRule` outside `waitFor` to avoid
repeated rule lookup
(for all similar `waitFor` calls)
--
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]