Search in sources :

Example 11 with AsyncStreamingInputPlus

use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.

the class AsyncStreamingInputPlusTest method rebufferTimeout.

@Test
public void rebufferTimeout() throws IOException {
    long timeoutMillis = 1000;
    inputPlus = new AsyncStreamingInputPlus(channel, timeoutMillis, TimeUnit.MILLISECONDS);
    long startNanos = nanoTime();
    try {
        inputPlus.readInt();
        Assert.fail("should not have been able to read from the queue");
    } catch (InputTimeoutException e) {
    // this is the success case, and is expected. any other exception is a failure.
    }
    long durationNanos = nanoTime() - startNanos;
    Assert.assertTrue(TimeUnit.MILLISECONDS.toNanos(timeoutMillis) <= durationNanos);
}
Also used : AsyncStreamingInputPlus(org.apache.cassandra.net.AsyncStreamingInputPlus) InputTimeoutException(org.apache.cassandra.net.AsyncStreamingInputPlus.InputTimeoutException) Test(org.junit.Test)

Aggregations

AsyncStreamingInputPlus (org.apache.cassandra.net.AsyncStreamingInputPlus)11 Test (org.junit.Test)8 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 ByteBuf (io.netty.buffer.ByteBuf)2 SSTableMultiWriter (org.apache.cassandra.io.sstable.SSTableMultiWriter)2 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)2 BufferedDataOutputStreamPlus (org.apache.cassandra.io.util.BufferedDataOutputStreamPlus)1 InputTimeoutException (org.apache.cassandra.net.AsyncStreamingInputPlus.InputTimeoutException)1