kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | c3395b80b593f6c566169b840e1076992c162e5f0baecab8fdc08b9da4e1f950 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-03-15 10:32 +01:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-03-15 10:32 +01:00 |
| Parents | 23c646c58e54, 172ea7610cbc |
5 files changed
modified driver-core/pom.xml +1 −0
| @@ -381,6 +381,7 @@ | ||
| 381 | 381 | <include>**/SSL*Test.java</include> |
| 382 | 382 | <include>**/UUIDsPID*.java</include> |
| 383 | 383 | <include>**/ControlConnectionTest.java</include> |
| 384 | + <include>**/ExtendedPeerCheckDisabledTest.java</include> | |
| 384 | 385 | </includes> |
| 385 | 386 | </configuration> |
| 386 | 387 | </plugin> |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +3 −7
| @@ -427,10 +427,9 @@ | ||
| 427 | 427 | InetAddress peer = peersRow.getInet("peer"); |
| 428 | 428 | InetAddress addr = peersRow.getInet("rpc_address"); |
| 429 | 429 | |
| 430 | - // We've already called isValid on the row, which checks this | |
| 431 | - assert addr != null; | |
| 432 | - | |
| 433 | - if (peer.equals(connectedHost.getAddress()) || addr.equals(connectedHost.getAddress())) { | |
| 430 | + if (addr == null) { | |
| 431 | + return null; | |
| 432 | + } else if (peer.equals(connectedHost.getAddress()) || addr.equals(connectedHost.getAddress())) { | |
| 434 | 433 | // Some DSE versions were inserting a line for the local node in peers (with mostly null values). This has been fixed, but if we |
| 435 | 434 | // detect that's the case, ignore it as it's not really a big deal. |
| 436 | 435 | logger.debug("System.peers on node {} has a line for itself. This is not normal but is a known problem of some DSE version. Ignoring the entry.", connectedHost); |
| @@ -733,9 +732,6 @@ | ||
| 733 | 732 | |
| 734 | 733 | for (Row row : peersFuture.get()) { |
| 735 | 734 | |
| 736 | - if (!isValidPeer(row, false)) | |
| 737 | - continue; | |
| 738 | - | |
| 739 | 735 | InetSocketAddress addr = addressToUseForPeerHost(row, connection.address, cluster); |
| 740 | 736 | if (addr == null || row.isNull("schema_version")) |
| 741 | 737 | continue; |
modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +2 −16
| @@ -225,7 +225,7 @@ | ||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | @DataProvider |
| 228 | - public Object[][] disallowedNullColumnsInPeerData() { | |
| 228 | + public static Object[][] disallowedNullColumnsInPeerData() { | |
| 229 | 229 | return new Object[][]{ |
| 230 | 230 | {"host_id"}, |
| 231 | 231 | {"data_center"}, |
| @@ -325,20 +325,6 @@ | ||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - /** | |
| 329 | - * Validates that if the com.datastax.driver.EXTENDED_PEER_CHECK system property is set to false that a peer | |
| 330 | - * with null values for host_id, data_center, rack, tokens is not ignored. | |
| 331 | - * | |
| 332 | - * @test_category host:metadata | |
| 333 | - * @jira_ticket JAVA-852 | |
| 334 | - * @since 2.1.10 | |
| 335 | - */ | |
| 336 | - @Test(groups = "isolated", dataProvider = "disallowedNullColumnsInPeerData") | |
| 337 | - @CCMConfig(createCcm = false) | |
| 338 | - public void should_use_peer_if_extended_peer_check_is_disabled(String columns) { | |
| 339 | - System.setProperty("com.datastax.driver.EXTENDED_PEER_CHECK", "false"); | |
| 340 | - run_with_null_peer_info(columns, true); | |
| 341 | - } | |
| 342 | 328 | |
| 343 | 329 | /** |
| 344 | 330 | * Validates that if the com.datastax.driver.EXTENDED_PEER_CHECK system property is set to true that a peer |
| @@ -368,7 +354,7 @@ | ||
| 368 | 354 | run_with_null_peer_info(columns, false); |
| 369 | 355 | } |
| 370 | 356 | |
| 371 | - private void run_with_null_peer_info(String columns, boolean expectPeer2) { | |
| 357 | + static void run_with_null_peer_info(String columns, boolean expectPeer2) { | |
| 372 | 358 | // given: A cluster with peer 2 having a null rack. |
| 373 | 359 | ScassandraCluster.ScassandraClusterBuilder builder = ScassandraCluster.builder() |
| 374 | 360 | .withNodes(3); |
added driver-core/src/test/java/com/datastax/driver/core/ExtendedPeerCheckDisabledTest.java +36 −0
| @@ -0,0 +1,36 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core; | |
| 17 | + | |
| 18 | +import org.testng.annotations.Test; | |
| 19 | + | |
| 20 | +public class ExtendedPeerCheckDisabledTest { | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * Validates that if the com.datastax.driver.EXTENDED_PEER_CHECK system property is set to false that a peer | |
| 24 | + * with null values for host_id, data_center, rack, tokens is not ignored. | |
| 25 | + * | |
| 26 | + * @test_category host:metadata | |
| 27 | + * @jira_ticket JAVA-852 | |
| 28 | + * @since 2.1.10 | |
| 29 | + */ | |
| 30 | + @Test(groups = "isolated", dataProvider = "disallowedNullColumnsInPeerData", dataProviderClass = ControlConnectionTest.class) | |
| 31 | + @CCMConfig(createCcm = false) | |
| 32 | + public void should_use_peer_if_extended_peer_check_is_disabled(String columns) { | |
| 33 | + System.setProperty("com.datastax.driver.EXTENDED_PEER_CHECK", "false"); | |
| 34 | + ControlConnectionTest.run_with_null_peer_info(columns, true); | |
| 35 | + } | |
| 36 | +} |
modified driver-core/src/test/java/com/datastax/driver/core/ScassandraCluster.java +7 −1
| @@ -52,6 +52,8 @@ | ||
| 52 | 52 | |
| 53 | 53 | private final List<Map<String, ?>> keyspaceRows; |
| 54 | 54 | |
| 55 | + private static final java.util.UUID schemaVersion = UUIDs.random(); | |
| 56 | + | |
| 55 | 57 | |
| 56 | 58 | private final Map<Integer, Map<Integer, Map<String, Object>>> forcedPeerInfos; |
| 57 | 59 | |
| @@ -297,6 +299,7 @@ | ||
| 297 | 299 | addPeerInfo(row, dc, n + 1, "rack", getPeerInfo(dc, n + 1, "rack", "rack1")); |
| 298 | 300 | addPeerInfo(row, dc, n + 1, "release_version", getPeerInfo(dc, n + 1, "release_version", "2.1.8")); |
| 299 | 301 | addPeerInfo(row, dc, n + 1, "tokens", ImmutableSet.of(tokens.get(n))); |
| 302 | + addPeerInfo(row, dc, n + 1, "schema_version", schemaVersion); | |
| 300 | 303 | } else { // prime system.peers. |
| 301 | 304 | query = "SELECT * FROM system.peers WHERE peer='" + address + "'"; |
| 302 | 305 | metadata = SELECT_PEERS; |
| @@ -308,6 +311,7 @@ | ||
| 308 | 311 | addPeerInfo(row, dc, n + 1, "release_version", getPeerInfo(dc, n + 1, "release_version", "2.1.8")); |
| 309 | 312 | addPeerInfo(row, dc, n + 1, "tokens", ImmutableSet.of(Long.toString(tokens.get(n)))); |
| 310 | 313 | addPeerInfo(row, dc, n + 1, "host_id", UUIDs.random()); |
| 314 | + addPeerInfo(row, dc, n + 1, "schema_version", schemaVersion); | |
| 311 | 315 | rows.add(row); |
| 312 | 316 | } |
| 313 | 317 | client.prime(PrimingRequest.queryBuilder() |
| @@ -379,7 +383,8 @@ | ||
| 379 | 383 | column("rack", TEXT), |
| 380 | 384 | column("release_version", TEXT), |
| 381 | 385 | column("tokens", set(TEXT)), |
| 382 | - column("host_id", UUID) | |
| 386 | + column("host_id", UUID), | |
| 387 | + column("schema_version", UUID) | |
| 383 | 388 | }; |
| 384 | 389 | |
| 385 | 390 | public static final org.scassandra.http.client.types.ColumnMetadata[] SELECT_LOCAL = { |
| @@ -394,6 +399,7 @@ | ||
| 394 | 399 | column("rack", TEXT), |
| 395 | 400 | column("release_version", TEXT), |
| 396 | 401 | column("tokens", set(TEXT)), |
| 402 | + column("schema_version", UUID) | |
| 397 | 403 | }; |
| 398 | 404 | |
| 399 | 405 | static final org.scassandra.http.client.types.ColumnMetadata[] SELECT_CLUSTER_NAME = { |