Elffuss BraidHub

kikocis/java-driver public

Fix cluster shutdown (JAVA-445).
Changeset84a5d8bc69e0de4df0420169399592739208a7487d17b4b785d4237d18165f43
Authorolim7t <omichallat+github@gmail.com> · 2014-09-08 21:20 -07:00
Committerolim7t <omichallat+github@gmail.com> · 2014-09-08 21:22 -07:00
Parents73e7b6a4d0ef

Browse the files at this changeset

2 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -12,6 +12,7 @@
1212 - [improvement] Add ResultSet.wasApplied() for conditional queries (JAVA-358)
1313 - [bug] Fix negative HostConnectionPool open count (JAVA-349)
1414 - [improvement] Log more connection details at trace and debug levels (JAVA-436)
15+- [bug] Fix cluster shutdown (JAVA-445)
1516
1617 2.0.5:
1718 ------
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +6 −5
@@ -1230,14 +1230,15 @@
12301230 logger.debug("Shutting down");
12311231
12321232 // If we're shutting down, there is no point in waiting on scheduled reconnections, nor on notifications
1233- // delivery so we use shutdownNow
1233+ // delivery or blocking tasks so we use shutdownNow
12341234 reconnectionExecutor.shutdownNow();
12351235 scheduledTasksExecutor.shutdownNow();
1236+ blockingExecutor.shutdownNow();
12361237
12371238 // but for the worker executor, we want to let submitted tasks finish unless the shutdown is forced.
12381239 executor.shutdown();
12391240
1240- // We also closes the metrics
1241+ // We also close the metrics
12411242 if (metrics != null)
12421243 metrics.shutdown();
12431244
@@ -1984,6 +1985,7 @@
19841985 reconnectionExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
19851986 scheduledTasksExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
19861987 executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
1988+ blockingExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
19871989
19881990 // Some of the jobs on the executors can be doing query stuff, so close the
19891991 // connectionFactory at the very last
@@ -2052,9 +2054,8 @@
20522054
20532055 void shutdown() {
20542056 shutdown = true;
2055- executor.shutdown();
2056- // Run the task one last time if a call to register raced with the two lines above (i.e.
2057- // saw shutdown as false but added its connection after the last task in the executor ran).
2057+ // Force shutdown to avoid waiting for the interval, and run the task manually one last time
2058+ executor.shutdownNow();
20582059 reaperTask.run();
20592060 }
20602061 }