Search in sources :

Example 1 with LoadBalance

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

the class FailoverHaStrategyTest method setUp.

@Before
@Override
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    super.setUp();
    loadBalance = mockery.mock(LoadBalance.class);
    final Referer<IWorld> referer1 = mockery.mock(Referer.class, "ref1");
    final Referer<IWorld> referer2 = mockery.mock(Referer.class, "ref2");
    referers = new ArrayList<Referer<IWorld>>();
    referers.add(referer1);
    referers.add(referer2);
    failoverHaStrategy = new FailoverHaStrategy<IWorld>() {

        @Override
        protected List<Referer<IWorld>> selectReferers(Request request, LoadBalance<IWorld> loadBalance) {
            return referers;
        }
    };
    URL url = new URL(MotanConstants.PROTOCOL_MOTAN, NetUtils.LOCALHOST, 0, IWorld.class.getName());
    url.addParameter(URLParamType.retries.getName(), String.valueOf(retries));
    failoverHaStrategy.setUrl(url);
}
Also used : IWorld(com.weibo.api.motan.protocol.example.IWorld) LoadBalance(com.weibo.api.motan.cluster.LoadBalance) Referer(com.weibo.api.motan.rpc.Referer) Request(com.weibo.api.motan.rpc.Request) DefaultRequest(com.weibo.api.motan.rpc.DefaultRequest) ArrayList(java.util.ArrayList) List(java.util.List) URL(com.weibo.api.motan.rpc.URL) Before(org.junit.Before)

Aggregations

LoadBalance (com.weibo.api.motan.cluster.LoadBalance)1 IWorld (com.weibo.api.motan.protocol.example.IWorld)1 DefaultRequest (com.weibo.api.motan.rpc.DefaultRequest)1 Referer (com.weibo.api.motan.rpc.Referer)1 Request (com.weibo.api.motan.rpc.Request)1 URL (com.weibo.api.motan.rpc.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Before (org.junit.Before)1