CrazyHZM commented on code in PR #13773: URL: https://github.com/apache/dubbo/pull/13773#discussion_r1496863380
########## dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java: ########## @@ -491,39 +522,43 @@ public Set<Invoker<T>> getDisabledInvokers() { } protected void setInvokers(BitList<Invoker<T>> invokers) { - this.invokers = invokers; - refreshInvokerInternal(); - this.invokersInitialized = true; + LockUtils.safeLock(invokerRefreshLock, 60_000, () -> { Review Comment: This lock is not required because refreshInvokerInternal already has a sync lock. So far, `invokersInitialized` and `invokers` repeat refresh is not a problem. My suggestion is to remove the lock on refreshInvokerInternal. ########## dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java: ########## @@ -414,25 +441,29 @@ private void refreshInvokers(BitList<Invoker<T>> targetInvokers, Collection<Invo @Override public void addDisabledInvoker(Invoker<T> invoker) { - if (invokers.contains(invoker)) { - disabledInvokers.add(invoker); - removeValidInvoker(invoker); - logger.info("Disable service address: " + invoker.getUrl() + "."); - } + LockUtils.safeLock(invokerRefreshLock, 60_000, () -> { + if (invokers.contains(invoker)) { + disabledInvokers.add(invoker); + removeValidInvoker(invoker); + logger.info("Disable service address: " + invoker.getUrl() + "."); + } + }); MetricsEventBus.publish( RegistryEvent.refreshDirectoryEvent(applicationModel, getSummary(), getDirectoryMeta())); } @Override public void recoverDisabledInvoker(Invoker<T> invoker) { - if (disabledInvokers.remove(invoker)) { - try { - addValidInvoker(invoker); - logger.info("Recover service address: " + invoker.getUrl() + " from disabled list."); - } catch (Throwable ignore) { + LockUtils.safeLock(invokerRefreshLock, 60_000, () -> { Review Comment: This lock is not required. ########## dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java: ########## @@ -382,9 +407,11 @@ public void checkConnectivity() { * 4. all the invokers disappeared from total invokers should be removed in the disabled invokers list */ public void refreshInvoker() { - if (invokersInitialized) { - refreshInvokerInternal(); - } + LockUtils.safeLock(invokerRefreshLock, 60_000, () -> { Review Comment: This lock is not required. ########## dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java: ########## @@ -414,25 +441,29 @@ private void refreshInvokers(BitList<Invoker<T>> targetInvokers, Collection<Invo @Override public void addDisabledInvoker(Invoker<T> invoker) { - if (invokers.contains(invoker)) { - disabledInvokers.add(invoker); - removeValidInvoker(invoker); - logger.info("Disable service address: " + invoker.getUrl() + "."); - } + LockUtils.safeLock(invokerRefreshLock, 60_000, () -> { Review Comment: This lock is not required. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org