Search in sources :

Example 1 with ByteStreamClientImpl

use of io.pravega.client.byteStream.impl.ByteStreamClientImpl in project pravega by pravega.

the class ByteStreamReaderTest method setup.

@Before
public void setup() {
    PravegaNodeUri endpoint = new PravegaNodeUri("localhost", 0);
    connectionFactory = new MockConnectionFactoryImpl();
    controller = new MockController(endpoint.getEndpoint(), endpoint.getPort(), connectionFactory, false);
    controller.createScope(SCOPE);
    controller.createStream(SCOPE, STREAM, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    MockSegmentStreamFactory streamFactory = new MockSegmentStreamFactory();
    clientFactory = new ByteStreamClientImpl(SCOPE, controller, connectionFactory, streamFactory, streamFactory, streamFactory);
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) MockSegmentStreamFactory(io.pravega.client.stream.mock.MockSegmentStreamFactory) MockConnectionFactoryImpl(io.pravega.client.stream.mock.MockConnectionFactoryImpl) MockController(io.pravega.client.stream.mock.MockController) ByteStreamClientImpl(io.pravega.client.byteStream.impl.ByteStreamClientImpl) Before(org.junit.Before)

Example 2 with ByteStreamClientImpl

use of io.pravega.client.byteStream.impl.ByteStreamClientImpl in project pravega by pravega.

the class ByteStreamWriterTest method setup.

@Before
public void setup() {
    PravegaNodeUri endpoint = new PravegaNodeUri("localhost", 0);
    connectionFactory = new MockConnectionFactoryImpl();
    ClientConnection connection = mock(ClientConnection.class);
    connectionFactory.provideConnection(endpoint, connection);
    controller = new MockController(endpoint.getEndpoint(), endpoint.getPort(), connectionFactory, false);
    controller.createScope(SCOPE);
    controller.createStream(SCOPE, STREAM, StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    MockSegmentStreamFactory streamFactory = new MockSegmentStreamFactory();
    clientFactory = new ByteStreamClientImpl(SCOPE, controller, connectionFactory, streamFactory, streamFactory, streamFactory);
    StreamSegments segments = Futures.getThrowingException(controller.getCurrentSegments(SCOPE, STREAM));
    Preconditions.checkState(segments.getNumberOfSegments() > 0, "Stream is sealed");
    Preconditions.checkState(segments.getNumberOfSegments() == 1, "Stream is configured with more than one segment");
}
Also used : PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) MockSegmentStreamFactory(io.pravega.client.stream.mock.MockSegmentStreamFactory) MockConnectionFactoryImpl(io.pravega.client.stream.mock.MockConnectionFactoryImpl) MockController(io.pravega.client.stream.mock.MockController) ClientConnection(io.pravega.client.connection.impl.ClientConnection) ByteStreamClientImpl(io.pravega.client.byteStream.impl.ByteStreamClientImpl) StreamSegments(io.pravega.client.stream.impl.StreamSegments) Before(org.junit.Before)

Example 3 with ByteStreamClientImpl

use of io.pravega.client.byteStream.impl.ByteStreamClientImpl in project pravega by pravega.

the class ByteStreamClientFactory method withScope.

/**
 * Creates a new instance of ByteStreamClientFactory.
 *
 * @param scope The scope string.
 * @param config Configuration for the client.
 * @return Instance of ByteStreamClientFactory implementation.
 */
static ByteStreamClientFactory withScope(String scope, ClientConfig config) {
    val connectionFactory = new SocketConnectionFactoryImpl(config);
    ControllerImpl controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(config).build(), connectionFactory.getInternalExecutor());
    val connectionPool = new ConnectionPoolImpl(config, Preconditions.checkNotNull(connectionFactory));
    val inputStreamFactory = new SegmentInputStreamFactoryImpl(controller, connectionPool);
    val outputStreamFactory = new SegmentOutputStreamFactoryImpl(controller, connectionPool);
    val metaStreamFactory = new SegmentMetadataClientFactoryImpl(controller, connectionPool);
    return new ByteStreamClientImpl(scope, controller, connectionPool, inputStreamFactory, outputStreamFactory, metaStreamFactory);
}
Also used : lombok.val(lombok.val) SegmentOutputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentOutputStreamFactoryImpl) ControllerImpl(io.pravega.client.control.impl.ControllerImpl) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) SegmentMetadataClientFactoryImpl(io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl) SegmentInputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) ByteStreamClientImpl(io.pravega.client.byteStream.impl.ByteStreamClientImpl)

