チュートリアルで遊んでみよう。


今回はチュートリアルを実際にやっていきたいと思います。
意外とおもしろいです。 というか何だか、使えてる"使えている"って気分いなれるものだったのでまとめを。w
といっても、本当にチュートリアルの内容そのまま試しているだけですので、読んでるだけだとつまらないかも。
実際に試してみるのがいいと思います。


前回までの内容が完成していることを前提として、進めていきたいと思います。

シナリオファイルの準備

"test-scenario"以を以下の内容に書き換えます。

# Invokes an Overlay Visualizer and 20 instances of DHT shell

timeoffset 2000

# invokes the first node
class ow.tool.dhtshell.Main
arg -p 10000
schedule 0 invoke

# invokes 3 nodes, which contacts the first node (emu0) to join an overlay
arg emu0
schedule 1000,1000,3 invoke

# keeps the emulator running
schedule inf control all halt

エミュレータの起動

前回同様、問題なくエミュレータを起動できると思います。
コンソールに以下のような結果が表示されると思います。
シナリオに書かれているように、emu0と1000ミリ秒間隔で3つのノードが立ち上げられていますね。

DHT configuration:
hostname:port: emu0:3997
transport type: UDP
routing algorithm: Chord
routing style: Iterative
directory type: VolatileMap
working directory: .
A DHT started.
A shell server is waiting on the port tcp/10000
DHT configuration:
hostname:port: emu1:3997
transport type: UDP
routing algorithm: Chord
routing style: Iterative
directory type: VolatileMap
working directory: .
initial contact: emu0:3997
A DHT started.
DHT configuration:
hostname:port: emu2:3997
transport type: UDP
routing algorithm: Chord
routing style: Iterative
directory type: VolatileMap
working directory: .
initial contact: emu0:3997
A DHT started.
DHT configuration:
hostname:port: emu3:3997
transport type: UDP
routing algorithm: Chord
routing style: Iterative
directory type: VolatileMap
working directory: .
initial contact: emu0:3997
A DHT started.

DHT シェルの制御 (手動)

私の場合ですと、"Windows 7"環境ですので、エミュレータではなくコマンドプロンプトを立ち上げて、以下のようにコマンドを実行します。


この際に、windows 7では初期設定のままだとTelnetコマンドが使えないので
過去のエントリ等を参考に。

telnet localhost 10000

Ready.
status
ID and address: ac4d64e281e1ad8670db2c3123a842874c394f4d:emu0:3997
Routing table:
predecessor:
5de550ebe439e30918a0d11c6173aa0a7df6afff:emu1:3997
successor list: [
f81e834fe35bbedc691ee2fea196bae7bc525570:emu3:3997
facb5f842f5855a3b3e651f132c65a1f65c5e48a:emu2:3997
5de550ebe439e30918a0d11c6173aa0a7df6afff:emu1:3997
ac4d64e281e1ad8670db2c3123a842874c394f4d:emu0:3997
]
finger table: [
1: f81e834fe35bbedc691ee2fea196bae7bc525570:emu3:3997
160: 5de550ebe439e30918a0d11c6173aa0a7df6afff:emu1:3997
]

Ready.
exit

ちょっと使えてる気分になりませんか?(`・ω・´)w

DHT シェルの制御 (シナリオ)

もう一度"test-scenario"を書き換えて実効。

timeoffset 2000

# invokes the first node
class ow.tool.dhtshell.Main
arg -p 10000
schedule 0 invoke

# invokes 3 nodes
arg
schedule 1000,1000,3 invoke

timeoffset 7000

# 3 nodes join an overlay
schedule 0 control 1 init emu0
schedule 1000 control 2 init emu0
schedule 2000 control 3 init emu0

# put and get
schedule 4000 control 1 put a_key a_value
schedule 5000 control 1 get a_key

今回は、シナリオをの通りに実行されますので結果を確認するのみ。

control 1 (Mon Nov 07 16:46:08 JST 2011): put a_key a_value
control 1 (Mon Nov 07 16:46:09 JST 2011): get a_key
key: 5d8b23c071cb95840397933b5969c69413fc87cf
value: a_value 10798

emu1のノードから

  • キー : a_key
  • バリュー : a_value

としてputしており、
また、emu1からキーを元にバリューをgetしているのが確認できると思います。

参考にさせていただいたサイト

Overlay Weaver - Tutorial