Created
July 22, 2012 20:23
-
-
Save daschl/3160974 to your computer and use it in GitHub Desktop.
exception handling and reopen
This file contains 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
/** | |
* 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