@Test(expectedExceptions = IllegalStateException.class) public void testResolveBeforeUpdateServiceUrl() { resolver.resolveHost(); }
@Override public InetSocketAddress resolveHost() { List<InetSocketAddress> list = addressList; checkState( list != null, "No service url is provided yet"); checkState( !list.isEmpty(), "No hosts found for service url : " + serviceUrl); if (list.size() == 1) { return list.get(0); } else { CURRENT_INDEX_UPDATER.getAndUpdate(this, last -> (last + 1) % list.size()); return list.get(currentIndex); } }
PulsarServiceNameResolver implements ServiceNameResolver { @Override public InetSocketAddress resolveHost() { List<InetSocketAddress> list = addressList; checkState( list != null, "No service url is provided yet"); checkState( !list.isEmpty(), "No hosts found for service url : " + serviceUrl); if (list.size() == 1) { return list.get(0); } else { CURRENT_INDEX_UPDATER.getAndUpdate(this, last -> (last + 1) % list.size()); return list.get(currentIndex); } } }
PulsarServiceNameResolver implements ServiceNameResolver { @Override public InetSocketAddress resolveHost() { List<InetSocketAddress> list = addressList; checkState( list != null, "No service url is provided yet"); checkState( !list.isEmpty(), "No hosts found for service url : " + serviceUrl); if (list.size() == 1) { return list.get(0); } else { CURRENT_INDEX_UPDATER.getAndUpdate(this, last -> (last + 1) % list.size()); return list.get(currentIndex); } }  }
PulsarServiceNameResolver implements ServiceNameResolver { @Override public InetSocketAddress resolveHost() { List<InetSocketAddress> list = addressList; checkState( list != null, "No service url is provided yet"); checkState( !list.isEmpty(), "No hosts found for service url : " + serviceUrl); if (list.size() == 1) { return list.get(0); } else { CURRENT_INDEX_UPDATER.getAndUpdate(this, last -> (last + 1) % list.size()); return list.get(currentIndex); } }  @Override InetSocketAddress resolveHost(); @Override URI resolveHostUri(); @Override String getServiceUrl(); @Override ServiceURI getServiceUri(); @Override void updateServiceUrl(String serviceUrl); }
PulsarServiceNameResolver implements ServiceNameResolver { @Override public InetSocketAddress resolveHost() { List<InetSocketAddress> list = addressList; checkState( list != null, "No service url is provided yet"); checkState( !list.isEmpty(), "No hosts found for service url : " + serviceUrl); if (list.size() == 1) { return list.get(0); } else { CURRENT_INDEX_UPDATER.getAndUpdate(this, last -> (last + 1) % list.size()); return list.get(currentIndex); } }  @Override InetSocketAddress resolveHost(); @Override URI resolveHostUri(); @Override String getServiceUrl(); @Override ServiceURI getServiceUri(); @Override void updateServiceUrl(String serviceUrl);  }