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

Added scheduler closure check during RegistryNotifier notify. #13273

Merged
merged 6 commits into from
Nov 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
import java.util.concurrent.atomic.AtomicInteger;

import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_DELAY_EXECUTE_TIMES;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_NOTIFY_EVENT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_NOTIFY_EVENT;

public abstract class RegistryNotifier {

private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(RegistryNotifier.class);
private volatile long lastExecuteTime;
private volatile long lastEventTime;

private final URL url;
private Object rawAddresses;
private long delayTime;

Expand All @@ -50,6 +51,7 @@ public RegistryNotifier(URL registryUrl, long delayTime) {
}

public RegistryNotifier(URL registryUrl, long delayTime, ScheduledExecutorService scheduler) {
this.url = registryUrl;
this.delayTime = delayTime;
if (scheduler == null) {
this.scheduler = registryUrl.getOrDefaultFrameworkModel().getBeanFactory()
Expand All @@ -68,7 +70,13 @@ public synchronized void notify(Object rawAddresses) {

// more than 10 calls && next execute time is in the future
boolean delay = shouldDelay.get() && delta < 0;
if (delay) {
// when the scheduler is shutdown, no notification is sent
if (scheduler.isShutdown()) {
if (logger.isWarnEnabled()) {
logger.warn(COMMON_FAILED_NOTIFY_EVENT, "", "", "Notification scheduler is off, no notifications are sent. Registry URL: " + url);
}
return;
Copy link
Member

Choose a reason for hiding this comment

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

Seems we shoud log something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get

} else if (delay) {
scheduler.schedule(new NotificationTask(this, notifyTime), -delta, TimeUnit.MILLISECONDS);
} else {
// check if more than 10 calls
Expand Down
Loading