Search in sources :

Example 31 with ConnectionPool

use of io.pravega.client.connection.impl.ConnectionPool 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 32 with ConnectionPool

use of io.pravega.client.connection.impl.ConnectionPool in project pravega by pravega.

the class ControllerCommandsTest method testDescribeStreamCommand.

@Test
@SneakyThrows
public void testDescribeStreamCommand() {
    String scope = "testScope";
    String testStream = "testStream";
    String commandResult = executeCommand("controller describe-stream " + scope + " " + testStream, cliConfig());
    Assert.assertTrue(commandResult.contains("stream_config"));
    Assert.assertTrue(commandResult.contains("stream_state"));
    Assert.assertTrue(commandResult.contains("segment_count"));
    Assert.assertTrue(commandResult.contains("is_sealed"));
    Assert.assertTrue(commandResult.contains("active_epoch"));
    Assert.assertTrue(commandResult.contains("truncation_record"));
    Assert.assertTrue(commandResult.contains("scaling_info"));
    // Exercise actual instantiateSegmentHelper
    CommandArgs commandArgs = new CommandArgs(Arrays.asList(scope, testStream), cliConfig());
    ControllerDescribeStreamCommand command = new ControllerDescribeStreamCommand(commandArgs);
    @Cleanup CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(CLUSTER.zookeeperConnectString(), new RetryOneTime(5000));
    curatorFramework.start();
    @Cleanup ConnectionPool pool = new ConnectionPoolImpl(CLIENT_CONFIG, new SocketConnectionFactoryImpl(CLIENT_CONFIG));
    @Cleanup SegmentHelper sh = command.instantiateSegmentHelper(curatorFramework, pool);
    Assert.assertNotNull(sh);
    // Try the Zookeeper backend, which is expected to fail and be handled by the command.
    Properties properties = new Properties();
    properties.setProperty("cli.store.metadata.backend", CLIConfig.MetadataBackends.ZOOKEEPER.name());
    cliConfig().getConfigBuilder().include(properties);
    commandArgs = new CommandArgs(Arrays.asList(scope, testStream), cliConfig());
    new ControllerDescribeStreamCommand(commandArgs).execute();
    properties.setProperty("cli.store.metadata.backend", CLIConfig.MetadataBackends.SEGMENTSTORE.name());
    cliConfig().getConfigBuilder().include(properties);
}
Also used : CommandArgs(io.pravega.cli.admin.CommandArgs) ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) CuratorFramework(org.apache.curator.framework.CuratorFramework) RetryOneTime(org.apache.curator.retry.RetryOneTime) ConnectionPoolImpl(io.pravega.client.connection.impl.ConnectionPoolImpl) SocketConnectionFactoryImpl(io.pravega.client.connection.impl.SocketConnectionFactoryImpl) SegmentHelper(io.pravega.controller.server.SegmentHelper) Properties(java.util.Properties) Cleanup(lombok.Cleanup) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 33 with ConnectionPool

use of io.pravega.client.connection.impl.ConnectionPool in project pravega by pravega.

the class UpdateSegmentAttributeCommand method execute.

@Override
public void execute() {
    ensureArgCount(5);
    final String fullyQualifiedSegmentName = getArg(0);
    final UUID attributeId = getUUIDArg(1);
    final long newValue = getLongArg(2);
    final long existingValue = getLongArg(3);
    final String segmentStoreHost = getArg(4);
    @Cleanup CuratorFramework zkClient = createZKClient();
    @Cleanup ConnectionPool pool = createConnectionPool();
    @Cleanup SegmentHelper segmentHelper = instantiateSegmentHelper(zkClient, pool);
    CompletableFuture<WireCommands.SegmentAttributeUpdated> reply = segmentHelper.updateSegmentAttribute(fullyQualifiedSegmentName, attributeId, newValue, existingValue, new PravegaNodeUri(segmentStoreHost, getServiceConfig().getAdminGatewayPort()), super.authHelper.retrieveMasterToken());
    output("UpdateSegmentAttribute: %s", reply.join().toString());
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) CuratorFramework(org.apache.curator.framework.CuratorFramework) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) UUID(java.util.UUID) SegmentHelper(io.pravega.controller.server.SegmentHelper) Cleanup(lombok.Cleanup)

Example 34 with ConnectionPool

use of io.pravega.client.connection.impl.ConnectionPool in project pravega by pravega.

the class GetSegmentAttributeCommand method execute.

@Override
public void execute() {
    ensureArgCount(3);
    final String fullyQualifiedSegmentName = getArg(0);
    final UUID attributeId = getUUIDArg(1);
    final String segmentStoreHost = getArg(2);
    @Cleanup CuratorFramework zkClient = createZKClient();
    @Cleanup ConnectionPool pool = createConnectionPool();
    @Cleanup SegmentHelper segmentHelper = instantiateSegmentHelper(zkClient, pool);
    CompletableFuture<WireCommands.SegmentAttribute> reply = segmentHelper.getSegmentAttribute(fullyQualifiedSegmentName, attributeId, new PravegaNodeUri(segmentStoreHost, getServiceConfig().getAdminGatewayPort()), super.authHelper.retrieveMasterToken());
    output("GetSegmentAttribute: %s", reply.join().toString());
}
Also used : ConnectionPool(io.pravega.client.connection.impl.ConnectionPool) CuratorFramework(org.apache.curator.framework.CuratorFramework) PravegaNodeUri(io.pravega.shared.protocol.netty.PravegaNodeUri) UUID(java.util.UUID) SegmentHelper(io.pravega.controller.server.SegmentHelper) Cleanup(lombok.Cleanup)

Example 35 with ConnectionPool

use of io.pravega.client.connection.impl.ConnectionPool 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

ConnectionPool (io.pravega.client.connection.impl.ConnectionPool)41 Cleanup (lombok.Cleanup)22 ConnectionPoolImpl (io.pravega.client.connection.impl.ConnectionPoolImpl)19 SocketConnectionFactoryImpl (io.pravega.client.connection.impl.SocketConnectionFactoryImpl)19 ClientConfig (io.pravega.client.ClientConfig)17 CompletableFuture (java.util.concurrent.CompletableFuture)17 Test (org.junit.Test)16 UUID (java.util.UUID)14 StreamManager (io.pravega.client.admin.StreamManager)13 StreamManagerImpl (io.pravega.client.admin.impl.StreamManagerImpl)13 List (java.util.List)13 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)12 VisibleForTesting (com.google.common.annotations.VisibleForTesting)11 ScalingPolicy (io.pravega.client.stream.ScalingPolicy)11 PravegaNodeUri (io.pravega.shared.protocol.netty.PravegaNodeUri)11 ConnectionFactory (io.pravega.client.connection.impl.ConnectionFactory)10 Exceptions (io.pravega.common.Exceptions)10 HostControllerStore (io.pravega.controller.store.host.HostControllerStore)10 ConnectionFailedException (io.pravega.shared.protocol.netty.ConnectionFailedException)10 WireCommands (io.pravega.shared.protocol.netty.WireCommands)10