Voldemortクライアントシェルは、Voldemortの対話型ツール。
(HBaseのHBase Shell、CassandraのCLIのようなもの)
クライアントシェルは Javaで作られている。実行されるクラスはvoldemort.VoldemortClientShell。
UNIXの場合は、VOLDEMORT_INSTALL/bin/voldemort-shell.shを使う。
Windowsでは同様の起動バッチファイルは用意されていない為、自分で作る。→voldemort-shell.bat
> cd C:\voldemort-0.80.2 > bin/voldemort-shell.bat test tcp://localhost:6666 Established connection to test via tcp://localhost:6666
voldemort-shell.sh(あるいはvoldemort-shell.bat)の第1引数には、操作する対象のストア(テーブル)名を指定する。
第2引数に接続するVoldemortのDBサーバーのIPアドレスとポート番号を指定する。
クライアントシェルからhelpコマンドを打ち込むとクライアントシェルのコマンド一覧が表示される。
> help Commands: put key value -- Associate the given value with the key. get key -- Retrieve the value associated with the key. getall key -- Retrieve the value(s) associated with the key. delete key -- Remove all values associated with the key. preflist key -- Get node preference list for given key. help -- Print this message. exit -- Exit from this shell.
コマンド名 | 引数 | 概要 |
---|---|---|
put | key value | ストアに値を登録する。 |
get | key | ストアから値を取得する。 |
getall | key 〔key…〕 | 複数のキーを指定してそれらの値を取得する。 |
delete | key | キー(値)を削除する。 |
preflist | key | ノードの状態を表示する。 |
exitまたはquitでクライアントシェルを終了する。
ストア(テーブル)に値を登録するコマンド。
→Java APIのput()
> put "hello" "world"
ストア(テーブル)から値を取得するコマンド。
→Java APIのget()
> get "hello" version(0:1): "world"
versionの括弧内の左側の数字は、ノードID。
versionの括弧内の右側の数字は、バージョン番号。同じキーに対してputを何回か実行すると増えていく。
キーが存在しなかった場合はnullが返る。
> get "nnn" null
複数のキーを指定して、それらの値を取得するコマンド。
→Java APIのgetAll()
> getall "hello" "abc" "foo" hello => version(0:1): "world" abc => version(0:3): "def"
存在しないキーの値は表示されない。
ひとつも存在しなかった場合はnullが返る。
> getall "nnn" null
ストアからキー(と値)を削除するコマンド。
→Java APIのdelete()
> delete "abc"
キーが存在していても無くてもエラーにはならない。
指定されたキーに関するノードの優先リストを表示するコマンド。
→Java APIのgetResponsibleNodes()
> preflist "hello" Node 0 host: localhost port: 6666 available: yes last checked: 1275587283329 ms ago
引数を何も指定しないとエラーになるが、指定するキーは存在しないものでもいいようだ。