Search in sources :

Example 6 with DLMetadata

use of org.apache.distributedlog.metadata.DLMetadata 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();
}
Also used : DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) URI(java.net.URI) DLMetadata(org.apache.distributedlog.metadata.DLMetadata) Test(org.junit.Test)

Aggregations

DLMetadata (org.apache.distributedlog.metadata.DLMetadata)6 URI (java.net.URI)4 Test (org.junit.Test)4 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)3 ZKException (org.apache.distributedlog.exceptions.ZKException)2 BKDLConfig (org.apache.distributedlog.impl.metadata.BKDLConfig)2