Class BaseLoadBalancer

  • All Implemented Interfaces:
    ILoadBalancer

    public abstract class BaseLoadBalancer
    extends java.lang.Object
    implements ILoadBalancer
    This class serves as the parent for all implementation of Load Balancing logic for SFS2X Cluster.

    A new implementation of the ILoadBalancer will typically extend the BaseLoadBalancer class which offers a few concrete methods to access the current nodes in the cluster and read the configuration properties for the Load Balancer itself.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.slf4j.Logger log  
      protected java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.String> props  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Collection<com.smartfoxserver.cluster.data.SFSGameNode> getGameNodes()
      Provides the list of active(1) and healthy(2) Game Nodes currently connected to the cluster.
      protected java.lang.String getProperty​(java.lang.String key)
      Get the value of specific load balancer setting.
      void init()
      Used for custom initialization if necessary
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • props

        protected final java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.String> props
    • Constructor Detail

      • BaseLoadBalancer

        public BaseLoadBalancer()
    • Method Detail

      • init

        public void init()
        Description copied from interface: ILoadBalancer
        Used for custom initialization if necessary
        Specified by:
        init in interface ILoadBalancer
      • getGameNodes

        protected java.util.Collection<com.smartfoxserver.cluster.data.SFSGameNode> getGameNodes()
        Provides the list of active(1) and healthy(2) Game Nodes currently connected to the cluster.
        1. active: nodes joined in the cluster
        2. healthy: nodes that have replied to health checks in less than the configured threshold
        Returns:
        the list of Game Nodes currently connected to the cluster
      • getProperty

        protected java.lang.String getProperty​(java.lang.String key)
        Get the value of specific load balancer setting.

        These values are configured via the AdminTool > Cluster Settings and provide runtime custom configuration for the LB

        Parameters:
        key - the key name
        Returns:
        the value associated with the provided key, or null if no value is associated to that key