安全下线服务,调整服务状态接口编写
This commit is contained in:
+14
-11
@@ -54,6 +54,13 @@ public class RestfulEurekaController {
|
||||
return ServerResponse.successMsgData("获取所有实例成功", map);
|
||||
}
|
||||
|
||||
@GetMapping("/appsInfo")
|
||||
@ApiOperation("获取所有的服务实例的详细信息")
|
||||
public ServerResponse appsInfos() {
|
||||
List<Application> 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<InstanceInfo> instanceInfos = new HashSet<>(10);
|
||||
List<Application> instanceInfos = new LinkedList<>();
|
||||
if (StringUtils.isNotBlank(appName)){
|
||||
List<Application> sortedApplications = getRegistry().getSortedApplications();
|
||||
for (Application sortedApplication : sortedApplications) {
|
||||
List<InstanceInfo> 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
|
||||
|
||||
Reference in New Issue
Block a user