|
16 | 16 | package com.datastax.driver.core; |
17 | 17 |
|
18 | 18 | import static com.datastax.driver.core.Assertions.assertThat; |
| 19 | +import static com.datastax.driver.core.ConditionChecker.check; |
19 | 20 | import static org.scassandra.cql.MapType.map; |
20 | 21 | import static org.scassandra.cql.PrimitiveType.BIG_INT; |
21 | 22 | import static org.scassandra.cql.PrimitiveType.BOOLEAN; |
|
45 | 46 | import java.util.Map; |
46 | 47 | import java.util.Set; |
47 | 48 | import java.util.TreeSet; |
| 49 | +import java.util.concurrent.Callable; |
48 | 50 | import java.util.concurrent.TimeUnit; |
49 | 51 | import org.scassandra.Scassandra; |
50 | 52 | import org.scassandra.ScassandraFactory; |
@@ -328,12 +330,32 @@ public void stopDC(Cluster cluster, int dc) { |
328 | 330 | public void stop(Cluster cluster, int node) { |
329 | 331 | logger.debug("Stopping node {}.", node); |
330 | 332 | Scassandra scassandra = node(node); |
| 333 | + Host host = TestUtils.findHost(cluster, node); |
331 | 334 | try { |
332 | 335 | scassandra.stop(); |
333 | 336 | } catch (Exception e) { |
334 | 337 | logger.error("Could not stop node " + scassandra, e); |
335 | 338 | } |
336 | 339 | assertThat(cluster).host(node).goesDownWithin(60, TimeUnit.SECONDS); |
| 340 | + waitUntilPoolsAreRemoved(cluster, host); |
| 341 | + } |
| 342 | + |
| 343 | + private void waitUntilPoolsAreRemoved(final Cluster cluster, final Host host) { |
| 344 | + if (host == null) return; |
| 345 | + |
| 346 | + check() |
| 347 | + .before(60, TimeUnit.SECONDS) |
| 348 | + .that( |
| 349 | + new Callable<Boolean>() { |
| 350 | + @Override |
| 351 | + public Boolean call() { |
| 352 | + for (SessionManager session : cluster.manager.sessions) { |
| 353 | + if (session.pools.containsKey(host)) return false; |
| 354 | + } |
| 355 | + return true; |
| 356 | + } |
| 357 | + }) |
| 358 | + .becomesTrue(); |
337 | 359 | } |
338 | 360 |
|
339 | 361 | /** |
|
0 commit comments