Hedwig Console

Apache Hedwig provides a console client, which allows users and administrators to interact with a hedwig cluster.

Connecting to hedwig cluster

Hedwig console client is shipped with hedwig server package.

To start the console client:

hedwig-server/bin/hedwig console

By default, the console client connects to hub server on localhost. If you want the console client to connect to a different hub server, you can override following environment variables.

HEDWIG_CONSOLE_SERVER_CONFPath of a hub server configuration file. Override to make hedwig console client connect to correct zookeeper cluster.
HEDWIG_CONSOLE_CLIENT_CONFPath of a hedwig client configuration file. Override to make hedwig console client communicate with correct hub servers.

Once connected, you should see something like:

Connecting to zookeeper/bookkeeper using HedwigAdmin

Connecting to default hub server localhost/127.0.0.1:4080
Welcome to Hedwig!
JLine support is enabled
JLine history support is enabled
[hedwig: (standalone) 16] 

From the shell, type help to get a list of commands that can be executed from the client:

[hedwig: (standalone) 16] help
HedwigConsole [options] [command] [args]

Available commands:
        pub
        sub
        closesub
        unsub
        rmsub
        consume
        consumeto
        pubsub
        show
        describe
        readtopic
        set
        history
        redo
        help
        quit
        exit

Finished 0.0020 s.

If you want to know detail usage for each command, type help {command} in the shell. For example:

[hedwig: (standalone) 17] help pub
pub: Publish a message to a topic in Hedwig
usage: pub {topic} {message}

  {topic}   : topic name.
              any printable string without spaces.
  {message} : message body.
              remaining arguments are used as message body to publish.

Finished 0.0 s.

Commands

All the available commands provided in hedwig console could be categorized into three groups. They are interactive commands, admin commands, utility commands.

Interactive Commands

Interactive commands are used by users to communicate with a hedwig cluster. They are pub, sub, closesub, unsub, consume and consumeto.

These commands are quite simple and have same semantics as the API provided in hedwig client.

Admin Commands

Admin commands are used by administrators to operate or debug a hedwig cluster. They are show, describe, pubsub and readtopic.

show is used to list all available hub servers or topics in the cluster.

You could use show to list hub servers to know how many hub servers are alive in the cluster.

[hedwig: (standalone) 27] show hubs
Available Hub Servers:
        192.168.1.102:4080:9876 :       0
Finished 0.0040 s.

Also, you could use show to list all topics. If you have a lot of topics on the clusters, this command will take a long time to run.

[hedwig: (standalone) 28] show topics
Topic List:
[mytopic]
Finished 0.0020 s.

To see the details of a topic, run describe. This shows the metadata of a topic, including topic owner, persistence info, subscriptions info.

[hedwig: (standalone) 43] describe topic mytopic
===== Topic Information : mytopic =====

Owner : 192.168.1.102:4080:9876

>>> Persistence Info <<<
Ledger 3 [ 1 ~ 9 ]

>>> Subscription Info <<<
Subscriber mysub : consumeSeqId: local:0

Finished 0.011 s.

When you are run the describe command, you should keep in mind that describe command reads the metadata from ZooKeeper directly, so the subscription info might not be completely up to date due to the fact that hub servers update the subscription metadata lazily.

The readtopic command is useful to see which messages have not been consumed by the client.

[hedwig: (standalone) 46] readtopic mytopic

>>>>> Ledger 3 [ 1 ~ 9] <<<<<

---------- MSGID=LOCAL(1) ----------
MsgId:     LOCAL(1)
SrcRegion: standalone
Message:

hello

---------- MSGID=LOCAL(2) ----------
MsgId:     LOCAL(2)
SrcRegion: standalone
Message:

hello 2

---------- MSGID=LOCAL(3) ----------
MsgId:     LOCAL(3)
SrcRegion: standalone
Message:

hello 3

...

pubsub is another useful command for administrators. It can be used to test availability and functionality of a cluster. It generates a temporary subscriber id with the current timestamp, subscribes to the given topic using generated subscriber id, publishes a message to given topic and testes whether the subscriber received the message.

[hedwig: (standalone) 48] pubsub testtopic testsub- 10 test message for availability
Starting PUBSUB test ...
Sub topic testtopic, subscriber id testsub--1338126964504
Pub topic testtopic : test message for availability-1338126964504
Received message : test message for availability-1338126964504
PUBSUB SUCCESS. TIME: 377 MS
Finished 0.388 s.

Utility Commands

Utility Commands are help, history, redo, quit and exit.

quit and exit are used to exit console, while history and redo are used to manage the history of commands executed in the shell.