From 5cce5bf1200f3025da0f71322f46a1fc701b419d Mon Sep 17 00:00:00 2001 From: winLsy <18332763730@163.com> Date: Thu, 8 Feb 2018 22:17:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E4=B8=8B=E7=BA=BF=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=EF=BC=8C=E8=B0=83=E6=95=B4=E6=9C=8D=E5=8A=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=8E=A5=E5=8F=A3=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RestfulEurekaController.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java b/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java index ca229b6..bd46faa 100644 --- a/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java +++ b/ms/register-center1/src/main/java/com/micro/fast/eureka/server/controller/RestfulEurekaController.java @@ -54,6 +54,13 @@ public class RestfulEurekaController { return ServerResponse.successMsgData("获取所有实例成功", map); } + @GetMapping("/appsInfo") + @ApiOperation("获取所有的服务实例的详细信息") + public ServerResponse appsInfos() { + List sortedApplications = getRegistry().getSortedApplications(); + return ServerResponse.successMsgData("获取所有实例成功", sortedApplications); + } + @GetMapping("/apps/{id}") @ApiOperation("根据id获取实例的信息,模糊查询") public ServerResponse getInstance(@PathVariable("id") String instanceId) { @@ -76,24 +83,20 @@ public class RestfulEurekaController { } @GetMapping("/apps/cluster/{appName}") - @ApiOperation("根据appId,也就是application.name查询实例,可能有多个") + @ApiOperation("根据appName,也就是application.name查询实例,模糊查询") public ServerResponse getInstancesByAppId(@PathVariable("appName") String appName) { - Set instanceInfos = new HashSet<>(10); + List instanceInfos = new LinkedList<>(); if (StringUtils.isNotBlank(appName)){ List sortedApplications = getRegistry().getSortedApplications(); for (Application sortedApplication : sortedApplications) { - List instances = sortedApplication.getInstances(); - for (InstanceInfo instance : instances) { - if (StringUtils.equalsIgnoreCase(instance.getAppName(),appName)){ - instanceInfos.add(instance); - } + if (sortedApplication.getName().contains(appName)){ + instanceInfos.add(sortedApplication); } - } }else { - return ServerResponse.errorMsg("instanceId不能为空"); + return ServerResponse.errorMsg("appName不能为空"); } - return ServerResponse.successMsgData("根据主机名获取实例信息成功", instanceInfos); + return ServerResponse.successMsgData("根据appName获取实例信息成功", instanceInfos); } @GetMapping("/apps/app/{appName}/{id}") @@ -124,7 +127,7 @@ public class RestfulEurekaController { } /** - * 调整服务的状态,可以用于在无感知的情况下热部署服务 + * 调整服务的状态,可以用于在不影响业务的情况下热部署服务 * @param appName * @param id * @param status