org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent Java Examples
The following examples show how to use
org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstanceDiscoveryListenerTest.java From Moss with Apache License 2.0 | 6 votes |
@Test public void should_only_discover_new_instances_when_new_heartbeat_is_emitted() { 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("test-1", "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(); }
Example #2
Source File: InstanceDiscoveryListenerTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void should_only_discover_new_instances_when_new_heartbeat_is_emitted() { Object heartbeat = new Object(); this.listener.onParentHeartbeat(new ParentHeartbeatEvent(new Object(), heartbeat)); when(this.discovery.getServices()).thenReturn(singletonList("service")); when(this.discovery.getInstances("service")) .thenReturn(singletonList(new DefaultServiceInstance("test-1", "service", "localhost", 80, false))); this.listener.onApplicationEvent(new HeartbeatEvent(new Object(), heartbeat)); StepVerifier.create(this.registry.getInstances()).verifyComplete(); this.listener.onApplicationEvent(new HeartbeatEvent(new Object(), new Object())); StepVerifier.create(this.registry.getInstances()) .assertNext((a) -> assertThat(a.getRegistration().getName()).isEqualTo("service")).verifyComplete(); }
Example #3
Source File: MossInstanceDiscoveryListener.java From Moss with Apache License 2.0 | 5 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { HeartbeatMonitor heartbeatMonitor = getHeartbeatMonitorByClient((ConsulDiscoveryClient) event.getSource()); threadLocalmonitor.set(heartbeatMonitor); discoverIfNeeded((ConsulDiscoveryClient) event.getSource(), event.getValue()); threadLocalmonitor.remove(); }
Example #4
Source File: MossInstanceDiscoveryListener.java From Moss with Apache License 2.0 | 5 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { HeartbeatMonitor heartbeatMonitor= getHeartbeatMonitorByClient((CloudEurekaClient) event.getSource()); threadLocalmonitor.set(heartbeatMonitor); discoverIfNeeded((CloudEurekaClient) event.getSource(),event.getValue()); threadLocalmonitor.remove(); }
Example #5
Source File: RouteRefreshListenerTests.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
@Test public void onParentHeartbeatEvent() { ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class); RouteRefreshListener listener = new RouteRefreshListener(publisher); listener.onApplicationEvent(new ParentHeartbeatEvent(this, 1L)); listener.onApplicationEvent(new ParentHeartbeatEvent(this, 1L)); listener.onApplicationEvent(new ParentHeartbeatEvent(this, 2L)); verify(publisher, times(2)).publishEvent(any(RefreshRoutesEvent.class)); }
Example #6
Source File: InstanceDiscoveryListener.java From Moss with Apache License 2.0 | 4 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { discoverIfNeeded(event.getValue()); }
Example #7
Source File: MossInstanceDiscoveryListener.java From Moss with Apache License 2.0 | 4 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { discoverIfNeeded(event.getValue()); }
Example #8
Source File: MossInstanceDiscoveryListener.java From Moss with Apache License 2.0 | 4 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { discoverIfNeeded(event.getValue()); }
Example #9
Source File: LightminApplicationDiscoveryListener.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
@EventListener public void onParentHeartbeat(final ParentHeartbeatEvent event) { this.discoverIfNeeded(event.getValue()); }
Example #10
Source File: InstanceDiscoveryListener.java From spring-boot-admin with Apache License 2.0 | 4 votes |
@EventListener public void onParentHeartbeat(ParentHeartbeatEvent event) { discoverIfNeeded(event.getValue()); }