首页 > 其他分享 >springcloud之eureka server启动原理

springcloud之eureka server启动原理

时间:2022-11-30 18:34:11浏览次数:45  
标签:String netflix springcloud eureka var10 entry new server


springcloud之eureka server启动原理_spring

/org/springframework/cloud/spring-cloud-netflix-eureka-server/2.1.0.RELEASE/spring-cloud-netflix-eureka-server-2.1.0.RELEASE.jar!/META-INF/spring.factories中 


org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration


进入EurekaServerAutoConfiguration类,看到

@Bean
@ConditionalOnProperty(
prefix = "eureka.dashboard",
name = {"enabled"},
matchIfMissing = true
)
public EurekaController eurekaController() {
return new EurekaController(this.applicationInfoManager);
}



@Bean
public Application jerseyApplication(Environment environment, ResourceLoader resourceLoader) {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false, environment);
provider.addIncludeFilter(new AnnotationTypeFilter(Path.class));
provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class));
Set<Class<?>> classes = new HashSet();
String[] var5 = EUREKA_PACKAGES;
int var6 = var5.length;

for(int var7 = 0; var7 < var6; ++var7) {
String basePackage = var5[var7];
Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
Iterator var10 = beans.iterator();

while(var10.hasNext()) {
BeanDefinition bd = (BeanDefinition)var10.next();
Class<?> cls = ClassUtils.resolveClassName(bd.getBeanClassName(), resourceLoader.getClassLoader());
classes.add(cls);
}
}

Map<String, Object> propsAndFeatures = new HashMap();
propsAndFeatures.put("com.sun.jersey.config.property.WebPageContentRegex", "/eureka/(fonts|images|css|js)/.*");
DefaultResourceConfig rc = new DefaultResourceConfig(classes);
rc.setPropertiesAndFeatures(propsAndFeatures);
return rc;
}

进入EurekaController类,作用:对控制面板页面的跳转的controller层的web对象

@Controller
@RequestMapping({"${eureka.dashboard.path:/}"})
public class EurekaController {
@Value("${eureka.dashboard.path:/}")
private String dashboardPath = "";
...
@RequestMapping(
value = {"/lastn"},
method = {RequestMethod.GET}
)
public String lastn(HttpServletRequest request, Map<String, Object> model) {
this.populateBase(request, model);
PeerAwareInstanceRegistryImpl registry = (PeerAwareInstanceRegistryImpl)this.getRegistry();
ArrayList<Map<String, Object>> lastNCanceled = new ArrayList();
List<Pair<Long, String>> list = registry.getLastNCanceledInstances();
Iterator var6 = list.iterator();

while(var6.hasNext()) {
Pair<Long, String> entry = (Pair)var6.next();
lastNCanceled.add(this.registeredInstance((String)entry.second(), (Long)entry.first()));
}

model.put("lastNCanceled", lastNCanceled);
list = registry.getLastNRegisteredInstances();
ArrayList<Map<String, Object>> lastNRegistered = new ArrayList();
Iterator var10 = list.iterator();

while(var10.hasNext()) {
Pair<Long, String> entry = (Pair)var10.next();
lastNRegistered.add(this.registeredInstance((String)entry.second(), (Long)entry.first()));
}

model.put("lastNRegistered", lastNRegistered);
return "eureka/lastn";
}

jerseyApplication:初始化jersey的有关配置,通过jersey快速搭建满足restful的web程序,看到

springcloud之eureka server启动原理_spring_02


EUREKA_PACKAGES点进去


private static final String[] EUREKA_PACKAGES = new String[]{"com.netflix.discovery", "com.netflix.eureka"};

扫描{"com.netflix.discovery", "com.netflix.eureka"}包下的


@Path @Provider,@Produces注解


springcloud之eureka server启动原理_spring_03

标签:String,netflix,springcloud,eureka,var10,entry,new,server
From: https://blog.51cto.com/u_12528551/5900120

相关文章

  • springcloud之eureka client的启动流程
    eurekaclien向eurekaserver准备的web接口发送http请求,完成服务注册,获取...org/springframework/cloud/spring-cloud-netflix-eureka-client/2.1.0.RELEASE/spring-cloud......
  • springcloud之负载均衡策略
    Ribbon内置了多种负载均衡策略,内部负责负载均衡的顶级接口为com.netflix.loadbalanced.IRule  服务消费者,application.yml中添加#修改ribbon的负载均衡策略服务名-......
  • SQL server 2016日志文件的清理
    SQL资源对象管理器1、sql库-->属性-->文件得到sql库的数据路径和日志路径,日志名称等;2、新建查询管理器:USEMASTERGOALTERDATABASEais20190925150901SETRECOVERY......
  • SpringCloud之Config分布式配置文件中心
    分布式系统面临的配置问题:微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务。由于每个服务都需要必要的配置信息......
  • SQL Server基础知识笔记1
    学习SQL笔记内容整理1、SQL是结构化查询语言(structuredQueryLanguage)2、SQL数据库是对数据进行储存和读取或者修改。3、数据库的基本构成:数据DATA对客观事物的符......
  • 【转】一致性hash算法与server列表维护
      普通的hash算法有个很大的问题:当hash的"模数"发生变化时,整个hash数据结构就需要重新hash,重新hash之后的数据分布一定会和hash之前的不同;在很多场景下,"模数"的变......
  • 【转载】一致性hash算法与server列表维护(备忘)
    普通的hash算法有个很大的问题:当hash的"模数"发生变化时,整个hash数据结构就需要重新hash,重新hash之后的数据分布一定会和hash之前的不同;在很多场景下,"模数"的变化时必......
  • 又一创新!阿里云 Serverless 调度论文被云计算顶会 ACM SoCC 收录
    近日,阿里云函数计算产品团队撰写的关于Serverless调度的创新性论文,被云计算领域ACMSoCC国际会议长文录用。去年阿里云函数计算团队首个提出在FaaS场景下的去中心化快......
  • 0 基础晋级 Serverless 高手课 — 初识 Serverless(下)
    冷启动     1.流量预测2.提前启动3.实例复用每个厂商规范不一致;,兼容,适配层;adapter;fs+oss     云厂商对比                产品维度   功能......
  • 又一创新!阿里云 Serverless 调度论文被云计算顶会 ACM SoCC 收录
    近日,阿里云函数计算产品团队撰写的关于Serverless调度的创新性论文,被云计算领域ACMSoCC国际会议长文录用。去年阿里云函数计算团队首个提出在FaaS场景下的去中心......