> Skal vi ikke lige blive enige om at det ikke er Java RMI du bruger,
> men derimod CORBA som er en anden implementation af Middelware.
Damn - i min febrilitet havde jeg pastet det forkerte kode. Her kommer det
rigtige - RMI koden
/////****TEST INTERFACE****/////
package RMIPerformanceTest;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Test extends Remote {
byte[] test(int bytenum) throws RemoteException;
}
//// ****TESTER CLASS ****//////
package RMIPerformanceTest;
import java.applet.Applet;
import java.awt.Graphics;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.io.*;
import java.util.Calendar;
public class Tester {
public static void main(String args[]) {
int NUM = Integer.parseInt(args[0]);
FileWriter fos = null;
try {
fos = new FileWriter(new File("c:\\test.txt"));
}
catch (IOException ex3) {
}
long start = 0;
long stop = 0;
System.out.println("Performance Test of RMI");
Test obj = null;
try {
obj = (Test) Naming.lookup("rmi://130.225.184.185/RMITestServer");
byte[] b = obj.test(NUM);
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println("Starting test. Running 50000 times.");
start = Calendar.getInstance().getTimeInMillis();
for (long i = 0; i < 50000; i++) {
try {
byte[] a = obj.test(NUM);
}
catch (Exception e) {
System.out.println("Exception occured on server!");
}
if (i % 1000 == 0) {
stop = Calendar.getInstance().getTimeInMillis();
long delta = stop - start;
try {
fos.write(String.valueOf(delta));
}
catch (IOException ex2) {
}
System.out.println("" + i + " requests done. 1000 requests/" + NUM +
" bytes : " + delta + " ms");
start = Calendar.getInstance().getTimeInMillis();
}
}
try {
fos.close();
}
catch (IOException ex1) {
}
System.out.println("Test terminated!");
}
}
//// ****TESTIMPL CLASS****/////
package RMIPerformanceTest;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class TestImpl extends UnicastRemoteObject implements Test {
public TestImpl() throws RemoteException {
super();
}
public byte[] test(int bytenum) {
return new byte[bytenum];
}
public static void main(String args[]) {
try {
TestImpl obj = new TestImpl();
// Bind this object instance to the name "HelloServer"
Naming.rebind("rmi://130.225.184.185/RMITestServer", obj);
} catch (Exception e) {
e.printStackTrace();
}
}
}