@Override public int getNumBadEndPoints() { return _pool.getNumBadEndPoints(); } }
/** * Builds a {@code MultiThreadedClientServiceCache} with a default executor and cleanup delay. * Used by the builder. * * @param serviceFactory The service factory for creating service handles * @param metricRegistry The metric registry for reporting metrics */ MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, MetricRegistry metricRegistry) { this(serviceFactory, buildDefaultExecutor(), DEFAULT_EVICTION_DELAY_SECONDS, DEFAULT_CLEANUP_DELAY_SECONDS, metricRegistry); }
@Override public Integer getValue() { return getNumValidEndPoints(); } });
@Override public void stop() { ServicePoolProxies.close(_proxy); } }
/** * Builds a dynamic proxy that wraps a {@code ServicePool} and implements the service interface directly. This is * appropriate for stateless services where it's sensible for the same retry policy to apply to every method. * <p/> * It is the caller's responsibility to shutdown the service pool when they're done with it by casting the proxy * to {@link java.io.Closeable} and calling the {@link java.io.Closeable#close()} method. * * @param retryPolicy The retry policy to apply for every service call. * @return The dynamic proxy instance that implements the service interface {@code S} and the * {@link java.io.Closeable} interface. */ public S buildProxy(RetryPolicy retryPolicy) { return ServicePoolProxy.create(_serviceType, retryPolicy, build(), _partitionContextSupplier, true); }
public ServiceCache<S> build() { checkNotNull(_cachingPolicy, "cachingPolicy"); if (_cachingPolicy.useMultiThreadedClientPolicy()) { checkNotNull(_serviceFactory, "serviceFactory"); checkArgument((_serviceFactory instanceof MultiThreadedServiceFactory), "Please implement MultiThreadedServiceFactory to construct MultiThreadedClientServiceCache"); return new MultiThreadedClientServiceCache<>((MultiThreadedServiceFactory<S>) _serviceFactory, _metricRegistry); } else { checkNotNull(_serviceFactory, "serviceFactory"); checkNotNull(_metricRegistry, "metricRegistry"); return new SingleThreadedClientServiceCache<>(_cachingPolicy, _serviceFactory, _metricRegistry); } }
@Override public R call() throws Exception { return _pool.execute(retryPolicy, callback); } });
/** * Builds a {@code com.bazaarvoice.ostrich.ServicePool}. * * @return The {@code com.bazaarvoice.ostrich.ServicePool} that was constructed. */ public com.bazaarvoice.ostrich.ServicePool<S> build() { return buildInternal(); }
@Override public int getNumActiveInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumActiveInstances(endPoint); } };
@Override public int getNumIdleCachedInstances(ServiceEndPoint endPoint) { return _serviceCache.getNumIdleInstances(endPoint); }
/** * Builds a dynamic proxy that wraps a {@code ServicePool} and implements the service interface directly. This is * appropriate for stateless services where it's sensible for the same retry policy to apply to every method. * <p/> * It is the caller's responsibility to shutdown the service pool when they're done with it by casting the proxy * to {@link java.io.Closeable} and calling the {@link java.io.Closeable#close()} method. * * @param retryPolicy The retry policy to apply for every service call. * @return The dynamic proxy instance that implements the service interface {@code S} and the * {@link java.io.Closeable} interface. */ public S buildProxy(RetryPolicy retryPolicy) { return ServicePoolProxy.create(_serviceType, retryPolicy, build(), _partitionContextSupplier, true); }
public ServiceCache<S> build() { checkNotNull(_cachingPolicy, "cachingPolicy"); if (_cachingPolicy.useMultiThreadedClientPolicy()) { checkNotNull(_serviceFactory, "serviceFactory"); checkArgument((_serviceFactory instanceof MultiThreadedServiceFactory), "Please implement MultiThreadedServiceFactory to construct MultiThreadedClientServiceCache"); return new MultiThreadedClientServiceCache<>((MultiThreadedServiceFactory<S>) _serviceFactory, _metricRegistry); } else { checkNotNull(_serviceFactory, "serviceFactory"); checkNotNull(_metricRegistry, "metricRegistry"); return new SingleThreadedClientServiceCache<>(_cachingPolicy, _serviceFactory, _metricRegistry); } }
@Override public int getNumBadEndPoints() { return _pool.getNumBadEndPoints(); } }
/** * Builds a basic service cache. * * @param policy The configuration for this cache. * @param serviceFactory The factory to fall back to on cache misses. * @param metrics The metric registry. */ SingleThreadedClientServiceCache(ServiceCachingPolicy policy, ServiceFactory<S> serviceFactory, MetricRegistry metrics) { this(policy, serviceFactory, buildDefaultExecutor(), metrics); }
@Override public R call() throws Exception { return _pool.execute(partitionContext, retryPolicy, callback); } });
/** * Builds a {@code com.bazaarvoice.ostrich.ServicePool}. * * @return The {@code com.bazaarvoice.ostrich.ServicePool} that was constructed. */ public com.bazaarvoice.ostrich.ServicePool<S> build() { return buildInternal(); }
@Override public Integer getValue() { return getNumBadEndPoints(); } });
/** * Builds a {@code MultiThreadedClientServiceCache} with a default executor and cleanup delay. * Used by the builder. * * @param serviceFactory The service factory for creating service handles * @param metricRegistry The metric registry for reporting metrics */ MultiThreadedClientServiceCache(MultiThreadedServiceFactory<S> serviceFactory, MetricRegistry metricRegistry) { this(serviceFactory, buildDefaultExecutor(), DEFAULT_EVICTION_DELAY_SECONDS, DEFAULT_CLEANUP_DELAY_SECONDS, metricRegistry); }
@Override public R call() throws Exception { return _pool.execute(retryPolicy, callback); } });
@Override public Integer getValue() { return getNumBadEndPoints(); } });