-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDDS-1285. Implement actions need to be taken after chill mode exit w… #612
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
202 changes: 202 additions & 0 deletions
202
...src/test/java/org/apache/hadoop/hdds/scm/chillmode/TestSCMChillModeWithPipelineRules.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.hdds.scm.chillmode; | ||
|
|
||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
| import org.apache.hadoop.hdds.scm.container.ReplicationManager; | ||
| import org.apache.hadoop.hdds.scm.pipeline.Pipeline; | ||
| import org.apache.hadoop.hdds.scm.pipeline.PipelineManager; | ||
| import org.apache.hadoop.hdds.scm.server.StorageContainerManager; | ||
| import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
| import org.apache.hadoop.test.GenericTestUtils; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
||
| import java.util.List; | ||
| import java.util.concurrent.TimeoutException; | ||
|
|
||
| import static org.junit.Assert.fail; | ||
|
|
||
| /** | ||
| * This class tests SCM Chill mode with pipeline rules. | ||
| */ | ||
|
|
||
| public class TestSCMChillModeWithPipelineRules { | ||
|
|
||
| private static MiniOzoneCluster cluster; | ||
| private OzoneConfiguration conf = new OzoneConfiguration(); | ||
| private PipelineManager pipelineManager; | ||
| private MiniOzoneCluster.Builder clusterBuilder; | ||
|
|
||
| @Rule | ||
| public TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
|
||
| public void setup(int numDatanodes) throws Exception { | ||
| conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, | ||
| temporaryFolder.newFolder().toString()); | ||
| conf.setBoolean( | ||
| HddsConfigKeys.HDDS_SCM_CHILLMODE_PIPELINE_AVAILABILITY_CHECK, | ||
| true); | ||
| conf.set(HddsConfigKeys.HDDS_SCM_WAIT_TIME_AFTER_CHILL_MODE_EXIT, "10s"); | ||
| conf.set(ScmConfigKeys.OZONE_SCM_PIPELINE_CREATION_INTERVAL, "10s"); | ||
| clusterBuilder = MiniOzoneCluster.newBuilder(conf) | ||
| .setNumDatanodes(numDatanodes) | ||
| .setHbInterval(1000) | ||
| .setHbProcessorInterval(1000); | ||
|
|
||
| cluster = clusterBuilder.build(); | ||
| cluster.waitForClusterToBeReady(); | ||
| StorageContainerManager scm = cluster.getStorageContainerManager(); | ||
| pipelineManager = scm.getPipelineManager(); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testScmChillMode() throws Exception { | ||
|
|
||
| int datanodeCount = 6; | ||
| setup(datanodeCount); | ||
|
|
||
| waitForRatis3NodePipelines(datanodeCount/3); | ||
| waitForRatis1NodePipelines(datanodeCount); | ||
|
|
||
| int totalPipelineCount = datanodeCount + (datanodeCount/3); | ||
|
|
||
| //Cluster is started successfully | ||
| cluster.stop(); | ||
|
|
||
| cluster.restartOzoneManager(); | ||
| cluster.restartStorageContainerManager(false); | ||
|
|
||
| pipelineManager = cluster.getStorageContainerManager().getPipelineManager(); | ||
| List<Pipeline> pipelineList = | ||
| pipelineManager.getPipelines(HddsProtos.ReplicationType.RATIS, | ||
| HddsProtos.ReplicationFactor.THREE); | ||
|
|
||
|
|
||
| pipelineList.get(0).getNodes().forEach(datanodeDetails -> { | ||
| try { | ||
| cluster.restartHddsDatanode(datanodeDetails, false); | ||
| } catch (Exception ex) { | ||
| fail("Datanode restart failed"); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
| SCMChillModeManager scmChillModeManager = | ||
| cluster.getStorageContainerManager().getScmChillModeManager(); | ||
|
|
||
|
|
||
| // Ceil(0.1 * 2) is 1, as one pipeline is healthy healthy pipeline rule is | ||
| // satisfied | ||
|
|
||
| GenericTestUtils.waitFor(() -> | ||
| scmChillModeManager.getHealthyPipelineChillModeRule() | ||
| .validate(), 1000, 60000); | ||
|
|
||
| // As Ceil(0.9 * 2) is 2, and from second pipeline no datanodes's are | ||
| // reported this rule is not met yet. | ||
| GenericTestUtils.waitFor(() -> | ||
|
Contributor
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. Here as well, do we need
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. Yes because here scm is restarted without waiting for any datanodes. |
||
| !scmChillModeManager.getOneReplicaPipelineChillModeRule() | ||
| .validate(), 1000, 60000); | ||
|
|
||
| Assert.assertTrue(cluster.getStorageContainerManager().isInChillMode()); | ||
|
nandakumar131 marked this conversation as resolved.
Outdated
|
||
|
|
||
| DatanodeDetails restartedDatanode = pipelineList.get(1).getFirstNode(); | ||
| // Now restart one datanode from the 2nd pipeline | ||
| try { | ||
| cluster.restartHddsDatanode(restartedDatanode, false); | ||
| } catch (Exception ex) { | ||
| fail("Datanode restart failed"); | ||
| } | ||
|
|
||
|
|
||
| GenericTestUtils.waitFor(() -> | ||
| scmChillModeManager.getOneReplicaPipelineChillModeRule() | ||
| .validate(), 1000, 60000); | ||
|
|
||
| GenericTestUtils.waitFor(() -> !scmChillModeManager.getInChillMode(), 1000, | ||
| 60000); | ||
|
|
||
| // As after chillmode wait time is not completed, we should have total | ||
| // pipeline's as original count 6(1 node pipelines) + 2 (3 node pipeline) | ||
| Assert.assertEquals(totalPipelineCount, | ||
| pipelineManager.getPipelines().size()); | ||
|
|
||
| ReplicationManager replicationManager = | ||
| cluster.getStorageContainerManager().getReplicationManager(); | ||
|
|
||
| GenericTestUtils.waitFor(() -> | ||
| replicationManager.isRunning(), 1000, 60000); | ||
|
|
||
|
|
||
| // As 4 datanodes are reported, 4 single node pipeline and 1 3 node | ||
| // pipeline. | ||
|
|
||
| waitForRatis1NodePipelines(4); | ||
| waitForRatis3NodePipelines(1); | ||
|
|
||
| // Restart other datanodes in the pipeline, and after some time we should | ||
| // have same count as original. | ||
| pipelineList.get(1).getNodes().forEach(datanodeDetails -> { | ||
| try { | ||
| if (!restartedDatanode.equals(datanodeDetails)) { | ||
| cluster.restartHddsDatanode(datanodeDetails, false); | ||
| } | ||
| } catch (Exception ex) { | ||
| fail("Datanode restart failed"); | ||
| } | ||
| }); | ||
|
|
||
| waitForRatis1NodePipelines(datanodeCount); | ||
| waitForRatis3NodePipelines(datanodeCount/3); | ||
|
|
||
| } | ||
|
|
||
| @After | ||
| public void tearDown() { | ||
| if (cluster != null) { | ||
| cluster.shutdown(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private void waitForRatis3NodePipelines(int numPipelines) | ||
| throws TimeoutException, InterruptedException { | ||
| GenericTestUtils.waitFor(() -> pipelineManager | ||
| .getPipelines(HddsProtos.ReplicationType.RATIS, | ||
| HddsProtos.ReplicationFactor.THREE, Pipeline.PipelineState.OPEN) | ||
| .size() == numPipelines, 100, 60000); | ||
| } | ||
|
|
||
| private void waitForRatis1NodePipelines(int numPipelines) | ||
| throws TimeoutException, InterruptedException { | ||
| GenericTestUtils.waitFor(() -> pipelineManager | ||
| .getPipelines(HddsProtos.ReplicationType.RATIS, | ||
| HddsProtos.ReplicationFactor.ONE, Pipeline.PipelineState.OPEN) | ||
| .size() == numPipelines, 100, 60000); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.