网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Ribbon之ILoadBalancer

Ribbon 负载均衡的连轴方法,它聚合来IPing,IRule, ServerList, ServerListUpdater, ServerListFilter。

目前成都创新互联已为上千家的企业提供了网站建设、域名、网站空间、网站改版维护、企业网站设计、康平网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

  • ILoadBalancer

public interface ILoadBalancer {

   /**
    * Initial list of servers.
    * This API also serves to add additional ones at a later time
    * The same logical server (host:port) could essentially be added multiple times
    * (helpful in cases where you want to give more "weightage" perhaps ..)
    * 
    * @param newServers new servers to add
    */
   public void addServers(List newServers);
   
   /**
    * Choose a server from load balancer.
    * 
    * @param key An object that the load balancer may use to determine which server to return. null if 
    *         the load balancer does not use this parameter.
    * @return server chosen
    */
   public Server chooseServer(Object key);
   
   /**
    * To be called by the clients of the load balancer to notify that a Server is down
    * else, the LB will think its still Alive until the next Ping cycle - potentially
    * (assuming that the LB Impl does a ping)
    * 
    * @param server Server to mark as down
    */
   public void markServerDown(Server server);
   
   /**
    * @deprecated 2016-01-20 This method is deprecated in favor of the
    * cleaner {@link #getReachableServers} (equivalent to availableOnly=true)
    * and {@link #getAllServers} API (equivalent to availableOnly=false).
    *
    * Get the current list of servers.
    *
    * @param availableOnly if true, only live and available servers should be returned
    */
   @Deprecated
   public List getServerList(boolean availableOnly);

   /**
    * @return Only the servers that are up and reachable.
     */
    public List getReachableServers();

    /**
     * @return All known servers, both reachable and unreachable.
     */
   public List getAllServers();
}
  • AbstractLoadBalancer

public abstract class AbstractLoadBalancer implements ILoadBalancer {
    
    public enum ServerGroup{
        ALL,
        STATUS_UP,
        STATUS_NOT_UP        
    }
        
    /**
     * delegate to {@link #chooseServer(Object)} with parameter null.
     */
    public Server chooseServer() {
       return chooseServer(null);
    }

    
    /**
     * List of servers that this Loadbalancer knows about
     * 
     * @param serverGroup Servers grouped by status, e.g., {@link ServerGroup#STATUS_UP}
     */
    public abstract List getServerList(ServerGroup serverGroup);
    
    /**
     * Obtain LoadBalancer related Statistics
     */
    public abstract LoadBalancerStats getLoadBalancerStats();    
}
  • BaseLoadBalancer

基本实现了ILoadBalancer所使用的接口。

  • DynamicServerListLoadBalancer

在BaseLoadBalancer上,增加额外特性。这里主要是实现动态的服务列表特性。

  • ZoneAwareLoadBalancer

DynamicServerListLoadBalancer之上,增加了额外的特性。分zone的形式来配置多个loadBalancer.


当前名称:Ribbon之ILoadBalancer
URL标题:http://bjjierui.cn/article/ghhpcp.html

其他资讯