Search in sources :

Example 1 with LogMetadataStore

use of com.twitter.distributedlog.metadata.LogMetadataStore in project distributedlog by twitter.

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 = FutureUtils.result(createStore.createLog(logName));
        Optional<URI> logLocation = FutureUtils.result(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(com.twitter.distributedlog.DistributedLogConfiguration) LogMetadataStore(com.twitter.distributedlog.metadata.LogMetadataStore) ZooKeeperClient(com.twitter.distributedlog.ZooKeeperClient) URI(java.net.URI) Test(org.junit.Test)

Aggregations

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