use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestAsyncReaderWriter method testCreateLogStreamWithDifferentReplicationFactor.
@Test(timeout = 60000)
public void testCreateLogStreamWithDifferentReplicationFactor() throws Exception {
String name = runtime.getMethodName();
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.addConfiguration(testConf);
confLocal.setOutputBufferSize(0);
confLocal.setImmediateFlushEnabled(false);
confLocal.setPeriodicFlushFrequencyMilliSeconds(0);
ConcurrentBaseConfiguration baseConf = new ConcurrentConstConfiguration(confLocal);
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(baseConf);
dynConf.setProperty(DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE, DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT - 1);
URI uri = createDLMURI("/" + name);
ensureURICreated(uri);
Namespace namespace = NamespaceBuilder.newBuilder().conf(confLocal).uri(uri).build();
// use the pool
DistributedLogManager dlm = namespace.openLog(name + "-pool");
AsyncLogWriter writer = dlm.startAsyncLogSegmentNonPartitioned();
Utils.ioResult(writer.write(DLMTestUtil.getLogRecordInstance(1L)));
List<LogSegmentMetadata> segments = dlm.getLogSegments();
assertEquals(1, segments.size());
long ledgerId = segments.get(0).getLogSegmentId();
LedgerHandle lh = ((BKNamespaceDriver) namespace.getNamespaceDriver()).getReaderBKC().get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8));
LedgerMetadata metadata = BookKeeperAccessor.getLedgerMetadata(lh);
assertEquals(DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT, metadata.getEnsembleSize());
lh.close();
Utils.close(writer);
dlm.close();
// use customized configuration
dlm = namespace.openLog(name + "-custom", java.util.Optional.empty(), java.util.Optional.of(dynConf), java.util.Optional.empty());
writer = dlm.startAsyncLogSegmentNonPartitioned();
Utils.ioResult(writer.write(DLMTestUtil.getLogRecordInstance(1L)));
segments = dlm.getLogSegments();
assertEquals(1, segments.size());
ledgerId = segments.get(0).getLogSegmentId();
lh = ((BKNamespaceDriver) namespace.getNamespaceDriver()).getReaderBKC().get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8));
metadata = BookKeeperAccessor.getLedgerMetadata(lh);
assertEquals(DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT - 1, metadata.getEnsembleSize());
lh.close();
Utils.close(writer);
dlm.close();
namespace.close();
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testGetRetentionPeriodHours.
@Test(timeout = 20000)
public void testGetRetentionPeriodHours() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
// get default value
assertEquals(BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT, dynConf.getRetentionPeriodHours());
// get value from old key of default config
defaultConfig.setProperty(BKDL_RETENTION_PERIOD_IN_HOURS_OLD, BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 1);
assertEquals(BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 1, dynConf.getRetentionPeriodHours());
// get value from new key of default config
defaultConfig.setProperty(BKDL_RETENTION_PERIOD_IN_HOURS, BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 2);
assertEquals(BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 2, dynConf.getRetentionPeriodHours());
// get value from old key of dynamic config
dynConf.setProperty(BKDL_RETENTION_PERIOD_IN_HOURS_OLD, BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 3);
assertEquals(BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 3, dynConf.getRetentionPeriodHours());
// get value from new key of default config
dynConf.setProperty(BKDL_RETENTION_PERIOD_IN_HOURS, BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 4);
assertEquals(BKDL_RETENTION_PERIOD_IN_HOURS_DEFAULT + 4, dynConf.getRetentionPeriodHours());
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testGetOutputBufferSize.
@Test(timeout = 20000)
public void testGetOutputBufferSize() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
// get default value
assertEquals(BKDL_OUTPUT_BUFFER_SIZE_DEFAULT, dynConf.getOutputBufferSize());
// get value from old key of default config
defaultConfig.setProperty(BKDL_OUTPUT_BUFFER_SIZE_OLD, BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 1);
assertEquals(BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 1, dynConf.getOutputBufferSize());
// get value from new key of default config
defaultConfig.setProperty(BKDL_OUTPUT_BUFFER_SIZE, BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 2);
assertEquals(BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 2, dynConf.getOutputBufferSize());
// get value from old key of dynamic config
dynConf.setProperty(BKDL_OUTPUT_BUFFER_SIZE_OLD, BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 3);
assertEquals(BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 3, dynConf.getOutputBufferSize());
// get value from new key of default config
dynConf.setProperty(BKDL_OUTPUT_BUFFER_SIZE, BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 4);
assertEquals(BKDL_OUTPUT_BUFFER_SIZE_DEFAULT + 4, dynConf.getOutputBufferSize());
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicConfigurationFactory method getConfigFactory.
private DynamicConfigurationFactory getConfigFactory(File configFile) {
String streamConfigPath = configFile.getParent();
ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1);
ConcurrentBaseConfiguration defaultConf = new ConcurrentConstConfiguration(new DistributedLogConfiguration());
return new DynamicConfigurationFactory(executorService, 100, TimeUnit.MILLISECONDS);
}
use of org.apache.distributedlog.common.config.ConcurrentBaseConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testGetReadAheadMaxRecords.
@Test(timeout = 20000)
public void testGetReadAheadMaxRecords() {
ConcurrentBaseConfiguration defaultConfig = new ConcurrentBaseConfiguration();
DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConfig);
// get default value
assertEquals(BKDL_READAHEAD_MAX_RECORDS_DEFAULT, dynConf.getReadAheadMaxRecords());
// get value from old key of default config
defaultConfig.setProperty(BKDL_READAHEAD_MAX_RECORDS_OLD, BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 1);
assertEquals(BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 1, dynConf.getReadAheadMaxRecords());
// get value from new key of default config
defaultConfig.setProperty(BKDL_READAHEAD_MAX_RECORDS, BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 2);
assertEquals(BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 2, dynConf.getReadAheadMaxRecords());
// get value from old key of dynamic config
dynConf.setProperty(BKDL_READAHEAD_MAX_RECORDS_OLD, BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 3);
assertEquals(BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 3, dynConf.getReadAheadMaxRecords());
// get value from new key of default config
dynConf.setProperty(BKDL_READAHEAD_MAX_RECORDS, BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 4);
assertEquals(BKDL_READAHEAD_MAX_RECORDS_DEFAULT + 4, dynConf.getReadAheadMaxRecords());
}
Aggregations