Skip to content

Commit

Permalink
Merge pull request alibaba#4663 from horizonzy/fix-4662
Browse files Browse the repository at this point in the history
[ISSUE-alibaba#4662] Just choose one between nacosDomain mode and servers mode.
  • Loading branch information
horizonzy committed Jan 11, 2021
2 parents aea9f5d + 8b6cb8c commit 0732a93
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class NamingProxy implements Closeable {
private Properties properties;

private ScheduledExecutorService executorService;

private int maxRetry;

public NamingProxy(String namespaceId, String endpoint, String serverList, Properties properties) {
Expand All @@ -119,8 +119,8 @@ public NamingProxy(String namespaceId, String endpoint, String serverList, Prope
this.namespaceId = namespaceId;
this.endpoint = endpoint;
this.maxRetry = ConvertUtils.toInt(properties.getProperty(PropertyKeyConst.NAMING_REQUEST_DOMAIN_RETRY_COUNT,
String.valueOf(UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT)));

String.valueOf(UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT)));
if (StringUtils.isNotEmpty(serverList)) {
this.serverList = Arrays.asList(serverList.split(","));
if (this.serverList.size() == 1) {
Expand Down Expand Up @@ -514,12 +514,12 @@ public String reqApi(String api, Map<String, String> params, Map<String, String>

params.put(CommonParams.NAMESPACE_ID, getNamespaceId());

if (CollectionUtils.isEmpty(servers) && StringUtils.isEmpty(nacosDomain)) {
if (CollectionUtils.isEmpty(servers) && StringUtils.isBlank(nacosDomain)) {
throw new NacosException(NacosException.INVALID_PARAM, "no server available");
}

NacosException exception = new NacosException();

if (StringUtils.isNotBlank(nacosDomain)) {
for (int i = 0; i < maxRetry; i++) {
try {
Expand All @@ -531,10 +531,7 @@ public String reqApi(String api, Map<String, String> params, Map<String, String>
}
}
}
}

if (servers != null && !servers.isEmpty()) {

} else {
Random random = new Random(System.currentTimeMillis());
int index = random.nextInt(servers.size());

Expand Down

0 comments on commit 0732a93

Please sign in to comment.