• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.curator.x.discovery.ServiceCache的典型用法代码示例。如果您正苦于以下问题:Java ServiceCache类的具体用法?Java ServiceCache怎么用?Java ServiceCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceCache类属于org.apache.curator.x.discovery包,在下文中一共展示了ServiceCache类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: registerDependencyRegistrationHooks

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Override
public void registerDependencyRegistrationHooks() {
	for (ZookeeperDependency zookeeperDependency : this.zookeeperDependencies.getDependencyConfigurations()) {
		String dependencyPath = zookeeperDependency.getPath();
		ServiceCache<?> serviceCache = getServiceDiscovery()
				.serviceCacheBuilder().name(dependencyPath).build();
		try {
			serviceCache.start();
		}
		catch (Exception e) {
			ReflectionUtils.rethrowRuntimeException(e);
		}
		this.dependencyPresenceOnStartupVerifier.verifyDependencyPresence(dependencyPath, serviceCache, zookeeperDependency.isRequired());
		this.dependencyRegistry.put(dependencyPath, serviceCache);
		serviceCache.addListener(new DependencyStateChangeListenerRegistry(this.listeners, dependencyPath, serviceCache));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:18,代码来源:DefaultDependencyWatcher.java


示例2: queryForInstances

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Override
public Collection<ServiceInstance<MetaInfo>> queryForInstances(String name) throws Exception {
	ServiceCache<MetaInfo> serviceCache = getServiceCache(name);
	if(serviceCache != null){
		return serviceCache.getInstances();
	}
    return serviceDiscovery.queryForInstances(name);
}
 
开发者ID:chenxh,项目名称:rpc,代码行数:9,代码来源:ZkServiceDiscovery.java


示例3: getServiceCache

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
private ServiceCache<MetaInfo> getServiceCache(String name) throws Exception{
	ServiceCache<MetaInfo> cache = cacheMap.get(name);
    if(cache == null){
    	final ServiceCache<MetaInfo> newCache = serviceDiscovery.serviceCacheBuilder().name(name).build();
    	newCache.start();
        cacheMap.putIfAbsent(name, newCache);
        return newCache;
    }
    return cache;
}
 
开发者ID:chenxh,项目名称:rpc,代码行数:11,代码来源:ZkServiceDiscovery.java


示例4: verifyDependencyPresence

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void verifyDependencyPresence(String dependencyName, @SuppressWarnings("rawtypes") ServiceCache serviceCache, boolean required) {
	if (required) {
		MANDATORY_DEPENDENCY_CHECKER.checkPresence(dependencyName, serviceCache.getInstances());
	} else {
		this.optionalDependencyChecker.checkPresence(dependencyName, serviceCache.getInstances());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:9,代码来源:DependencyPresenceOnStartupVerifier.java


示例5: should_throw_exception_if_obligatory_dependencies_are_missing

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Test public void should_throw_exception_if_obligatory_dependencies_are_missing() {
	//given:
	DefaultDependencyPresenceOnStartupVerifier dependencyVerifier = new DefaultDependencyPresenceOnStartupVerifier();
	ServiceCache serviceCache = mock(ServiceCache.class);
	given(serviceCache.getInstances()).willReturn(Collections.emptyList());
	//when:
	try {
		dependencyVerifier.verifyDependencyPresence(SERVICE_NAME, serviceCache, true);
		Assert.fail("Should throw no instances running exception");
	} catch (Exception e) {
		//then:
		then(e).isInstanceOf(NoInstancesRunningException.class);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:15,代码来源:DefaultDependencyPresenceOnStartupVerifierTests.java


示例6: should_check_optional_dependency_using_optional_dependency_checker

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Test public void should_check_optional_dependency_using_optional_dependency_checker() {
	//given:
	PresenceChecker optionalDependencyChecker = mock(PresenceChecker.class);
	DependencyPresenceOnStartupVerifier dependencyVerifier = new DependencyPresenceOnStartupVerifier(optionalDependencyChecker) {
	};
	ServiceCache serviceCache = mock(ServiceCache.class);
	given(serviceCache.getInstances()).willReturn(Collections.emptyList());
	//when:
	dependencyVerifier.verifyDependencyPresence(SERVICE_NAME, serviceCache, false);
	//then:
	then(optionalDependencyChecker).should().checkPresence(SERVICE_NAME, serviceCache.getInstances());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:13,代码来源:DependencyPresenceOnStartupVerifierTests.java


示例7: build

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
/**
 * Return a new service cache with the current settings
 *
 * @return service cache
 */
@Override
public ServiceCache<T> build()
{
    if (executorService != null)
    {
        return new ServiceCacheImpl<T>(discovery, name, executorService);
    }
    else
    {
        return new ServiceCacheImpl<T>(discovery, name, threadFactory);
    }
}
 
开发者ID:apache,项目名称:curator,代码行数:18,代码来源:ServiceCacheBuilderImpl.java


示例8: DependencyStateChangeListenerRegistry

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
public DependencyStateChangeListenerRegistry(List<DependencyWatcherListener> listeners, String dependencyName, ServiceCache<?> serviceCache) {
	this.listeners = listeners;
	this.dependencyName = dependencyName;
	this.serviceCache = serviceCache;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:6,代码来源:DependencyStateChangeListenerRegistry.java


示例9: clearDependencyRegistrationHooks

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Override
public void clearDependencyRegistrationHooks() throws IOException {
	for (ServiceCache<?> cache : this.dependencyRegistry.values()) {
		cache.close();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:7,代码来源:DefaultDependencyWatcher.java


示例10: verifyDependencyPresence

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Override public void verifyDependencyPresence(String dependencyName,
		ServiceCache serviceCache, boolean required) {
	startupPresenceVerified = true;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:5,代码来源:DefaultDependencyWatcherSpringTests.java


示例11: cacheOpened

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
void cacheOpened(ServiceCache<T> cache)
{
    caches.add(cache);
}
 
开发者ID:apache,项目名称:curator,代码行数:5,代码来源:ServiceDiscoveryImpl.java


示例12: cacheClosed

import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
void cacheClosed(ServiceCache<T> cache)
{
    caches.remove(cache);
}
 
开发者ID:apache,项目名称:curator,代码行数:5,代码来源:ServiceDiscoveryImpl.java



注:本文中的org.apache.curator.x.discovery.ServiceCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerFailedEvent类代码示例发布时间:2022-05-22
下一篇:
Java UndoAction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap