Search in sources :

Example 21 with DistributedLogNamespace

use of com.twitter.distributedlog.namespace.DistributedLogNamespace in project distributedlog by twitter.

the class TestLogSegmentsZK method testCompleteLogSegmentConflicts.

@Test(timeout = 60000)
public void testCompleteLogSegmentConflicts() throws Exception {
    URI uri = createURI();
    String streamName = testName.getMethodName();
    DistributedLogConfiguration conf = new DistributedLogConfiguration().setLockTimeout(99999).setOutputBufferSize(0).setImmediateFlushEnabled(true).setEnableLedgerAllocatorPool(true).setLedgerAllocatorPoolName("test");
    DistributedLogNamespace namespace = DistributedLogNamespaceBuilder.newBuilder().conf(conf).uri(uri).build();
    namespace.createLog(streamName);
    DistributedLogManager dlm1 = namespace.openLog(streamName);
    DistributedLogManager dlm2 = namespace.openLog(streamName);
    // dlm1 is writing
    BKSyncLogWriter out1 = (BKSyncLogWriter) dlm1.startLogSegmentNonPartitioned();
    out1.write(DLMTestUtil.getLogRecordInstance(1));
    // before out1 complete, out2 is in on recovery
    // it completed the log segments which bump the version of /ledgers znode
    BKAsyncLogWriter out2 = (BKAsyncLogWriter) dlm2.startAsyncLogSegmentNonPartitioned();
    try {
        out1.closeAndComplete();
        fail("Should fail closeAndComplete since other people already completed it.");
    } catch (IOException ioe) {
    }
}
Also used : DistributedLogNamespace(com.twitter.distributedlog.namespace.DistributedLogNamespace) IOException(java.io.IOException) URI(java.net.URI) Test(org.junit.Test)

Aggregations

DistributedLogNamespace (com.twitter.distributedlog.namespace.DistributedLogNamespace)21 URI (java.net.URI)18 Test (org.junit.Test)13 DynamicDistributedLogConfiguration (com.twitter.distributedlog.config.DynamicDistributedLogConfiguration)4 LogEmptyException (com.twitter.distributedlog.exceptions.LogEmptyException)3 LogNotFoundException (com.twitter.distributedlog.exceptions.LogNotFoundException)3 IOException (java.io.IOException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)2 LockingException (com.twitter.distributedlog.exceptions.LockingException)2 BKDLConfig (com.twitter.distributedlog.metadata.BKDLConfig)2 DistributedLogManager (com.twitter.distributedlog.DistributedLogManager)1 ZooKeeperClient (com.twitter.distributedlog.ZooKeeperClient)1 AccessControlManager (com.twitter.distributedlog.acl.AccessControlManager)1 ZKAccessControl (com.twitter.distributedlog.acl.ZKAccessControl)1 NamespaceListener (com.twitter.distributedlog.callback.NamespaceListener)1 ConcurrentBaseConfiguration (com.twitter.distributedlog.config.ConcurrentBaseConfiguration)1 ConcurrentConstConfiguration (com.twitter.distributedlog.config.ConcurrentConstConfiguration)1 DLException (com.twitter.distributedlog.exceptions.DLException)1