Package com.reve.redis.cluster
Class ClusterObserver
java.lang.Object
com.reve.redis.cluster.ClusterObserver
This class holds all the information about a cluster.
#TODO This cluster should be Thread which constantly monitors but not yet implemented.
-
Constructor Summary
ConstructorsConstructorDescriptionClusterObserver(String redisHost, int redisPort, String redisPassword) Create an observer instanceClusterObserver(String redisHost, int redisPort, String redisPassword, int maxConnectionCount) Create an observer instanceClusterObserver(String entryNodeAddress, String redisPassword) Create an observer instance -
Method Summary
Modifier and TypeMethodDescriptionredis.clients.jedis.JedisClusterFor Cluster commands, need to get a connectionMy node is the clusterNodethisClusterObservertreating as the closest node This value is configured by usergetSlotKeysForTable(String tableName) Get the slot key list for the specified table.voidReads the cluster and saves all the nodes running in this clusterbooleansaveSlotKeyForTable(String tableName, String slotKey) Save a slot key for the table specified.voidsetSslConfiguration(com.reve.websocket.ssl.SSLConfiguration sslConfiguration) If ssl enabled for this redis cluster, then an instance ofSSLConfigurationmust be set before creating any connection to the cluster
-
Constructor Details
-
ClusterObserver
Create an observer instance- Parameters:
entryNodeAddress- HOST:PORT for the entry node, this node will be treated as the nearest node.redisPassword- password for entering to this cluster. This is actually the password for theentryNodeAddress
-
ClusterObserver
Create an observer instance- Parameters:
redisHost- Ip address for the entry node, this node will be treated as the nearest node.redisPort- port for the entry noderedisPassword- password for entering to this cluster. This is actually the password for theentryNodeAddress
-
ClusterObserver
public ClusterObserver(String redisHost, int redisPort, String redisPassword, int maxConnectionCount) Create an observer instance- Parameters:
redisHost- Ip address for the entry node, this node will be treated as the nearest node.redisPort- port for the entry noderedisPassword- password for entering to this cluster. This is actually the password for theentryNodeAddressmaxConnectionCount- number of maximum connection to the cluster
-
-
Method Details
-
setSslConfiguration
public void setSslConfiguration(com.reve.websocket.ssl.SSLConfiguration sslConfiguration) If ssl enabled for this redis cluster, then an instance ofSSLConfigurationmust be set before creating any connection to the cluster- Parameters:
sslConfiguration- SSL related configurations that are needed to connect to the redis cluster
-
loadClusterNodes
public void loadClusterNodes()Reads the cluster and saves all the nodes running in this cluster -
getClusterConnection
public redis.clients.jedis.JedisCluster getClusterConnection()For Cluster commands, need to get a connection- Returns:
- if needed then creates and returns a new connection otherwise gets a free connection and returns it
-
getClusterNodes
- Returns:
- the list of all cluster
Node
-
getMyNode
My node is the clusterNodethisClusterObservertreating as the closest node This value is configured by user- Returns:
- the nearest
Node
-
getSlotKeysForTable
Get the slot key list for the specified table. Each instance of SBC can have one slot key for a table. So in that case a table will end up having multiple slot keys mapped for it -
saveSlotKeyForTable
Save a slot key for the table specified. This method will also save the in my node table -> slotKey map if the given slot key belongs to myNode- Parameters:
tableName- Name of the table this slot key has been mapped forslotKey- The slot key which has been mapped- Returns:
- true if was successfully added to the list otherwise false
-