use of org.apache.cassandra.net.AsyncStreamingOutputPlus in project cassandra by apache.
the class ZeroCopyStreamingBenchmark method partialStreamWriter.
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void partialStreamWriter(BenchmarkState state) throws Exception {
EmbeddedChannel channel = createMockNettyChannel();
AsyncStreamingOutputPlus out = new AsyncStreamingOutputPlus(channel);
state.partialStreamWriter.write(out);
out.close();
channel.finishAndReleaseAll();
}
use of org.apache.cassandra.net.AsyncStreamingOutputPlus in project cassandra by apache.
the class CassandraEntireSSTableStreamWriterTest method testBlockWriterOverWire.
@Test
public void testBlockWriterOverWire() throws IOException {
StreamSession session = setupStreamingSessionForTest();
EmbeddedChannel channel = new EmbeddedChannel();
try (AsyncStreamingOutputPlus out = new AsyncStreamingOutputPlus(channel);
ComponentContext context = ComponentContext.create(descriptor)) {
CassandraEntireSSTableStreamWriter writer = new CassandraEntireSSTableStreamWriter(sstable, session, context);
writer.write(out);
Queue msgs = channel.outboundMessages();
assertTrue(msgs.peek() instanceof DefaultFileRegion);
}
}
use of org.apache.cassandra.net.AsyncStreamingOutputPlus in project cassandra by apache.
the class CassandraEntireSSTableStreamWriterTest method testBlockReadingAndWritingOverWire.
@Test
public void testBlockReadingAndWritingOverWire() throws Throwable {
StreamSession session = setupStreamingSessionForTest();
InetAddressAndPort peer = FBUtilities.getBroadcastAddressAndPort();
// This is needed as Netty releases the ByteBuffers as soon as the channel is flushed
ByteBuf serializedFile = Unpooled.buffer(8192);
EmbeddedChannel channel = createMockNettyChannel(serializedFile);
try (AsyncStreamingOutputPlus out = new AsyncStreamingOutputPlus(channel);
ComponentContext context = ComponentContext.create(descriptor)) {
CassandraEntireSSTableStreamWriter writer = new CassandraEntireSSTableStreamWriter(sstable, session, context);
writer.write(out);
session.prepareReceiving(new StreamSummary(sstable.metadata().id, 1, 5104));
CassandraStreamHeader header = CassandraStreamHeader.builder().withSSTableFormat(sstable.descriptor.formatType).withSSTableVersion(sstable.descriptor.version).withSSTableLevel(0).withEstimatedKeys(sstable.estimatedKeys()).withSections(Collections.emptyList()).withSerializationHeader(sstable.header.toComponent()).withComponentManifest(context.manifest()).isEntireSSTable(true).withFirstKey(sstable.first).withTableId(sstable.metadata().id).build();
CassandraEntireSSTableStreamReader reader = new CassandraEntireSSTableStreamReader(new StreamMessageHeader(sstable.metadata().id, peer, session.planId(), false, 0, 0, 0, null), header, session);
SSTableMultiWriter sstableWriter = reader.read(new DataInputBuffer(serializedFile.nioBuffer(), false));
Collection<SSTableReader> newSstables = sstableWriter.finished();
assertEquals(1, newSstables.size());
}
}
use of org.apache.cassandra.net.AsyncStreamingOutputPlus in project cassandra by apache.
the class EntireSSTableStreamingCorrectFilesCountTest method constructDataOutputStream.
private AsyncStreamingOutputPlus constructDataOutputStream() {
// This is needed as Netty releases the ByteBuffers as soon as the channel is flushed
ByteBuf serializedFile = Unpooled.buffer(8192);
EmbeddedChannel channel = createMockNettyChannel(serializedFile);
return new AsyncStreamingOutputPlus(channel) {
public void flush() throws IOException {
// NO-OP
}
};
}
use of org.apache.cassandra.net.AsyncStreamingOutputPlus in project cassandra by apache.
the class EntireSSTableStreamConcurrentComponentMutationTest method testStreamWithConcurrentComponentMutation.
private void testStreamWithConcurrentComponentMutation(Callable<?> runBeforeStreaming, Callable<?> runConcurrentWithStreaming) throws Throwable {
ByteBuf serializedFile = Unpooled.buffer(8192);
InetAddressAndPort peer = FBUtilities.getBroadcastAddressAndPort();
StreamSession session = setupStreamingSessionForTest();
Collection<OutgoingStream> outgoingStreams = store.getStreamManager().createOutgoingStreams(session, rangesAtEndpoint, NO_PENDING_REPAIR, PreviewKind.NONE);
CassandraOutgoingFile outgoingFile = (CassandraOutgoingFile) Iterables.getOnlyElement(outgoingStreams);
Future<?> streaming = executeAsync(() -> {
runBeforeStreaming.call();
try (AsyncStreamingOutputPlus out = new AsyncStreamingOutputPlus(createMockNettyChannel(serializedFile))) {
outgoingFile.write(session, out, MessagingService.current_version);
assertTrue(sstable.descriptor.getTemporaryFiles().isEmpty());
}
return null;
});
Future<?> concurrentMutations = executeAsync(runConcurrentWithStreaming);
streaming.get(3, TimeUnit.MINUTES);
concurrentMutations.get(3, TimeUnit.MINUTES);
session.prepareReceiving(new StreamSummary(sstable.metadata().id, 1, 5104));
StreamMessageHeader messageHeader = new StreamMessageHeader(sstable.metadata().id, peer, session.planId(), false, 0, 0, 0, null);
try (DataInputBuffer in = new DataInputBuffer(serializedFile.nioBuffer(), false)) {
CassandraStreamHeader header = CassandraStreamHeader.serializer.deserialize(in, MessagingService.current_version);
CassandraEntireSSTableStreamReader reader = new CassandraEntireSSTableStreamReader(messageHeader, header, session);
SSTableReader streamedSSTable = Iterables.getOnlyElement(reader.read(in).finished());
SSTableUtils.assertContentEquals(sstable, streamedSSTable);
}
}
Aggregations