public void addPayload(String key, String value) { payload.add(key, value); }
@Override protected Discoverable pick(ServiceDiscovered serviceDiscovered) { return pickRandom(serviceDiscovered); }
private static void waitForService(DiscoveryServiceClient discoveryService, String discoverableName) throws InterruptedException { EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryService.discover(discoverableName)); Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", discoverableName); }
public StickyEndpointStrategy(Supplier<ServiceDiscovered> serviceDiscoveredSupplier) { super(serviceDiscoveredSupplier); this.picker = new RandomEndpointStrategy(serviceDiscoveredSupplier); }
@Override public Boolean call() throws Exception { return endpointStrategy.pick() == null; } }, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
public static ResolvingDiscoverable of(Discoverable discoverable) { return new ResolvingDiscoverable(discoverable); }
@Override public void onChange(ServiceDiscovered serviceDiscovered) { // The serviceDiscovered provided is the same as the one in the field, hence ok to just call pick(). Discoverable discoverable = pick(); if (discoverable != null) { future.set(discoverable); } } }, Threads.SAME_THREAD_EXECUTOR);
private static void waitForService(String service) { EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryServiceClient.discover(service)); Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", service); }
public StickyEndpointStrategy(ServiceDiscovered serviceDiscovered) { super(serviceDiscovered); this.picker = new RandomEndpointStrategy(serviceDiscovered); }
public void addPayload(String key, String value) { payload.add(key, value); }
public static ResolvingDiscoverable of(Discoverable discoverable) { return new ResolvingDiscoverable(discoverable); }
private static void waitForService(String name) { EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryService.discover(name)); Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", name); }
@Override public EndpointStrategy get() { return new RandomEndpointStrategy(() -> discoveryClient.discover(Service.EXPLORE_HTTP_USER_SERVICE)); } });
private static void waitForService(String service) { EndpointStrategy endpointStrategy = new RandomEndpointStrategy(() -> discoveryServiceClient.discover(service)); Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", service); }
@Override public EndpointStrategy get() { return new RandomEndpointStrategy(discoveryClient.discover(Service.EXPLORE_HTTP_USER_SERVICE)); } });
@Override public EndpointStrategy get() { return new RandomEndpointStrategy(() -> discoveryClient.discover(discoverableServiceName)); } });
@Override public EndpointStrategy get() { return new RandomEndpointStrategy(discoveryClient.discover(discoverableServiceName)); } });
@Override public EndpointStrategy get() { return new RandomEndpointStrategy(() -> discoveryServiceClient.discover(Constants.Service.APP_FABRIC_HTTP)); } });