use of io.pravega.segmentstore.contracts.tables.TableStore 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();
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class ReadTest method testEventPointer.
@Test(timeout = 10000)
public void testEventPointer() throws ReinitializationRequiredException, NoSuchEventException {
String endpoint = "localhost";
String streamName = "testEventPointer";
String readerName = "reader";
String readerGroup = "testEventPointer-group";
int port = TestUtils.getAvailableListenPort();
String testString = "Hello world ";
String scope = "Scope1";
StreamSegmentStore store = SERVICE_BUILDER.createStreamSegmentService();
TableStore tableStore = SERVICE_BUILDER.createTableStoreService();
@Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, port, store, tableStore, NoOpScheduledExecutor.get());
server.startListening();
@Cleanup MockStreamManager streamManager = new MockStreamManager(scope, endpoint, port);
@Cleanup MockClientFactory clientFactory = streamManager.getClientFactory();
ReaderGroupConfig groupConfig = ReaderGroupConfig.builder().disableAutomaticCheckpoints().stream(Stream.of(scope, streamName)).build();
streamManager.createScope(scope);
streamManager.createStream(scope, streamName, null);
streamManager.createReaderGroup(readerGroup, groupConfig);
JavaSerializer<String> serializer = new JavaSerializer<>();
@Cleanup EventStreamWriter<String> producer = clientFactory.createEventWriter(streamName, serializer, EventWriterConfig.builder().build());
for (int i = 0; i < 100; i++) {
producer.writeEvent(testString + i);
}
producer.flush();
@Cleanup EventStreamReader<String> reader = clientFactory.createReader(readerName, readerGroup, serializer, ReaderConfig.builder().build());
for (int i = 0; i < 100; i++) {
EventPointer pointer = reader.readNextEvent(5000).getEventPointer();
String read = reader.fetchEvent(pointer);
assertEquals(testString + i, read);
}
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class BoundedStreamReaderTest method setUp.
@Before
public void setUp() throws Exception {
super.before();
zkTestServer = new TestingServerStarter().start();
serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
serviceBuilder.initialize();
StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
TableStore tableStore = serviceBuilder.createTableStoreService();
server = new PravegaConnectionListener(false, servicePort, store, tableStore, serviceBuilder.getLowPriorityExecutor());
server.startListening();
controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
controllerWrapper.awaitRunning();
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class CheckpointTest method testMoreReadersThanSegments.
@Test(timeout = 20000)
public void testMoreReadersThanSegments() throws ReinitializationRequiredException, InterruptedException, ExecutionException, TimeoutException {
String endpoint = "localhost";
String streamName = "testMoreReadersThanSegments";
String readerGroupName = "testMoreReadersThanSegments-group";
int port = TestUtils.getAvailableListenPort();
String testString = "Hello world\n";
String scope = "Scope1";
StreamSegmentStore store = SERVICE_BUILDER.createStreamSegmentService();
TableStore tableStore = SERVICE_BUILDER.createTableStoreService();
@Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, port, store, tableStore, SERVICE_BUILDER.getLowPriorityExecutor());
server.startListening();
@Cleanup MockStreamManager streamManager = new MockStreamManager(scope, endpoint, port);
@Cleanup MockClientFactory clientFactory = streamManager.getClientFactory();
ReaderGroupConfig groupConfig = ReaderGroupConfig.builder().stream(Stream.of(scope, streamName)).build();
streamManager.createScope(scope);
streamManager.createStream(scope, streamName, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
streamManager.createReaderGroup(readerGroupName, groupConfig);
@Cleanup ReaderGroup readerGroup = streamManager.getReaderGroup(readerGroupName);
JavaSerializer<String> serializer = new JavaSerializer<>();
@Cleanup EventStreamWriter<String> producer = clientFactory.createEventWriter(streamName, serializer, EventWriterConfig.builder().build());
producer.writeEvent(testString);
producer.writeEvent(testString);
producer.writeEvent(testString);
producer.flush();
AtomicLong clock = new AtomicLong();
@Cleanup EventStreamReader<String> reader1 = clientFactory.createReader("reader1", readerGroupName, serializer, ReaderConfig.builder().build(), clock::get, clock::get);
@Cleanup EventStreamReader<String> reader2 = clientFactory.createReader("reader2", readerGroupName, serializer, ReaderConfig.builder().build(), clock::get, clock::get);
clock.addAndGet(CLOCK_ADVANCE_INTERVAL);
@Cleanup("shutdown") final InlineExecutor backgroundExecutor = new InlineExecutor();
CompletableFuture<Checkpoint> checkpoint = readerGroup.initiateCheckpoint("Checkpoint", backgroundExecutor);
assertFalse(checkpoint.isDone());
EventRead<String> read = reader1.readNextEvent(60000);
assertTrue(read.isCheckpoint());
assertEquals("Checkpoint", read.getCheckpointName());
assertNull(read.getEvent());
read = reader2.readNextEvent(60000);
assertTrue(read.isCheckpoint());
assertEquals("Checkpoint", read.getCheckpointName());
assertNull(read.getEvent());
read = reader1.readNextEvent(100);
assertFalse(read.isCheckpoint());
assertEquals(testString, read.getEvent());
read = reader2.readNextEvent(100);
assertFalse(read.isCheckpoint());
assertNull(read.getEvent());
Checkpoint cpResult = checkpoint.get(5, TimeUnit.SECONDS);
assertTrue(checkpoint.isDone());
assertEquals("Checkpoint", cpResult.getName());
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class ControllerFailoverTest method setup.
@Before
public void setup() throws Exception {
// 1. Start ZK
zkTestServer = new TestingServerStarter().start();
// 2. Start Pravega SSS
serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
serviceBuilder.initialize();
StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
TableStore tableStore = serviceBuilder.createTableStoreService();
server = new PravegaConnectionListener(false, servicePort, store, tableStore, serviceBuilder.getLowPriorityExecutor());
server.startListening();
}
Aggregations