@Test public void testServiceDetail() throws Exception { ObjectNode result = catalogController.serviceDetail(Constants.DEFAULT_NAMESPACE_ID, TEST_GROUP_NAME + Constants.SERVICE_INFO_SPLITER + TEST_SERVICE_NAME); String actual = result.toString(); assertTrue(actual.contains("\"service\":{")); assertTrue(actual.contains("\"groupName\":\"test-group-name\"")); assertTrue(actual.contains("\"metadata\":{}")); assertTrue(actual.contains("\"name\":\"test-service\"")); assertTrue(actual.contains("\"selector\":{\"type\":\"none\"}")); assertTrue(actual.contains("\"protectThreshold\":12.34")); assertTrue(actual.contains("\"clusters\":[{")); assertTrue(actual.contains("\"defaultCheckPort\":80")); assertTrue(actual.contains("\"defaultPort\":1")); assertTrue(actual.contains("\"healthChecker\":{\"type\":\"TCP\"}")); assertTrue(actual.contains("\"metadata\":{}")); assertTrue(actual.contains("\"name\":\"test-cluster\"")); assertTrue(actual.contains("\"serviceName\":\"test-service\"")); assertTrue(actual.contains("\"useIPPort4Check\":true")); }
@Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, String serviceName) throws NacosException { Service detailedService = serviceManager.getService(namespaceId, serviceName); if (detailedService == null) { throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!"); } ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode(); serviceObject.put("name", NamingUtils.getServiceName(serviceName)); serviceObject.put("protectThreshold", detailedService.getProtectThreshold()); serviceObject.put("groupName", NamingUtils.getGroupName(serviceName)); serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector())); serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getMetadata())); ObjectNode detailView = JacksonUtils.createEmptyJsonNode(); detailView.replace("service", serviceObject); List<Cluster> clusters = new ArrayList<>(); for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); clusterView.setMetadata(cluster.getMetadata()); clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check()); clusterView.setDefaultPort(cluster.getDefaultPort()); clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort()); clusterView.setServiceName(cluster.getService().getName()); clusters.add(clusterView); } detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters)); return detailView; }
CatalogController { @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, String serviceName) throws NacosException { Service detailedService = serviceManager.getService(namespaceId, serviceName); if (detailedService == null) { throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!"); } ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode(); serviceObject.put("name", NamingUtils.getServiceName(serviceName)); serviceObject.put("protectThreshold", detailedService.getProtectThreshold()); serviceObject.put("groupName", NamingUtils.getGroupName(serviceName)); serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector())); serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getMetadata())); ObjectNode detailView = JacksonUtils.createEmptyJsonNode(); detailView.replace("service", serviceObject); List<Cluster> clusters = new ArrayList<>(); for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); clusterView.setMetadata(cluster.getMetadata()); clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check()); clusterView.setDefaultPort(cluster.getDefaultPort()); clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort()); clusterView.setServiceName(cluster.getService().getName()); clusters.add(clusterView); } detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters)); return detailView; } }
CatalogController { @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, String serviceName) throws NacosException { Service detailedService = serviceManager.getService(namespaceId, serviceName); if (detailedService == null) { throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!"); } ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode(); serviceObject.put("name", NamingUtils.getServiceName(serviceName)); serviceObject.put("protectThreshold", detailedService.getProtectThreshold()); serviceObject.put("groupName", NamingUtils.getGroupName(serviceName)); serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector())); serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getMetadata())); ObjectNode detailView = JacksonUtils.createEmptyJsonNode(); detailView.replace("service", serviceObject); List<Cluster> clusters = new ArrayList<>(); for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); clusterView.setMetadata(cluster.getMetadata()); clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check()); clusterView.setDefaultPort(cluster.getDefaultPort()); clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort()); clusterView.setServiceName(cluster.getService().getName()); clusters.add(clusterView); } detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters)); return detailView; }  }
CatalogController { @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, String serviceName) throws NacosException { Service detailedService = serviceManager.getService(namespaceId, serviceName); if (detailedService == null) { throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!"); } ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode(); serviceObject.put("name", NamingUtils.getServiceName(serviceName)); serviceObject.put("protectThreshold", detailedService.getProtectThreshold()); serviceObject.put("groupName", NamingUtils.getGroupName(serviceName)); serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector())); serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getMetadata())); ObjectNode detailView = JacksonUtils.createEmptyJsonNode(); detailView.replace("service", serviceObject); List<Cluster> clusters = new ArrayList<>(); for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); clusterView.setMetadata(cluster.getMetadata()); clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check()); clusterView.setDefaultPort(cluster.getDefaultPort()); clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort()); clusterView.setServiceName(cluster.getService().getName()); clusters.add(clusterView); } detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters)); return detailView; }  @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            String serviceName); @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @RequestMapping(value = "/instances") ObjectNode instanceList(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            @RequestParam String serviceName, @RequestParam String clusterName, @RequestParam(name = "pageNo") int page,
            @RequestParam int pageSize); @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/services") Object listDetail(@RequestParam(required = false) boolean withInstances,
            @RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            @RequestParam(required = false) int pageNo, @RequestParam(required = false) int pageSize,
            @RequestParam(name = "serviceNameParam", defaultValue = StringUtils.EMPTY) String serviceName,
            @RequestParam(name = "groupNameParam", defaultValue = StringUtils.EMPTY) String groupName,
            @RequestParam(name = "instance", defaultValue = StringUtils.EMPTY) String containedInstance,
            @RequestParam(required = false) boolean hasIpCount); @RequestMapping("/rt/service") ObjectNode rt4Service(HttpServletRequest request); }
CatalogController { @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") public ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, String serviceName) throws NacosException { Service detailedService = serviceManager.getService(namespaceId, serviceName); if (detailedService == null) { throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!"); } ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode(); serviceObject.put("name", NamingUtils.getServiceName(serviceName)); serviceObject.put("protectThreshold", detailedService.getProtectThreshold()); serviceObject.put("groupName", NamingUtils.getGroupName(serviceName)); serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector())); serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getMetadata())); ObjectNode detailView = JacksonUtils.createEmptyJsonNode(); detailView.replace("service", serviceObject); List<Cluster> clusters = new ArrayList<>(); for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); clusterView.setMetadata(cluster.getMetadata()); clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check()); clusterView.setDefaultPort(cluster.getDefaultPort()); clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort()); clusterView.setServiceName(cluster.getService().getName()); clusters.add(clusterView); } detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters)); return detailView; }  @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/service") ObjectNode serviceDetail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            String serviceName); @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @RequestMapping(value = "/instances") ObjectNode instanceList(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            @RequestParam String serviceName, @RequestParam String clusterName, @RequestParam(name = "pageNo") int page,
            @RequestParam int pageSize); @Secured(parser = NamingResourceParser.class, action = ActionTypes.READ) @GetMapping("/services") Object listDetail(@RequestParam(required = false) boolean withInstances,
            @RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
            @RequestParam(required = false) int pageNo, @RequestParam(required = false) int pageSize,
            @RequestParam(name = "serviceNameParam", defaultValue = StringUtils.EMPTY) String serviceName,
            @RequestParam(name = "groupNameParam", defaultValue = StringUtils.EMPTY) String groupName,
            @RequestParam(name = "instance", defaultValue = StringUtils.EMPTY) String containedInstance,
            @RequestParam(required = false) boolean hasIpCount); @RequestMapping("/rt/service") ObjectNode rt4Service(HttpServletRequest request);  }