Search in sources :

Example 1 with ContainerKeyMapperTask

use of org.apache.hadoop.ozone.recon.tasks.ContainerKeyMapperTask in project ozone by apache.

the class TestContainerEndpoint method setUp.

@Before
public void setUp() throws Exception {
    // The following setup runs only once
    if (!isSetupDone) {
        initializeInjector();
        isSetupDone = true;
    }
    List<OmKeyLocationInfo> omKeyLocationInfoList = new ArrayList<>();
    BlockID blockID1 = new BlockID(1, 101);
    OmKeyLocationInfo omKeyLocationInfo1 = getOmKeyLocationInfo(blockID1, pipeline);
    omKeyLocationInfoList.add(omKeyLocationInfo1);
    BlockID blockID2 = new BlockID(2, 102);
    OmKeyLocationInfo omKeyLocationInfo2 = getOmKeyLocationInfo(blockID2, pipeline);
    omKeyLocationInfoList.add(omKeyLocationInfo2);
    OmKeyLocationInfoGroup omKeyLocationInfoGroup = new OmKeyLocationInfoGroup(0, omKeyLocationInfoList);
    // key = key_one, Blocks = [ {CID = 1, LID = 101}, {CID = 2, LID = 102} ]
    writeDataToOm(reconOMMetadataManager, "key_one", "bucketOne", "sampleVol", Collections.singletonList(omKeyLocationInfoGroup));
    List<OmKeyLocationInfoGroup> infoGroups = new ArrayList<>();
    BlockID blockID3 = new BlockID(1, 103);
    OmKeyLocationInfo omKeyLocationInfo3 = getOmKeyLocationInfo(blockID3, pipeline);
    List<OmKeyLocationInfo> omKeyLocationInfoListNew = new ArrayList<>();
    omKeyLocationInfoListNew.add(omKeyLocationInfo3);
    infoGroups.add(new OmKeyLocationInfoGroup(0, omKeyLocationInfoListNew));
    BlockID blockID4 = new BlockID(1, 104);
    OmKeyLocationInfo omKeyLocationInfo4 = getOmKeyLocationInfo(blockID4, pipeline);
    omKeyLocationInfoListNew = new ArrayList<>();
    omKeyLocationInfoListNew.add(omKeyLocationInfo4);
    infoGroups.add(new OmKeyLocationInfoGroup(1, omKeyLocationInfoListNew));
    // key = key_two, Blocks = [ {CID = 1, LID = 103}, {CID = 1, LID = 104} ]
    writeDataToOm(reconOMMetadataManager, "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(reconOMMetadataManager, "key_three", "bucketOne", "sampleVol", Collections.singletonList(omKeyLocationInfoGroup2));
    // Generate Recon container DB data.
    OMMetadataManager omMetadataManagerMock = mock(OMMetadataManager.class);
    Table tableMock = mock(Table.class);
    when(tableMock.getName()).thenReturn("KeyTable");
    when(omMetadataManagerMock.getKeyTable(getBucketLayout())).thenReturn(tableMock);
    ContainerKeyMapperTask containerKeyMapperTask = new ContainerKeyMapperTask(reconContainerMetadataManager);
    containerKeyMapperTask.reprocess(reconOMMetadataManager);
}
Also used : OmKeyLocationInfoGroup(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup) Table(org.apache.hadoop.hdds.utils.db.Table) ContainerKeyMapperTask(org.apache.hadoop.ozone.recon.tasks.ContainerKeyMapperTask) ArrayList(java.util.ArrayList) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) BlockID(org.apache.hadoop.hdds.client.BlockID) OMMetadataManagerTestUtils.getOmKeyLocationInfo(org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getOmKeyLocationInfo) OmKeyLocationInfo(org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 BlockID (org.apache.hadoop.hdds.client.BlockID)1 Table (org.apache.hadoop.hdds.utils.db.Table)1 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)1 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)1 OmKeyLocationInfoGroup (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup)1 OMMetadataManagerTestUtils.getOmKeyLocationInfo (org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getOmKeyLocationInfo)1 ReconOMMetadataManager (org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager)1 ContainerKeyMapperTask (org.apache.hadoop.ozone.recon.tasks.ContainerKeyMapperTask)1 Before (org.junit.Before)1