I have no idea how to do this...any help or snippets of code to get me on the right track would be most appreciated!
Last class before graduation...I am not a programmer and have the up most respect for everyone in this field....
For Step 2 of the RMI project you need to implement a non-distributed version of the application utilizing 2 components: Input/Output (IO) module and Process Coordinator (PC). The former is responsible for all I/O operations and the latter is to provide a service of remote matrix multiplication.
I/O Module:
1.Create a class, containing main() method which accepts command-line arguments. Name the class IO to honor function of the module.
2.Read an integer to be used as length of all 3 square matrices as a command-line argument. For example running java IO.IO 15 needs to be interpreted as passing N=15 where all matrices are assumed to be of dimension 15x15. It is assumed here that class IO is placed into a package named IO, that's why you run java IO.IO ... and not just java IO ... In case you don't want to deal with packages --- it is completely up to you, no points will be deducted.
3.Fill in 2 matrices A and B randomly generated integers in the range from -100 to +100. In case when matrices dimensions are appropriate (small enough) -- print both matrices. In any case, save both matrices into a text file while separating entries of the same row by a space or a tab and separating rows by a new line character, i.e. \n. Save each matrix in a separate file (we will use these files later on Step 3 to evaluate correctness of the result).
4.Locate a registry, running on the PC side (IP address or hostname can be passed as the 4th command-line argument or to be hardcoded). In case that the registry cannot be located, the I/O program must be exited with error message.
5.Lookup for a particular name (to be specified on the PC site) in the located registry and obtain a reference to the remote object registered on PC.
6.Invoke remote method mult() which takes 2 matrices (objects of class Matrix which you need to develop or simply 2-dimensional arrays of integers, i.e. int[][]) and returns their product, i.e. another matrix of whichever type you used to specify method's params.
7.Resulting matrix C, returned by the remote method needs to be displayed (in case it fits the screen) and saved into a text file, using the same format as for matrices A and B.
PC module:
1.Create a class, containing implementation of the remote method mult() to be used by I/O. This method needs to be able to multiply two matrices and return the resulting one. The class needs to be declared as extends UnicastRemoteObject implements <name of the interface>, where <name of the interface> is suggested to reflect the fact that a service is provided by PC to IO, for example PC2IO is a good candidate to name such an interface. Following the logic of naming the interface, the logic implementing class can be named to honor the fact that it contains implementation of the remote method, i.e. PC2IO_Impl. Have in mind that method mult() must be declared as throwing RemoteException, otherwise you will not be able to remotely invoke this method by means of RMI.
2.Create another class, call it PC (for instance). This class will have main() method. Within main() method:
1.Create object of class PC2IO_Impl
Note: Have in mind that such an object must be declared as of type PC2IO (interface) but needs to be created by calling constructor of class PC2IO_Impl.
2.Create new or obtain a reference to already existing Registry.
Note: At first you need to make an attempt to create a Registry. This operation may fail for many reasons, for example, when Registry does already exist. In case of failure, an exception will be thrown, so you need to catch and handle it. In the attempt to handle such thrown exception you need to try to re-use existing Registry. In case of success just use the obtained reference to the existing Registry, otherwise, in case of failure, you need to inform the user that PC cannot start (it is useless without available Registry).
3.Bind the newly created PC2IO_Impl object with some particular name (see above, in the description of the IO module) in the Registry.
Note: Following the introduced naming convention, a good name would be "PC2IO".
Overview of the operations:
Having all classes (PC, IO, PC2IO_Impl) and shared interface (PC2IO) created, you will need to run PC first. The next step is to run IO so it will generate random matrices A and B, will contact PC, will invoke remote method mult(), and finally will optionally print and save result of matrix multiplication. Both programs can be run either on the same or different computers. In former later case, IP address of the PC needs to be known on the IO side (hardcoded or passed as a command line argument). Also, in case of having both programs running on different computers, the existence of PC2IO interface on both sides must be enforced.