From 214112b2d706b301d18c4b270280cd7eee70e81e Mon Sep 17 00:00:00 2001 From: Mukul Kumar Singh Date: Thu, 7 Feb 2019 18:06:23 +0530 Subject: [PATCH] HDDS-1010. ContainerSet#getContainerMap should be renamed. Contributed by Supratim Deka. --- .../ozone/container/common/impl/ContainerSet.java | 3 ++- .../container/common/TestBlockDeletingService.java | 2 +- .../impl/TestContainerDeletionChoosingPolicy.java | 4 ++-- .../common/impl/TestContainerPersistence.java | 14 +++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java index 3c09f02eb0..aff22751bd 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java @@ -135,7 +135,8 @@ public Iterator> getContainerMapIterator() { * Return a copy of the containerMap. * @return containerMap */ - public Map getContainerMap() { + @VisibleForTesting + public Map getContainerMapCopy() { return ImmutableMap.copyOf(containerMap); } diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java index e8ae266597..27fe4ffedd 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java @@ -204,7 +204,7 @@ public void testBlockDeletion() throws Exception { MetadataStore meta = BlockUtils.getDB( (KeyValueContainerData) containerData.get(0), conf); - Map containerMap = containerSet.getContainerMap(); + Map containerMap = containerSet.getContainerMapCopy(); // NOTE: this test assumes that all the container is KetValueContainer and // have DeleteTransactionId in KetValueContainerData. If other // types is going to be added, this test should be checked. diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDeletionChoosingPolicy.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDeletionChoosingPolicy.java index 745f730151..f4b089b693 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDeletionChoosingPolicy.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerDeletionChoosingPolicy.java @@ -78,7 +78,7 @@ public void testRandomChoosingPolicy() throws IOException { KeyValueContainer container = new KeyValueContainer(data, conf); containerSet.addContainer(container); Assert.assertTrue( - containerSet.getContainerMap().containsKey(data.getContainerID())); + containerSet.getContainerMapCopy().containsKey(data.getContainerID())); } ContainerDeletionChoosingPolicy deletionPolicy = @@ -138,7 +138,7 @@ public void testTopNOrderedChoosingPolicy() throws IOException { KeyValueContainer container = new KeyValueContainer(data, conf); containerSet.addContainer(container); Assert.assertTrue( - containerSet.getContainerMap().containsKey(containerId)); + containerSet.getContainerMapCopy().containsKey(containerId)); } ContainerDeletionChoosingPolicy deletionPolicy = diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java index 8bc73d418d..f2e44cb2dd 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java @@ -177,7 +177,7 @@ private Container addContainer(ContainerSet cSet, long cID) public void testCreateContainer() throws Exception { long testContainerID = getTestContainerID(); addContainer(containerSet, testContainerID); - Assert.assertTrue(containerSet.getContainerMap() + Assert.assertTrue(containerSet.getContainerMapCopy() .containsKey(testContainerID)); KeyValueContainerData kvData = (KeyValueContainerData) containerSet.getContainer(testContainerID) @@ -226,14 +226,14 @@ public void testDeleteContainer() throws Exception { Container container2 = addContainer(containerSet, testContainerID2); - Assert.assertTrue(containerSet.getContainerMap() + Assert.assertTrue(containerSet.getContainerMapCopy() .containsKey(testContainerID1)); - Assert.assertTrue(containerSet.getContainerMap() + Assert.assertTrue(containerSet.getContainerMapCopy() .containsKey(testContainerID2)); container1.delete(); containerSet.removeContainer(testContainerID1); - Assert.assertFalse(containerSet.getContainerMap() + Assert.assertFalse(containerSet.getContainerMapCopy() .containsKey(testContainerID1)); // Adding block to a deleted container should fail. @@ -254,7 +254,7 @@ public void testDeleteContainer() throws Exception { exception.expectMessage( "Container cannot be deleted because it is not empty."); container2.delete(); - Assert.assertTrue(containerSet.getContainerMap() + Assert.assertTrue(containerSet.getContainerMapCopy() .containsKey(testContainerID1)); } @@ -762,8 +762,8 @@ public void testUpdateContainer() throws IOException { container.update(newMetadata, false); - Assert.assertEquals(1, containerSet.getContainerMap().size()); - Assert.assertTrue(containerSet.getContainerMap() + Assert.assertEquals(1, containerSet.getContainerMapCopy().size()); + Assert.assertTrue(containerSet.getContainerMapCopy() .containsKey(testContainerID)); // Verify in-memory map