Skip to content

Instantly share code, notes, and snippets.

@daschl
Created July 22, 2012 20:23
Show Gist options
  • Save daschl/3160974 to your computer and use it in GitHub Desktop.
Save daschl/3160974 to your computer and use it in GitHub Desktop.
exception handling and reopen
/**
* Infinitely loop processing IO.
*/
@Override
public void run() {
while (running) {
try {
handleIO();
} catch (IOException e) {
logRunException(e);
} catch (CancelledKeyException e) {
logRunException(e);
} catch (ClosedSelectorException e) {
logRunException(e);
} catch (IllegalStateException e) {
logRunException(e);
} catch (Exception e) {
logRunException(e);
// iterate through all nodes and callsetupResend
// to cancel current ops.
for (MemcachedNode qa : locator.getAll()) {
qa.setupResend();
try {
qa.getChannel().close();
qa.setChannel(SocketChannel.open(qa.getSocketAddress()));
} catch(IOException ex) {
// die? "couldnt recover"?
logRunException(ex);
}
}
}
}
getLogger().info("Shut down memcached client");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment