Skip to content

Commit

Permalink
HDDS-32. Fix TestContainerDeletionChoosingPolicy#testTopNOrderedChoos…
Browse files Browse the repository at this point in the history
…ingPolicy.

Contributed by Mukul Kumar Singh.
  • Loading branch information
anuengineer committed May 12, 2018
1 parent cd8b9e9 commit 53c8ebc
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -28,6 +28,7 @@
import java.util.Random; import java.util.Random;


import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.hadoop.hdds.scm.TestUtils; import org.apache.hadoop.hdds.scm.TestUtils;
import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.hdfs.server.datanode.StorageLocation; import org.apache.hadoop.hdfs.server.datanode.StorageLocation;
Expand Down Expand Up @@ -138,14 +139,14 @@ public void testTopNOrderedChoosingPolicy() throws IOException {


int numContainers = 10; int numContainers = 10;
Random random = new Random(); Random random = new Random();
Map<String, Integer> name2Count = new HashMap<>(); Map<Long, Integer> name2Count = new HashMap<>();
// create [numContainers + 1] containers // create [numContainers + 1] containers
for (int i = 0; i <= numContainers; i++) { for (int i = 0; i <= numContainers; i++) {
String containerName = OzoneUtils.getRequestID(); long containerId = RandomUtils.nextLong();
ContainerData data = new ContainerData(new Long(i), conf); ContainerData data = new ContainerData(containerId, conf);
containerManager.createContainer(data); containerManager.createContainer(data);
Assert.assertTrue( Assert.assertTrue(
containerManager.getContainerMap().containsKey(containerName)); containerManager.getContainerMap().containsKey(containerId));


// don't create deletion blocks in the last container. // don't create deletion blocks in the last container.
if (i == numContainers) { if (i == numContainers) {
Expand All @@ -155,7 +156,7 @@ public void testTopNOrderedChoosingPolicy() throws IOException {
// create random number of deletion blocks and write to container db // create random number of deletion blocks and write to container db
int deletionBlocks = random.nextInt(numContainers) + 1; int deletionBlocks = random.nextInt(numContainers) + 1;
// record <ContainerName, DeletionCount> value // record <ContainerName, DeletionCount> value
name2Count.put(containerName, deletionBlocks); name2Count.put(containerId, deletionBlocks);
for (int j = 0; j <= deletionBlocks; j++) { for (int j = 0; j <= deletionBlocks; j++) {
MetadataStore metadata = KeyUtils.getDB(data, conf); MetadataStore metadata = KeyUtils.getDB(data, conf);
String blk = "blk" + i + "-" + j; String blk = "blk" + i + "-" + j;
Expand Down

0 comments on commit 53c8ebc

Please sign in to comment.