|
![]() |
Computational Peer-To-Peer (P2P) is becoming a key execution environment. The potential of 100,000 of nodes interconnected to execute a single application is rather appealing, especially for Grid computing. Mimicking data P2P, one could start a computation that no failure would ever be able to stop (and maybe nobody).
The ProActive P2P aims to use sparse CPU cycles from organizations or institution's desktop workstations.
This short document explains to create a simple computational P2P network. This network is a dynamic JVMs network which works like, computational nodes.
The P2P infrastructure works like an overlay network. It works with a P2P Service which is a peer which in turn is computational node. The P2P Service is implemented with a ProActive JVM and few Actives Objects. The next figure shows an example of a network of hosts where some JVMs are running and several of them are running the P2P Service.
Example of a ProActive P2P infrastructure.
When the P2P infrastructure is running, it is very easy to obtain some nodes (JVMs). The next section describes how to use it.
Further research informations are available here.
The outline of this short handbook:
The P2P infrastructure is self-organized and tunable. When the infrastructure is running you have nothing to do to keep it up. There are 4 parameters to tune:
Parameters are placed in the Java class org.objectweb.proactive.p2p.core.service.P2PService. You are free to modify values as you need in the source code itself.
The bootstrapping or first contact problem is how a new peer can join the p2p infrastructure. We solved this problem by just specifying one or several addresses of supposed peers which are running in the p2p infrastructure. Next, we will explain how and where you can specify this list of peers.
Now, you have just to start peers. There are two ways to do it:
This method explains how to rapidly launch a simple P2P Service on one host.
ProActive provides a very simple script to start a P2P Service on your local host. The name of this script is startP2PService.
ProActive/p2p/scripts/unix/startP2PService.sh
file. ProActive/p2p/scripts/windows/startP2PService.bat
file.Before launching this script, you have to specify some arguments to this command:
startP2PService [acquisitionMethod [portNumber]] [-s Server]... [-f ServerListFile]
rmi://applepie.proactive.org:8080
-s
but peers are specified in file ServerListFile
. One by line.All arguments are optional.
Comment: With the UNIX version of the startP2PService script, the P2P service is persistent and runs like a UNIX nice process. If the JVMs that are running the P2P service stop (for a Java exception) the script re-starts a new one.
In this illustration, we will explain how to start a first peer and thenafter how new peers can create a P2P network with the first one.
Start the first peer with rmi protocol and listening on port 2410:
first.peer.host$ startP2PService.sh rmi 2410
Now, start new peers and connect them to the first peer to create a tiny P2P network:
second.peer.host$ startP2PService.sh rmi 2410 -s rmi://first.peer.host
third.peer.host$ startP2PService.sh rmi 2602 -s rmi://first.peer.host
You could specify different port number for each peer.
Use a file to specify address of peers:
The file hosts.file:
rmi://first.peer.host:2410 rmi://third.peer.host:2602
file.peer.host$ startP2PService.sh rmi 8989 -f hosts.file
Last, a new peer joins the P2P network by another peer of the first:
last.peer.host$ startP2PService.sh rmi 6666 -s rmi://third.peer.host:2410
Usage example P2P network (after firsts connections).
The daemon aim to use computers in Peer-to-Peer computations, there will be a Java virtual machine sleeping on your computers and waking up at scheduled times to get some work done.
By default, the JVM is scheduled to wake up during the weekend and during the night. Next, we will explain how to change the schedule. The JVM is running with the lowest priority.
Go to the directory: ProActive/compile
and run this
command:
$ ./build daemon
Before compile you should change some parameter like the daemon
user or the port in the file:
ProActive/p2p/src/common/proactivep2p.h
.
Ask to your system administrator to add the daemon in a crontab or
init.d. The process to run is located here:
ProActive/p2p/build/proactivep2p
To compile daemon source (in c++), we don't porvide any
automatic script, you have to do it by yourself. All sources for
Windows are in the directory:
ProActive/p2p/src/windows
. If you use Visual Studio
or else in the same directory you found Microsoft projects files.
After that you are ready to install the daemon with Windows, you have jsut to run this script:
C:> ProActive\p2p\scripts\windows\Service\install.bat
To remove the daemon:
C:> ProActive\p2p\scripts\windows\Service\remove.bat
Comment: By default the port number of the daemon is 9015.
The daemon is configured with XML files in the ProActive/p2p/config/
directory. To find the correct configuration file, the daemon will first try with a host dependant file: config/proactivep2p.${HOST}.xml
for example: config/proactivep2p.camel.inria.fr.xml
if the daemon is running on the host named camel.inria.fr.
If this host specific file is not found, the daemon will load config/proactivep2p.xml
. This mechanism can be useful to setup a default configuration and have a specific configuration for some hosts.
The reference is the XML Schema in proactivep2p.xsd. For those not fluent in XML Schema, here is a description of every markup tags--
The root element in <configFile> it contains one or many <p2pconfig> . This latter element can start with some <loadconfig path="path/to/xml"/> they will include the designated XML file. After these file inclusions, you can with <host name="name.domain"> specify which hosts are concerned by the configuration. Then there can be a <configForHost> element containing a configuration for the selected hosts and/or a <default> element if no suitable configuration was already found.
Keep in mind that the XML parser sees a lot of configuration and the first that matches is used and the parsing is finished. This means that the elements we have just seen are tightly linked together. For example if an XML file designated by a <loadconfig> contains a <default> element, then after this file no other element will be evaluated. This is because either a configuration was already found so the parsing stops, or no configuration matched and the <default> does, so the parsing ends.
The proper configuration is contained in a <configForHost> or <default> element. It consists of the scheduled times for work and the hosts where we register ourselves. Here is an example:
<periods> <period> <start day="monday" hour="18" minute="0"/> <end day="tuesday" hour="6" minute="0"/> </period> <period> <start day="saturday" hour="0" minute="0"/> <end day="monday" hour="6" minute="0"/> </period> </periods> <register> <registry url="trinidad.inria.fr"/> <registry url="amda.inria.fr"/> <registry url="tranquility.inria.fr"/> <registry url="psychoquack.inria.fr"/> </register>
In this example we clearly see that the JVM will wake up Monday evening and shut down Tuesday morning. It will also work during the weekend. In the <register> part we put the URL in which we will register ourselves, in the example we used the short form which is equivalent to rmi://host:9301.
$ ProActive/p2p/build/p2pctl stop
$ ProActive/p2p/build/p2pctl killdaemon
Under Windows you could use some littles scripts in
ProActive/p2p/script/windows/JVM
to do that.
You can customize some P2P settings such as:
In order to get nodes, the "peerSet" tag will allow you to specify entry point of your P2P Infrastructure, where ProActive should ask for node.
You can get nodes from the P2P Infrastructure using the ProActive
Deployement Descriptor as described above.
In fact you will ask for a certain number of nodes and ProActive will
notify a "listener" (one of your class), every time a new node is
available.
ProActiveDescriptor pad = ProActive.getProactiveDescriptor("myP2PXmlDescriptor.xml"); // getting virtual node "p2pvn" defined in the ProActive Deployement Descriptor VirtualNode vn = pad.getVirtualNode("p2pvn"); // adding "this" or anyother class has a listener of the "NodeCreationEvent" ((VirtualNodeImpl) vn).addNodeCreationEventListener(this); //activate that virtual node vn.activate();
As you can see the class executing this code, must implements an interface
in order to be notified when a new node is available from the P2P
infrastructure.
Basically you will have to implement the interface
NodeCreationEventListener that can be found in package
org.objectweb.proactive.core.event
For example this method will be called every time a new host is acquired :
public void nodeCreated(NodeCreationEvent event) { // get the node Node newNode = event.getNode(); // now you can create an active object on your node. }
You should carefully notice that you can be notified at any time, whatever the code you are executing, once you have activated the virtual node.
A short preview of a XML descriptor:
<infrastructure> <processes> <processDefinition id="localJVM"> <jvmProcess class="org.objectweb.proactive.core.process.JVMNodeProcess"> </jvmProcess> </processDefinition> </processes> <services> <serviceDefinition id="p2plookup"> <P2PLookup nodeNumber="2" timeout="70000" lookupFrequence="5000"> <peerSet> <peer>rmi://localhost:3000</peer> </peerSet> </P2PLookup> </serviceDefinition> </services> </infrastructure>
A complete example of file is available here.
For more information about ProActive XML Deployment Descriptor see this page.
The next little sample of code explains how from an application you can start a P2P Service and deploy on it ProActive nodes:
import org.objectweb.proactive.ProActive;
import org.objectweb.proactive.core.ProActiveException;
import org.objectweb.proactive.core.mop.ClassNotReifiableException;
import org.objectweb.proactive.core.node.Node;
import org.objectweb.proactive.core.node.NodeException;
import org.objectweb.proactive.core.node.NodeFactory;
import org.objectweb.proactive.core.runtime.ProActiveRuntime;
import org.objectweb.proactive.core.runtime.RuntimeFactory;
import org.objectweb.proactive.p2p.core.service.P2PService;
import org.objectweb.proactive.p2p.core.service.StartP2PService;
...
// This constructor uses a file with address of peers
// See the Javadoc to choose different paramaters
StartP2PService startServiceP2P = new StartP2PService(p2pFile)
// Start the P2P Service on the local host
startServiceP2P.start();
// Get the reference on the P2P Service
P2PService serviceP2P = startServiceP2P.getP2PService();
// By the application's P2P Service ask to the P2P infrastructure
// for get ProActiveRuntimes.
ProActiveRuntime[] par = null;
try {
par = serviceP2P.getProActiveJVMs(nbRuntimeAsked);
} catch (ProActiveException e) {
...
}
// We got ProActiveRuntimes. Now, we have to create ProActive nodes
Node[] workerNodes = new Node[par.length];
try {
for (int i = 0; i < par.length; i++) {
workerNodes[i] = NodeFactory.getNode(par[i].createLocalNode(
"Node" + i, false, null,
par[i].getVMInformation().getName(),
par[i].getJobID()));
}
} catch (NodeException ne) {
...
} catch (ProActiveException pe) {
...
}
// Use workerNodes to delpoy your application
...