use of org.apache.distributedlog.common.config.ConcurrentConstConfiguration 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.ConcurrentConstConfiguration 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.ConcurrentConstConfiguration in project bookkeeper by apache.
the class TestDynamicDistributedLogConfiguration method testDefaults.
@Test(timeout = 20000)
public void testDefaults() throws Exception {
// Default config defines retention period plus two other params, but eaves ack quorum unspecified
DistributedLogConfiguration underlyingConfig = new DistributedLogConfiguration();
underlyingConfig.setRetentionPeriodHours(99);
underlyingConfig.setProperty("rpsHardWriteLimit", 99);
ConcurrentConstConfiguration defaultConfig = new ConcurrentConstConfiguration(underlyingConfig);
DynamicDistributedLogConfiguration config = new DynamicDistributedLogConfiguration(defaultConfig);
assertEquals(99, config.getRetentionPeriodHours());
assertEquals(99, config.getRpsHardWriteLimit());
config.setProperty(DistributedLogConfiguration.BKDL_RETENTION_PERIOD_IN_HOURS, 5);
// Config checks primary then secondary then const defaults
assertEquals(5, config.getRetentionPeriodHours());
assertEquals(99, config.getRpsHardWriteLimit());
}
Aggregations