QuentinYo commented on code in PR #12118: URL: https://github.com/apache/dubbo/pull/12118#discussion_r1172286982
########## dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java: ########## @@ -209,6 +219,51 @@ public void unexport() { repository.unregisterProvider(providerModel); } + private void waitForIdle() { + int timeout = ConfigurationUtils.getServerShutdownTimeout(getScopeModel()); + + long idleTime = System.currentTimeMillis() - providerModel.getLastInvokeTime(); + + // 1. if service has idle for 10s(shutdown time), un-export directly + if (idleTime > timeout) { + return; + } + + // 2. if service has idle for more than 6.7s(2/3 of shutdown time), wait for the rest time, then un-export directly + int tick = timeout / 3; + if (timeout - idleTime < tick) { + logger.info("Service " + getUniqueServiceName() + " has idle for " + idleTime + " ms, wait for " + (timeout - idleTime) + " ms to un-export"); + try { + Thread.sleep(timeout - idleTime); + } catch (InterruptedException e) { + logger.warn(INTERNAL_ERROR, "unknown error in registry module", "", e.getMessage(), e); + Thread.currentThread().interrupt(); + } + return; + } + + // 3. Wait for 3.33s(1/3 of shutdown time), if service has idle for 3.33s(1/3 of shutdown time), un-export directly, + // otherwise wait for the rest time until idle for 3.33s(1/3 of shutdown time). The max wait time is 10s(shutdown time). + idleTime = 0; Review Comment: 可能最少只等待3.33s? -- 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