use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class WatermarkingTest method recreateStreamWatermarkTest.
@Test(timeout = 120000)
public void recreateStreamWatermarkTest() throws Exception {
StreamConfiguration config = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(5)).build();
ClientConfig clientConfig = ClientConfig.builder().controllerURI(PRAVEGA.getControllerURI()).build();
@Cleanup StreamManager streamManager = StreamManager.create(clientConfig);
// then delete stream and move to next iteration and verify that watermarks are generated.
for (int i = 0; i < 2; i++) {
String scope = "scope";
String stream = "recreateStreamWatermarkTest";
streamManager.createScope(scope);
streamManager.createStream(scope, stream, config);
// create writer
@Cleanup EventStreamClientFactory clientFactory = EventStreamClientFactory.withScope(scope, clientConfig);
JavaSerializer<Long> javaSerializer = new JavaSerializer<>();
@Cleanup EventStreamWriter<Long> writer = clientFactory.createEventWriter(stream, javaSerializer, EventWriterConfig.builder().build());
AtomicBoolean stopFlag = new AtomicBoolean(false);
// write events
CompletableFuture<Void> writerFuture = writeEvents(writer, stopFlag);
@Cleanup SynchronizerClientFactory syncClientFactory = SynchronizerClientFactory.withScope(scope, clientConfig);
String markStream = NameUtils.getMarkStreamForStream(stream);
@Cleanup RevisionedStreamClient<Watermark> watermarkReader = syncClientFactory.createRevisionedStreamClient(markStream, new WatermarkSerializer(), SynchronizerConfig.builder().build());
LinkedBlockingQueue<Watermark> watermarks = new LinkedBlockingQueue<>();
fetchWatermarks(watermarkReader, watermarks, stopFlag);
AssertExtensions.assertEventuallyEquals(true, () -> watermarks.size() >= 2, 100000);
// stop run and seal and delete stream
stopFlag.set(true);
writerFuture.join();
streamManager.sealStream(scope, stream);
streamManager.deleteStream(scope, stream);
}
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class LargeEventTest method createScopeStream.
private void createScopeStream(String scope, String stream, StreamConfiguration config) {
ClientConfig clientConfig = ClientConfig.builder().build();
try (ConnectionPool cp = new ConnectionPoolImpl(clientConfig, new SocketConnectionFactoryImpl(clientConfig));
StreamManager streamManager = new StreamManagerImpl(controller, cp)) {
// create a scope
Boolean createScopeStatus = streamManager.createScope(scope);
log.info("Create Scope status {}.", createScopeStatus);
// create a stream
Boolean createStreamStatus = streamManager.createStream(scope, stream, config);
log.info("Create Stream status {}.", createStreamStatus);
}
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class ControllerFailoverTest method testSessionExpiryTolerance.
private void testSessionExpiryTolerance(final ControllerWrapper controllerWrapper, final int controllerPort) throws Exception {
controllerWrapper.awaitRunning();
// Simulate ZK session timeout
controllerWrapper.forceClientSessionExpiry();
// Now, that session has expired, lets do some operations.
controllerWrapper.awaitPaused();
controllerWrapper.awaitRunning();
URI controllerURI = URI.create("tcp://localhost:" + controllerPort);
@Cleanup StreamManager streamManager = StreamManager.create(ClientConfig.builder().controllerURI(controllerURI).build());
// Create scope
streamManager.createScope(SCOPE);
// Create stream
StreamConfiguration streamConfiguration = StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build();
streamManager.createStream(SCOPE, STREAM, streamConfiguration);
streamManager.sealStream(SCOPE, STREAM);
streamManager.deleteStream(SCOPE, STREAM);
streamManager.deleteScope(SCOPE);
controllerWrapper.close();
controllerWrapper.awaitTerminated();
}
use of io.pravega.client.admin.StreamManager in project pravega by pravega.
the class ControllerStreamMetadataTest method streamManagerImpltest.
@Test(timeout = 10000)
public void streamManagerImpltest() {
ClientConfig config = ClientConfig.builder().build();
@Cleanup ConnectionPool cp = new ConnectionPoolImpl(config, new SocketConnectionFactoryImpl(config));
@Cleanup StreamManager streamManager = new StreamManagerImpl(controller, cp);
// Create and delete scope
assertTrue(streamManager.createScope(SCOPE));
assertTrue(streamManager.deleteScope(SCOPE));
// Create scope twice
assertTrue(streamManager.createScope(SCOPE));
assertFalse(streamManager.createScope(SCOPE));
assertTrue(streamManager.deleteScope(SCOPE));
// Delete twice
assertFalse(streamManager.deleteScope(SCOPE));
}
Aggregations