Search in sources :

Example 6 with StreamImpl

use of com.twitter.distributedlog.service.stream.StreamImpl in project distributedlog by twitter.

the class TestDistributedLogService method testFailRequestsDuringClosing.

@Test(timeout = 60000)
public void testFailRequestsDuringClosing() throws Exception {
    String streamName = testName.getMethodName();
    StreamImpl s = createUnstartedStream(service, streamName);
    Future<Void> closeFuture = s.requestClose("close");
    assertTrue("Stream " + streamName + " should be set to " + StreamStatus.CLOSING, StreamStatus.CLOSING == s.getStatus() || StreamStatus.CLOSED == s.getStatus());
    WriteOp op1 = createWriteOp(service, streamName, 0L);
    s.submit(op1);
    WriteResponse response1 = Await.result(op1.result());
    assertEquals("Op should fail with " + StatusCode.STREAM_UNAVAILABLE + " if it is closing", StatusCode.STREAM_UNAVAILABLE, response1.getHeader().getCode());
    Await.result(closeFuture);
    assertEquals("Stream " + streamName + " should be set to " + StreamStatus.CLOSED, StreamStatus.CLOSED, s.getStatus());
    WriteOp op2 = createWriteOp(service, streamName, 1L);
    s.submit(op2);
    WriteResponse response2 = Await.result(op2.result());
    assertEquals("Op should fail with " + StatusCode.STREAM_UNAVAILABLE + " if it is closed", StatusCode.STREAM_UNAVAILABLE, response2.getHeader().getCode());
}
Also used : WriteOp(com.twitter.distributedlog.service.stream.WriteOp) StreamImpl(com.twitter.distributedlog.service.stream.StreamImpl) WriteResponse(com.twitter.distributedlog.thrift.service.WriteResponse) Test(org.junit.Test)

Example 7 with StreamImpl

use of com.twitter.distributedlog.service.stream.StreamImpl in project distributedlog by twitter.

the class TestDistributedLogService method createUnstartedStream.

private StreamImpl createUnstartedStream(DistributedLogServiceImpl service, String name) throws Exception {
    StreamImpl stream = (StreamImpl) service.newStream(name);
    stream.initialize();
    return stream;
}
Also used : StreamImpl(com.twitter.distributedlog.service.stream.StreamImpl)

Aggregations

StreamImpl (com.twitter.distributedlog.service.stream.StreamImpl)7 WriteResponse (com.twitter.distributedlog.thrift.service.WriteResponse)6 Test (org.junit.Test)6 WriteOp (com.twitter.distributedlog.service.stream.WriteOp)4 Future (com.twitter.util.Future)4 ArrayList (java.util.ArrayList)4 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)2 StreamManagerImpl (com.twitter.distributedlog.service.stream.StreamManagerImpl)2 OwnershipAcquireFailedException (com.twitter.distributedlog.exceptions.OwnershipAcquireFailedException)1 ServerConfiguration (com.twitter.distributedlog.service.config.ServerConfiguration)1 Stream (com.twitter.distributedlog.service.stream.Stream)1 HeartbeatOptions (com.twitter.distributedlog.thrift.service.HeartbeatOptions)1 WriteContext (com.twitter.distributedlog.thrift.service.WriteContext)1 List (java.util.List)1