Guest User

Untitled

a guest
Jun 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. diff --git a/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java b/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
  2. index e2c1f9c..a6b6bb3 100644
  3. --- a/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
  4. +++ b/src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorFactory.java
  5. @@ -130,10 +130,20 @@ public class ClientRequestExecutorFactory implements
  6. while(!socketChannel.finishConnect()) {
  7. long diff = finishConnectTimeoutMs - System.currentTimeMillis();
  8.  
  9. - if(diff < 0)
  10. + if(diff < 0) {
  11. + // Don't forget to close the socket before we throw our
  12. + // exception or they'll leak :(
  13. + try {
  14. + socketChannel.close();
  15. + } catch(Exception e) {
  16. + if(logger.isEnabledFor(Level.WARN))
  17. + logger.warn(e, e);
  18. + }
  19. +
  20. throw new ConnectException("Cannot connect socket " + numCreated + " for "
  21. + dest.getHost() + ":" + dest.getPort() + " after "
  22. + connectTimeoutMs + " ms");
  23. + }
  24.  
  25. if(logger.isTraceEnabled())
  26. logger.trace("Still creating socket " + numCreated + " for " + dest.getHost() + ":"
  27. @@ -182,10 +192,23 @@ public class ClientRequestExecutorFactory implements
  28. // Block while we wait for the protocol negotiation to complete.
  29. clientRequest.await();
  30.  
  31. - // This will throw an error if the result of the protocol negotiation
  32. - // failed, otherwise it returns an uninteresting token we can safely
  33. - // ignore.
  34. - clientRequest.getResult();
  35. + try {
  36. + // This will throw an error if the result of the protocol
  37. + // negotiation failed, otherwise it returns an uninteresting token
  38. + // we can safely ignore.
  39. + clientRequest.getResult();
  40. + } catch(Exception e) {
  41. + // Don't forget to close the socket before we throw our exception or
  42. + // they'll leak :(
  43. + try {
  44. + socketChannel.close();
  45. + } catch(Exception ex) {
  46. + if(logger.isEnabledFor(Level.WARN))
  47. + logger.warn(ex, ex);
  48. + }
  49. +
  50. + throw e;
  51. + }
  52.  
  53. return clientRequestExecutor;
  54. }
  55. diff --git a/test/integration/voldemort/performance/benchmark/Benchmark.java b/test/integration/voldemort/performance/benchmark/Benchmark.java
  56. index 3d21798..eea33c9 100644
  57. --- a/test/integration/voldemort/performance/benchmark/Benchmark.java
  58. +++ b/test/integration/voldemort/performance/benchmark/Benchmark.java
  59. @@ -346,10 +346,11 @@ public class Benchmark {
  60. ClientConfig clientConfig = new ClientConfig().setMaxThreads(numThreads)
  61. .setMaxTotalConnections(numThreads)
  62. .setMaxConnectionsPerNode(numThreads)
  63. + .setFailureDetectorBannagePeriod(5000)
  64. .setBootstrapUrls(socketUrl)
  65. - .setConnectionTimeout(60,
  66. - TimeUnit.SECONDS)
  67. - .setSocketTimeout(60, TimeUnit.SECONDS)
  68. + .setConnectionTimeout(500,
  69. + TimeUnit.MILLISECONDS)
  70. + .setSocketTimeout(5, TimeUnit.SECONDS)
  71. .setFailureDetectorRequestLengthThreshold(TimeUnit.SECONDS.toMillis(60))
  72. .setSocketBufferSize(socketBufferSize)
  73. .setSelectors(numSelectors)
Add Comment
Please, Sign In to add comment