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