bjfrbjx opened a new issue, #10392: URL: https://github.com/apache/dubbo/issues/10392
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy --> - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate. ### Environment * Dubbo version: 2.7.12 * Operating System version: win10 * Java version: 8 ### Steps to reproduce this issue 1. dubbo-registry-nacos模块的NacosRegistry类下getAllServiceNames()方法,会按照nacos.service.names.pagination.size(默认100)大小进行分页查询nacos的/v1/ns/service/list ,并按照返回的count判断是否继续翻页。可看过nacos源码,count是小于等于一页行数的,也就是说getAllServiceNames()永远不会翻页,只会返回前100个服务。 Pls. provide [GitHub address] to reproduce this issue. ### Expected Behavior getAllServiceNames()能自动翻页 ### Actual Behavior dubbo: ``` private Set<String> getAllServiceNames() { final Set<String> serviceNames = new LinkedHashSet<>(); execute(namingService -> { int pageIndex = 1; ListView<String> listView = namingService.getServicesOfServer(pageIndex, PAGINATION_SIZE, getUrl().getParameter(GROUP_KEY, Constants.DEFAULT_GROUP)); // First page data List<String> firstPageData = listView.getData(); // Append first page into list serviceNames.addAll(firstPageData); // the total count int count = listView.getCount(); // the number of pages int pageNumbers = count / PAGINATION_SIZE; int remainder = count % PAGINATION_SIZE; // remain if (remainder > 0) { pageNumbers += 1; } // If more than 1 page while (pageIndex < pageNumbers) { listView = namingService.getServicesOfServer(++pageIndex, PAGINATION_SIZE, getUrl().getParameter(GROUP_KEY, Constants.DEFAULT_GROUP)); serviceNames.addAll(listView.getData()); } }); return serviceNames; } ``` nacos: ``` @GetMapping("/service/list") @Secured(action = ActionTypes.READ) public ObjectNode listService(@RequestParam(defaultValue = "v2", required = false) String ver, HttpServletRequest request) throws Exception { final int pageNo = NumberUtils.toInt(WebUtils.required(request, "pageNo")); final int pageSize = NumberUtils.toInt(WebUtils.required(request, "pageSize")); String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID); String groupName = WebUtils.optional(request, CommonParams.GROUP_NAME, Constants.DEFAULT_GROUP); String selectorString = WebUtils.optional(request, "selector", StringUtils.EMPTY); ObjectNode result = JacksonUtils.createEmptyJsonNode(); Collection<String> serviceNameList = getServiceOperator(ver) .listService(namespaceId, groupName, selectorString); result.put("count", serviceNameList.size()); result.replace("doms", JacksonUtils.transferToJsonNode(ServiceUtil.pageServiceName(pageNo, pageSize, serviceNameList))); return result; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
