/** * Closes the service pool associated with the specified dynamic service proxy. * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. */ public static <S> void close(S dynamicProxy) { // Use closeQuietly since ServicePool.close() doesn't throw IOException. try { Closeables.close(getPool(dynamicProxy), true); } catch (IOException e) { throw new AssertionError(); // close swallows IOExceptions } }
@Override public void stop() { ServicePoolProxies.close(_proxy); } }
/** * Wraps the specified dynamic proxy with the Dropwizard {@link Managed} interface. * @param proxy A dynamic service proxy created by {@link ServicePoolBuilder#buildProxy(RetryPolicy)}. */ public ManagedServicePoolProxy(Object proxy) { checkArgument(ServicePoolProxies.isProxy(proxy)); _proxy = proxy; }
/** * Gets the number of valid end points that the provided service pool knows about. * @see ServicePool#getNumValidEndPoints() */ public static <S> int getNumValidEndPoints(S dynamicProxy) { return getPool(dynamicProxy).getNumValidEndPoints(); }
@Override public void run() { _log.info("Closing service pool and ZooKeeper connection for {}", location); ServicePoolProxies.close(authDataStore); if (curator.isPresent()) { try { Closeables.close(curator.get(), true); } catch (IOException e) { // Won't happen, already caught } } } };
/** * Returns the {@link com.bazaarvoice.ostrich.ServicePool} used by the specified dynamic service proxy. This can be * used for various reasons, including making a service call using non-standard retry parameters or getting access * to service pool statistics. * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. * @return The {@link com.bazaarvoice.ostrich.ServicePool} used by the specified dynamic service proxy. */ public static <S> com.bazaarvoice.ostrich.ServicePool<S> getPool(S dynamicProxy) { checkNotNull(dynamicProxy); checkArgument(isProxy(dynamicProxy)); @SuppressWarnings("unchecked") ServicePoolProxy<S> poolProxy = (ServicePoolProxy<S>) Proxy.getInvocationHandler(dynamicProxy); return poolProxy.getServicePool(); } }
/** * Gets the number of bad end points that the provided service pool knows about. * @see ServicePool#getNumBadEndPoints() */ public static <S> int getNumBadEndPoints(S dynamicProxy) { return getPool(dynamicProxy).getNumBadEndPoints(); }
@Override public void run() { _log.info("Closing service pool and ZooKeeper connection for {}", location); ServicePoolProxies.close(authDataStore); if (curator.isPresent()) { try { Closeables.close(curator.get(), true); } catch (IOException e) { // Won't happen, already caught } } } };
/** * Returns the {@link com.bazaarvoice.ostrich.ServicePool} used by the specified dynamic service proxy. This can be * used for various reasons, including making a service call using non-standard retry parameters or getting access * to service pool statistics. * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. * @return The {@link com.bazaarvoice.ostrich.ServicePool} used by the specified dynamic service proxy. */ public static <S> com.bazaarvoice.ostrich.ServicePool<S> getPool(S dynamicProxy) { checkNotNull(dynamicProxy); checkArgument(isProxy(dynamicProxy)); @SuppressWarnings("unchecked") ServicePoolProxy<S> poolProxy = (ServicePoolProxy<S>) Proxy.getInvocationHandler(dynamicProxy); return poolProxy.getServicePool(); } }
/** * Gets the number of valid end points that the provided service pool knows about. * @see ServicePool#getNumValidEndPoints() */ public static <S> int getNumValidEndPoints(S dynamicProxy) { return getPool(dynamicProxy).getNumValidEndPoints(); }
ServicePoolProxies.close(uac);
/** * Finds a healthy end point in the pool and provides the result of the health check that showed it to be healthy. * @see com.bazaarvoice.ostrich.ServicePool#checkForHealthyEndPoint * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. * @return {@code HealthCheckResults} with the first healthy end point found, or a {@code HealthCheckResults} * containing all failed {@code HealthCheckResult}s encountered if no healthy end points exist. */ public static <S> HealthCheckResults checkForHealthyEndPoint(S dynamicProxy) { return getPool(dynamicProxy).checkForHealthyEndPoint(); }
ServicePoolProxies.close(service); Closeables.close(curator, true);
/** * Finds a healthy end point in the pool and provides the result of the health check that showed it to be healthy. * @see com.bazaarvoice.ostrich.ServicePool#checkForHealthyEndPoint * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. * @return {@code HealthCheckResults} with the first healthy end point found, or a {@code HealthCheckResults} * containing all failed {@code HealthCheckResult}s encountered if no healthy end points exist. */ public static <S> HealthCheckResults checkForHealthyEndPoint(S dynamicProxy) { return getPool(dynamicProxy).checkForHealthyEndPoint(); }
user.use(); ServicePoolProxies.close(service); Closeables.close(curator, true);
/** * Returns a newly constructed health check for the pool of the given proxy that will show as healthy if * it has at least one healthy end point. * * @param proxy The {@code ServicePoolProxy} containing the service pool to look for valid end points in. */ public static ContainsHealthyEndPointCheck forProxy(Object proxy) { return new ContainsHealthyEndPointCheck(ServicePoolProxies.getPool(proxy)); }
/** * Returns a newly constructed health check for the pool of the given proxy that will show as healthy if it has at * least one valid end point. * * @param proxy The {@code ServicePoolProxy} containing the service pool to look for valid end points in. */ public static ContainsValidEndPointCheck forProxy(Object proxy) { return new ContainsValidEndPointCheck(ServicePoolProxies.getPool(proxy)); }
/** * Gets the number of bad end points that the provided service pool knows about. * @see ServicePool#getNumBadEndPoints() */ public static <S> int getNumBadEndPoints(S dynamicProxy) { return getPool(dynamicProxy).getNumBadEndPoints(); }
public static ContainsHealthyEndPointCheck create(AuthDatabus authDatabus) { return ContainsHealthyEndPointCheck.forPool(ServicePoolProxies.getPool(authDatabus)); }
/** * Closes the service pool associated with the specified dynamic service proxy. * @param dynamicProxy A service pool dynamic proxy created by {@link ServicePoolBuilder#buildProxy}. * @param <S> The service interface type. */ public static <S> void close(S dynamicProxy) { // Use closeQuietly since ServicePool.close() doesn't throw IOException. try { Closeables.close(getPool(dynamicProxy), true); } catch (IOException e) { throw new AssertionError(); // close swallows IOExceptions } }