HDDS-1010. ContainerSet#getContainerMap should be renamed. Contributed by Supratim Deka.

This commit is contained in:
Mukul Kumar Singh 2019-02-07 18:06:23 +05:30
parent de804e53b9
commit 214112b2d7
4 changed files with 12 additions and 11 deletions

View File

@ -135,7 +135,8 @@ public Iterator<Map.Entry<Long, Container>> getContainerMapIterator() {
* Return a copy of the containerMap.
* @return containerMap
*/
public Map<Long, Container> getContainerMap() {
@VisibleForTesting
public Map<Long, Container> getContainerMapCopy() {
return ImmutableMap.copyOf(containerMap);
}

View File

@ -204,7 +204,7 @@ public void testBlockDeletion() throws Exception {
MetadataStore meta = BlockUtils.getDB(
(KeyValueContainerData) containerData.get(0), conf);
Map<Long, Container> containerMap = containerSet.getContainerMap();
Map<Long, Container> 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.

View File

@ -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 =

View File

@ -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