Search in sources :

Example 11 with WriteOp

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

the class TestStreamOp method testResponseSucceededThenFailed.

@Test(timeout = 60000)
public void testResponseSucceededThenFailed() throws Exception {
    AsyncLogWriter writer = mock(AsyncLogWriter.class);
    when(writer.write((LogRecord) any())).thenReturn(Future.value(new DLSN(1, 2, 3)));
    when(writer.getStreamName()).thenReturn("test");
    WriteOp writeOp = getWriteOp();
    writeOp.execute(writer, new Sequencer() {

        public long nextId() {
            return 0;
        }
    }, new Object());
    writeOp.fail(new InternalServerException("test2"));
    WriteResponse response = Await.result(writeOp.result());
    assertEquals(StatusCode.SUCCESS, response.getHeader().getCode());
}
Also used : Sequencer(com.twitter.distributedlog.util.Sequencer) DLSN(com.twitter.distributedlog.DLSN) WriteOp(com.twitter.distributedlog.service.stream.WriteOp) InternalServerException(com.twitter.distributedlog.exceptions.InternalServerException) WriteResponse(com.twitter.distributedlog.thrift.service.WriteResponse) AsyncLogWriter(com.twitter.distributedlog.AsyncLogWriter) Test(org.junit.Test)

Aggregations

WriteOp (com.twitter.distributedlog.service.stream.WriteOp)11 Test (org.junit.Test)10 WriteResponse (com.twitter.distributedlog.thrift.service.WriteResponse)8 StreamImpl (com.twitter.distributedlog.service.stream.StreamImpl)4 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)2 InternalServerException (com.twitter.distributedlog.exceptions.InternalServerException)2 OwnershipAcquireFailedException (com.twitter.distributedlog.exceptions.OwnershipAcquireFailedException)2 StreamUnavailableException (com.twitter.distributedlog.exceptions.StreamUnavailableException)2 ServerConfiguration (com.twitter.distributedlog.service.config.ServerConfiguration)2 Stream (com.twitter.distributedlog.service.stream.Stream)2 Future (com.twitter.util.Future)2 ArrayList (java.util.ArrayList)2 SettableFeature (org.apache.bookkeeper.feature.SettableFeature)2 AsyncLogWriter (com.twitter.distributedlog.AsyncLogWriter)1 DLSN (com.twitter.distributedlog.DLSN)1 BulkWriteOp (com.twitter.distributedlog.service.stream.BulkWriteOp)1 Sequencer (com.twitter.distributedlog.util.Sequencer)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 BoxedUnit (scala.runtime.BoxedUnit)1