Emulating Multiple Nodes on a Single Computer[English | Japanese]last-updated: February 13, 2011 |
In this tutorial, you use Distributed Environment Emulator, invoke multiple instances of DHT shell on it.
The following instructions assume that you have the toolkit installed (extracted and built), and set PATH environment variable to execute toolkit commands in bin directory. You can execute the commands without setting the PATH by preceding the commands with the path of the bin directory.
Emulator reads a scenario from a file or world-wide web. You have to prepare a scenario in advance.
Prepare a file named SimpleScenario which contains the following text.
This scenario first invokes a node and the node waits for connection at 10000/tcp to read DHT shell commands. Next, the scenario invokes 3 nodes. They contacts the first node (emu0) to join an overlay.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
Type the following command to start an Emulator.
owemu SimpleScenario
You see messages from 4 instances of DHT shell.
... 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.
As specified, the first instance of DHT shell is waiting on 10000 port. Try to connect the shell.
Open another character terminal and telnet to the shell.
telnet localhost 10000
You see the shell prompting you.
Type status command and see routing table of the node.Ready.
status
Type quit command to exit from the shell.ID and address: ac4d64e281e1ad8670db2c3123a842874c394f4d:emu0:3997 Routing table: predecessor: 5de550ebe439e30918a0d11c6173aa0a7df6afff:emu1:3997 successor list: [ ...
quit
Stop the Emulator before the next step,
for example, by typing Ctrl + C.
Try an advanced scenario. Prepare a scenario file named AdvancedScenario. The file should contain the following text.
This scenario controls 4 DHT shells after invoking them. The scenario contains a new scenario command "schedule". It schedules issues of commands sent to each DHT shell. For example, "schedule 5000 control 1 get a_key" means that the emulator sends a command "get a_key" to a DHT shell on a virtual node numbered 1 (emu1) at 5000 millisecond after the specified offset (7000 msec).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
Start an Emulator with the scenario file.
owemu AdvancedScenario
You see the result of get command issued to the second DHT shell.
... control 1 (Sun Feb 13 21:52:18 JST 2011): get a_key key: 5d8b23c071cb95840397933b5969c69413fc87cf value: a_value 10798