use of org.apache.hadoop.hdds.scm.metadata.SCMDBTransactionBufferImpl in project ozone by apache.
the class TestSequenceIDGenerator method testSequenceIDGenUponNonRatis.
@Test
public void testSequenceIDGenUponNonRatis() throws Exception {
OzoneConfiguration conf = SCMTestUtils.getConf();
SCMMetadataStore scmMetadataStore = new SCMMetadataStoreImpl(conf);
scmMetadataStore.start(conf);
SCMHAManager scmHAManager = MockSCMHAManager.getInstance(true, new SCMDBTransactionBufferImpl());
SequenceIdGenerator sequenceIdGen = new SequenceIdGenerator(conf, scmHAManager, scmMetadataStore.getSequenceIdTable());
// the first batch is [1, 1000]
Assert.assertEquals(1L, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(2L, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(3L, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(1L, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(2L, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(3L, sequenceIdGen.getNextId("otherKey"));
// default batchSize is 1000, the next batch is [1001, 2000]
sequenceIdGen.invalidateBatch();
Assert.assertEquals(1001, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(1002, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(1003, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(1001, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(1002, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(1003, sequenceIdGen.getNextId("otherKey"));
// default batchSize is 1000, the next batch is [2001, 3000]
sequenceIdGen.invalidateBatch();
Assert.assertEquals(2001, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(2002, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(2003, sequenceIdGen.getNextId("someKey"));
Assert.assertEquals(2001, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(2002, sequenceIdGen.getNextId("otherKey"));
Assert.assertEquals(2003, sequenceIdGen.getNextId("otherKey"));
}
use of org.apache.hadoop.hdds.scm.metadata.SCMDBTransactionBufferImpl in project ozone by apache.
the class TestReplicationManager method createReplicationManager.
private void createReplicationManager(ReplicationManagerConfiguration rmConf) throws InterruptedException, IOException {
OzoneConfiguration config = new OzoneConfiguration();
testDir = GenericTestUtils.getTestDir(TestContainerManagerImpl.class.getSimpleName());
config.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
config.setTimeDuration(HddsConfigKeys.HDDS_SCM_WAIT_TIME_AFTER_SAFE_MODE_EXIT, 0, TimeUnit.SECONDS);
config.setFromObject(rmConf);
SCMHAManager scmHAManager = MockSCMHAManager.getInstance(true, new SCMDBTransactionBufferImpl());
dbStore = DBStoreBuilder.createDBStore(config, new SCMDBDefinition());
replicationManager = new ReplicationManager(config, containerManager, containerPlacementPolicy, eventQueue, SCMContext.emptyContext(), serviceManager, nodeManager, clock, scmHAManager, SCMDBDefinition.MOVE.getTable(dbStore));
serviceManager.notifyStatusChanged();
scmLogs.clearOutput();
Thread.sleep(100L);
}
Aggregations