use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class XmlCodecTest method testEncodingDecodingWithMetaData.
@Test
public void testEncodingDecodingWithMetaData() throws Exception {
Applications applications = InstanceInfoGenerator.newBuilder(10, 2).withMetaData(true).build().toApplications();
XStream xstream = XmlXStream.getInstance();
String xmlDocument = xstream.toXML(applications);
Applications decodedApplications = (Applications) xstream.fromXML(xmlDocument);
assertThat(EurekaEntityComparators.equal(decodedApplications, applications), is(true));
}
use of com.netflix.discovery.shared.Applications in project eureka by Netflix.
the class XmlCodecTest method testEncodingDecodingWithoutMetaData.
@Test
public void testEncodingDecodingWithoutMetaData() throws Exception {
Applications applications = InstanceInfoGenerator.newBuilder(10, 2).withMetaData(false).build().toApplications();
XStream xstream = XmlXStream.getInstance();
String xmlDocument = xstream.toXML(applications);
Applications decodedApplications = (Applications) xstream.fromXML(xmlDocument);
assertThat(EurekaEntityComparators.equal(decodedApplications, applications), is(true));
}
use of com.netflix.discovery.shared.Applications in project spring-boot by Linda-Tan.
the class EurekaInstanceCanceledListener method onApplicationEvent.
@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
// 服务挂掉自动通知
if (applicationEvent instanceof EurekaInstanceCanceledEvent) {
EurekaInstanceCanceledEvent event = (EurekaInstanceCanceledEvent) applicationEvent;
// 获取当前Eureka示例中的节点信息
PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry();
Applications applications = registry.getApplications();
// 便利获取已注册节点中与当前失效节点ID一致 的节点信息
applications.getRegisteredApplications().forEach(registryApplication -> {
registryApplication.getInstances().forEach(instance -> {
if (Objects.equals(instance.getInstanceId(), event.getServerId())) {
log.info("服务:{}挂啦。。。", instance.getAppName());
// emailService.send(new SimpleMailMessage());
}
});
});
}
if (applicationEvent instanceof EurekaInstanceRegisteredEvent) {
EurekaInstanceRegisteredEvent event = (EurekaInstanceRegisteredEvent) applicationEvent;
log.info("服务:{}注册成功啦。。。", event.getInstanceInfo().getAppName());
}
if (applicationEvent instanceof EurekaInstanceRenewedEvent) {
EurekaInstanceRenewedEvent event = (EurekaInstanceRenewedEvent) applicationEvent;
log.info("心跳检测服务:{}。。。", event.getInstanceInfo().getAppName());
}
if (applicationEvent instanceof EurekaRegistryAvailableEvent) {
log.info("服务 Available。。。");
}
}
use of com.netflix.discovery.shared.Applications in project spring-cloud-netflix by spring-cloud.
the class RestTemplateEurekaHttpClientTest method testGetApplications.
@Test
public void testGetApplications() {
Applications entity = eurekaHttpClient.getApplications().getEntity();
Assert.assertNotNull(entity);
Assert.assertNotNull(eurekaHttpClient.getApplications("us", "eu").getEntity());
}
use of com.netflix.discovery.shared.Applications in project spring-cloud-netflix by spring-cloud.
the class EurekaBasedTurbineClustersProvider method getClusterNames.
@Override
public List<String> getClusterNames() {
Applications applications = eurekaClient.getApplications();
List<Application> registeredApplications = applications.getRegisteredApplications();
List<String> appNames = new ArrayList<>(registeredApplications.size());
for (Application application : registeredApplications) {
appNames.add(application.getName());
}
log.trace("Using clusters names: " + appNames);
return appNames;
}
Aggregations