Make sure that all required files are present
This includes all involved classes, implicitly or explicity. Also check out the
version of the JDK you are using. For instance, under jdk 1.1.6 you cannot start
the
CX environment. You you will need at least jdk1.2 or (preferably) jdk1.3, in order to
run your code.
Start the RMI registry
prompt> rmiregistry -J-cp -JCX.jar
The above command starts the rmiregistry at the defaule port. If you get errors
like java.net.BindException don't panic. It
means
that someone else has already started the rmiregistry (at the default port).
Start the Task Server
prompt> java -cp CX.jar -Djava.security.policy=policy.all TaskServerImpl
nodeInfo topologyInfo
For those of you that are familiar with the RMI policy files, you can
easily recognize the syntax above. The policy file called policy.all
gives permission to all, so if you want to be more restrictive you should
provide your own policy file (how to write policy files it's beyond the
scope of this tutorial). TaskServerImpl is the default implementation of
the TaskServer interface, and you simply use it (you don't have to write
or add anything). The last two arguments, namely nodeInfo and topologyInfo
provide Task Server with information about "who am I" and "where
should I connect to" respectively. Look below in the appendix for a
more detailed description on how you can create them.
Start the Producer
prompt> java -cp CX.jar -Djava.security.policy=policy.all ProducerImpl
nodeInfo topologyInfo
The syntax is basically the same with the Task Server. Even the nodeInfo
and topologyInfo have the same format, as it is discussed later in the
appendix. In general, to start a producer is not a requirement. If you
have set the flag isServerAllowed to true, you can use only Task
Servers for your computations (note: still, you must start more
than one Task Server, since the root Task Server is not computing any tasks).
Start the Consumer
prompt> java -cp .;CX.jar -Djava.security.policy=policy.all
ConsumerImpl
nodeInfo topologyInfo
Ok, now it's the big time: to submit your task and wait for the results.
The ConsumerImpl implements the Consumer interface and we so how we can
create one using the CXTool at step 3. After executing the above command,
and assuming you have done correctly all the previous steps, you will get
back the results, or whatever you put in the code of the putResults
method.
The most common errors that you might encounter are missing classes
and/or connection refused. S, before start yelling make sure that all the
required classes (explicity or implicitly) are present and you have your
components started in the proper order.
Appendix: How to create node and topology files using the CXTool
To create nodeInfo and topologyInfo use the middle panel of the CXTool.
First start the CXTool by typing the following command:
prompt> java -cp CX.jar CXTool.java
Than, in the New node area you must define three fields:
-
The first one, with initial value //localhost/TS1, contains the
value of the name by which the specific node will bind with the rmiregistry. The
default values start with //localhost/... which is fine if all the code runs in
a single machine, but if you want to start some components on different machines, then
you must change the localhost to the specific machine name/IP address.
-
The second field, with initial value 1, is the node identification
number, and must be unique for a specific production network. The root
Task Server must have Id equal to 1. The rest of the nodes can have any
valid (long) number.
-
The third input parameter is the node type; that can be "producer",
"consumer" or "task server"
After choosing the appropriate type press the "Add new node" button,
and a new row will be added to the table above. The fourth column (named
"connected to") contains the default value 1, which means that this node
will be connected with node whose Id is equal to 1 (which happened to be
the root Task Server). If you don't like the default value, you can simply
edit it (but first, make sure that target node exists!)
If you have downloaded the CX toolkit, there are some demo node and topology files,
that can be used to start 1 task server,1 producer and 1 consumer on a single
machine. This is good enough when you are developing your code, and you are not
interested in performance issues. Using those files, you can set up a mini production
network by typing the following commands:
$> rmiregistry -J-cp -JCX.jar
$> java -cp CX.jar -Djava.security.policy=policy.all TaskServerImpl n1 t1
$> java -cp CX.jar -Djava.security.policy=policy.all ProducerImpl n50 t50
$> java -cp .;CX.jar -Djava.security.policy=policy.all ConsumerImpl n100
t100
Note: The sequence is important! rmiregistry must start first, and then the task
server. Producer and consumer can start without respect to each other, but is much
more reasonable to start the producer first.