Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions dubbo
Submodule dubbo added at efed26
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ public List<URL> lookup(URL url) {
}
}
}
if (result.isEmpty() && localCacheEnabled) {
List<URL> cached = getCacheUrls(url);
if (CollectionUtils.isNotEmpty(cached)) {
logger.info("Using local cache URLs for lookup of " + url.getServiceKey());
result.addAll(cached);
}
}
return result;
}

Expand Down Expand Up @@ -456,6 +463,20 @@ public void subscribe(URL url, NotifyListener listener) {
Set<NotifyListener> listeners =
ConcurrentHashMapUtils.computeIfAbsent(subscribed, url, n -> new ConcurrentHashSet<>());
listeners.add(listener);
if (localCacheEnabled && !isAvailable()) {
try {
List<URL> cached = getCacheUrls(url);
if (CollectionUtils.isNotEmpty(cached)) {
listener.notify(cached);
logger.info("Registry unavailable or not yet ready. Loaded cached URLs for " + url.getServiceKey()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not-empty cached urls means Registry unavailable or not yet ready ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(localCacheEnabled){
            try{
                List<URL> cached=getCacheUrls(url);
                if(CollectionUtils.isNotEmpty(cached)){
                    listener.notify(cached);
                    logger.info("Registry unavailable or not yet ready. Loaded cached URLs for "+url.getServiceKey()+" : "+cached.size());
                }
            }catch(Throwable t){
                logger.warn(INTERNAL_ERROR,"failed to load local cache","","Failed to load chached registry data for "+url,t);
                throw t;
            }
        }

from what i understood, i think cached list being not empty simply refers to some cached urls being available and the functionality checking for the unavailability of registry is taken care of by
if(localcacheenbled)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and now looking at it i think instead of
if(localCacheEnabled)

it should be
if(localCacheEnabled and !isAvailable()) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as for me, it might be better than changing the default behavior directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just added the !isavailable parameter as well

+ " : " + cached.size());
}
} catch (Throwable t) {
logger.warn(
INTERNAL_ERROR, "failed to load cached URLs", "", "Failed to load cached URLs for " + url, t);
throw t;
}
}
}

@Override
Expand Down
Loading