use of org.apache.hadoop.ozone.recon.api.NSSummaryEndpoint in project ozone by apache.
the class TestReconWithOzoneManagerFSO method testNamespaceSummaryAPI.
@Test
public void testNamespaceSummaryAPI() throws Exception {
// add a vol, bucket and key
addKeys(0, 10, "dir");
OzoneManagerServiceProviderImpl impl = (OzoneManagerServiceProviderImpl) cluster.getReconServer().getOzoneManagerServiceProvider();
impl.syncDataFromOM();
ReconNamespaceSummaryManager namespaceSummaryManager = cluster.getReconServer().getReconNamespaceSummaryManager();
ReconOMMetadataManager omMetadataManagerInstance = (ReconOMMetadataManager) cluster.getReconServer().getOzoneManagerServiceProvider().getOMMetadataManagerInstance();
OzoneStorageContainerManager reconSCM = cluster.getReconServer().getReconStorageContainerManager();
NSSummaryEndpoint endpoint = new NSSummaryEndpoint(namespaceSummaryManager, omMetadataManagerInstance, reconSCM);
Response basicInfo = endpoint.getBasicInfo("/vol1/bucket1/dir1");
NamespaceSummaryResponse entity = (NamespaceSummaryResponse) basicInfo.getEntity();
Assert.assertSame(entity.getEntityType(), EntityType.DIRECTORY);
Assert.assertEquals(1, entity.getNumTotalKey());
Assert.assertEquals(0, entity.getNumTotalDir());
for (int i = 0; i < 10; i++) {
Assert.assertNotNull(impl.getOMMetadataManagerInstance().getVolumeTable().get("/vol" + i));
}
addKeys(10, 12, "dir");
impl.syncDataFromOM();
// test Recon is sync'ed with OM.
for (int i = 10; i < 12; i++) {
Assert.assertNotNull(impl.getOMMetadataManagerInstance().getVolumeTable().getSkipCache("/vol" + i));
}
// test root response
Response rootBasicRes = endpoint.getBasicInfo("/");
NamespaceSummaryResponse rootBasicEntity = (NamespaceSummaryResponse) rootBasicRes.getEntity();
Assert.assertSame(EntityType.ROOT, rootBasicEntity.getEntityType());
// one additional dummy volume at creation
Assert.assertEquals(13, rootBasicEntity.getNumVolume());
Assert.assertEquals(12, rootBasicEntity.getNumBucket());
Assert.assertEquals(12, rootBasicEntity.getNumTotalDir());
Assert.assertEquals(12, rootBasicEntity.getNumTotalKey());
}
Aggregations