org.springframework.cloud.netflix.eureka.server是SpringCloud和Eureka整合的源码包
com.netflix.eureka:eureka-core就是eureka的核心源码包(功能实现)
在resours目录下的ApplicationResource就是服务注册功能(对应某一个微服务实例)
类ApplicationResource下的addInstance就是服务注册功能的入口:
@POST
@Consumes({
"application/json", "application/xml"})
public Response addInstance(InstanceInfo info, @HeaderParam("x-netflix-discovery-replication") String isReplication) {
logger.debug("Registering instance {} (replication={})", info.getId(), isReplication);
//都是参数校验
if (this.isBlank(info.getId())) {
return Response.status(400).entity("Missing instanceId").build();
} else if (this.isBlank(info.getHostName())) {
return Response.status(400).entity("Missing hostname").build();
} else if (this.isBlank(info.getIPAddr())) {
return Response.status(400).entity("Missing ip address").build();
} else if (this.isBlank(info.getAppName())) {
return Response.status(400).entity("Missing appName").build();
} else if (!this.appName.equals(info.getAppName())) {
return Response.status(400).entity("Mismatched appName, expecting " + this.appName + " but was " + info.getAppName()).build();
} else if (info.getDataCenterInfo() == null) {
return Response.status(400).entity("M