温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Ribbon之ILoadBalancer

发布时间:2020-07-29 14:49:12 来源:网络 阅读:703 作者:乾坤刀 栏目:软件技术

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<Server> 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<Server> getServerList(boolean availableOnly);    /**     * @return Only the servers that are up and reachable.      */     public List<Server> getReachableServers();     /**      * @return All known servers, both reachable and unreachable.      */    public List<Server> 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<Server> getServerList(ServerGroup serverGroup);          /**      * Obtain LoadBalancer related Statistics      */     public abstract LoadBalancerStats getLoadBalancerStats();     }
  • BaseLoadBalancer

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

  • DynamicServerListLoadBalancer

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

  • ZoneAwareLoadBalancer

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



















向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI