apache / dubbo-admin

The ops and reference implementation for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
4k stars 2.17k forks source link

使用Nacos作为dubbo注册中心时,服务列表不全 #1285

Open muxue-wang opened 2 months ago

muxue-wang commented 2 months ago

Environment

Steps to reproduce this issue

后台显示服务列表不全 image

问题出现在这个方法,这个返回值count错误,导致不会继续拉取下一页,入参PAGINATION_SIZE是多少,返回值count就是多少 org.apache.dubbo.admin.registry.mapping.impl.NacosServiceMapping#getAllServiceNames org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper#getServicesOfServer image

image

muxue-wang commented 2 months ago

Dubbo Admin version:0.6.0

muxue-wang commented 2 months ago

这个分页错误,可以改成这样

    private Set<String> getAllServiceNames() throws NacosException {
        Set<String> serviceNames = new HashSet<>();
        int pageIndex = 1;
        ListView<String> listView;

        do {
            listView = namingService.getServicesOfServer(pageIndex++, PAGINATION_SIZE, Constants.DEFAULT_GROUP);
            serviceNames.addAll(listView.getData());
        } while (listView.getData().size() == PAGINATION_SIZE && !listView.getData().isEmpty());

        return serviceNames;
    }