Package org.apfloat.samples
Class RemoteOperationExecutor
java.lang.Object
org.apfloat.samples.RemoteOperationExecutor
- All Implemented Interfaces:
OperationExecutor
- Direct Known Subclasses:
PiDistributed.Node
Class to call an
OperationServer to execute Operations remotely.- Version:
- 1.9.0
- Author:
- Mikko Tommila
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteOperationExecutor(String host, int port) Create a new client that will connect to the server running at the specified host and port. -
Method Summary
Modifier and TypeMethodDescription<T> TExecute an operation remotely.<T> BackgroundOperation<T> executeBackground(Operation<T> operation) Execute an operation remotely.getHost()Returns the host name.intgetPort()Returns the host port.intReturns the relative weight of this executor.
-
Constructor Details
-
RemoteOperationExecutor
Create a new client that will connect to the server running at the specified host and port.- Parameters:
host- Hostname of the remote server.port- Port of the remote server.
-
-
Method Details
-
execute
Execute an operation remotely. This method will block until the return value has been received.- Specified by:
executein interfaceOperationExecutor- Type Parameters:
T- Return value type of the operation.- Parameters:
operation- The operation to execute remotely.- Returns:
- The result of the operation.
- Throws:
RuntimeException- In case of network error or if the return value class is unknown.
-
executeBackground
Execute an operation remotely. This method starts a new thread running the remote call and returns immediately.- Specified by:
executeBackgroundin interfaceOperationExecutor- Type Parameters:
T- Return value type of the operation.- Parameters:
operation- The operation to execute remotely.- Returns:
- A
BackgroundOperationfor retrieving the result of the operation later.
-
getWeight
public int getWeight()Description copied from interface:OperationExecutorReturns the relative weight of this executor. The weights of different operation executors can be used to distribute work more equally.- Specified by:
getWeightin interfaceOperationExecutor- Returns:
- The relative weight of this operation executor.
-
getHost
-
getPort
public int getPort()Returns the host port.- Returns:
- The host port.
-