Developer's Guide[English | Japanese]
last-updated: January 23, 2011
This guide shows starting points to develop applications and routing algorithms which work with the toolkit.
The toolkit provides higher-level services, Distributed Hash Table (DHT) and multicast (Mcast) services for application writers. To use them, an application obtains an object representing a service and controls it through the respective interfaces, ow.dht.DHT and ow.mcast.Mcast.
Please refer to initialize method of ow.tool.util.toolframework.AbstractDHTBasedTool class. It shows how to obtain such a DHT object. A sample code for the Mcast service is in ow.tool.util.toolframework.AbstractMcastBasedTool#initialize.
A higher-level service constructs other underlying services to use them. The construction is performed by a higher-level service and you do not have to care about it usually. But you can construct them by yourself, or even use them independently.
Please refer to a constructor of ow.dht.impl.BasicDHTImpl and ow.mcast.impl.McastImpl, which show the construction process.
To add a new routing algorithm, you have to provide a provider class, a configuration class and algorithm implementation itself. Each class respectively implements the following interfaces, RoutingAlgorithmProvider, RoutingAlgorithmConfiguration and RoutingAlgorithm in the ow.routing package.
You can implement an algorithm by extending ow.routing.impl.AbstractRoutingAlgorithm class, which implements the RoutingAlgorithm interface. In this case the implementation class should provide the following methods:
Finally, you add the provider class to a PROVIDERS field in ow.routing.RoutingAlgorithmFactory class.
Please refer to existing implementations of algorithms the toolkit provides. Implementations of Chord, FRT-Chord, Kademlia, Koorde, Pastry, and Tapestry are respectively located in ow.routing.chord, ow.routing.frtchord, ow.routing.kademlia, ow.routing.koorde, ow.routing.pastry, and ow.routing.tapestry packages.
Any Java application with its main class, which has a main method, runs on the emulator. On the other hand the main class of the application has to implement ow.tool.emulator.EmulatorControllable interface to be controlled along an emulation scenario. The interface has the only method invoke. Your implementation of invoke method should return a Writer, the application reads commands from it. And the application writes output to an argument PrintStream out, which are given through the invoke method.
The application on an emulator can perform communication with socket and any other means as usual. Of course, it should avoid conflicts of port numbers. If the application uses the messaging service provided by Overlay Weaver, all communication messages are carried in the emulator process (JVM).