org.apache.curator.x.discovery.ServiceCacheBuilder Java Examples

The following examples show how to use org.apache.curator.x.discovery.ServiceCacheBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceProviderImpl.java    From curator with Apache License 2.0 6 votes vote down vote up
protected ServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, ExecutorService executorService, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy)
{
    this.discovery = discovery;
    this.providerStrategy = providerStrategy;

    downInstanceManager = new DownInstanceManager<>(downInstancePolicy);
    final ServiceCacheBuilder<T> builder = discovery.serviceCacheBuilder().name(serviceName);
    if (executorService != null)
    {
        builder.executorService(executorService);
    } else
    {
        //noinspection deprecation
        builder.threadFactory(threadFactory);
    }
    cache = builder.build();

    ArrayList<InstanceFilter<T>> localFilters = Lists.newArrayList(filters);
    localFilters.add(downInstanceManager);
    localFilters.add(ServiceInstance::isEnabled);
    instanceProvider = new FilteredInstanceProvider<>(cache, localFilters);
}
 
Example #2
Source File: ServiceDiscoveryImpl.java    From xian with Apache License 2.0 5 votes vote down vote up
/**
 * Allocate a new group cache builder. The refresh padding is defaulted to 1 second.
 *
 * @return new cache builder
 */
@Override
public ServiceCacheBuilder<T> serviceCacheBuilder()
{
    return new ServiceCacheBuilderImpl<T>(this)
        .threadFactory(ThreadUtils.newThreadFactory("ServiceCache"));
}
 
Example #3
Source File: MockServiceDiscovery.java    From curator with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceCacheBuilder<T> serviceCacheBuilder()
{
    throw new UnsupportedOperationException();
}
 
Example #4
Source File: ServiceDiscoveryImpl.java    From curator with Apache License 2.0 4 votes vote down vote up
/**
 * Allocate a new service cache builder. The refresh padding is defaulted to 1 second.
 *
 * @return new cache builder
 */
@Override
public ServiceCacheBuilder<T> serviceCacheBuilder()
{
    return new ServiceCacheBuilderImpl<T>(this);
}