Search in sources :

Example 11 with ReconTaskStatus

use of org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus in project ozone by apache.

the class TestReconTaskControllerImpl method testBadBehavedTaskIsIgnored.

@Test
public void testBadBehavedTaskIsIgnored() throws Exception {
    String taskName = "Dummy_" + System.currentTimeMillis();
    DummyReconDBTask dummyReconDBTask = new DummyReconDBTask(taskName, DummyReconDBTask.TaskType.ALWAYS_FAIL);
    reconTaskController.registerTask(dummyReconDBTask);
    OMUpdateEventBatch omUpdateEventBatchMock = mock(OMUpdateEventBatch.class);
    when(omUpdateEventBatchMock.isEmpty()).thenReturn(false);
    when(omUpdateEventBatchMock.getLastSequenceNumber()).thenReturn(100L);
    OMMetadataManager omMetadataManagerMock = mock(OMMetadataManager.class);
    for (int i = 0; i < 2; i++) {
        reconTaskController.consumeOMEvents(omUpdateEventBatchMock, omMetadataManagerMock);
        assertFalse(reconTaskController.getRegisteredTasks().isEmpty());
        assertEquals(dummyReconDBTask, reconTaskController.getRegisteredTasks().get(dummyReconDBTask.getTaskName()));
    }
    // Should be ignored now.
    reconTaskController.consumeOMEvents(omUpdateEventBatchMock, omMetadataManagerMock);
    assertTrue(reconTaskController.getRegisteredTasks().isEmpty());
    reconTaskStatusDao = getDao(ReconTaskStatusDao.class);
    ReconTaskStatus dbRecord = reconTaskStatusDao.findById(taskName);
    Assert.assertEquals(taskName, dbRecord.getTaskName());
    Assert.assertEquals(Long.valueOf(0L), dbRecord.getLastUpdatedTimestamp());
    Assert.assertEquals(Long.valueOf(0L), dbRecord.getLastUpdatedSeqNumber());
}
Also used : ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) ReconTaskStatusDao(org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) AbstractReconSqlDBTest(org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest) Test(org.junit.Test)

Example 12 with ReconTaskStatus

use of org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus in project ozone by apache.

the class TestReconTaskControllerImpl method testFailedTaskRetryLogic.

@Test
public void testFailedTaskRetryLogic() throws Exception {
    String taskName = "Dummy_" + System.currentTimeMillis();
    DummyReconDBTask dummyReconDBTask = new DummyReconDBTask(taskName, DummyReconDBTask.TaskType.FAIL_ONCE);
    reconTaskController.registerTask(dummyReconDBTask);
    long currentTime = System.currentTimeMillis();
    OMUpdateEventBatch omUpdateEventBatchMock = mock(OMUpdateEventBatch.class);
    when(omUpdateEventBatchMock.isEmpty()).thenReturn(false);
    when(omUpdateEventBatchMock.getLastSequenceNumber()).thenReturn(100L);
    reconTaskController.consumeOMEvents(omUpdateEventBatchMock, mock(OMMetadataManager.class));
    assertFalse(reconTaskController.getRegisteredTasks().isEmpty());
    assertEquals(dummyReconDBTask, reconTaskController.getRegisteredTasks().get(dummyReconDBTask.getTaskName()));
    reconTaskStatusDao = getDao(ReconTaskStatusDao.class);
    ReconTaskStatus dbRecord = reconTaskStatusDao.findById(taskName);
    Assert.assertEquals(taskName, dbRecord.getTaskName());
    Assert.assertTrue(dbRecord.getLastUpdatedTimestamp() > currentTime);
    Assert.assertEquals(Long.valueOf(100L), dbRecord.getLastUpdatedSeqNumber());
}
Also used : ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) ReconTaskStatusDao(org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) AbstractReconSqlDBTest(org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest) Test(org.junit.Test)

Example 13 with ReconTaskStatus

