use of org.apache.distributedlog.DistributedLogConfiguration in project bookkeeper by apache.
the class TestZkMetadataResolver method testFederatedNamespace.
@Test(timeout = 60000)
public void testFederatedNamespace() throws Exception {
DistributedLogConfiguration dlConf = new DistributedLogConfiguration();
URI uri = createURI("/messaging/distributedlog-testfederatednamespace/dl1");
DLMetadata meta1 = DLMetadata.create(new BKDLConfig("127.0.0.1:7000", "ledgers"));
meta1.create(uri);
BKDLConfig read1 = BKDLConfig.resolveDLConfig(zkc, uri);
BKDLConfig.propagateConfiguration(read1, dlConf);
assertTrue(dlConf.getCreateStreamIfNotExists());
BKDLConfig.clearCachedDLConfigs();
DLMetadata meta2 = DLMetadata.create(new BKDLConfig("127.0.0.1:7000", "ledgers").setFederatedNamespace(true));
meta2.update(uri);
BKDLConfig read2 = BKDLConfig.resolveDLConfig(zkc, uri);
BKDLConfig.propagateConfiguration(read2, dlConf);
assertFalse(dlConf.getCreateStreamIfNotExists());
BKDLConfig.clearCachedDLConfigs();
DLMetadata meta3 = DLMetadata.create(new BKDLConfig("127.0.0.1:7000", "ledgers").setFederatedNamespace(false));
meta3.update(uri);
BKDLConfig read3 = BKDLConfig.resolveDLConfig(zkc, uri);
BKDLConfig.propagateConfiguration(read3, dlConf);
// if it is non-federated namespace, it won't change the create stream behavior.
assertFalse(dlConf.getCreateStreamIfNotExists());
BKDLConfig.clearCachedDLConfigs();
}
use of org.apache.distributedlog.DistributedLogConfiguration in project bookkeeper by apache.
the class TestFederatedZKLogMetadataStore method testZooKeeperSessionExpired.
@Test(timeout = 60000)
public void testZooKeeperSessionExpired() throws Exception {
Set<String> allLogs = createLogs(2 * maxLogsPerSubnamespace, "test-zookeeper-session-expired-");
TestNamespaceListenerWithExpectedSize listener = new TestNamespaceListenerWithExpectedSize(2 * maxLogsPerSubnamespace + 1);
metadataStore.registerNamespaceListener(listener);
ZooKeeperClientUtils.expireSession(zkc, BKNamespaceDriver.getZKServersFromDLUri(uri), zkSessionTimeoutMs);
String testLogName = "test-log-name";
allLogs.add(testLogName);
DistributedLogConfiguration anotherConf = new DistributedLogConfiguration();
anotherConf.addConfiguration(baseConf);
ZooKeeperClient anotherZkc = TestZooKeeperClientBuilder.newBuilder().uri(uri).sessionTimeoutMs(zkSessionTimeoutMs).build();
FederatedZKLogMetadataStore anotherMetadataStore = new FederatedZKLogMetadataStore(anotherConf, uri, anotherZkc, scheduler);
Utils.ioResult(anotherMetadataStore.createLog(testLogName));
listener.waitForDone();
Set<String> receivedLogs = listener.getResult();
assertEquals(2 * maxLogsPerSubnamespace + 1, receivedLogs.size());
assertEquals(allLogs, receivedLogs);
}
use of org.apache.distributedlog.DistributedLogConfiguration in project bookkeeper by apache.
the class TestFederatedZKLogMetadataStore method setup.
@Before
public void setup() throws Exception {
zkc = TestZooKeeperClientBuilder.newBuilder().uri(createDLMURI("/")).sessionTimeoutMs(zkSessionTimeoutMs).build();
scheduler = OrderedScheduler.newSchedulerBuilder().name("test-zk-logmetadata-store").numThreads(2).build();
DistributedLogConfiguration conf = new DistributedLogConfiguration();
conf.addConfiguration(baseConf);
this.uri = createDLMURI("/" + runtime.getMethodName());
FederatedZKLogMetadataStore.createFederatedNamespace(uri, zkc);
metadataStore = new FederatedZKLogMetadataStore(conf, uri, zkc, scheduler);
}
use of org.apache.distributedlog.DistributedLogConfiguration in project bookkeeper by apache.
the class TestLedgerAllocator method testAllocatorWithoutEnoughBookies.
@Test(timeout = 60000)
public void testAllocatorWithoutEnoughBookies() throws Exception {
String allocationPath = "/allocator-without-enough-bookies";
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.addConfiguration(conf);
confLocal.setEnsembleSize(numBookies * 2);
confLocal.setWriteQuorumSize(numBookies * 2);
SimpleLedgerAllocator allocator1 = createAllocator(allocationPath, confLocal);
allocator1.allocate();
ZKTransaction txn1 = newTxn();
try {
Utils.ioResult(allocator1.tryObtain(txn1, NULL_LISTENER));
fail("Should fail allocating ledger if there aren't enough bookies");
} catch (AllocationException ioe) {
// expected
assertEquals(Phase.ERROR, ioe.getPhase());
}
byte[] data = zkc.get().getData(allocationPath, false, null);
assertEquals(0, data.length);
}
use of org.apache.distributedlog.DistributedLogConfiguration 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