|
@@ -44,6 +44,7 @@ import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
|
|
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
|
|
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
|
|
import org.apache.hadoop.ozone.recon.AbstractOMMetadataManagerTest;
|
|
import org.apache.hadoop.ozone.recon.AbstractOMMetadataManagerTest;
|
|
import org.apache.hadoop.ozone.recon.ReconUtils;
|
|
import org.apache.hadoop.ozone.recon.ReconUtils;
|
|
|
|
+import org.apache.hadoop.ozone.recon.api.types.ContainerMetadata;
|
|
import org.apache.hadoop.ozone.recon.api.types.KeyMetadata;
|
|
import org.apache.hadoop.ozone.recon.api.types.KeyMetadata;
|
|
import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
|
|
import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager;
|
|
import org.apache.hadoop.ozone.recon.spi.ContainerDBServiceProvider;
|
|
import org.apache.hadoop.ozone.recon.spi.ContainerDBServiceProvider;
|
|
@@ -112,10 +113,6 @@ public class TestContainerKeyService extends AbstractOMMetadataManagerTest {
|
|
});
|
|
});
|
|
containerDbServiceProvider = injector.getInstance(
|
|
containerDbServiceProvider = injector.getInstance(
|
|
ContainerDBServiceProvider.class);
|
|
ContainerDBServiceProvider.class);
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testGetKeysForContainer() throws Exception {
|
|
|
|
|
|
|
|
//Write Data to OM
|
|
//Write Data to OM
|
|
Pipeline pipeline = getRandomPipeline();
|
|
Pipeline pipeline = getRandomPipeline();
|
|
@@ -162,6 +159,25 @@ public class TestContainerKeyService extends AbstractOMMetadataManagerTest {
|
|
writeDataToOm(omMetadataManager,
|
|
writeDataToOm(omMetadataManager,
|
|
"key_two", "bucketOne", "sampleVol", infoGroups);
|
|
"key_two", "bucketOne", "sampleVol", infoGroups);
|
|
|
|
|
|
|
|
+ List<OmKeyLocationInfo> omKeyLocationInfoList2 = new ArrayList<>();
|
|
|
|
+ BlockID blockID5 = new BlockID(2, 2);
|
|
|
|
+ OmKeyLocationInfo omKeyLocationInfo5 = getOmKeyLocationInfo(blockID5,
|
|
|
|
+ pipeline);
|
|
|
|
+ omKeyLocationInfoList2.add(omKeyLocationInfo5);
|
|
|
|
+
|
|
|
|
+ BlockID blockID6 = new BlockID(2, 3);
|
|
|
|
+ OmKeyLocationInfo omKeyLocationInfo6 = getOmKeyLocationInfo(blockID6,
|
|
|
|
+ pipeline);
|
|
|
|
+ omKeyLocationInfoList2.add(omKeyLocationInfo6);
|
|
|
|
+
|
|
|
|
+ OmKeyLocationInfoGroup omKeyLocationInfoGroup2 = new
|
|
|
|
+ OmKeyLocationInfoGroup(0, omKeyLocationInfoList2);
|
|
|
|
+
|
|
|
|
+ //key = key_three, Blocks = [ {CID = 2, LID = 2}, {CID = 2, LID = 3} ]
|
|
|
|
+ writeDataToOm(omMetadataManager,
|
|
|
|
+ "key_three", "bucketOne", "sampleVol",
|
|
|
|
+ Collections.singletonList(omKeyLocationInfoGroup2));
|
|
|
|
+
|
|
//Take snapshot of OM DB and copy over to Recon OM DB.
|
|
//Take snapshot of OM DB and copy over to Recon OM DB.
|
|
DBCheckpoint checkpoint = omMetadataManager.getStore()
|
|
DBCheckpoint checkpoint = omMetadataManager.getStore()
|
|
.getCheckpoint(true);
|
|
.getCheckpoint(true);
|
|
@@ -176,6 +192,10 @@ public class TestContainerKeyService extends AbstractOMMetadataManagerTest {
|
|
ContainerKeyMapperTask containerKeyMapperTask = new ContainerKeyMapperTask(
|
|
ContainerKeyMapperTask containerKeyMapperTask = new ContainerKeyMapperTask(
|
|
ozoneManagerServiceProvider, containerDbServiceProvider);
|
|
ozoneManagerServiceProvider, containerDbServiceProvider);
|
|
containerKeyMapperTask.run();
|
|
containerKeyMapperTask.run();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetKeysForContainer() {
|
|
|
|
|
|
Response response = containerKeyService.getKeysForContainer(1L);
|
|
Response response = containerKeyService.getKeysForContainer(1L);
|
|
|
|
|
|
@@ -208,6 +228,27 @@ public class TestContainerKeyService extends AbstractOMMetadataManagerTest {
|
|
assertTrue(keyMetadataList.isEmpty());
|
|
assertTrue(keyMetadataList.isEmpty());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetContainers() {
|
|
|
|
+
|
|
|
|
+ Response response = containerKeyService.getContainers();
|
|
|
|
+
|
|
|
|
+ List<ContainerMetadata> containers = new ArrayList<>(
|
|
|
|
+ (Collection<ContainerMetadata>) response.getEntity());
|
|
|
|
+
|
|
|
|
+ assertTrue(containers.size() == 2);
|
|
|
|
+
|
|
|
|
+ Iterator<ContainerMetadata> iterator = containers.iterator();
|
|
|
|
+
|
|
|
|
+ ContainerMetadata containerMetadata = iterator.next();
|
|
|
|
+ assertTrue(containerMetadata.getContainerID() == 1L);
|
|
|
|
+ assertTrue(containerMetadata.getNumberOfKeys() == 3L);
|
|
|
|
+
|
|
|
|
+ containerMetadata = iterator.next();
|
|
|
|
+ assertTrue(containerMetadata.getContainerID() == 2L);
|
|
|
|
+ assertTrue(containerMetadata.getNumberOfKeys() == 2L);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get Test OzoneConfiguration instance.
|
|
* Get Test OzoneConfiguration instance.
|
|
* @return OzoneConfiguration
|
|
* @return OzoneConfiguration
|