use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class HealthyReadOnlyNodeHandler method onMessage.
@Override
public void onMessage(DatanodeDetails datanodeDetails, EventPublisher publisher) {
LOG.info("Datanode {} moved to HEALTHY READONLY state.", datanodeDetails);
Set<PipelineID> pipelineIDs = nodeManager.getPipelines(datanodeDetails);
for (PipelineID id : pipelineIDs) {
LOG.info("Closing pipeline {} which uses HEALTHY READONLY datanode {} ", id, datanodeDetails);
try {
pipelineManager.closePipeline(pipelineManager.getPipeline(id), false);
} catch (IOException ex) {
LOG.error("Failed to close pipeline {} which uses HEALTHY READONLY " + "datanode {}: ", id, datanodeDetails, ex);
}
}
// add node back if it is not present in networkTopology
NetworkTopology nt = nodeManager.getClusterNetworkTopologyMap();
if (!nt.contains(datanodeDetails)) {
nt.add(datanodeDetails);
// make sure after DN is added back into topology, DatanodeDetails
// instance returned from nodeStateManager has parent correctly set.
Preconditions.checkNotNull(nodeManager.getNodeByUuid(datanodeDetails.getUuidString()).getParent());
}
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class StaleNodeHandler method onMessage.
@Override
public void onMessage(DatanodeDetails datanodeDetails, EventPublisher publisher) {
Set<PipelineID> pipelineIds = nodeManager.getPipelines(datanodeDetails);
LOG.info("Datanode {} moved to stale state. Finalizing its pipelines {}", datanodeDetails, pipelineIds);
for (PipelineID pipelineID : pipelineIds) {
try {
Pipeline pipeline = pipelineManager.getPipeline(pipelineID);
pipelineManager.closePipeline(pipeline, true);
} catch (IOException e) {
LOG.info("Could not finalize pipeline={} for dn={}", pipelineID, datanodeDetails);
}
}
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class StartDatanodeAdminHandler method onMessage.
@Override
public void onMessage(DatanodeDetails datanodeDetails, EventPublisher publisher) {
Set<PipelineID> pipelineIds = nodeManager.getPipelines(datanodeDetails);
LOG.info("Admin start on datanode {}. Finalizing its pipelines {}", datanodeDetails, pipelineIds);
for (PipelineID pipelineID : pipelineIds) {
try {
Pipeline pipeline = pipelineManager.getPipeline(pipelineID);
pipelineManager.closePipeline(pipeline, false);
} catch (IOException e) {
LOG.info("Could not finalize pipeline={} for dn={}", pipelineID, datanodeDetails);
}
}
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class TestSCMInstallSnapshot method testInstallCheckPoint.
@Test
public void testInstallCheckPoint() throws Exception {
DBCheckpoint checkpoint = downloadSnapshot();
StorageContainerManager scm = cluster.getStorageContainerManager();
DBStore db = HAUtils.loadDB(conf, checkpoint.getCheckpointLocation().getParent().toFile(), checkpoint.getCheckpointLocation().getFileName().toString(), new SCMDBDefinition());
// Hack the transaction index in the checkpoint so as to ensure the
// checkpointed transaction index is higher than when it was downloaded
// from.
Assert.assertNotNull(db);
HAUtils.getTransactionInfoTable(db, new SCMDBDefinition()).put(OzoneConsts.TRANSACTION_INFO_KEY, TransactionInfo.builder().setCurrentTerm(10).setTransactionIndex(100).build());
db.close();
ContainerID cid = scm.getContainerManager().getContainers().get(0).containerID();
PipelineID pipelineID = scm.getPipelineManager().getPipelines().get(0).getId();
scm.getScmMetadataStore().getPipelineTable().delete(pipelineID);
scm.getContainerManager().deleteContainer(cid);
Assert.assertNull(scm.getScmMetadataStore().getPipelineTable().get(pipelineID));
Assert.assertFalse(scm.getContainerManager().containerExist(cid));
SCMStateMachine sm = scm.getScmHAManager().getRatisServer().getSCMStateMachine();
sm.pause();
sm.setInstallingDBCheckpoint(checkpoint);
sm.reinitialize();
Assert.assertNotNull(scm.getScmMetadataStore().getPipelineTable().get(pipelineID));
Assert.assertNotNull(scm.getScmMetadataStore().getContainerTable().get(cid));
Assert.assertTrue(scm.getPipelineManager().containsPipeline(pipelineID));
Assert.assertTrue(scm.getContainerManager().containerExist(cid));
Assert.assertEquals(100, scm.getScmMetadataStore().getTransactionInfoTable().get(OzoneConsts.TRANSACTION_INFO_KEY).getTransactionIndex());
Assert.assertEquals(100, scm.getScmHAManager().asSCMHADBTransactionBuffer().getLatestTrxInfo().getTermIndex().getIndex());
}
use of org.apache.hadoop.hdds.scm.pipeline.PipelineID in project ozone by apache.
the class TestReconPipelineReportHandler method testProcessPipelineReport.
@Test
public void testProcessPipelineReport() throws IOException {
// Check with pipeline which does not exist in Recon.
Pipeline pipeline = getRandomPipeline();
PipelineID pipelineID = pipeline.getId();
HddsProtos.PipelineID pipelineIDProto = pipelineID.getProtobuf();
ReconPipelineManager reconPipelineManagerMock = mock(ReconPipelineManager.class);
when(reconPipelineManagerMock.getPipeline(pipelineID)).thenReturn(pipeline);
StorageContainerServiceProvider scmServiceProviderMock = mock(StorageContainerServiceProvider.class);
when(scmServiceProviderMock.getPipeline(pipelineIDProto)).thenReturn(pipeline);
OzoneConfiguration configuration = new OzoneConfiguration();
ReconPipelineReportHandler handler = new ReconPipelineReportHandler(new ReconSafeModeManager(), reconPipelineManagerMock, SCMContext.emptyContext(), configuration, scmServiceProviderMock);
EventPublisher eventPublisherMock = mock(EventPublisher.class);
PipelineReport report = mock(PipelineReport.class);
when(report.getPipelineID()).thenReturn(pipelineIDProto);
handler.processPipelineReport(report, pipeline.getNodes().get(0), eventPublisherMock);
// Verify that the new pipeline was added to pipeline manager.
verify(reconPipelineManagerMock, times(1)).addPipeline(pipeline);
verify(reconPipelineManagerMock, times(1)).getPipeline(pipelineID);
// Check with pipeline which already exists in Recon.
pipeline = getRandomPipeline();
pipelineID = pipeline.getId();
pipelineIDProto = pipelineID.getProtobuf();
when(reconPipelineManagerMock.containsPipeline(pipelineID)).thenReturn(true);
when(reconPipelineManagerMock.getPipeline(pipelineID)).thenReturn(pipeline);
when(report.getPipelineID()).thenReturn(pipelineIDProto);
handler.processPipelineReport(report, pipeline.getNodes().get(0), eventPublisherMock);
// Verify that the pipeline was not added to pipeline manager.
verify(reconPipelineManagerMock, times(0)).addPipeline(pipeline);
verify(reconPipelineManagerMock, times(1)).getPipeline(pipelineID);
}
Aggregations