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

Java HeartbeatEvent类代码示例

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

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



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

示例1: single_discovery_for_same_heartbeat

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Test
public void single_discovery_for_same_heartbeat() {
    Object heartbeat = new Object();
    listener.onParentHeartbeat(new ParentHeartbeatEvent(new Object(), heartbeat));

    when(discovery.getServices()).thenReturn(singletonList("service"));
    when(discovery.getInstances("service")).thenReturn(
            singletonList(new DefaultServiceInstance("service", "localhost", 80, false)));

    listener.onApplicationEvent(new HeartbeatEvent(new Object(), heartbeat));
    StepVerifier.create(registry.getInstances()).verifyComplete();

    listener.onApplicationEvent(new HeartbeatEvent(new Object(), new Object()));
    StepVerifier.create(registry.getInstances())
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("service"))
                .verifyComplete();
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:18,代码来源:InstanceDiscoveryListenerTest.java


示例2: shouldRetryAndSucceedGetConfigServerInstanceFromDiscoveryClient

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Test
public void shouldRetryAndSucceedGetConfigServerInstanceFromDiscoveryClient()
		throws Exception {
	givenDiscoveryClientReturnsInfoOnThirdTry();

	setup("spring.cloud.config.discovery.enabled=true",
			"spring.cloud.config.retry.maxAttempts=3",
			"spring.cloud.config.retry.initialInterval=10",
			"spring.cloud.config.fail-fast=true");

	expectDiscoveryClientConfigServiceBootstrapConfigurationIsSetup();
	verifyDiscoveryClientCalledThreeTimes();

	context.publishEvent(new HeartbeatEvent(context, "new"));

	expectConfigClientPropertiesHasConfigurationFromEureka();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:18,代码来源:DiscoveryClientConfigServiceBootstrapConfigurationTests.java


示例3: catalogServicesWatch

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Scheduled(fixedDelayString = "${spring.cloud.consul.discovery.catalogServicesWatchDelay:30000}")
public void catalogServicesWatch() {
	try {
		long index = -1;
		if (catalogServicesIndex.get() != null) {
			index = catalogServicesIndex.get().longValue();
		}

		Response<Map<String, List<String>>> response = consul
				.getCatalogServices(new QueryParams(properties
						.getCatalogServicesWatchTimeout(), index));
		Long consulIndex = response.getConsulIndex();
		if (consulIndex != null) {
			catalogServicesIndex.set(BigInteger.valueOf(consulIndex));
		}

		log.trace("Received services update from consul: {}, index: {}",
				response.getValue(), consulIndex);
		publisher.publishEvent(new HeartbeatEvent(this, consulIndex));
	}
	catch (Exception e) {
		log.error("Error watching Consul CatalogServices", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:25,代码来源:ConsulCatalogWatch.java


示例4: onApplicationEvent

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
	if (event instanceof ContextRefreshedEvent) {
		refresh();
	}
	else if (event instanceof HeartbeatEvent) {
		if (this.monitor.update(((HeartbeatEvent) event).getValue())) {
			refresh();
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-lattice,代码行数:12,代码来源:DiscoverConfigServerBootstrapConfiguration.java


示例5: childEvent

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Override
public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {
	if (event.getType().equals(TreeCacheEvent.Type.NODE_ADDED)
			|| event.getType().equals(TreeCacheEvent.Type.NODE_REMOVED)
			|| event.getType().equals(TreeCacheEvent.Type.NODE_UPDATED)) {
		long newCacheChange = this.cacheChange.incrementAndGet();
		this.publisher.publishEvent(new HeartbeatEvent(this, newCacheChange));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:10,代码来源:ZookeeperServiceWatch.java


示例6: onApplicationEvent

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
	if (event instanceof ContextRefreshedEvent
			|| event instanceof RefreshScopeRefreshedEvent
			|| event instanceof RoutesRefreshedEvent) {
		this.zuulHandlerMapping.setDirty(true);
	}
	else if (event instanceof HeartbeatEvent) {
		if (this.heartbeatMonitor.update(((HeartbeatEvent) event).getValue())) {
			this.zuulHandlerMapping.setDirty(true);
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:14,代码来源:ZuulServerAutoConfiguration.java


示例7: onCacheRefreshed

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Override
protected void onCacheRefreshed() {
	super.onCacheRefreshed();

	if (this.cacheRefreshedCount != null) { //might be called during construction and will be null
		long newCount = this.cacheRefreshedCount.incrementAndGet();
		log.trace("onCacheRefreshed called with count: " + newCount);
		this.publisher.publishEvent(new HeartbeatEvent(this, newCount));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:CloudEurekaClient.java


示例8: poll

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Scheduled(fixedDelayString = "${spring.cloud.cloudfoundry.discovery.heartbeatFrequency:5000}")
public void poll() {
	if (this.publisher != null) {
		List<String> services = this.client.getServices();
		this.publisher.publishEvent(new HeartbeatEvent(this.client, services));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry,代码行数:8,代码来源:CloudFoundryHeartbeatSender.java


示例9: supportsEventType

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
	return ContextRefreshedEvent.class.isAssignableFrom(eventType)
			|| HeartbeatEvent.class.isAssignableFrom(eventType);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-lattice,代码行数:6,代码来源:DiscoverConfigServerBootstrapConfiguration.java


示例10: discoveryHeartbeat

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@EventListener
public void discoveryHeartbeat(HeartbeatEvent event) {
	if (this.enabled && this.monitor.update(event.getValue())) {
		this.adapter.rebind();
	}
}
 
开发者ID:spring-projects,项目名称:spring-bus,代码行数:7,代码来源:DiscoveryClientAutoConfiguration.java


示例11: onApplicationEvent

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@EventListener
public void onApplicationEvent(HeartbeatEvent event) {
    discoverIfNeeded(event.getValue());
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:5,代码来源:InstanceDiscoveryListener.java


示例12: deregister_removed_app

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Test
public void deregister_removed_app() {
    StepVerifier.create(registry.register(Registration.create("ignored", "http://health").build()))
                .consumeNextWith((id) -> {})
                .verifyComplete();
    StepVerifier.create(
            registry.register(Registration.create("different-source", "http://health2").source("http-api").build()))
                .consumeNextWith((id) -> {})
                .verifyComplete();
    listener.setIgnoredServices(singleton("ignored"));

    List<ServiceInstance> instances = new ArrayList<>();
    instances.add(new DefaultServiceInstance("service", "localhost", 80, false));
    instances.add(new DefaultServiceInstance("service", "example.net", 80, false));

    when(discovery.getServices()).thenReturn(singletonList("service"));
    when(discovery.getInstances("service")).thenReturn(instances);

    listener.onApplicationEvent(new HeartbeatEvent(new Object(), new Object()));

    StepVerifier.create(registry.getInstances("service"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("service"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("service"))
                .verifyComplete();

    StepVerifier.create(registry.getInstances("ignored"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("ignored"))
                .verifyComplete();

    StepVerifier.create(registry.getInstances("different-source"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("different-source"))
                .verifyComplete();


    instances.remove(0);

    listener.onApplicationEvent(new HeartbeatEvent(new Object(), new Object()));
    StepVerifier.create(registry.getInstances("service"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("service"))
                .verifyComplete();

    StepVerifier.create(registry.getInstances("ignored"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("ignored"))
                .verifyComplete();

    StepVerifier.create(registry.getInstances("different-source"))
                .assertNext(a -> assertThat(a.getRegistration().getName()).isEqualTo("different-source"))
                .verifyComplete();
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:50,代码来源:InstanceDiscoveryListenerTest.java


示例13: heartbeat

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@EventListener(HeartbeatEvent.class)
public void heartbeat(HeartbeatEvent event) {
	if (monitor.update(event.getValue())) {
		refresh();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:7,代码来源:DiscoveryClientConfigServiceBootstrapConfiguration.java


示例14: onWhenHeartbeat

import org.springframework.cloud.client.discovery.event.HeartbeatEvent; //导入依赖的package包/类
@Test
public void onWhenHeartbeat() throws Exception {
	setup("spring.cloud.config.discovery.enabled=true");

	expectDiscoveryClientConfigServiceBootstrapConfigurationIsSetup();

	givenDiscoveryClientReturnsInfo();
	verifyDiscoveryClientCalledOnce();

	context.publishEvent(new HeartbeatEvent(context, "new"));

	expectConfigClientPropertiesHasConfigurationFromEureka();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:14,代码来源:DiscoveryClientConfigServiceBootstrapConfigurationTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Fishing类代码示例发布时间:2022-05-22
下一篇:
Java NSClassNotFoundException类代码示例发布时间: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