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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations