Search in sources :

Example 1 with SCMDBTransactionBufferImpl

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"));
}
Also used : SCMMetadataStoreImpl(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl) SCMDBTransactionBufferImpl(org.apache.hadoop.hdds.scm.metadata.SCMDBTransactionBufferImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) SCMMetadataStore(org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore) Test(org.junit.Test)

Example 2 with SCMDBTransactionBufferImpl

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);
}
Also used : SCMHAManager(org.apache.hadoop.hdds.scm.ha.SCMHAManager) MockSCMHAManager(org.apache.hadoop.hdds.scm.ha.MockSCMHAManager) SCMDBDefinition(org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition) SCMDBTransactionBufferImpl(org.apache.hadoop.hdds.scm.metadata.SCMDBTransactionBufferImpl) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration)

Aggregations

OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 SCMDBTransactionBufferImpl (org.apache.hadoop.hdds.scm.metadata.SCMDBTransactionBufferImpl)2 MockSCMHAManager (org.apache.hadoop.hdds.scm.ha.MockSCMHAManager)1 SCMHAManager (org.apache.hadoop.hdds.scm.ha.SCMHAManager)1 SCMDBDefinition (org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition)1 SCMMetadataStore (org.apache.hadoop.hdds.scm.metadata.SCMMetadataStore)1 SCMMetadataStoreImpl (org.apache.hadoop.hdds.scm.metadata.SCMMetadataStoreImpl)1 Test (org.junit.Test)1