Search in sources :

Example 6 with ReconOMMetadataManager

use of org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager 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)

Example 7 with ReconOMMetadataManager

use of org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager in project ozone by apache.

the class MockOzoneServiceProvider method testSyncDataFromOMDeltaUpdates.

@Test
public void testSyncDataFromOMDeltaUpdates() throws Exception {
    // Non-Empty OM DB to start with.
    ReconOMMetadataManager omMetadataManager = getTestReconOmMetadataManager(initializeNewOmMetadataManager(temporaryFolder.newFolder()), temporaryFolder.newFolder());
    ReconTaskStatusDao reconTaskStatusDaoMock = mock(ReconTaskStatusDao.class);
    doNothing().when(reconTaskStatusDaoMock).update(any(ReconTaskStatus.class));
    ReconTaskController reconTaskControllerMock = getMockTaskController();
    when(reconTaskControllerMock.getReconTaskStatusDao()).thenReturn(reconTaskStatusDaoMock);
    doNothing().when(reconTaskControllerMock).consumeOMEvents(any(OMUpdateEventBatch.class), any(OMMetadataManager.class));
    OzoneManagerServiceProviderImpl ozoneManagerServiceProvider = new OzoneManagerServiceProviderImpl(configuration, omMetadataManager, reconTaskControllerMock, new ReconUtils(), ozoneManagerProtocol);
    OzoneManagerSyncMetrics metrics = ozoneManagerServiceProvider.getMetrics();
    // Should trigger delta updates.
    ozoneManagerServiceProvider.syncDataFromOM();
    ArgumentCaptor<ReconTaskStatus> captor = ArgumentCaptor.forClass(ReconTaskStatus.class);
    verify(reconTaskStatusDaoMock, times(1)).update(captor.capture());
    assertTrue(captor.getValue().getTaskName().equals(OmDeltaRequest.name()));
    verify(reconTaskControllerMock, times(1)).consumeOMEvents(any(OMUpdateEventBatch.class), any(OMMetadataManager.class));
    assertEquals(0, metrics.getNumSnapshotRequests().value());
}
Also used : ReconUtils(org.apache.hadoop.ozone.recon.ReconUtils) OzoneManagerSyncMetrics(org.apache.hadoop.ozone.recon.metrics.OzoneManagerSyncMetrics) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) ReconTaskController(org.apache.hadoop.ozone.recon.tasks.ReconTaskController) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) ReconTaskStatusDao(org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) OMUpdateEventBatch(org.apache.hadoop.ozone.recon.tasks.OMUpdateEventBatch) Test(org.junit.Test)

Example 8 with ReconOMMetadataManager

use of org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager in project ozone by apache.

the class TestReconTaskControllerImpl method testReInitializeTasks.

@Test
public void testReInitializeTasks() throws Exception {
    ReconOMMetadataManager omMetadataManagerMock = mock(ReconOMMetadataManager.class);
    ReconOmTask reconOmTaskMock = getMockTask("MockTask2");
    when(reconOmTaskMock.reprocess(omMetadataManagerMock)).thenReturn(new ImmutablePair<>("MockTask2", true));
    when(omMetadataManagerMock.getLastSequenceNumberFromDB()).thenReturn(100L);
    long startTime = System.currentTimeMillis();
    reconTaskController.registerTask(reconOmTaskMock);
    reconTaskController.reInitializeTasks(omMetadataManagerMock);
    long endTime = System.currentTimeMillis();
    verify(reconOmTaskMock, times(1)).reprocess(omMetadataManagerMock);
    verify(omMetadataManagerMock, times(1)).getLastSequenceNumberFromDB();
    ReconTaskStatus reconTaskStatus = reconTaskStatusDao.findById("MockTask2");
    long taskTimeStamp = reconTaskStatus.getLastUpdatedTimestamp();
    long seqNumber = reconTaskStatus.getLastUpdatedSeqNumber();
    Assert.assertTrue(startTime <= taskTimeStamp && taskTimeStamp <= endTime);
    Assert.assertEquals(seqNumber, omMetadataManagerMock.getLastSequenceNumberFromDB());
}
Also used : ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) AbstractReconSqlDBTest(org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest) Test(org.junit.Test)

Example 9 with ReconOMMetadataManager

use of org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager in project ozone by apache.

the class OMMetadataManagerTestUtils method getTestReconOmMetadataManager.

/**
 * Given an underlying OM DB, return an instance of Recon OM Metadata
 * manager.
 * @return ReconOMMetadataManager
 * @throws IOException when creating the RocksDB instance.
 */
public static ReconOMMetadataManager getTestReconOmMetadataManager(OMMetadataManager omMetadataManager, File reconOmDbDir) throws IOException {
    DBCheckpoint checkpoint = omMetadataManager.getStore().getCheckpoint(true);
    assertNotNull(checkpoint.getCheckpointLocation());
    OzoneConfiguration configuration = new OzoneConfiguration();
    configuration.set(OZONE_RECON_OM_SNAPSHOT_DB_DIR, reconOmDbDir.getAbsolutePath());
    ReconOMMetadataManager reconOMMetaMgr = new ReconOmMetadataManagerImpl(configuration, new ReconUtils());
    reconOMMetaMgr.start(configuration);
    reconOMMetaMgr.updateOmDB(checkpoint.getCheckpointLocation().toFile());
    return reconOMMetaMgr;
}
Also used : DBCheckpoint(org.apache.hadoop.hdds.utils.db.DBCheckpoint) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) ReconOmMetadataManagerImpl(org.apache.hadoop.ozone.recon.recovery.ReconOmMetadataManagerImpl)

Aggregations

ReconOMMetadataManager (org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager)9 Test (org.junit.Test)6 ReconUtils (org.apache.hadoop.ozone.recon.ReconUtils)4 ReconTaskController (org.apache.hadoop.ozone.recon.tasks.ReconTaskController)4 DBCheckpoint (org.apache.hadoop.hdds.utils.db.DBCheckpoint)3 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)3 ReconTaskStatus (org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 ReconUtils.createTarFile (org.apache.hadoop.ozone.recon.ReconUtils.createTarFile)2 OzoneManagerSyncMetrics (org.apache.hadoop.ozone.recon.metrics.OzoneManagerSyncMetrics)2 ReconTaskStatusDao (org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao)2 BufferedWriter (java.io.BufferedWriter)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 ArrayList (java.util.ArrayList)1 Response (javax.ws.rs.core.Response)1 BlockID (org.apache.hadoop.hdds.client.BlockID)1