Search in sources :

Example 1 with ZKHelper

use of io.pravega.cli.admin.utils.ZKHelper in project pravega by pravega.

the class ControllerMetadataViewReaderInfoCommand method execute.

@Override
public void execute() throws Exception {
    ensureArgCount(3);
    final String hostId = getArg(0);
    final String readerGroupName = getArg(1);
    final String readerId = getArg(2);
    try {
        ZKHelper zkHelper = ZKHelper.create(getServiceConfig().getZkURL(), getServiceConfig().getClusterName());
        output("reader-metadata: \n %s", zkHelper.getMetaDataForReader(getReaderPath(hostId, readerGroupName, readerId)));
    } catch (Exception e) {
        output("Exception accessing to reader metadata : " + e.getMessage());
    }
}
Also used : ZKHelper(io.pravega.cli.admin.utils.ZKHelper)

Example 2 with ZKHelper

use of io.pravega.cli.admin.utils.ZKHelper in project pravega by pravega.

the class GetClusterNodesCommand method execute.

@Override
public void execute() {
    ensureArgCount(0);
    try {
        @Cleanup ZKHelper zkStoreHelper = ZKHelper.create(getServiceConfig().getZkURL(), getServiceConfig().getClusterName());
        prettyJSONOutput("cluster_name", getServiceConfig().getClusterName());
        prettyJSONOutput("controllers", zkStoreHelper.getControllers());
        prettyJSONOutput("segment_stores", zkStoreHelper.getSegmentStores());
        prettyJSONOutput("bookies", zkStoreHelper.getBookies());
    } catch (ZKConnectionFailedException e) {
        System.err.println("Exception accessing to Zookeeper cluster metadata.");
    }
}
Also used : ZKHelper(io.pravega.cli.admin.utils.ZKHelper) ZKConnectionFailedException(io.pravega.cli.admin.utils.ZKConnectionFailedException) Cleanup(lombok.Cleanup)

Example 3 with ZKHelper

use of io.pravega.cli.admin.utils.ZKHelper in project pravega by pravega.

the class AbstractControllerMetadataCommandsTest method testControllerMetadataViewReaderInfoCommandWithException.

@Test
public void testControllerMetadataViewReaderInfoCommandWithException() throws Exception {
    final String process = UUID.randomUUID().toString();
    final String readerGroup = UUID.randomUUID().toString();
    final String reader = UUID.randomUUID().toString();
    ZKHelper zkHelper = ZKHelper.create(SETUP_UTILS.getZkTestServer().getConnectString(), "pravega-cluster");
    CheckpointStore checkpointStore = zkHelper.getCheckPointStore();
    checkpointStore.addReaderGroup(process, readerGroup);
    String commandResult = TestUtils.executeCommand("controller-metadata get-reader " + process + " " + readerGroup + " " + reader, STATE.get());
    Assert.assertTrue(commandResult.contains("Exception accessing to reader metadata"));
}
Also used : ZKHelper(io.pravega.cli.admin.utils.ZKHelper) CheckpointStore(io.pravega.controller.store.checkpoint.CheckpointStore) Test(org.junit.Test)

Example 4 with ZKHelper

use of io.pravega.cli.admin.utils.ZKHelper in project pravega by pravega.

the class AbstractControllerMetadataCommandsTest method testControllerMetadataViewReaderInfoCommand.

@Test
public void testControllerMetadataViewReaderInfoCommand() throws Exception {
    final String process = UUID.randomUUID().toString();
    final String readerGroup = UUID.randomUUID().toString();
    final String reader = UUID.randomUUID().toString();
    ZKHelper zkHelper = ZKHelper.create(SETUP_UTILS.getZkTestServer().getConnectString(), "pravega-cluster");
    CheckpointStore checkpointStore = zkHelper.getCheckPointStore();
    checkpointStore.addReaderGroup(process, readerGroup);
    checkpointStore.addReader(process, readerGroup, reader);
    Position position = new PositionImpl(ImmutableMap.of(new SegmentWithRange(Segment.fromScopedName("testScope/testStream/0"), 0, 0.5), 9999999L, new SegmentWithRange(Segment.fromScopedName("testScope/testStream/1"), 0.5, 1.0), -1L));
    checkpointStore.setPosition(process, readerGroup, reader, position);
    String commandResult = TestUtils.executeCommand("controller-metadata get-reader " + process + " " + readerGroup + " " + reader, STATE.get());
    Assert.assertTrue(commandResult.contains("testScope/testStream"));
}
Also used : ZKHelper(io.pravega.cli.admin.utils.ZKHelper) Position(io.pravega.client.stream.Position) PositionImpl(io.pravega.client.stream.impl.PositionImpl) SegmentWithRange(io.pravega.client.stream.impl.SegmentWithRange) CheckpointStore(io.pravega.controller.store.checkpoint.CheckpointStore) Test(org.junit.Test)

Example 5 with ZKHelper

use of io.pravega.cli.admin.utils.ZKHelper in project pravega by pravega.

the class ListContainersCommand method execute.

@Override
public void execute() {
    ensureArgCount(0);
    try {
        @Cleanup ZKHelper zkStoreHelper = ZKHelper.create(getServiceConfig().getZkURL(), getServiceConfig().getClusterName());
        prettyJSONOutput("segment_store_container_map", zkStoreHelper.getCurrentHostMap());
    } catch (Exception e) {
        System.err.println("Exception accessing to Zookeeper cluster metadata: " + e.getMessage());
    }
}
Also used : ZKHelper(io.pravega.cli.admin.utils.ZKHelper) Cleanup(lombok.Cleanup)

Aggregations

ZKHelper (io.pravega.cli.admin.utils.ZKHelper)6 Cleanup (lombok.Cleanup)3 ZKConnectionFailedException (io.pravega.cli.admin.utils.ZKConnectionFailedException)2 CheckpointStore (io.pravega.controller.store.checkpoint.CheckpointStore)2 Test (org.junit.Test)2 Position (io.pravega.client.stream.Position)1 PositionImpl (io.pravega.client.stream.impl.PositionImpl)1 SegmentWithRange (io.pravega.client.stream.impl.SegmentWithRange)1 Host (io.pravega.common.cluster.Host)1