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

[Dubbo add comments for RegistryDirectory]Add comments #3181

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
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 @@ -216,9 +216,7 @@ private void refreshOverrideAndInvoker(List<URL> urls) {
private void refreshInvoker(List<URL> invokerUrls) {
Assert.notNull(invokerUrls, "invokerUrls should not be null");

if (invokerUrls.size() == 1 && invokerUrls.get(0) != null && Constants.EMPTY_PROTOCOL.equals(invokerUrls
.get(0)
.getProtocol())) {
if (invokerUrls.size() == 1 && Constants.EMPTY_PROTOCOL.equals(invokerUrls.get(0).getProtocol())) {
this.forbidden = true; // Forbid to access
this.invokers = Collections.emptyList();
routerChain.setInvokers(this.invokers);
Expand All @@ -240,8 +238,14 @@ private void refreshInvoker(List<URL> invokerUrls) {
}
Map<String, Invoker<T>> newUrlInvokerMap = toInvokers(invokerUrls);// Translate url list to Invoker map

// state change
// If the calculation is wrong, it is not processed.
/**
* If the calculation is wrong, it is not processed.
*
* 1. The protocol configured by the client is inconsistent with the protocol of the server.
* eg: consumer protocol = dubbo, provider only has other protocol services(rest).
* 2. The registration center is not robust and pushes illegal specification data.
*
*/
if (newUrlInvokerMap == null || newUrlInvokerMap.size() == 0) {
logger.error(new IllegalStateException("urls to invokers error .invokerUrls.size :" + invokerUrls.size() + ", invoker.size :0. urls :" + invokerUrls
.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ private synchronized void initConnectStatusCheckCommand() {
@Override
public void run() {
try {
if (cancelFutureIfOffline()) return;
chickenlj marked this conversation as resolved.
Show resolved Hide resolved

if (!isConnected()) {
connect();
} else {
Expand All @@ -172,7 +174,29 @@ public void run() {
}
}
}

private boolean cancelFutureIfOffline() {
/**
* If the provider service is detected offline,
* the client should not attempt to connect again.
*
* issue: https://github.com/apache/incubator-dubbo/issues/3158
*/
if(isClosed()) {
ScheduledFuture<?> future = reconnectExecutorFuture;
if(future != null && !future.isCancelled()){
/**
chickenlj marked this conversation as resolved.
Show resolved Hide resolved
* Client has been destroyed and
* scheduled task should be cancelled.
*/
future.cancel(true);
}
return true;
}
return false;
}
};

reconnectExecutorFuture = reconnectExecutorService.scheduleWithFixedDelay(connectStatusCheckCommand, reconnect, reconnect, TimeUnit.MILLISECONDS);
}
}
Expand Down Expand Up @@ -344,14 +368,14 @@ public void reconnect() throws RemotingException {
@Override
public void close() {
try {
if (executor != null) {
ExecutorUtil.shutdownNow(executor, 100);
}
super.close();
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
}
try {
super.close();
if (executor != null) {
ExecutorUtil.shutdownNow(executor, 100);
}
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
}
Expand Down