public class RMIMethodExecutor
extends java.lang.Object
implements java.lang.Cloneable
AlgorithmRMIServer
Constructor and Description |
---|
RMIMethodExecutor(java.net.InetAddress host,
int port)
Creates a new instance of RMI algorithm.
|
RMIMethodExecutor(java.lang.String host,
int port)
Creates a new instance of RMI algorithm.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
void |
connect()
Connects this algorithm to the RMI service.
|
void |
disconnect()
Disconnects this algorithm from the RMI service.
|
void |
finalize() |
java.net.InetAddress |
getHost()
Returns the remote algorithm's IP address.
|
int |
getPort()
Returns the remote algorithm's RMI port.
|
boolean |
isConnected()
Returns true if the algorithm is currently connected.
|
protected java.lang.Object |
methodExecute(java.lang.String methodName,
int reconnectRetries,
java.lang.Object... methodArguments)
Executes a given method on the remote algorithm and returns result.
|
public RMIMethodExecutor(java.net.InetAddress host, int port)
host
- the remote algorithm's IP addressport
- the remote algorithm's RMI portpublic RMIMethodExecutor(java.lang.String host, int port) throws java.net.UnknownHostException
host
- the remote algorithm's host nameport
- the remote algorithm's RMI portjava.net.UnknownHostException
- if the host name cannot be resolved to IP addresspublic void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public java.net.InetAddress getHost()
public int getPort()
public boolean isConnected()
public void connect() throws java.io.IOException
java.io.IOException
- if there was a problem connectingpublic void disconnect()
protected java.lang.Object methodExecute(java.lang.String methodName, int reconnectRetries, java.lang.Object... methodArguments) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
reconnectRetries
times. After that
an IllegalStateException
is thrown.
Note that the result returned might be an exception.methodName
- the name of the method to execute on the remote algorithmreconnectRetries
- the number of reconnection retries if there is an
IOException
while establishing the RMI connectionmethodArguments
- the arguments for the methodjava.lang.IllegalStateException
- if there was a problem communicating with the remote algorithmjava.lang.IllegalArgumentException
- if there was a problem reading the class in the remote algorithm's result