Search in sources :

Example 1 with LogMetadataStore

use of org.apache.distributedlog.metadata.LogMetadataStore in project bookkeeper by apache.

the class TestFederatedZKLogMetadataStore method testCreateLog.

@Test(timeout = 60000)
public void testCreateLog() throws Exception {
    DistributedLogConfiguration conf = new DistributedLogConfiguration();
    conf.addConfiguration(baseConf);
    ZooKeeperClient anotherZkc = TestZooKeeperClientBuilder.newBuilder().uri(uri).sessionTimeoutMs(zkSessionTimeoutMs).build();
    FederatedZKLogMetadataStore anotherMetadataStore = new FederatedZKLogMetadataStore(conf, uri, anotherZkc, scheduler);
    for (int i = 0; i < 2 * maxLogsPerSubnamespace; i++) {
        LogMetadataStore createStore, checkStore;
        if (i % 2 == 0) {
            createStore = metadataStore;
            checkStore = anotherMetadataStore;
        } else {
            createStore = anotherMetadataStore;
            checkStore = metadataStore;
        }
        String logName = "test-create-log-" + i;
        URI logUri = Utils.ioResult(createStore.createLog(logName));
        Optional<URI> logLocation = Utils.ioResult(checkStore.getLogLocation(logName));
        assertTrue("Log " + logName + " doesn't exist", logLocation.isPresent());
        assertEquals("Different log location " + logLocation.get() + " is found", logUri, logLocation.get());
    }
    assertEquals(2, metadataStore.getSubnamespaces().size());
    assertEquals(2, anotherMetadataStore.getSubnamespaces().size());
}
Also used : DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) LogMetadataStore(org.apache.distributedlog.metadata.LogMetadataStore) ZooKeeperClient(org.apache.distributedlog.ZooKeeperClient) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)1 DistributedLogConfiguration (org.apache.distributedlog.DistributedLogConfiguration)1 ZooKeeperClient (org.apache.distributedlog.ZooKeeperClient)1 LogMetadataStore (org.apache.distributedlog.metadata.LogMetadataStore)1 Test (org.junit.Test)1