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());
}
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;
}
Aggregations