Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #3628] set naming client updateTask interval more flexible #3637

Merged
merged 4 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class ServiceInfo {

private long cacheMillis = 1000L;

private long failCount = 0L;
horizonzy marked this conversation as resolved.
Show resolved Hide resolved

private List<Instance> hosts = new ArrayList<Instance>();

private long lastRefTime = 0L;
Expand Down Expand Up @@ -87,6 +89,18 @@ public ServiceInfo(String name, String clusters) {
this.clusters = clusters;
}

public void incFailCount() {
this.failCount++;
}

public long getFailCount() {
return failCount;
}

public void setFailCount(long failCount) {
this.failCount = failCount;
}

public int ipCount() {
return hosts.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ public void updateServiceNow(String serviceName, String clusters) {
processServiceJson(result);
}
} catch (Exception e) {
oldService.incFailCount();
NAMING_LOGGER.error("[NA] failed to update serviceName: " + serviceName, e);
} finally {
if (oldService != null) {
Expand Down Expand Up @@ -411,7 +412,7 @@ public void run() {
return;
}

delayTime = serviceObj.getCacheMillis();
delayTime = serviceObj.getCacheMillis() + Math.min(serviceObj.getFailCount() * 1000L, 10000L);
horizonzy marked this conversation as resolved.
Show resolved Hide resolved

} catch (Throwable e) {
NAMING_LOGGER.warn("[NA] failed to update serviceName: " + serviceName, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,21 +516,21 @@ public ObjectNode doSrvIpxt(String namespaceId, String serviceName, String agent
ClientInfo clientInfo = new ClientInfo(agent);
ObjectNode result = JacksonUtils.createEmptyJsonNode();
Service service = serviceManager.getService(namespaceId, serviceName);

long cacheMillis = switchDomain.getDefaultCacheMillis();
horizonzy marked this conversation as resolved.
Show resolved Hide resolved

if (service == null) {
if (Loggers.SRV_LOG.isDebugEnabled()) {
Loggers.SRV_LOG.debug("no instance to serve for service: {}", serviceName);
}
result.put("name", serviceName);
result.put("clusters", clusters);
result.put("cacheMillis", cacheMillis);
result.replace("hosts", JacksonUtils.createEmptyArrayNode());
return result;
}

checkIfDisabled(service);

long cacheMillis = switchDomain.getDefaultCacheMillis();

// now try to enable the push
try {
if (udpPort > 0 && pushService.canEnablePush(agent)) {
Expand Down