The steps of this exercise are:
What to turn in: The code for your assignment should be in your account on talon, in a subdirectory entitled "JavaRMIExercise" or something equally obvious. I will grade your assignment by executing your code from talon. Turn in the answers to the questions on paper to me in class.
RPC is a technique for building distributed, client-server based applications. It extends the notion of conventional, or local procedure calling. With RPC the called procedure does not need to be in the same address space as the calling procedure. The two processes can be executing on the same computer or on different computers. Programmers using RPC do not need to understand the details of the interface with the network. Because RPC is a layer over the transport layer of the network, it separates the application from the physical and logical elements of the data communcations mechanisms. RPC is the predecessor to RMI.
RMI makes object function calls between Java Virtual Machines (JVMs) possible, even when the JVMs are located on separate computers. Put another way, one JVM can call methods that belong to an object that is stored in another JVM. While many RPC and similar systems only allow simple parameters, RMI allows any Java object type to be passed as a parameter. RMI even allows both client and server to dynamically load new object types and pass them as parameters! RMI abstracts the problem so that the program/client machine does not know or care whether the requested object is executed locally or on another JVM. RMI also provides security and cross-platform portability that requires a large amount of overhead using RPC, but is limited since it can only call methods written in Java.
Read the article by Waldo Waldo, J., "Remote Procedure Calls and Java Remote Method Invocation," IEEE Concurrency, vol. 6, no. 3, pp. 5-7, July 1998. Available at http://csce.uark.edu/~aapon/courses/gridcomputing/papers/waldo98.pdf, for a detailed comparison of RPC and RMI.
Notice! These will be different on talon than specified in the tutorial:
env command as follows:env CLASSPATH /home/username/directoryenv --unset CLASSPATH
rmic34 instead of rmic
myCalculator exception: Connection refused to host:
The following is a log of the tutorial. The headings correspond to the headings in the tutorial.
<<< Begin of log from talon.csce.uark.edu >>>
[username@talon JavaRMIExercise]$ pwd
/home/username/JavaRMIExercise
[username@talon JavaRMIExercise]$ ls
client compute engine
[username@talon JavaRMIExercise]$ ls client/
ComputePi.java Pi.java
[username@talon JavaRMIExercise]$ ls compute/
Compute.java Task.java
[username@talon JavaRMIExercise]$ ls engine/
ComputeEngine.java
<<< Build a JAR File of Interface Classes >>>
[username@talon JavaRMIExercise]$ javac compute/*.java
[username@talon JavaRMIExercise]$ jar cvf compute.jar compute/*.class
adding: META-INF/ (in=0) (out=0) (stored 0%)
adding: META-INF/MANIFEST.MF (in=56) (out=56) (stored 0%)
adding: compute/Compute.class (in=238) (out=168) (deflated 29%)
adding: compute/Task.class (in=166) (out=138) (deflated 16%)
Total:
------
(in = 449) (out = 813) (deflated -81%)
<<< Build the Server Classes >>>
[username@talon JavaRMIExercise]$ cd /home/username
[username@talon username]$ mkdir public_html
[username@talon username]$ mkdir public_html/classes/
[username@talon username]$ cp JavaRMIExercise/compute.jar public_html/classes/
[username@talon username]$ cd /home/username/JavaRMIExercise/
[username@talon JavaRMIExercise]$ javac -classpath ./compute.jar engine/ComputeEngine.java
[username@talon JavaRMIExercise]$ rmic34 -d . engine.ComputeEngine
[username@talon JavaRMIExercise]$ mkdir /home/username/public_html/classes/engine
[username@talon JavaRMIExercise]$ cp engine/ComputeEngine_*.class /home/username/public_html/classes/engine/
[username@talon JavaRMIExercise]$ cd /home/username/public_html/classes/
[username@talon classes]$ jar xvf compute.jar
created: META-INF/
extracted: META-INF/MANIFEST.MF
created: compute/
inflated: compute/Compute.class
inflated: compute/Task.class
<<< Build the Client Classes >>>
[username@talon ~]$ cd /home/username/JavaRMIExercise
[username@talon ~/JavaRMIExercise]$ cp compute.jar /home/username/public_html/classes/
[username@talon ~/JavaRMIExercise]$ javac -classpath /home/username/public_html/classes/compute.jar client/Pi.java
[username@talon ~/JavaRMIExercise]$ javac -classpath /home/username/JavaRMIExercise:/home/username/public_html/classes/compute.jar -d /home/username/public_html/classes/ client/myCalculator.java
<<< Start the Server >>>
[username@talon classes]$ cd /home/username/JavaRMIExercise/
[username@talon JavaRMIExercise]$ rmiregistry &
[1] 28650
[username@talon JavaRMIExercise]$ java -Djava.server.codebase=http://talon.csce.uark.edu/~username/classes/ -Djava.rmi.server.hostname=talon.csce.uark.edu engine.ComputeEngine
ComputeEngine bound
<<< Start the Client (in another terminal) >>>
[username@talon ~/JavaRMIExercise]$ java -classpath /home/username/JavaRMIExercise:/home/username/public_html/classes -Djava.rmi.server.codebase=http://talon.csce.uark.edu/~username/classes/
client.ComputePi talon.csce.uark.edu 8
3.14159265
<<< End Log from talon.csce.uark.edu>>>
Note: Steps 1-3 do not require any code editing, except for replacing "host" with "talon.csce.uark.edu" in ComputeEngine.java.
client.myCalculator machinename operator value1 value2
client.myCalculator talon.csce.uark.edu subtract 1 2
This should output the value of 1 - 2 which is -1.
(see http://java.sun.com/docs/books/tutorial/rmi/client.html for client help)
Also create the Calc class in the client package which will actually do the work (see Pi.java). ( http://java.sun.com/docs/books/tutorial/rmi/client.html )
Use the command: javac file1.java file2.java or
javac *.java for files that contain dependencies.
NOTE: javac may return errors if you use it to compile the files separately because it cannot resolve their dependencies. You can also use the classpath command line option to specify where to look for dependencies.
Rate each of the following on a scale of 1-10 where 1 is "almost none" and 10 is "a whole lot"
Enjoy!