next up previous contents
Next: Extracting information from the Up: The Graphical User Interface Previous: The Graphical User Interface   Contents

Remote Method Invocation

The server program runs on a UNIX cluster, such as the CA Linux cluster. This program monitors the nodes of the cluster dynamically. The observer pattern is used to update an observer object, whenever the cluster changes in any way. This object is broadcast using RMI(Remote Method Invocation). The client GUI connects into the server, and gets a proxy to the observer object, which is used to update a graphical display, showing the status of all the nodes in the cluster.

The server broadcasts an object, using the Naming.rebind method. The object which is broadcast is the "Spy" class which contains all the information about the cluster. The "Spy" class implements an interface called "SpyInterface" which extends Remote. Every method defined in this interface must throw a RemoteException because they are going to be called remotely.


\begin{lstlisting}[frame=trbl,caption=Extract from Monitor.java]{}
UnicastRemote...
...py);
Naming.rebind(''rmi://localhost:'' + port +''/spy'', spy);
\end{lstlisting}


The client application can obtain a proxy to this object, by calling the Naming.lookup object. This is then casted into a SpyInterface object, which is the remote interface. This object is then passed through to the GUI, where the information is extracted from it.


\begin{lstlisting}[frame=trbl,caption=Extract from RmiClient.java]{}
Object obje...
... + ''/spy'');
SpyInterface spyInterface = (SpyInterface)object;
\end{lstlisting}


The main reason for using RMI over a multi-threaded ServerSocket implementation on the server-side, is that it is more efficient. There is no need to create a socket for every client machine that logs on to the server. The most important motivation for using RMI though, is that there is a relatively large amount of information to be sent to the client applications. It is much more efficient to package this information in an object and then broadcast it using RMI, than to send multiple arrays from server to client.


next up previous contents
Next: Extracting information from the Up: The Graphical User Interface Previous: The Graphical User Interface   Contents
Colm O hEigeartaigh 2003-05-30