use of org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus 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 14 with ReconTaskStatus

use of org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus in project ozone by apache.

the class TestReconTaskControllerImpl method testConsumeOMEvents.

@Test
public void testConsumeOMEvents() throws Exception {
    ReconOmTask reconOmTaskMock = getMockTask("MockTask");
    when(reconOmTaskMock.process(any(OMUpdateEventBatch.class))).thenReturn(new ImmutablePair<>("MockTask", true));
    reconTaskController.registerTask(reconOmTaskMock);
    OMUpdateEventBatch omUpdateEventBatchMock = mock(OMUpdateEventBatch.class);
    when(omUpdateEventBatchMock.getLastSequenceNumber()).thenReturn(100L);
    when(omUpdateEventBatchMock.isEmpty()).thenReturn(false);
    long startTime = System.currentTimeMillis();
    reconTaskController.consumeOMEvents(omUpdateEventBatchMock, mock(OMMetadataManager.class));
    verify(reconOmTaskMock, times(1)).process(any());
    long endTime = System.currentTimeMillis();
    reconTaskStatusDao = getDao(ReconTaskStatusDao.class);
    ReconTaskStatus reconTaskStatus = reconTaskStatusDao.findById("MockTask");
    long taskTimeStamp = reconTaskStatus.getLastUpdatedTimestamp();
    long seqNumber = reconTaskStatus.getLastUpdatedSeqNumber();
    Assert.assertTrue(startTime <= taskTimeStamp && taskTimeStamp <= endTime);
    Assert.assertEquals(seqNumber, omUpdateEventBatchMock.getLastSequenceNumber());
}
Also used : ReconOMMetadataManager(org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) ReconTaskStatusDao(org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) AbstractReconSqlDBTest(org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest) Test(org.junit.Test)

Example 15 with ReconTaskStatus

use of org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus in project ozone by apache.

the class ReconTaskControllerImpl method storeLastCompletedTransaction.

/**
 * Store the last completed event sequence number and timestamp to the DB
 * for that task.
 * @param taskName taskname to be updated.
 * @param lastSequenceNumber contains the new sequence number.
 */
private void storeLastCompletedTransaction(String taskName, long lastSequenceNumber) {
    ReconTaskStatus reconTaskStatusRecord = new ReconTaskStatus(taskName, System.currentTimeMillis(), lastSequenceNumber);
    reconTaskStatusDao.update(reconTaskStatusRecord);
}
Also used : ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus)

Aggregations

ReconTaskStatus (org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus)19 Test (org.junit.Test)12 ReconTaskStatusDao (org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao)11 AbstractReconSqlDBTest (org.apache.hadoop.ozone.recon.persistence.AbstractReconSqlDBTest)7 ReconOMMetadataManager (org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager)6 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)4 ArrayList (java.util.ArrayList)2 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)2 ContainerManager (org.apache.hadoop.hdds.scm.container.ContainerManager)2 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)2 ReconUtils (org.apache.hadoop.ozone.recon.ReconUtils)2 OzoneManagerSyncMetrics (org.apache.hadoop.ozone.recon.metrics.OzoneManagerSyncMetrics)2 ContainerHealthSchemaManager (org.apache.hadoop.ozone.recon.persistence.ContainerHealthSchemaManager)2 ReconStorageContainerManagerFacade (org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade)2 StorageContainerServiceProvider (org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider)2 OMUpdateEventBatch (org.apache.hadoop.ozone.recon.tasks.OMUpdateEventBatch)2 ReconTaskConfig (org.apache.hadoop.ozone.recon.tasks.ReconTaskConfig)2 ReconTaskController (org.apache.hadoop.ozone.recon.tasks.ReconTaskController)2 ContainerSchemaDefinition (org.hadoop.ozone.recon.schema.ContainerSchemaDefinition)2 UnhealthyContainersDao (org.hadoop.ozone.recon.schema.tables.daos.UnhealthyContainersDao)2