com.alibaba.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance Java Examples
The following examples show how to use
com.alibaba.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractClusterInvokerTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
/** * Test balance. */ @Test public void testSelectBalance() { LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker, AtomicLong> counter = new ConcurrentHashMap<Invoker, AtomicLong>(); for (Invoker invoker : invokers) { counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for (int i = 0; i < runs; i++) { selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker : counter.keySet()) { Long count = counter.get(minvoker).get(); // System.out.println(count); if (minvoker.isAvailable()) Assert.assertTrue("count should > avg", count > runs / invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get() + counter.get(invoker4).get()); ; }
Example #2
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 5 votes |
/** * 测试均衡. */ @Test public void testSelectBalance(){ LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>(); for(Invoker invoker :invokers){ counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for(int i=0;i<runs;i++){ selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker :counter.keySet() ){ Long count = counter.get(minvoker).get(); // System.out.println(count); if(minvoker.isAvailable()) Assert.assertTrue("count should > avg", count>runs/invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());; }
Example #3
Source File: AbstractClusterInvokerTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
/** * 测试均衡. */ @Test public void testSelectBalance(){ LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>(); for(Invoker invoker :invokers){ counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for(int i=0;i<runs;i++){ selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker :counter.keySet() ){ Long count = counter.get(minvoker).get(); // System.out.println(count); if(minvoker.isAvailable()) Assert.assertTrue("count should > avg", count>runs/invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());; }
Example #4
Source File: AbstractClusterInvokerTest.java From dubbo3 with Apache License 2.0 | 5 votes |
/** * 测试均衡. */ @Test public void testSelectBalance(){ LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>(); for(Invoker invoker :invokers){ counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for(int i=0;i<runs;i++){ selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker :counter.keySet() ){ Long count = counter.get(minvoker).get(); // System.out.println(count); if(minvoker.isAvailable()) Assert.assertTrue("count should > avg", count>runs/invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());; }
Example #5
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 5 votes |
/** * 测试均衡. */ @Test public void testSelectBalance(){ LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>(); for(Invoker invoker :invokers){ counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for(int i=0;i<runs;i++){ selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker :counter.keySet() ){ Long count = counter.get(minvoker).get(); // System.out.println(count); if(minvoker.isAvailable()) Assert.assertTrue("count should > avg", count>runs/invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());; }
Example #6
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 5 votes |
/** * 测试均衡. */ @Test public void testSelectBalance(){ LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME); initlistsize5(); Map<Invoker,AtomicLong> counter = new ConcurrentHashMap<Invoker,AtomicLong>(); for(Invoker invoker :invokers){ counter.put(invoker, new AtomicLong(0)); } int runs = 1000; for(int i=0;i<runs;i++){ selectedInvokers.clear(); Invoker sinvoker = cluster.select(lb, invocation, invokers, selectedInvokers); counter.get(sinvoker).incrementAndGet(); } for (Invoker minvoker :counter.keySet() ){ Long count = counter.get(minvoker).get(); // System.out.println(count); if(minvoker.isAvailable()) Assert.assertTrue("count should > avg", count>runs/invokers.size()); } Assert.assertEquals(runs, counter.get(invoker2).get()+counter.get(invoker4).get());; }
Example #7
Source File: AbstractClusterInvokerTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers(RoundRobinLoadBalance.NAME); testSelect_multiInvokers(LeastActiveLoadBalance.NAME); testSelect_multiInvokers(RandomLoadBalance.NAME); }
Example #8
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers( RoundRobinLoadBalance.NAME); testSelect_multiInvokers( LeastActiveLoadBalance.NAME); testSelect_multiInvokers( RandomLoadBalance.NAME); }
Example #9
Source File: AbstractClusterInvokerTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers( RoundRobinLoadBalance.NAME); testSelect_multiInvokers( LeastActiveLoadBalance.NAME); testSelect_multiInvokers( RandomLoadBalance.NAME); }
Example #10
Source File: AbstractClusterInvokerTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers( RoundRobinLoadBalance.NAME); testSelect_multiInvokers( LeastActiveLoadBalance.NAME); testSelect_multiInvokers( RandomLoadBalance.NAME); }
Example #11
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers( RoundRobinLoadBalance.NAME); testSelect_multiInvokers( LeastActiveLoadBalance.NAME); testSelect_multiInvokers( RandomLoadBalance.NAME); }
Example #12
Source File: AbstractClusterInvokerTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testSelect_multiInvokers() throws Exception { testSelect_multiInvokers( RoundRobinLoadBalance.NAME); testSelect_multiInvokers( LeastActiveLoadBalance.NAME); testSelect_multiInvokers( RandomLoadBalance.NAME); }