Search in sources :

Example 56 with StreamManager

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);
    }
}
Also used : EventStreamClientFactory(io.pravega.client.EventStreamClientFactory) WatermarkSerializer(io.pravega.client.watermark.WatermarkSerializer) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Cleanup(lombok.Cleanup) JavaSerializer(io.pravega.client.stream.impl.JavaSerializer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SynchronizerClientFactory(io.pravega.client.SynchronizerClientFactory) StreamManager(io.pravega.client.admin.StreamManager) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) AtomicLong(java.util.concurrent.atomic.AtomicLong) ClientConfig(io.pravega.client.ClientConfig) Watermark(io.pravega.shared.watermarks.Watermark) Test(org.junit.Test)

Example 57 with StreamManager

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);
    }
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) StreamManager(io.pravega.client.admin.StreamManager) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) StreamManagerImpl(io.pravega.client.admin.impl.StreamManagerImpl) ClientConfig(io.pravega.client.ClientConfig) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 58 with StreamManager

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();
}
Also used : StreamManager(io.pravega.client.admin.StreamManager) StreamConfiguration(io.pravega.client.stream.StreamConfiguration) URI(java.net.URI) Cleanup(lombok.Cleanup)

Example 59 with StreamManager

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));
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) StreamManager(io.pravega.client.admin.StreamManager) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) StreamManagerImpl(io.pravega.client.admin.impl.StreamManagerImpl) ClientConfig(io.pravega.client.ClientConfig) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Aggregations

StreamManager (io.pravega.client.admin.StreamManager)59 Cleanup (lombok.Cleanup)54 Test (org.junit.Test)44 ClientConfig (io.pravega.client.ClientConfig)32 StreamConfiguration (io.pravega.client.stream.StreamConfiguration)31 ReaderGroupManager (io.pravega.client.admin.ReaderGroupManager)24 StreamManagerImpl (io.pravega.client.admin.impl.StreamManagerImpl)22 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)20 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)19 ConnectionPool (io.pravega.client.connection.impl.ConnectionPool)18 Stream (io.pravega.client.stream.Stream)17 EventStreamClientFactory (io.pravega.client.EventStreamClientFactory)15 ReaderGroupConfig (io.pravega.client.stream.ReaderGroupConfig)15 ReaderGroupManagerImpl (io.pravega.client.admin.impl.ReaderGroupManagerImpl)12 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)12 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)12 URI (java.net.URI)12 ClientFactoryImpl (io.pravega.client.stream.impl.ClientFactoryImpl)11 Controller (io.pravega.client.control.impl.Controller)10 StreamImpl (io.pravega.client.stream.impl.StreamImpl)10