本文整理汇总了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));
}
}
示例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);
}
示例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;
}
示例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());
}
}
示例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);
}
}
示例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();
}
}
示例10: verifyDependencyPresence
import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
@Override public void verifyDependencyPresence(String dependencyName,
ServiceCache serviceCache, boolean required) {
startupPresenceVerified = true;
}
示例11: cacheOpened
import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
void cacheOpened(ServiceCache<T> cache)
{
caches.add(cache);
}
示例12: cacheClosed
import org.apache.curator.x.discovery.ServiceCache; //导入依赖的package包/类
void cacheClosed(ServiceCache<T> cache)
{
caches.remove(cache);
}