use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class BigTableZeroCopyWriterTest method writeDataFile_RebufferingByteBufDataInputPlus.
@Test
public void writeDataFile_RebufferingByteBufDataInputPlus() {
try (AsyncStreamingInputPlus input = new AsyncStreamingInputPlus(new EmbeddedChannel())) {
writeDataTestCycle(buffer -> {
input.append(Unpooled.wrappedBuffer(buffer));
return input;
});
input.requestClosure();
}
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method consumeUntilTestCycle.
private void consumeUntilTestCycle(int nBuffs, int buffSize, int startOffset, int len) throws IOException {
inputPlus = new AsyncStreamingInputPlus(channel);
byte[] expectedBytes = new byte[len];
int count = 0;
for (int j = 0; j < nBuffs; j++) {
ByteBuf buf = channel.alloc().buffer(buffSize);
for (int i = 0; i < buf.capacity(); i++) {
buf.writeByte(j);
if (count >= startOffset && (count - startOffset) < len)
expectedBytes[count - startOffset] = (byte) j;
count++;
}
inputPlus.append(buf);
}
inputPlus.requestClosure();
TestableWritableByteChannel wbc = new TestableWritableByteChannel(len);
inputPlus.skipBytesFully(startOffset);
BufferedDataOutputStreamPlus writer = new BufferedDataOutputStreamPlus(wbc);
inputPlus.consume(buffer -> {
writer.write(buffer);
return buffer.remaining();
}, len);
writer.close();
Assert.assertEquals(String.format("Test with %d buffers starting at %d consuming %d bytes", nBuffs, startOffset, len), len, wbc.writtenBytes.readableBytes());
Assert.assertArrayEquals(expectedBytes, wbc.writtenBytes.array());
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method append_closed.
// @Test
// public void isOpen()
// {
// Assert.assertTrue(inputPlus.isOpen());
// inputPlus.requestClosure();
// Assert.assertFalse(inputPlus.isOpen());
// }
@Test
public void append_closed() {
inputPlus = new AsyncStreamingInputPlus(channel);
inputPlus.requestClosure();
inputPlus.close();
buf = channel.alloc().buffer(4);
assertFalse(inputPlus.append(buf));
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method available_HappyPath.
@Test
public void available_HappyPath() {
inputPlus = new AsyncStreamingInputPlus(channel);
int size = 4;
buf = channel.alloc().heapBuffer(size);
buf.writerIndex(size);
inputPlus.append(buf);
Assert.assertEquals(size, inputPlus.unsafeAvailable());
}
use of org.apache.cassandra.net.AsyncStreamingInputPlus in project cassandra by apache.
the class AsyncStreamingInputPlusTest method available_closed.
// @Test (expected = EOFException.class)
// public void read_closed() throws IOException
// {
// inputPlus.requestClosure();
// ByteBuffer buf = ByteBuffer.allocate(1);
// inputPlus.read(buf);
// }
@Test
public void available_closed() {
inputPlus = new AsyncStreamingInputPlus(channel);
inputPlus.requestClosure();
inputPlus.unsafeAvailable();
}
Aggregations