feature(web): 优化额外参数的输入和服务信息查询优化
This commit is contained in:
@@ -10,6 +10,7 @@ import com.lanyuanxiaoyao.service.web.controller.base.BaseController;
|
||||
import com.lanyuanxiaoyao.service.web.entity.CloudServiceVO;
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import java.util.Map;
|
||||
import org.apache.curator.x.discovery.ServiceInstance;
|
||||
import org.eclipse.collections.api.block.function.Function;
|
||||
import org.eclipse.collections.api.factory.Lists;
|
||||
import org.eclipse.collections.api.factory.Maps;
|
||||
@@ -20,6 +21,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.netflix.eureka.EurekaServiceInstance;
|
||||
import org.springframework.cloud.zookeeper.discovery.ZookeeperInstance;
|
||||
import org.springframework.cloud.zookeeper.discovery.ZookeeperServiceInstance;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -68,6 +71,14 @@ public class CloudController extends BaseController {
|
||||
service.setServiceUpTime(info.getLeaseInfo().getServiceUpTimestamp());
|
||||
}
|
||||
}
|
||||
if (instance instanceof ZookeeperServiceInstance) {
|
||||
ZookeeperServiceInstance zookeeperServiceInstance = (ZookeeperServiceInstance) instance;
|
||||
ServiceInstance<ZookeeperInstance> serviceInstance = zookeeperServiceInstance.getServiceInstance();
|
||||
if (ObjectUtil.isNotNull(serviceInstance)) {
|
||||
service.setServiceUpTime(serviceInstance.getRegistrationTimeUTC());
|
||||
service.setStatus(serviceInstance.getPayload().getMetadata().getOrDefault("instance_status", ""));
|
||||
}
|
||||
}
|
||||
return service;
|
||||
});
|
||||
}
|
||||
@@ -76,7 +87,7 @@ public class CloudController extends BaseController {
|
||||
return services()
|
||||
.groupBy(groupByField)
|
||||
.toMap()
|
||||
.collectValues((serviceId, services) -> new CloudServiceVO(serviceId, services.toSortedListBy(CloudServiceVO.Service::getHost).toImmutable()))
|
||||
.collectValues((serviceId, services) -> new CloudServiceVO(serviceId, services.toSortedListBy(CloudServiceVO.Service::getServiceUpTime).toImmutable()))
|
||||
.valuesView()
|
||||
.toSortedListBy(CloudServiceVO::getName)
|
||||
.toImmutable();
|
||||
|
||||
Reference in New Issue
Block a user