public interface RRemoteService
1. Server side instance (worker instance). Register object with RRemoteService instance.
RRemoteService remoteService = redisson.getRemoteService();
// register remote service before any remote invocation
remoteService.register(SomeServiceInterface.class, someServiceImpl);
2. Client side instance. Invokes method remotely.
RRemoteService remoteService = redisson.getRemoteService();
SomeServiceInterface service = remoteService.get(SomeServiceInterface.class);
String result = service.doSomeStuff(1L, "secondParam", new AnyParam());
There are two timeouts during execution:
Acknowledge (Ack) timeout.Client side instance waits for acknowledge message from Server side instance.
If acknowledge has not been received by Client side instance then RemoteServiceAckTimeoutException
will be thrown.
And next invocation attempt can be made.
If acknowledge has not been received Client side instance but Server side instance has received invocation message already. In this case invocation will be skipped, due to ack timeout checking by Server side instance.
Execution timeout. Client side instance received acknowledge message. If it hasn't received any result or error
from server side during execution timeout then RemoteServiceTimeoutException
will be thrown.
Modifier and Type | Method and Description |
---|---|
<T> void |
deregister(Class<T> remoteInterface)
Deregister all workers for remote service
|
<T> T |
get(Class<T> remoteInterface)
Get remote service object for remote invocations.
|
<T> T |
get(Class<T> remoteInterface,
long executionTimeout,
TimeUnit executionTimeUnit)
Get remote service object for remote invocations
with specified invocation timeout.
|
<T> T |
get(Class<T> remoteInterface,
long executionTimeout,
TimeUnit executionTimeUnit,
long ackTimeout,
TimeUnit ackTimeUnit)
Get remote service object for remote invocations
with specified invocation and ack timeouts
This method is a shortcut for
get(remoteInterface, RemoteInvocationOptions.defaults()
.expectAckWithin(ackTimeout, ackTimeUnit)
.expectResultWithin(executionTimeout, executionTimeUnit))
|
<T> T |
get(Class<T> remoteInterface,
RemoteInvocationOptions options)
Get remote service object for remote invocations
with the specified options
Note that when using the noResult() option,
it is expected that the invoked method returns void,
or else IllegalArgumentException will be thrown.
|
int |
getFreeWorkers(Class<?> remoteInterface)
Returns free workers amount available for invocations
|
int |
getPendingInvocations(Class<?> remoteInterface)
Returns pending invocations amount for handling in free workers.
|
RFuture<Integer> |
getPendingInvocationsAsync(Class<?> remoteInterface)
Returns pending invocations amount for handling in free workers.
|
<T> void |
register(Class<T> remoteInterface,
T object)
Register remote service with single worker
|
<T> void |
register(Class<T> remoteInterface,
T object,
int workersAmount)
Register remote service with custom workers amount
|
<T> void |
register(Class<T> remoteInterface,
T object,
int workers,
ExecutorService executor)
Register remote service with custom workers amount
and executor for running them
|
<T> boolean |
tryExecute(Class<T> remoteInterface,
T object,
ExecutorService executorService,
long timeout,
TimeUnit timeUnit)
Tries to execute one awaiting remote request.
|
<T> boolean |
tryExecute(Class<T> remoteInterface,
T object,
long timeout,
TimeUnit timeUnit)
Tries to execute one awaiting remote request.
|
<T> RFuture<Boolean> |
tryExecuteAsync(Class<T> remoteInterface,
T object)
Tries to execute one awaiting remote request.
|
<T> RFuture<Boolean> |
tryExecuteAsync(Class<T> remoteInterface,
T object,
ExecutorService executorService,
long timeout,
TimeUnit timeUnit)
Tries to execute one awaiting remote request.
|
<T> RFuture<Boolean> |
tryExecuteAsync(Class<T> remoteInterface,
T object,
long timeout,
TimeUnit timeUnit)
Tries to execute one awaiting remote request.
|
int getFreeWorkers(Class<?> remoteInterface)
remoteInterface
- - remote service interfaceint getPendingInvocations(Class<?> remoteInterface)
remoteInterface
- - remote service interfaceRFuture<Integer> getPendingInvocationsAsync(Class<?> remoteInterface)
remoteInterface
- - remote service interface<T> void register(Class<T> remoteInterface, T object)
T
- type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service object<T> void register(Class<T> remoteInterface, T object, int workersAmount)
T
- type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objectworkersAmount
- - workers amount<T> void register(Class<T> remoteInterface, T object, int workers, ExecutorService executor)
T
- type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objectworkers
- - workers amountexecutor
- - executor service used to invoke methods<T> void deregister(Class<T> remoteInterface)
T
- type of remote serviceremoteInterface
- - remote service interface<T> boolean tryExecute(Class<T> remoteInterface, T object, long timeout, TimeUnit timeUnit) throws InterruptedException
timeout
if necessary until remote request became available.T
- - type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objecttimeout
- - maximum wait time until remote request became availabletimeUnit
- - time unittrue
if method was successfully executed and
false
if timeout reached before executionInterruptedException
- - if the thread is interrupted<T> boolean tryExecute(Class<T> remoteInterface, T object, ExecutorService executorService, long timeout, TimeUnit timeUnit) throws InterruptedException
timeout
if necessary until remote request became available.T
- - type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objecttimeout
- - maximum wait time until remote request became availabletimeUnit
- - time unitexecutorService
- - executor service used to invoke methodstrue
if method was successfully executed and
false
if timeout reached before executionInterruptedException
- - if the thread is interrupted<T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object)
T
- - type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objecttrue
if method was successfully executed and
false
if timeout reached before execution<T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object, long timeout, TimeUnit timeUnit)
timeout
if necessary until remote request became available.T
- - type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objecttimeout
- - maximum wait time until remote request became availabletimeUnit
- - time unittrue
if method was successfully executed and
false
if timeout reached before execution<T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object, ExecutorService executorService, long timeout, TimeUnit timeUnit)
timeout
if necessary until remote request became available.T
- - type of remote serviceremoteInterface
- - remote service interfaceobject
- - remote service objecttimeout
- - maximum wait time until remote request became availabletimeUnit
- - time unitexecutorService
- - executor service used to invoke methodstrue
if method was successfully executed and
false
if timeout reached before execution<T> T get(Class<T> remoteInterface)
This method is a shortcut for
get(remoteInterface, RemoteInvocationOptions.defaults())
T
- type of remote serviceremoteInterface
- - remote service interfaceRemoteInvocationOptions.defaults()
,
get(Class, RemoteInvocationOptions)
<T> T get(Class<T> remoteInterface, long executionTimeout, TimeUnit executionTimeUnit)
This method is a shortcut for
get(remoteInterface, RemoteInvocationOptions.defaults() .expectResultWithin(executionTimeout, executionTimeUnit))
T
- type of remote serviceremoteInterface
- - remote service interfaceexecutionTimeout
- - invocation timeoutexecutionTimeUnit
- - time unitRemoteInvocationOptions.defaults()
,
get(Class, RemoteInvocationOptions)
<T> T get(Class<T> remoteInterface, long executionTimeout, TimeUnit executionTimeUnit, long ackTimeout, TimeUnit ackTimeUnit)
This method is a shortcut for
get(remoteInterface, RemoteInvocationOptions.defaults() .expectAckWithin(ackTimeout, ackTimeUnit) .expectResultWithin(executionTimeout, executionTimeUnit))
T
- type of remote serviceremoteInterface
- - remote service interfaceexecutionTimeout
- - invocation timeoutexecutionTimeUnit
- - time unitackTimeout
- - ack timeoutackTimeUnit
- - time unitRemoteInvocationOptions
,
get(Class, RemoteInvocationOptions)
<T> T get(Class<T> remoteInterface, RemoteInvocationOptions options)
Note that when using the noResult() option, it is expected that the invoked method returns void, or else IllegalArgumentException will be thrown.
T
- type of remote serviceremoteInterface
- - remote service interfaceoptions
- - service optionsRemoteInvocationOptions
Copyright © 2014–2020 Redisson. All rights reserved.