commit | author | age
|
a18bfa
|
1 |
package com.codingapi.tx.motan.balance; |
Z |
2 |
|
|
3 |
import com.weibo.api.motan.cluster.loadbalance.ConfigurableWeightLoadBalance; |
|
4 |
import com.weibo.api.motan.common.MotanConstants; |
|
5 |
import com.weibo.api.motan.core.extension.Activation; |
|
6 |
import com.weibo.api.motan.core.extension.SpiMeta; |
|
7 |
import com.weibo.api.motan.rpc.Referer; |
|
8 |
import com.weibo.api.motan.rpc.Request; |
|
9 |
|
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
/** |
|
13 |
* <p>权重可配置的负载均衡器</p> |
|
14 |
* |
|
15 |
* @author 张峰 zfvip_it@163.com |
|
16 |
* 2017/12/1 10:44 |
|
17 |
*/ |
|
18 |
@SpiMeta(name = "configurableWeightLcn") |
|
19 |
@Activation(key = {MotanConstants.NODE_TYPE_SERVICE, MotanConstants.NODE_TYPE_REFERER}) |
|
20 |
public class ConfigurableWeightLoadBalanceProxy extends ConfigurableWeightLoadBalance { |
|
21 |
|
|
22 |
private LCNBalanceProxy lcnBalanceProxy = new LCNBalanceProxy(); |
|
23 |
|
|
24 |
@Override |
|
25 |
protected Referer doSelect(Request request) { |
|
26 |
return lcnBalanceProxy.proxy(getReferers(),super.doSelect(request)); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
protected void doSelectToHolder(Request request, List refersHolder) { |
|
31 |
super.doSelectToHolder(request, refersHolder); |
|
32 |
refersHolder.set(0, lcnBalanceProxy.proxy(getReferers(),super.doSelect(request))); |
|
33 |
} |
|
34 |
} |