You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by gi...@apache.org on 2018/06/29 20:14:32 UTC
[41/50] [abbrv] hadoop git commit: HDDS-185:
TestCloseContainerByPipeline#testCloseContainerViaRatis fail intermittently.
Contributed by Shashikant Banerjee.
HDDS-185: TestCloseContainerByPipeline#testCloseContainerViaRatis fail intermittently. Contributed by Shashikant Banerjee.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/852ca6b4
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/852ca6b4
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/852ca6b4
Branch: refs/heads/HADOOP-15461
Commit: 852ca6b432a801df51f957a9b169483008e3c744
Parents: 2911943
Author: Nanda kumar <na...@apache.org>
Authored: Fri Jun 29 04:11:39 2018 +0530
Committer: Nanda kumar <na...@apache.org>
Committed: Fri Jun 29 04:11:39 2018 +0530
----------------------------------------------------------------------
.../TestCloseContainerByPipeline.java | 65 +++++++++++++++++---
1 file changed, 58 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/852ca6b4/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
index 9e8cb46..265c82b 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java
@@ -23,6 +23,8 @@ import org.apache.hadoop.hdds.client.ReplicationType;
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.container.ContainerID;
+import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerInfo;
import org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
import org.apache.hadoop.ozone.HddsDatanodeService;
import org.apache.hadoop.ozone.MiniOzoneCluster;
@@ -33,6 +35,7 @@ import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.container.common.helpers.ContainerData;
+import org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
import org.apache.hadoop.ozone.ksm.helpers.KsmKeyArgs;
import org.apache.hadoop.ozone.ksm.helpers.KsmKeyLocationInfo;
@@ -45,6 +48,7 @@ import org.junit.Test;
import java.io.IOException;
import java.util.List;
+import java.util.Random;
import java.util.concurrent.TimeoutException;
public class TestCloseContainerByPipeline {
@@ -89,6 +93,59 @@ public class TestCloseContainerByPipeline {
}
@Test
+ public void testIfCloseContainerCommandHandlerIsInvoked() throws Exception {
+ OzoneOutputStream key = objectStore.getVolume("test").getBucket("test")
+ .createKey("testCloseContainer", 1024, ReplicationType.STAND_ALONE,
+ ReplicationFactor.ONE);
+ key.write("standalone".getBytes());
+ key.close();
+
+ //get the name of a valid container
+ KsmKeyArgs keyArgs =
+ new KsmKeyArgs.Builder().setVolumeName("test").setBucketName("test")
+ .setType(HddsProtos.ReplicationType.STAND_ALONE)
+ .setFactor(HddsProtos.ReplicationFactor.ONE).setDataSize(1024)
+ .setKeyName("testCloseContainer").build();
+
+ KsmKeyLocationInfo ksmKeyLocationInfo =
+ cluster.getKeySpaceManager().lookupKey(keyArgs).getKeyLocationVersions()
+ .get(0).getBlocksLatestVersionOnly().get(0);
+
+ long containerID = ksmKeyLocationInfo.getContainerID();
+ List<DatanodeDetails> datanodes =
+ cluster.getStorageContainerManager().getContainerInfo(containerID)
+ .getPipeline().getMachines();
+ Assert.assertTrue(datanodes.size() == 1);
+
+ DatanodeDetails datanodeDetails = datanodes.get(0);
+ HddsDatanodeService datanodeService = null;
+ Assert
+ .assertFalse(isContainerClosed(cluster, containerID, datanodeDetails));
+ for (HddsDatanodeService datanodeServiceItr : cluster.getHddsDatanodes()) {
+ if (datanodeDetails.equals(datanodeServiceItr.getDatanodeDetails())) {
+ datanodeService = datanodeServiceItr;
+ break;
+ }
+ }
+ CommandHandler closeContainerHandler =
+ datanodeService.getDatanodeStateMachine().getCommandDispatcher()
+ .getCloseContainerHandler();
+ int lastInvocationCount = closeContainerHandler.getInvocationCount();
+ //send the order to close the container
+ cluster.getStorageContainerManager().getScmNodeManager()
+ .addDatanodeCommand(datanodeDetails.getUuid(),
+ new CloseContainerCommand(containerID,
+ HddsProtos.ReplicationType.STAND_ALONE));
+ GenericTestUtils
+ .waitFor(() -> isContainerClosed(cluster, containerID, datanodeDetails),
+ 500, 5 * 1000);
+ // Make sure the closeContainerCommandHandler is Invoked
+ Assert.assertTrue(
+ closeContainerHandler.getInvocationCount() > lastInvocationCount);
+
+ }
+
+ @Test
public void testCloseContainerViaStandaAlone()
throws IOException, TimeoutException, InterruptedException {
@@ -205,13 +262,7 @@ public class TestCloseContainerByPipeline {
containerData =
datanodeService.getDatanodeStateMachine().getContainer()
.getContainerManager().readContainer(containerID);
- if (!containerData.isOpen()) {
- // make sure the closeContainerHandler on the Datanode is invoked
- Assert.assertTrue(
- datanodeService.getDatanodeStateMachine().getCommandDispatcher()
- .getCloseContainerHandler().getInvocationCount() > 0);
- return true;
- }
+ return !containerData.isOpen();
}
} catch (StorageContainerException e) {
throw new AssertionError(e);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org