Created
January 15, 2018 06:27
-
-
Save qsLI/db4cd7b50545292175b460e399b3fedb to your computer and use it in GitHub Desktop.
timeout scanner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static class RemotingInvocationTimeoutScan implements Runnable { | |
public void run() { | |
while (true) { | |
try { | |
for (DefaultFuture future : FUTURES.values()) { | |
if (future == null || future.isDone()) { | |
continue; | |
} | |
if (System.currentTimeMillis() - future.getStartTimestamp() > future.getTimeout()) { | |
// create exception response. | |
Response timeoutResponse = new Response(future.getId()); | |
// set timeout status. | |
timeoutResponse.setStatus(future.isSent() ? Response.SERVER_TIMEOUT : Response.CLIENT_TIMEOUT); | |
timeoutResponse.setErrorMessage(future.getTimeoutMessage(true)); | |
// handle response. | |
DefaultFuture.received(future.getChannel(), timeoutResponse); | |
} | |
} | |
Thread.sleep(30); | |
} catch (Throwable e) { | |
logger.error("Exception when scan the timeout invocation of remoting.", e); | |
} | |
} | |
} | |
} | |
static { | |
Thread th = new Thread(new RemotingInvocationTimeoutScan(), "DubboResponseTimeoutScanTimer"); | |
th.setDaemon(true); | |
th.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment