bharatviswa504 commented on a change in pull request #2294:
URL: https://github.com/apache/ozone/pull/2294#discussion_r648010195
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/HealthyPipelineSafeModeRule.java
##########
@@ -130,30 +124,61 @@ protected void process(Pipeline pipeline) {
SCMSafeModeManager.getLogger().info(
"SCM in safe mode. Healthy pipelines reported count is {}, " +
"required healthy pipeline reported count is {}",
- currentHealthyPipelineCount, healthyPipelineThresholdCount);
+ currentHealthyPipelineCount, getHealthyPipelineThresholdCount());
+
}
}
+
+ public synchronized void refresh() {
+ if (!validate()) {
+ initializeRule(true);
+ }
+ }
+
+ private synchronized void initializeRule(boolean refresh) {
+ int pipelineCount = pipelineManager.getPipelines(
+ new RatisReplicationConfig(HddsProtos.ReplicationFactor.THREE),
+ Pipeline.PipelineState.OPEN).size();
+
+ healthyPipelineThresholdCount = Math.max(minHealthyPipelines,
+ (int) Math.ceil(healthyPipelinesPercent * pipelineCount));
+
+ if (refresh) {
+ LOG.info("Refreshed total pipeline count is {}, healthy pipeline " +
+ "threshold count is {}", pipelineCount,
+ healthyPipelineThresholdCount);
+ } else {
+ LOG.info("Total pipeline count is {}, healthy pipeline " +
+ "threshold count is {}", pipelineCount,
+ healthyPipelineThresholdCount);
+ }
+
+ getSafeModeMetrics().setNumHealthyPipelinesThreshold(
+ healthyPipelineThresholdCount);
+ }
+
+
@Override
- protected void cleanup() {
+ protected synchronized void cleanup() {
processedPipelineIDs.clear();
}
@VisibleForTesting
- public int getCurrentHealthyPipelineCount() {
+ public synchronized int getCurrentHealthyPipelineCount() {
Review comment:
To avoid contention between refresh and process reports.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]