return applicationManager.isRunning(serviceId);
}
@Override
public URL getServiceURL() {
ServiceDiscovered serviceDiscovered = discoveryServiceClient.discover(String.format("service.%s.%s.%s",
accountId,
applicationId,
serviceName));
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(serviceDiscovered);
Discoverable discoverable = endpointStrategy.pick();
if (discoverable != null) {
return createURL(discoverable, applicationId, serviceName);
}
final SynchronousQueue<URL> discoverableQueue = new SynchronousQueue<URL>();
Cancellable discoveryCancel = serviceDiscovered.watchChanges(new ServiceDiscovered.ChangeListener() {
@Override
public void onChange(ServiceDiscovered serviceDiscovered) {
try {
URL url = createURL(serviceDiscovered.iterator().next(), applicationId, serviceName);
discoverableQueue.offer(url);
} catch (NoSuchElementException e) {
LOG.debug("serviceDiscovered is empty");
}
}