WeightedResponseTimeRule:它在功能区中如何工作?

时间:2018-06-21 08:58:26

标签: java load-balancing ribbon

WeightedResponseTimeRule如何在功能区中工作?

关于WeightedResponseTimeRule

使用平均/百分响应时间为每个服务器分配动态“权重”的规则,然后在“加权循环”中使用该规则。

但是,我不了解它calculates the *weights* per Server which is then used in the "Weighted Round Robin" fashion

这是AbstractLoadBalancerAwareClient的源代码,并且没有任何跟踪标记已更新所使用服务器的weights

```java

 public T executeWithLoadBalancer(final S request, final IClientConfig requestConfig) throws ClientException {
    LoadBalancerCommand<T> command = buildLoadBalancerCommand(request, requestConfig);

    try {
        return command.submit(
            new ServerOperation<T>() {
                @Override
                public Observable<T> call(Server server) {
                    URI finalUri = reconstructURIWithServer(server, request.getUri());
                    S requestForServer = (S) request.replaceUri(finalUri);
                    try {
                        return Observable.just(AbstractLoadBalancerAwareClient.this.execute(requestForServer, requestConfig));
                    } 
                    catch (Exception e) {
                        return Observable.error(e);
                    }
                }
            })
            .toBlocking()
            .single();
    } catch (Exception e) {
        Throwable t = e.getCause();
        if (t instanceof ClientException) {
            throw (ClientException) t;
        } else {
            throw new ClientException(e);
        }
    }

}

```

  

谢谢

0 个答案:

没有答案