use of io.pravega.client.stream.impl.ByteBufferSerializer in project pravega by pravega.
the class AppendTest method appendALotOfData.
@Test(timeout = 100000)
public void appendALotOfData() {
String endpoint = "localhost";
String scope = "Scope";
String streamName = "appendALotOfData";
int port = TestUtils.getAvailableListenPort();
long heapSize = Runtime.getRuntime().maxMemory();
long messageSize = Math.min(1024 * 1024, heapSize / 20000);
ByteBuffer payload = ByteBuffer.allocate((int) messageSize);
StreamSegmentStore store = SERVICE_BUILDER.createStreamSegmentService();
TableStore tableStore = SERVICE_BUILDER.createTableStoreService();
@Cleanup("shutdown") InlineExecutor tokenExpiryExecutor = new InlineExecutor();
@Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, port, store, tableStore, tokenExpiryExecutor);
server.startListening();
ClientConfig config = ClientConfig.builder().build();
SocketConnectionFactoryImpl clientCF = new SocketConnectionFactoryImpl(config);
@Cleanup ConnectionPoolImpl connectionPool = new ConnectionPoolImpl(config, clientCF);
Controller controller = new MockController(endpoint, port, connectionPool, true);
@Cleanup StreamManagerImpl streamManager = new StreamManagerImpl(controller, connectionPool);
streamManager.createScope(scope);
@Cleanup ClientFactoryImpl clientFactory = new ClientFactoryImpl(scope, controller, config);
streamManager.createStream("Scope", streamName, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
@Cleanup EventStreamWriter<ByteBuffer> producer = clientFactory.createEventWriter(streamName, new ByteBufferSerializer(), EventWriterConfig.builder().build());
@Cleanup RawClient rawClient = new RawClient(new PravegaNodeUri(endpoint, port), connectionPool);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 100; j++) {
producer.writeEvent(payload.slice());
}
producer.flush();
long requestId = rawClient.getFlow().getNextSequenceNumber();
String scopedName = new Segment(scope, streamName, 0).getScopedName();
WireCommands.TruncateSegment request = new WireCommands.TruncateSegment(requestId, scopedName, i * 100L * (payload.remaining() + TYPE_PLUS_LENGTH_SIZE), "");
Reply reply = rawClient.sendRequest(requestId, request).join();
assertFalse(reply.toString(), reply.isFailure());
}
producer.close();
}
Aggregations