Search in sources :

Example 1 with InputTimeoutException

use of org.apache.cassandra.net.AsyncStreamingInputPlus.InputTimeoutException 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)1 InputTimeoutException (org.apache.cassandra.net.AsyncStreamingInputPlus.InputTimeoutException)1 Test (org.junit.Test)1