public class ShardedAsyncRedisClient extends AbstractAsyncRedisClient
AsyncRedisConnection
Objects and forwards the commands to one of them based on the hash of the key in the command. If there are multiple keys all the keys should map
to the same server unless aredis supports splitting of the command into multiple commands and aggregating the results of those commands.
MGET, MSET and DEL are the commands with multiple keys for which splitting of the command is supported. If multiple keys map to multiple servers
and the command is not one of these then an IllegalArgumentException is thrown.Constructor and Description |
---|
ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections)
Basic Constructor.
|
ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections,
Executor pexecutor)
Constructor which uses ConsistentKeyHasher as default.
|
ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections,
Executor pexecutor,
KeyHasher pkeyHasher)
It is preferable to use
AsyncRedisFactory than this constructor. |
Modifier and Type | Method and Description |
---|---|
List<AsyncRedisConnection> |
getConnections()
Gets List of connections
|
KeyHasher |
getKeyHasher()
Gets the Keyhasher being used
|
static int |
getUseableConnections(AsyncRedisConnection[] connections,
boolean[] useable)
Untility Method for use by KeyHashers to return the useable connections.
|
void |
setKeyHasher(KeyHasher pkeyHasher)
Sets the Keyhasher
|
Future<RedisCommandInfo> |
submitCommand(RedisCommandInfo commandInfo,
AsyncHandler<RedisCommandInfo> completionHandler,
boolean requireFutureResult,
boolean isSyncCallback)
Submit a Redis Command.
|
Future<RedisCommandInfo[]> |
submitCommands(RedisCommandInfo[] commandInfos,
AsyncHandler<RedisCommandInfo[]> completionHandler,
boolean requireFutureResult,
boolean isSyncCallback)
Submit multiple Redis Commands.
|
sendCommand, sendCommand, sendCommand, sendCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommands, submitCommands
public ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections, Executor pexecutor, KeyHasher pkeyHasher)
AsyncRedisFactory
than this constructor.pconnections
- Underlying AsyncRedisConnectionspexecutor
- Task Executor to use for Asyc APIs. Can be null if you do not use Async APIs with completion handlerpkeyHasher
- KeyHasher to use. ConsistentKeyHasher is used as default if null is passed.public ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections, Executor pexecutor)
pconnections
- Underlying AsyncRedisConnectionspexecutor
- Task Executor to use for Asyc APIs. Can be null if you do not use Async APIs with completion handlerpublic ShardedAsyncRedisClient(List<AsyncRedisConnection> pconnections)
pconnections
- Underlying AsyncRedisConnectionspublic static int getUseableConnections(AsyncRedisConnection[] connections, boolean[] useable)
connections
- Array of connectionsuseable
- A boolean array of same size containing true for those connections which are useablepublic Future<RedisCommandInfo[]> submitCommands(RedisCommandInfo[] commandInfos, AsyncHandler<RedisCommandInfo[]> completionHandler, boolean requireFutureResult, boolean isSyncCallback)
AsyncRedisClient
submitCommands
in interface AsyncRedisClient
submitCommands
in class AbstractAsyncRedisClient
commandInfos
- commands to run along with their parameterscompletionHandler
- Handler to call upon command completion. Can be nullrequireFutureResult
- Whether a Future return value is requiredisSyncCallback
- If true the callback is made directly by the Socket Channel Thread and not the configured executor. Pass true only if the handler logic is extremely light like moving the command to another Q.public Future<RedisCommandInfo> submitCommand(RedisCommandInfo commandInfo, AsyncHandler<RedisCommandInfo> completionHandler, boolean requireFutureResult, boolean isSyncCallback)
AsyncRedisClient
submitCommand
in interface AsyncRedisClient
submitCommand
in class AbstractAsyncRedisClient
commandInfo
- command to run along with its parameterscompletionHandler
- Handler to call upon command completion. Can be nullrequireFutureResult
- Whether a Future return value is requiredisSyncCallback
- If true the callback is made directly by the Socket Channel Thread and not the configured executor. Pass true only if the handler logic is extremely light like moving the command to another Q.public List<AsyncRedisConnection> getConnections()
public KeyHasher getKeyHasher()
public void setKeyHasher(KeyHasher pkeyHasher)
pkeyHasher
- KeyHasher to use for distributing a key amongst connectionsCopyright © 2013- Suresh Mahalingam. All Rights Reserved.