Example 4 with ByteStreamClientImpl

use of io.pravega.client.byteStream.impl.ByteStreamClientImpl in project pravega by pravega.

the class ByteClientTest method createClientFactory.

ByteStreamClientFactory createClientFactory(String scope) {
    ClientConfig config = ClientConfig.builder().build();
    ConnectionFactory connectionFactory = new SocketConnectionFactoryImpl(config);
    ControllerImpl controller = new ControllerImpl(ControllerImplConfig.builder().clientConfig(Utils.buildClientConfig(controllerURI)).build(), connectionFactory.getInternalExecutor());
    ConnectionPool pool = new ConnectionPoolImpl(config, connectionFactory);
    val inputStreamFactory = new SegmentInputStreamFactoryImpl(controller, pool);
    val outputStreamFactory = new SegmentOutputStreamFactoryImpl(controller, pool);
    val metaStreamFactory = new SegmentMetadataClientFactoryImpl(controller, pool);
    return new ByteStreamClientImpl(scope, controller, pool, inputStreamFactory, outputStreamFactory, metaStreamFactory);
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) lombok.val(lombok.val) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) SegmentOutputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentOutputStreamFactoryImpl) ControllerImpl(io.pravega.client.control.impl.ControllerImpl) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) SegmentMetadataClientFactoryImpl(io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl) SegmentInputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl) ClientConfig(io.pravega.client.ClientConfig) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) ByteStreamClientImpl(io.pravega.client.byteStream.impl.ByteStreamClientImpl)

Example 5 with ByteStreamClientImpl

use of io.pravega.client.byteStream.impl.ByteStreamClientImpl in project pravega by pravega.

the class ByteStreamTest method createClientFactory.

ByteStreamClientFactory createClientFactory(String scope) {
    ClientConfig config = ClientConfig.builder().build();
    ConnectionFactory connectionFactory = new SocketConnectionFactoryImpl(config);
    ConnectionPool pool = new ConnectionPoolImpl(config, connectionFactory);
    val inputStreamFactory = new SegmentInputStreamFactoryImpl(PRAVEGA.getLocalController(), pool);
    val outputStreamFactory = new SegmentOutputStreamFactoryImpl(PRAVEGA.getLocalController(), pool);
    val metaStreamFactory = new SegmentMetadataClientFactoryImpl(PRAVEGA.getLocalController(), pool);
    return new ByteStreamClientImpl(scope, PRAVEGA.getLocalController(), pool, inputStreamFactory, outputStreamFactory, metaStreamFactory);
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) lombok.val(lombok.val) ConnectionFactory(io.pravega.client.connection.impl.ConnectionFactory) SegmentOutputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentOutputStreamFactoryImpl) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) SegmentMetadataClientFactoryImpl(io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl) SegmentInputStreamFactoryImpl(io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl) ClientConfig(io.pravega.client.ClientConfig) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) ByteStreamClientImpl(io.pravega.client.byteStream.impl.ByteStreamClientImpl)

Aggregations

ByteStreamClientImpl (io.pravega.client.byteStream.impl.ByteStreamClientImpl)5 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)3 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)3 SegmentInputStreamFactoryImpl (io.pravega.client.segment.impl.SegmentInputStreamFactoryImpl)3 SegmentMetadataClientFactoryImpl (io.pravega.client.segment.impl.SegmentMetadataClientFactoryImpl)3 SegmentOutputStreamFactoryImpl (io.pravega.client.segment.impl.SegmentOutputStreamFactoryImpl)3 lombok.val (lombok.val)3 ClientConfig (io.pravega.client.ClientConfig)2 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)2 ConnectionPool (io.pravega.client.connection.impl.ConnectionPool)2 ControllerImpl (io.pravega.client.control.impl.ControllerImpl)2 MockConnectionFactoryImpl (io.pravega.client.stream.mock.MockConnectionFactoryImpl)2 MockController (io.pravega.client.stream.mock.MockController)2 MockSegmentStreamFactory (io.pravega.client.stream.mock.MockSegmentStreamFactory)2 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)2 Before (org.junit.Before)2 ClientConnection (io.pravega.client.connection.impl.ClientConnection)1 StreamSegments (io.pravega.client.stream.impl.StreamSegments)1