本文整理汇总了Java中org.apache.curator.x.discovery.ProviderStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ProviderStrategy类的具体用法?Java ProviderStrategy怎么用?Java ProviderStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProviderStrategy类属于org.apache.curator.x.discovery包,在下文中一共展示了ProviderStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServiceProviderImpl
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public ServiceProviderImpl(ServiceDiscoveryImpl<T> discovery, String serviceName, ProviderStrategy<T> providerStrategy, ThreadFactory threadFactory, List<InstanceFilter<T>> filters, DownInstancePolicy downInstancePolicy)
{
this.discovery = discovery;
this.providerStrategy = providerStrategy;
downInstanceManager = new DownInstanceManager<T>(downInstancePolicy);
cache = discovery.serviceCacheBuilder().name(serviceName).threadFactory(threadFactory).build();
ArrayList<InstanceFilter<T>> localFilters = Lists.newArrayList(filters);
localFilters.add(downInstanceManager);
localFilters.add(new InstanceFilter<T>()
{
@Override
public boolean apply(ServiceInstance<T> instance)
{
return instance.isEnabled();
}
});
instanceProvider = new FilteredInstanceProvider<T>(cache, localFilters);
}
示例2: DiscoveryClient
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
/**
* Constructor
*
* @param serviceName
* name of the service to monitor
* @param discovery
* {@link ServiceDiscovery}
* @param downInstancePolicy
* {@link DownInstancePolicy} to use when marking instances as
* down
* @param providerStrategy
* {@link ProviderStrategy} to use when selecting an instance
*/
public DiscoveryClient(final String serviceName,
final ServiceDiscovery<InstanceMetadata> discovery,
final DownInstancePolicy downInstancePolicy,
final ProviderStrategy<InstanceMetadata> providerStrategy) {
checkNotNull(serviceName);
checkArgument(!serviceName.isEmpty(), "serviceName cannot be empty");
checkNotNull(providerStrategy);
this.discovery = checkNotNull(discovery);
this.provider = discovery.serviceProviderBuilder()
.serviceName(serviceName)
.downInstancePolicy(downInstancePolicy)
.providerStrategy(providerStrategy).build();
}
示例3: DiscoveryServiceProviderFactory
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public DiscoveryServiceProviderFactory(ZKConfig config,
ProviderStrategy<MetaData> providerStrategy,
CuratorFramework curatorFramework,
IDiscoveryBackupManager discoveryStacksBackupManager) {
this.config = config;
this.providerStrategy = providerStrategy;
this.curatorFramework = curatorFramework;
this.discoveryStacksBackupManager = discoveryStacksBackupManager;
init();
}
示例4: DynamicServiceProviderManager
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
DynamicServiceProviderManager(ZKConfig config,
ProviderStrategy<MetaData> providerStrategy,
Supplier<Set<XreStackPath>> availableStacksSupplier,
Initializer backupInitializer,
DynamicServiceProviderFactory dynamicServiceProviderFactory) {
super(providerStrategy, config);
this.stacksChangeObserver = new StacksChangeObserver(availableStacksSupplier);
this.backupInitializer = backupInitializer;
this.dynamicServiceProviderFactory = dynamicServiceProviderFactory;
this.updatePeriodInSeconds = config.getDiscoveryUpdatePeriodInSeconds();
start();
}
示例5: AggregateServiceProvider
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public AggregateServiceProvider(ProviderStrategy<MetaData> providerStrategy,
Collection<IFilteredServiceProvider> providers,
String flavor) {
this.providerStrategy = providerStrategy;
this.instanceProvider = new InstanceProviderImpl(providers);
this.flavor = flavor;
}
示例6: GenericDiscoveryContext
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, TypeToken<T> payloadType)
{
this.serviceDiscovery = serviceDiscovery;
this.providerStrategy = providerStrategy;
this.instanceRefreshMs = instanceRefreshMs;
this.payloadType = payloadType;
}
示例7: TestServiceProvider
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public TestServiceProvider(ProviderStrategy providerStrategy, List<ServiceInstance<MetaData>> serviceInstances, XreStackPath stack) {
this.providerStrategy = providerStrategy;
this.serviceInstances = serviceInstances;
this.stack = stack;
}
示例8: providerStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Bean
public ProviderStrategy<MetaData> providerStrategy() {
return new RoundRobinStrategy<>();
}
示例9: setProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Autowired(required = false)
public void setProviderStrategy(ProviderStrategy<MetaData> providerStrategy) {
this.providerStrategy = providerStrategy;
}
示例10: AbstractServiceProviderManager
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
AbstractServiceProviderManager(ProviderStrategy<MetaData> providerStrategy, ZKConfig config) {
this.providerStrategy = providerStrategy;
this.config = config;
this.excludedApps = config.getExcludedAppsFromStackAutoDiscovery();
}
示例11: StaticServiceProviderManager
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
StaticServiceProviderManager(Set<StackData> stacks, ZKConfig config, ProviderStrategy<MetaData> providerStrategy) {
super(providerStrategy, config);
applyStaticStackData(stacks);
}
示例12: build
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Module build() {
checkState(serviceName != null, "name not set.");
checkState(discoveryAnnotation != null, "Annotation for discovery not set.");
checkState(targetAnnotation != null, "Target annotation not set.");
return new AbstractModule() {
@Override
protected void configure() {
requireBinding(discoveryAnnotation.generateKey(Types.newParameterizedType(ServiceProviderBuilder.class,
payloadClass)));
final Key<ServiceProviderManager<T>> manager = (Key<ServiceProviderManager<T>>) targetAnnotation
.generateKey(Types.newParameterizedType(ServiceProviderManager.class, payloadClass));
install(new PrivateModule() {
@Override
protected void configure() {
AnnotationHolder privateAnnotation = AnnotationHolder.create(Private.class);
Multibinder<InstanceFilter<T>> filters = Multibinder.newSetBinder(
binder(),
(TypeLiteral<InstanceFilter<T>>) Key.get(
Types.newParameterizedType(InstanceFilter.class, payloadClass))
.getTypeLiteral(), Private.class);
for (InstanceFilter<T> o : instanceFilters) {
filters.addBinding().toInstance(o);
}
if (strategy != null) {
bind(
(Key<ProviderStrategy<T>>) Key.get(
Types.newParameterizedType(ProviderStrategy.class, payloadClass),
Private.class)).toInstance(strategy);
}
if (threads != null) {
bind(ThreadFactory.class).annotatedWith(Private.class).toInstance(threads);
}
if (downInstancePolicy != null) {
bind(DownInstancePolicy.class).annotatedWith(Private.class).toInstance(downInstancePolicy);
}
bind(
(Key<ServiceProviderBuilder<T>>) privateAnnotation.generateKey(Types
.newParameterizedType(ServiceProviderBuilder.class, payloadClass))).to(
(Key<ServiceProviderBuilder<T>>) discoveryAnnotation.generateKey(Types
.newParameterizedType(ServiceProviderBuilder.class, payloadClass)));
bindConstant().annotatedWith(Private.class).to(serviceName);
Key<ServiceProvider<T>> target = (Key<ServiceProvider<T>>) targetAnnotation.generateKey(Types
.newParameterizedType(ServiceProvider.class, payloadClass));
bind(target).toProvider(
(Key<ServiceProviderProvider<T>>) Key.get(Types.newParameterizedType(
ServiceProviderProvider.class, payloadClass))).in(Singleton.class);
expose(target);
bind(
(Key<ServiceProvider<T>>) privateAnnotation.generateKey(Types.newParameterizedType(
ServiceProvider.class, payloadClass))).to(target).in(Singleton.class);
bind(manager).to(
(Key<ServiceProviderManager<T>>) Key.get(Types.newParameterizedType(
ServiceProviderManager.class, payloadClass))).in(Singleton.class);
expose(manager);
}
});
Multibinder.newSetBinder(binder(), CuratorService.class).addBinding().to(manager);
}
};
}
示例13: setProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Inject(optional = true)
public void setProviderStrategy(@Private final ProviderStrategy<T> strategy) {
builder.providerStrategy(strategy);
}
示例14: MapDiscoveryContext
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public MapDiscoveryContext(ServiceDiscovery<Map<String, String>> serviceDiscovery, ProviderStrategy<Map<String, String>> providerStrategy, int instanceRefreshMs)
{
super(serviceDiscovery, providerStrategy, instanceRefreshMs, new TypeToken<Map<String, String>>(){});
}
示例15: IntegerDiscoveryContext
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public IntegerDiscoveryContext(ServiceDiscovery<Integer> serviceDiscovery, ProviderStrategy<Integer> providerStrategy, int instanceRefreshMs)
{
this.serviceDiscovery = serviceDiscovery;
this.providerStrategy = providerStrategy;
this.instanceRefreshMs = instanceRefreshMs;
}