kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 542f59d6e0ecdccdb799ec3de77a933669f75a2f130099089ce87e375dcb4ee2 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 12:19 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 12:19 +01:00 |
| Parents | dfc873429762 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +8 −3
| @@ -284,13 +284,18 @@ | ||
| 284 | 284 | public void should_expose_tokens_per_host() { |
| 285 | 285 | for (Host host : cluster.getMetadata().allHosts()) { |
| 286 | 286 | assertThat(host.getTokens()).hasSize(numTokens); |
| 287 | - | |
| 288 | 287 | // Check against the info in the system tables, which is a bit weak since it's exactly how the metadata is |
| 289 | 288 | // constructed in the first place, but there's not much else we can do. |
| 290 | 289 | // Note that this relies on all queries going to node 1, which is why we use a WhiteList LBP in setup(). |
| 291 | - Row row = session.execute("select tokens from system.peers where peer = '" + host.getBroadcastAddress().getHostAddress() + "'").one(); | |
| 292 | - if (row == null) | |
| 290 | + boolean isControlHost = host.getSocketAddress().equals(cluster.manager.controlConnection.connectionRef.get().address); | |
| 291 | + Row row; | |
| 292 | + if (isControlHost) { | |
| 293 | 293 | row = session.execute("select tokens from system.local").one(); |
| 294 | + } else { | |
| 295 | + // non-control hosts are populated from system.peers and their broadcast address should be known | |
| 296 | + assertThat(host.getBroadcastAddress()).isNotNull(); | |
| 297 | + row = session.execute("select tokens from system.peers where peer = '" + host.getBroadcastAddress().getHostAddress() + "'").one(); | |
| 298 | + } | |
| 294 | 299 | Set<String> tokenStrings = row.getSet("tokens", String.class); |
| 295 | 300 | assertThat(tokenStrings).hasSize(numTokens); |
| 296 | 301 | Iterable<Token> tokensFromSystemTable = Iterables.transform(tokenStrings, new Function<String, Token>() { |