-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-12938. Refactor OneReplicaPipelineSafeModeRule to not use PipelineReportFromDatanode #8410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.base.Preconditions; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||
|
|
@@ -51,7 +52,7 @@ public class OneReplicaPipelineSafeModeRule extends | |
| private static final String NAME = "AtleastOneDatanodeReportedRule"; | ||
|
|
||
| private int thresholdCount; | ||
| private final Set<PipelineID> reportedPipelineIDSet = new HashSet<>(); | ||
| private Set<PipelineID> reportedPipelineIDSet = new HashSet<>(); | ||
| private Set<PipelineID> oldPipelineIDSet; | ||
| private int currentReportedPipelineCount = 0; | ||
| private PipelineManager pipelineManager; | ||
|
|
@@ -85,11 +86,19 @@ protected TypedEvent<PipelineReportFromDatanode> getEventType() { | |
|
|
||
| @Override | ||
| protected synchronized boolean validate() { | ||
| if (validateBasedOnReportProcessing()) { | ||
| return currentReportedPipelineCount >= thresholdCount; | ||
| } | ||
|
|
||
| updateReportedPipelineSet(); | ||
| return currentReportedPipelineCount >= thresholdCount; | ||
| } | ||
|
|
||
| @Override | ||
| protected synchronized void process(PipelineReportFromDatanode report) { | ||
| if (!validateBasedOnReportProcessing()) { | ||
| return; | ||
| } | ||
| Preconditions.checkNotNull(report); | ||
| for (PipelineReport report1 : report.getReport().getPipelineReportList()) { | ||
| Pipeline pipeline; | ||
|
|
@@ -137,6 +146,11 @@ public synchronized int getCurrentReportedPipelineCount() { | |
| return currentReportedPipelineCount; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public Set<PipelineID> getReportedPipelineIDSet() { | ||
| return reportedPipelineIDSet; | ||
| } | ||
|
|
||
| @Override | ||
| public String getStatusText() { | ||
| String status = String.format( | ||
|
|
@@ -171,6 +185,25 @@ public synchronized void refresh(boolean forceRefresh) { | |
| } | ||
| } | ||
|
|
||
| private void updateReportedPipelineSet() { | ||
| List<Pipeline> openRatisPipelines = | ||
| pipelineManager.getPipelines(RatisReplicationConfig.getInstance(ReplicationFactor.THREE), | ||
| Pipeline.PipelineState.OPEN); | ||
|
|
||
| for (Pipeline pipeline : openRatisPipelines) { | ||
| PipelineID pipelineID = pipeline.getId(); | ||
| boolean allDNsPipelineReported = pipeline.getNodeSet().size() == 3; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain why line 195 check is added? The old logic seems not check that. TIA!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check ensures that all three DN have reported that particular pipeline. We can do pipeline.getNodeSet().size() > 1 to check for at least one replica! |
||
| boolean notAlreadyReported = !reportedPipelineIDSet.contains(pipelineID); | ||
| boolean wasExistingPipeline = oldPipelineIDSet.contains(pipelineID); | ||
|
|
||
| if (allDNsPipelineReported && notAlreadyReported && wasExistingPipeline) { | ||
| getSafeModeMetrics().incCurrentHealthyPipelinesWithAtleastOneReplicaReportedCount(); | ||
| currentReportedPipelineCount++; | ||
| reportedPipelineIDSet.add(pipelineID); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void initializeRule(boolean refresh) { | ||
|
|
||
| oldPipelineIDSet = pipelineManager.getPipelines( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two
removeFirstFromNodeStatusandsetInNodeStatuscan be removed. To make a 2-node pipeline, usepipelineManager.deletePipelineto delete original one and add a 2-node one back through it.