@Test public void multipleEndpoints() { RemoteEndpoint ep1 = new RemoteEndpoint().setServiceName(TEST_SERVICE).setEndpoint("ep1"); RemoteEndpoint ep2 = new RemoteEndpoint().setServiceName(TEST_SERVICE).setEndpoint("ep2"); registry.addEndpoint(ep1); registry.addEndpoint(ep2); Map<String, AtomicInteger> epCounts = new HashMap<String, AtomicInteger>(); epCounts.put(ep1.getEndpoint(), new AtomicInteger()); epCounts.put(ep2.getEndpoint(), new AtomicInteger()); for (int i = 0; i < 1000; i++) { RemoteEndpoint ep = random.selectEndpoint(TEST_SERVICE); epCounts.get(ep.getEndpoint()).incrementAndGet(); } Assert.assertTrue(epCounts.get(ep1.getEndpoint()).get() > 0); Assert.assertTrue(epCounts.get(ep2.getEndpoint()).get() > 0); }
@Override public RemoteEndpoint selectEndpoint(QName serviceName) { if (getRegistry() == null) { return null; } RemoteEndpoint selectedEp = null; List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName); if (!eps.isEmpty()) { int idx = _random.nextInt(Integer.MAX_VALUE) % eps.size(); selectedEp = eps.get(idx); } return selectedEp; }
RandomStrategy extends BaseStrategy { @Override public RemoteEndpoint selectEndpoint(QName serviceName) { if (getRegistry() == null) { return null; } RemoteEndpoint selectedEp = null; List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName); if (!eps.isEmpty()) { int idx = _random.nextInt(Integer.MAX_VALUE) % eps.size(); selectedEp = eps.get(idx); } return selectedEp; } }
RandomStrategy extends BaseStrategy { @Override public RemoteEndpoint selectEndpoint(QName serviceName) { if (getRegistry() == null) { return null; } RemoteEndpoint selectedEp = null; List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName); if (!eps.isEmpty()) { int idx = _random.nextInt(Integer.MAX_VALUE) % eps.size(); selectedEp = eps.get(idx); } return selectedEp; } RandomStrategy(); }
RandomStrategy extends BaseStrategy { @Override public RemoteEndpoint selectEndpoint(QName serviceName) { if (getRegistry() == null) { return null; } RemoteEndpoint selectedEp = null; List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName); if (!eps.isEmpty()) { int idx = _random.nextInt(Integer.MAX_VALUE) % eps.size(); selectedEp = eps.get(idx); } return selectedEp; } RandomStrategy(); @Override RemoteEndpoint selectEndpoint(QName serviceName); }
RandomStrategy extends BaseStrategy { @Override public RemoteEndpoint selectEndpoint(QName serviceName) { if (getRegistry() == null) { return null; } RemoteEndpoint selectedEp = null; List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName); if (!eps.isEmpty()) { int idx = _random.nextInt(Integer.MAX_VALUE) % eps.size(); selectedEp = eps.get(idx); } return selectedEp; } RandomStrategy(); @Override RemoteEndpoint selectEndpoint(QName serviceName);  }