Package org.redisson
Class RedissonRemoteService
- java.lang.Object
-
- org.redisson.remote.BaseRemoteService
-
- org.redisson.RedissonRemoteService
-
- All Implemented Interfaces:
RRemoteService
- Direct Known Subclasses:
RedissonExecutorRemoteService
public class RedissonRemoteService extends BaseRemoteService implements RRemoteService
- Author:
- Nikita Koksharov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRedissonRemoteService.Entry
-
Field Summary
-
Fields inherited from class org.redisson.remote.BaseRemoteService
cancelRequestMapName, cancelResponseMapName, codec, commandExecutor, executorId, name, responseQueueName
-
-
Constructor Summary
Constructors Constructor Description RedissonRemoteService(Codec codec, String name, CommandAsyncExecutor commandExecutor, String executorId, ConcurrentMap<String,ResponseEntry> responses)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RFuture<Boolean>addAsync(String requestQueueName, RemoteServiceRequest request, RemotePromise<Object> result)<T> voidderegister(Class<T> remoteInterface)Deregister all workers for remote serviceintgetFreeWorkers(Class<?> remoteInterface)Returns free workers amount available for invocationsintgetPendingInvocations(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.StringgetRequestTasksMapName(Class<?> remoteInterface)protected RFuture<RemoteServiceRequest>getTask(String requestId, RMap<String,RemoteServiceRequest> tasks)protected <T> voidinvokeMethod(RemoteServiceRequest request, RemoteServiceMethod method, RFuture<RemoteServiceCancelRequest> cancelRequestFuture, RPromise<RRemoteServiceResponse> responsePromise)<T> voidregister(Class<T> remoteInterface, T object)Register remote service with single worker<T> voidregister(Class<T> remoteInterface, T object, int workers)Register remote service with custom workers amount<T> voidregister(Class<T> remoteInterface, T object, int workers, ExecutorService executor)Register remote service with custom workers amount and executor for running themprotected RFuture<Boolean>removeAsync(String requestQueueName, RequestId taskId)<T> booleantryExecute(Class<T> remoteInterface, T object, long timeout, TimeUnit timeUnit)Tries to execute one awaiting remote request.<T> booleantryExecute(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)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.<T> RFuture<Boolean>tryExecuteAsync(Class<T> remoteInterface, T object, ExecutorService executor, long timeout, TimeUnit timeUnit)Tries to execute one awaiting remote request.-
Methods inherited from class org.redisson.remote.BaseRemoteService
encode, generateRequestId, get, get, get, get, getAckName, getAckName, getMap, getMethodSignature, getRequestQueueName, getResponseQueueName, getTimeout, scheduleCheck
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.redisson.api.RRemoteService
get, get, get, get
-
-
-
-
Constructor Detail
-
RedissonRemoteService
public RedissonRemoteService(Codec codec, String name, CommandAsyncExecutor commandExecutor, String executorId, ConcurrentMap<String,ResponseEntry> responses)
-
-
Method Detail
-
addAsync
protected RFuture<Boolean> addAsync(String requestQueueName, RemoteServiceRequest request, RemotePromise<Object> result)
- Specified by:
addAsyncin classBaseRemoteService
-
removeAsync
protected RFuture<Boolean> removeAsync(String requestQueueName, RequestId taskId)
- Specified by:
removeAsyncin classBaseRemoteService
-
register
public <T> void register(Class<T> remoteInterface, T object)
Description copied from interface:RRemoteServiceRegister remote service with single worker- Specified by:
registerin interfaceRRemoteService- Type Parameters:
T- type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service object
-
deregister
public <T> void deregister(Class<T> remoteInterface)
Description copied from interface:RRemoteServiceDeregister all workers for remote service- Specified by:
deregisterin interfaceRRemoteService- Type Parameters:
T- type of remote service- Parameters:
remoteInterface- - remote service interface
-
getPendingInvocations
public int getPendingInvocations(Class<?> remoteInterface)
Description copied from interface:RRemoteServiceReturns pending invocations amount for handling in free workers.- Specified by:
getPendingInvocationsin interfaceRRemoteService- Parameters:
remoteInterface- - remote service interface- Returns:
- invocations amount
-
getPendingInvocationsAsync
public RFuture<Integer> getPendingInvocationsAsync(Class<?> remoteInterface)
Description copied from interface:RRemoteServiceReturns pending invocations amount for handling in free workers.- Specified by:
getPendingInvocationsAsyncin interfaceRRemoteService- Parameters:
remoteInterface- - remote service interface- Returns:
- invocations amount
-
getFreeWorkers
public int getFreeWorkers(Class<?> remoteInterface)
Description copied from interface:RRemoteServiceReturns free workers amount available for invocations- Specified by:
getFreeWorkersin interfaceRRemoteService- Parameters:
remoteInterface- - remote service interface- Returns:
- workers amount
-
register
public <T> void register(Class<T> remoteInterface, T object, int workers)
Description copied from interface:RRemoteServiceRegister remote service with custom workers amount- Specified by:
registerin interfaceRRemoteService- Type Parameters:
T- type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objectworkers- - workers amount
-
register
public <T> void register(Class<T> remoteInterface, T object, int workers, ExecutorService executor)
Description copied from interface:RRemoteServiceRegister remote service with custom workers amount and executor for running them- Specified by:
registerin interfaceRRemoteService- Type Parameters:
T- type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objectworkers- - workers amountexecutor- - executor service used to invoke methods
-
tryExecute
public <T> boolean tryExecute(Class<T> remoteInterface, T object, long timeout, TimeUnit timeUnit) throws InterruptedException
Description copied from interface:RRemoteServiceTries to execute one awaiting remote request. Waits up totimeoutif necessary until remote request became available.- Specified by:
tryExecutein interfaceRRemoteService- Type Parameters:
T- - type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objecttimeout- - maximum wait time until remote request became availabletimeUnit- - time unit- Returns:
trueif method was successfully executed andfalseif timeout reached before execution- Throws:
InterruptedException- - if the thread is interrupted
-
tryExecute
public <T> boolean tryExecute(Class<T> remoteInterface, T object, ExecutorService executorService, long timeout, TimeUnit timeUnit) throws InterruptedException
Description copied from interface:RRemoteServiceTries to execute one awaiting remote request. Waits up totimeoutif necessary until remote request became available.- Specified by:
tryExecutein interfaceRRemoteService- Type Parameters:
T- - type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objectexecutorService- - executor service used to invoke methodstimeout- - maximum wait time until remote request became availabletimeUnit- - time unit- Returns:
trueif method was successfully executed andfalseif timeout reached before execution- Throws:
InterruptedException- - if the thread is interrupted
-
tryExecuteAsync
public <T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object, long timeout, TimeUnit timeUnit)
Description copied from interface:RRemoteServiceTries to execute one awaiting remote request. Waits up totimeoutif necessary until remote request became available.- Specified by:
tryExecuteAsyncin interfaceRRemoteService- Type Parameters:
T- - type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objecttimeout- - maximum wait time until remote request became availabletimeUnit- - time unit- Returns:
trueif method was successfully executed andfalseif timeout reached before execution
-
tryExecuteAsync
public <T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object, ExecutorService executor, long timeout, TimeUnit timeUnit)
Description copied from interface:RRemoteServiceTries to execute one awaiting remote request. Waits up totimeoutif necessary until remote request became available.- Specified by:
tryExecuteAsyncin interfaceRRemoteService- Type Parameters:
T- - type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service objectexecutor- - executor service used to invoke methodstimeout- - maximum wait time until remote request became availabletimeUnit- - time unit- Returns:
trueif method was successfully executed andfalseif timeout reached before execution
-
tryExecuteAsync
public <T> RFuture<Boolean> tryExecuteAsync(Class<T> remoteInterface, T object)
Description copied from interface:RRemoteServiceTries to execute one awaiting remote request.- Specified by:
tryExecuteAsyncin interfaceRRemoteService- Type Parameters:
T- - type of remote service- Parameters:
remoteInterface- - remote service interfaceobject- - remote service object- Returns:
trueif method was successfully executed andfalseif timeout reached before execution
-
invokeMethod
protected <T> void invokeMethod(RemoteServiceRequest request, RemoteServiceMethod method, RFuture<RemoteServiceCancelRequest> cancelRequestFuture, RPromise<RRemoteServiceResponse> responsePromise)
-
getTask
protected RFuture<RemoteServiceRequest> getTask(String requestId, RMap<String,RemoteServiceRequest> tasks)
-
-