Search in sources :

Example 1 with SCMDBDefinition

use of org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition in project ozone by apache.

the class TestDBDefinitionFactory method testGetDefinition.

@Test
public void testGetDefinition() {
    DBDefinition definition = DBDefinitionFactory.getDefinition(new OMDBDefinition().getName());
    assertTrue(definition instanceof OMDBDefinition);
    definition = DBDefinitionFactory.getDefinition(new SCMDBDefinition().getName());
    assertTrue(definition instanceof SCMDBDefinition);
    definition = DBDefinitionFactory.getDefinition(new ReconSCMDBDefinition().getName());
    assertTrue(definition instanceof ReconSCMDBDefinition);
    definition = DBDefinitionFactory.getDefinition(RECON_OM_SNAPSHOT_DB + "_1");
    assertTrue(definition instanceof OMDBDefinition);
    definition = DBDefinitionFactory.getDefinition(RECON_CONTAINER_KEY_DB + "_1");
    assertTrue(definition instanceof ReconDBDefinition);
    DBDefinitionFactory.setDnDBSchemaVersion("V2");
    definition = DBDefinitionFactory.getDefinition(Paths.get("/tmp/test-container.db"));
    assertTrue(definition instanceof DatanodeSchemaTwoDBDefinition);
    DBDefinitionFactory.setDnDBSchemaVersion("V1");
    definition = DBDefinitionFactory.getDefinition(Paths.get("/tmp/test-container.db"));
    assertTrue(definition instanceof DatanodeSchemaOneDBDefinition);
}
Also used : ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) DatanodeSchemaOneDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) DatanodeSchemaTwoDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition) ReconDBDefinition(org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition) DBDefinition(org.apache.hadoop.hdds.utils.db.DBDefinition) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) OMDBDefinition(org.apache.hadoop.ozone.om.codec.OMDBDefinition) DatanodeSchemaTwoDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaTwoDBDefinition) ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) ReconSCMDBDefinition(org.apache.hadoop.ozone.recon.scm.ReconSCMDBDefinition) ReconDBDefinition(org.apache.hadoop.ozone.recon.spi.impl.ReconDBDefinition) DatanodeSchemaOneDBDefinition(org.apache.hadoop.ozone.container.metadata.DatanodeSchemaOneDBDefinition) Test(org.junit.Test)

Example 2 with SCMDBDefinition

use of org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition 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());
}
Also used : StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) ContainerID(org.apache.hadoop.hdds.scm.container.ContainerID) DBCheckpoint(org.apache.hadoop.hdds.utils.db.DBCheckpoint) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) SCMStateMachine(org.apache.hadoop.hdds.scm.ha.SCMStateMachine) DBStore(org.apache.hadoop.hdds.utils.db.DBStore) Test(org.junit.Test)

Example 3 with SCMDBDefinition

use of org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition in project ozone by apache.

the class GeneratorScm method call.

@Override
public Void call() throws Exception {
    init();
    ConfigurationSource config = createOzoneConfiguration();
    scmDb = DBStoreBuilder.createDBStore(config, new SCMDBDefinition());
    containerStore = CONTAINERS.getTable(scmDb);
    timer = getMetrics().timer("scm-generator");
    runTests(this::writeScmData);
    scmDb.close();
    return null;
}
Also used : ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)

Example 4 with SCMDBDefinition

use of org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition in project ozone by apache.

the class SCMHAManagerImpl method installCheckpoint.

@Override
public TermIndex installCheckpoint(DBCheckpoint dbCheckpoint) throws Exception {
    Path checkpointLocation = dbCheckpoint.getCheckpointLocation();
    TransactionInfo checkpointTrxnInfo = HAUtils.getTrxnInfoFromCheckpoint(OzoneConfiguration.of(conf), checkpointLocation, new SCMDBDefinition());
    LOG.info("Installing checkpoint with SCMTransactionInfo {}", checkpointTrxnInfo);
    return installCheckpoint(checkpointLocation, checkpointTrxnInfo);
}
Also used : Path(java.nio.file.Path) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) TransactionInfo(org.apache.hadoop.hdds.utils.TransactionInfo)

Example 5 with SCMDBDefinition

use of org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition in project ozone by apache.

the class TestPipelinePlacementPolicy method init.

@Before
public void init() throws Exception {
    cluster = initTopology();
    // start with nodes with rack awareness.
    nodeManager = new MockNodeManager(cluster, getNodesWithRackAwareness(), false, PIPELINE_PLACEMENT_MAX_NODES_COUNT);
    conf = SCMTestUtils.getConf();
    conf.setInt(OZONE_DATANODE_PIPELINE_LIMIT, PIPELINE_LOAD_LIMIT);
    conf.setStorageSize(OZONE_DATANODE_RATIS_VOLUME_FREE_SPACE_MIN, 10, StorageUnit.MB);
    nodeManager.setNumPipelinePerDatanode(PIPELINE_LOAD_LIMIT);
    testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName() + UUID.randomUUID());
    conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
    dbStore = DBStoreBuilder.createDBStore(conf, new SCMDBDefinition());
    scmhaManager = MockSCMHAManager.getInstance(true);
    stateManager = PipelineStateManagerImpl.newBuilder().setPipelineStore(SCMDBDefinition.PIPELINES.getTable(dbStore)).setRatisServer(scmhaManager.getRatisServer()).setNodeManager(nodeManager).setSCMDBTransactionBuffer(scmhaManager.getDBTransactionBuffer()).build();
    placementPolicy = new PipelinePlacementPolicy(nodeManager, stateManager, conf);
}
Also used : SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) TestContainerManagerImpl(org.apache.hadoop.hdds.scm.container.TestContainerManagerImpl) MockNodeManager(org.apache.hadoop.hdds.scm.container.MockNodeManager) Before(org.junit.Before)

Aggregations

SCMDBDefinition (org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)20 Before (org.junit.Before)11 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)9 MockNodeManager (org.apache.hadoop.hdds.scm.container.MockNodeManager)6 TestContainerManagerImpl (org.apache.hadoop.hdds.scm.container.TestContainerManagerImpl)5 MockSCMHAManager (org.apache.hadoop.hdds.scm.ha.MockSCMHAManager)5 SCMHAManager (org.apache.hadoop.hdds.scm.ha.SCMHAManager)5 MockPipelineManager (org.apache.hadoop.hdds.scm.pipeline.MockPipelineManager)5 Path (java.nio.file.Path)4 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)4 IOException (java.io.IOException)3 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)3 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)3 PipelineManager (org.apache.hadoop.hdds.scm.pipeline.PipelineManager)3 TransactionInfo (org.apache.hadoop.hdds.utils.TransactionInfo)3 Test (org.junit.Test)3 File (java.io.File)2 SCMServiceManager (org.apache.hadoop.hdds.scm.ha.SCMServiceManager)2 SequenceIdGenerator (org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator)2 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)2