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);
}
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());
}
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());
}
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;
}
Aggregations