Class ClusterObserver

java.lang.Object
com.reve.redis.cluster.ClusterObserver

public class ClusterObserver extends Object
This class holds all the information about a cluster. #TODO This cluster should be Thread which constantly monitors but not yet implemented.
  • Constructor Details

    • ClusterObserver

      public ClusterObserver(String entryNodeAddress, String redisPassword)
      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 the entryNodeAddress
    • ClusterObserver

      public ClusterObserver(String redisHost, int redisPort, String redisPassword)
      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 node
      redisPassword - password for entering to this cluster. This is actually the password for the entryNodeAddress
    • 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 node
      redisPassword - password for entering to this cluster. This is actually the password for the entryNodeAddress
      maxConnectionCount - 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 of SSLConfiguration must 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

      public ArrayList<Node> getClusterNodes()
      Returns:
      the list of all cluster Node
    • getMyNode

      public Node getMyNode()
      My node is the cluster Node this ClusterObserver treating as the closest node This value is configured by user
      Returns:
      the nearest Node
    • getSlotKeysForTable

      public Set<String> getSlotKeysForTable(String tableName)
      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
      Parameters:
      tableName - table name for which slot key is needed
      Returns:
      returns a HashSet<String> containing the slot keys if this table already have some slot keys Otherwise it will return null
    • saveSlotKeyForTable

      public boolean saveSlotKeyForTable(String tableName, String slotKey)
      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 for
      slotKey - The slot key which has been mapped
      Returns:
      true if was successfully added to the list otherwise false