Search in sources :

Example 1 with RandomLoadBalance

use of com.weibo.api.motan.cluster.loadbalance.RandomLoadBalance in project motan by weibocom.

the class ClusterTest method setUp.

@Override
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    super.setUp();
    HaStrategy<IHello> ha = new FailoverHaStrategy<IHello>();
    LoadBalance<IHello> lb = new RandomLoadBalance<IHello>();
    referers = new ArrayList<Referer<IHello>>();
    referers.add(mockery.mock(Referer.class, "ref1"));
    referers.add(mockery.mock(Referer.class, "ref2"));
    cluster.setUrl(new URL(MotanConstants.PROTOCOL_MOTAN, NetUtils.getLocalAddress().getHostAddress(), 0, RegistryService.class.getName()));
    cluster.setHaStrategy(ha);
    cluster.setLoadBalance(lb);
    cluster.onRefresh(referers);
    cluster.init();
}
Also used : Referer(com.weibo.api.motan.rpc.Referer) FailoverHaStrategy(com.weibo.api.motan.cluster.ha.FailoverHaStrategy) IHello(com.weibo.api.motan.protocol.example.IHello) RandomLoadBalance(com.weibo.api.motan.cluster.loadbalance.RandomLoadBalance) URL(com.weibo.api.motan.rpc.URL)

Aggregations

FailoverHaStrategy (com.weibo.api.motan.cluster.ha.FailoverHaStrategy)1 RandomLoadBalance (com.weibo.api.motan.cluster.loadbalance.RandomLoadBalance)1 IHello (com.weibo.api.motan.protocol.example.IHello)1 Referer (com.weibo.api.motan.rpc.Referer)1 URL (com.weibo.api.motan.rpc.URL)1