static List<ProviderInfo> convertInstancesToProviders(List<Instance> allInstances) {
        List<ProviderInfo> providerInfos = new ArrayList<ProviderInfo>();
        if (CommonUtils.isEmpty(allInstances)) {
            return providerInfos;
        }

        for (Instance instance : allInstances) {
            String url = convertInstanceToUrl(instance);
            ProviderInfo providerInfo = ProviderHelper.toProviderInfo(url);

            // Nacos的默认权重为1.0
            // 当Nacos默认权重传入1.0，根据代码逻辑计算结果为100，与sofa-rpc默认权重一致
            // 因为是接口级别，如果不同的服务具有不同的权重也不会出现被覆盖或者冲突的情况
            long weight = Math.round(providerInfo.getWeight() * instance.getWeight());
            providerInfo.setWeight(Math.round(weight));

            providerInfos.add(providerInfo);
        }
        return providerInfos;
    }
@Test
    public void convertInstancesToProviders() {
        Instance instance = new Instance();
        instance.setClusterName(NacosRegistryHelper.DEFAULT_CLUSTER);
        instance.setIp("1.1.1.1");
        instance.setPort(12200);
        instance.setServiceName("com.alipay.xxx.TestService");

        List<ProviderInfo> providerInfos = NacosRegistryHelper
            .convertInstancesToProviders(Lists.newArrayList(instance));
        assertNotNull(providerInfos);
        assertEquals(1, providerInfos.size());

        ProviderInfo providerInfo = providerInfos.get(0);
        assertNotNull(providerInfo);
        assertEquals(instance.getIp(), providerInfo.getHost());
        assertEquals(instance.getPort(), providerInfo.getPort());

        assertEquals(RpcConfigs.getStringValue(RpcOptions.DEFAULT_PROTOCOL), providerInfo.getProtocolType());

        Map<String, String> metaData = Maps.newHashMap();
        metaData.put(RpcConstants.CONFIG_KEY_PROTOCOL, RpcConstants.PROTOCOL_TYPE_REST);
        instance.setMetadata(metaData);

        providerInfos = NacosRegistryHelper.convertInstancesToProviders(Lists.newArrayList(instance));
        providerInfo = providerInfos.get(0);
        assertEquals(RpcConstants.PROTOCOL_TYPE_REST, providerInfo.getProtocolType());
    }