siddhantsangwan commented on code in PR #7008:
URL: https://github.com/apache/ozone/pull/7008#discussion_r1750051625
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModeMetrics.java:
##########
@@ -75,10 +79,18 @@ public void
setNumContainerWithOneReplicaReportedThreshold(long val) {
this.numContainerWithOneReplicaReportedThreshold.set(val);
}
+ public void setNumContainerWithECDataReplicaReportedThreshold(long val) {
+ this.numContainerWithECDataReplicaReportedThreshold.incr(val);
Review Comment:
Should use set() instead of incr().
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/ContainerSafeModeRule.java:
##########
@@ -71,83 +84,166 @@ public ContainerSafeModeRule(String ruleName, EventQueue
eventQueue,
HddsConfigKeys.HDDS_SCM_SAFEMODE_THRESHOLD_PCT +
" value should be >= 0.0 and <= 1.0");
- containerMap = new ConcurrentHashMap<>();
+ ratisContainerMap = new ConcurrentHashMap<>();
+ ratisContainerDNsMap = new ConcurrentHashMap<>();
+ ecContainerMap = new ConcurrentHashMap<>();
+ ecContainerDNsMap = new ConcurrentHashMap<>();
+
containers.forEach(container -> {
// There can be containers in OPEN/CLOSING state which were never
// created by the client. We are not considering these containers for
// now. These containers can be handled by tracking pipelines.
- Optional.ofNullable(container.getState())
- .filter(state -> (state == HddsProtos.LifeCycleState.QUASI_CLOSED ||
- state == HddsProtos.LifeCycleState.CLOSED)
- && container.getNumberOfKeys() > 0)
- .ifPresent(s -> containerMap.put(container.getContainerID(),
- container));
+ LifeCycleState containerState = container.getState();
+ ReplicationConfig replicationConfig = container.getReplicationConfig();
+
+ if (checkContainerState(containerState) && container.getNumberOfKeys() >
0) {
+ if (replicationConfig instanceof RatisReplicationConfig) {
+ ratisContainerMap.put(container.getContainerID(), container);
+ }
+ if (replicationConfig instanceof ECReplicationConfig) {
+ ecContainerMap.put(container.getContainerID(), container);
+ }
+ }
});
- maxContainer = containerMap.size();
- long cutOff = (long) Math.ceil(maxContainer * safeModeCutoff);
-
getSafeModeMetrics().setNumContainerWithOneReplicaReportedThreshold(cutOff);
- LOG.info("containers with one replica threshold count {}", cutOff);
+ ratisMaxContainer = ratisContainerMap.size();
+ ecMaxContainer = ecContainerMap.size();
+
+ long ratisCutOff = (long) Math.ceil(ratisMaxContainer * safeModeCutoff);
+ long ecCutOff = (long) Math.ceil(ecMaxContainer * safeModeCutoff);
+
+
getSafeModeMetrics().setNumContainerWithOneReplicaReportedThreshold(ratisCutOff);
Review Comment:
Let's set EC metrics as well.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/ContainerSafeModeRule.java:
##########
@@ -170,28 +266,44 @@ public synchronized void refresh(boolean forceRefresh) {
}
}
+ private boolean checkContainerState(LifeCycleState state) {
+ if (state == LifeCycleState.QUASI_CLOSED || state ==
LifeCycleState.CLOSED) {
+ return true;
+ }
+ return false;
+ }
+
private void reInitializeRule() {
- containerMap.clear();
+
Review Comment:
Looks like most of the code inside this method is the same as before. If
possible, let's refactor this to avoid repetition.
--
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]