本文整理汇总了Java中org.apache.curator.x.discovery.ProviderStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ProviderStrategy类的具体用法?Java ProviderStrategy怎么用?Java ProviderStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProviderStrategy类属于org.apache.curator.x.discovery包,在下文中一共展示了ProviderStrategy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:apache,项目名称:curator,代码行数:21,代码来源:ServiceProviderImpl.java
示例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();
}
开发者ID:GeneralElectric,项目名称:snowizard-discovery,代码行数:29,代码来源:DiscoveryClient.java
示例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();
}
开发者ID:Comcast,项目名称:redirector,代码行数:12,代码来源:DiscoveryServiceProviderFactory.java
示例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();
}
开发者ID:Comcast,项目名称:redirector,代码行数:16,代码来源:DynamicServiceProviderManager.java
示例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;
}
开发者ID:Comcast,项目名称:redirector,代码行数:8,代码来源:AggregateServiceProvider.java
示例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;
}
开发者ID:apache,项目名称:curator,代码行数:8,代码来源:GenericDiscoveryContext.java
示例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;
}
开发者ID:Comcast,项目名称:redirector,代码行数:6,代码来源:TestServiceProvider.java
示例8: providerStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Bean
public ProviderStrategy<MetaData> providerStrategy() {
return new RoundRobinStrategy<>();
}
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:AbstractCommonBeans.java
示例9: setProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Autowired(required = false)
public void setProviderStrategy(ProviderStrategy<MetaData> providerStrategy) {
this.providerStrategy = providerStrategy;
}
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:ServiceProviderManagerFactory.java
示例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();
}
开发者ID:Comcast,项目名称:redirector,代码行数:6,代码来源:AbstractServiceProviderManager.java
示例11: StaticServiceProviderManager
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
StaticServiceProviderManager(Set<StackData> stacks, ZKConfig config, ProviderStrategy<MetaData> providerStrategy) {
super(providerStrategy, config);
applyStaticStackData(stacks);
}
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:StaticServiceProviderManager.java
示例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);
}
};
}
开发者ID:dclements,项目名称:cultivar_old,代码行数:80,代码来源:ServiceProviderModuleBuilder.java
示例13: setProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Inject(optional = true)
public void setProviderStrategy(@Private final ProviderStrategy<T> strategy) {
builder.providerStrategy(strategy);
}
开发者ID:dclements,项目名称:cultivar_old,代码行数:5,代码来源:ServiceProviderProvider.java
示例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>>(){});
}
开发者ID:apache,项目名称:curator,代码行数:5,代码来源:MapDiscoveryContext.java
示例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;
}
开发者ID:apache,项目名称:curator,代码行数:7,代码来源:IntegerDiscoveryContext.java
示例16: getProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Override
public ProviderStrategy<Integer> getProviderStrategy()
{
return providerStrategy;
}
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:IntegerDiscoveryContext.java
示例17: getProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Override
public ProviderStrategy<T> getProviderStrategy()
{
return providerStrategy;
}
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:GenericDiscoveryContext.java
示例18: StringDiscoveryContext
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public StringDiscoveryContext(ServiceDiscovery<String> serviceDiscovery, ProviderStrategy<String> providerStrategy, int instanceRefreshMs)
{
this.serviceDiscovery = serviceDiscovery;
this.providerStrategy = providerStrategy;
this.instanceRefreshMs = instanceRefreshMs;
}
开发者ID:apache,项目名称:curator,代码行数:7,代码来源:StringDiscoveryContext.java
示例19: getProviderStrategy
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
@Override
public ProviderStrategy<String> getProviderStrategy()
{
return providerStrategy;
}
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:StringDiscoveryContext.java
示例20: ServiceDetailsDiscoveryContext
import org.apache.curator.x.discovery.ProviderStrategy; //导入依赖的package包/类
public ServiceDetailsDiscoveryContext(ServiceDiscovery<ServiceDetails> serviceDiscovery, ProviderStrategy<ServiceDetails> providerStrategy, int instanceRefreshMs)
{
super(serviceDiscovery, providerStrategy, instanceRefreshMs, ServiceDetails.class);
}
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:ServiceDetailsDiscoveryContext.java
注:本文中的org.apache.curator.x.discovery.ProviderStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论