-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-6135. SCM Container DB bootstrap on Recon startup for SCM HA. #2972
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
7 commits
Select commit
Hold shift + click to select a range
b1c7095
HDDS-6135. SCM Container DB bootstrap on Recon startup for SCM HA.
aswinshakil f1091d3
HDDS-6135. Refactored code and tests.
aswinshakil d9f6489
HDDS-6135. Fixed checkstyle.
aswinshakil 1fb7574
Trigger CI
aswinshakil d188eb0
Fixed tests
aswinshakil 534637b
Fixed spacing and logging
aswinshakil 9ebc777
Retrigger CI
smengcl 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
70 changes: 70 additions & 0 deletions
70
.../integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconScmHASnapshot.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,70 @@ | ||
| /** | ||
| * 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.ozone.recon; | ||
|
|
||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
| import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.Timeout; | ||
|
|
||
| import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY; | ||
|
|
||
| /** | ||
| * Test Recon SCM HA Snapshot Download implementation. | ||
| */ | ||
| public class TestReconScmHASnapshot { | ||
|
|
||
| /** | ||
| * Set a timeout for each test. | ||
| */ | ||
| @Rule | ||
| public Timeout timeout = Timeout.seconds(100); | ||
| private OzoneConfiguration conf; | ||
| private MiniOzoneCluster ozoneCluster = null; | ||
|
|
||
| @Before | ||
| public void setup() throws Exception { | ||
| conf = new OzoneConfiguration(); | ||
| conf.setBoolean(OZONE_SCM_HA_ENABLE_KEY, true); | ||
| conf.setBoolean( | ||
| ReconServerConfigKeys.OZONE_RECON_SCM_SNAPSHOT_ENABLED, true); | ||
| conf.setInt(ReconServerConfigKeys.OZONE_RECON_SCM_CONTAINER_THRESHOLD, 0); | ||
| conf.setInt(ScmConfigKeys.OZONE_DATANODE_PIPELINE_LIMIT, 5); | ||
| ozoneCluster = MiniOzoneCluster.newBuilder(conf) | ||
| .setNumDatanodes(4) | ||
| .includeRecon(true) | ||
| .build(); | ||
| ozoneCluster.waitForClusterToBeReady(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testScmHASnapshot() throws Exception { | ||
| TestReconScmSnapshot.testSnapshot(ozoneCluster); | ||
| } | ||
|
|
||
| @After | ||
| public void shutdown() throws Exception { | ||
| if (ozoneCluster != null) { | ||
| ozoneCluster.shutdown(); | ||
| } | ||
| } | ||
| } |
133 changes: 133 additions & 0 deletions
133
...ne/integration-test/src/test/java/org/apache/hadoop/ozone/recon/TestReconScmSnapshot.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,133 @@ | ||
| /** | ||
| * 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.ozone.recon; | ||
|
|
||
| import org.apache.hadoop.hdds.client.RatisReplicationConfig; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.hdds.scm.container.ContainerInfo; | ||
| import org.apache.hadoop.hdds.scm.container.ContainerManager; | ||
| import org.apache.hadoop.hdds.scm.pipeline.PipelineManager; | ||
| import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
| import org.apache.hadoop.ozone.recon.scm.ReconNodeManager; | ||
| import org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade; | ||
| import org.apache.ozone.test.GenericTestUtils; | ||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.Timeout; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| /** | ||
| * Test Recon SCM Snapshot Download implementation. | ||
| */ | ||
| public class TestReconScmSnapshot { | ||
| /** | ||
| * Set a timeout for each test. | ||
| */ | ||
| @Rule | ||
| public Timeout timeout = Timeout.seconds(100); | ||
| private OzoneConfiguration conf; | ||
| private MiniOzoneCluster ozoneCluster = null; | ||
|
|
||
| @Before | ||
| public void setup() throws Exception { | ||
| conf = new OzoneConfiguration(); | ||
| conf.setBoolean( | ||
| ReconServerConfigKeys.OZONE_RECON_SCM_SNAPSHOT_ENABLED, true); | ||
| conf.setInt(ReconServerConfigKeys.OZONE_RECON_SCM_CONTAINER_THRESHOLD, 0); | ||
| ozoneCluster = MiniOzoneCluster.newBuilder(conf) | ||
| .setNumDatanodes(4) | ||
| .includeRecon(true) | ||
| .build(); | ||
| ozoneCluster.waitForClusterToBeReady(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testScmSnapshot() throws Exception { | ||
| testSnapshot(ozoneCluster); | ||
| } | ||
|
|
||
| public static void testSnapshot(MiniOzoneCluster cluster) throws Exception{ | ||
| GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer | ||
| .captureLogs(LoggerFactory.getLogger( | ||
| ReconStorageContainerManagerFacade.class)); | ||
|
|
||
| List<ContainerInfo> reconContainers = cluster.getReconServer() | ||
| .getReconStorageContainerManager().getContainerManager() | ||
| .getContainers(); | ||
| assertEquals(0, reconContainers.size()); | ||
|
|
||
| ReconNodeManager nodeManager; | ||
| nodeManager = (ReconNodeManager) cluster.getReconServer() | ||
| .getReconStorageContainerManager().getScmNodeManager(); | ||
| long keyCountBefore = nodeManager.getNodeDBKeyCount(); | ||
|
|
||
| //Stopping Recon to add Containers in SCM | ||
| cluster.stopRecon(); | ||
|
|
||
| ContainerManager containerManager; | ||
| containerManager = cluster.getStorageContainerManager() | ||
| .getContainerManager(); | ||
|
|
||
| for (int i = 0; i < 10; i++) { | ||
| containerManager.allocateContainer(new RatisReplicationConfig( | ||
| HddsProtos.ReplicationFactor.ONE), "testOwner"); | ||
| } | ||
|
|
||
| cluster.startRecon(); | ||
|
|
||
| //ContainerCount after Recon DB is updated with SCM DB | ||
| containerManager = cluster.getStorageContainerManager() | ||
| .getContainerManager(); | ||
| ContainerManager reconContainerManager = cluster.getReconServer() | ||
| .getReconStorageContainerManager().getContainerManager(); | ||
| assertTrue(logCapturer.getOutput() | ||
| .contains("Recon Container Count: " + reconContainers.size() + | ||
| ", SCM Container Count: " + containerManager.getContainers().size())); | ||
| assertEquals(containerManager.getContainers().size(), | ||
| reconContainerManager.getContainers().size()); | ||
|
|
||
| //PipelineCount after Recon DB is updated with SCM DB | ||
| PipelineManager scmPipelineManager = cluster.getStorageContainerManager() | ||
| .getPipelineManager(); | ||
| PipelineManager reconPipelineManager = cluster.getReconServer() | ||
| .getReconStorageContainerManager().getPipelineManager(); | ||
| assertEquals(scmPipelineManager.getPipelines().size(), | ||
| reconPipelineManager.getPipelines().size()); | ||
|
|
||
| //NodeCount after Recon DB updated with SCM DB | ||
| nodeManager = (ReconNodeManager) cluster.getReconServer() | ||
| .getReconStorageContainerManager().getScmNodeManager(); | ||
| long keyCountAfter = nodeManager.getNodeDBKeyCount(); | ||
| assertEquals(keyCountAfter, keyCountBefore); | ||
| } | ||
|
|
||
| @After | ||
| public void shutdown() throws Exception { | ||
| if (ozoneCluster != null) { | ||
| ozoneCluster.shutdown(); | ||
| } | ||
| } | ||
| } |
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
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.