kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | bef68d1959a63134975d79a212bd68336ebfcb413178b3147e570df6c28d1f89 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-10 17:14 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-10 17:14 +01:00 |
| Parents | d99db6eb7663, c41d2ad63311 |
6 files changed
modified changelog/README.md +3 −0
| @@ -5,6 +5,9 @@ | ||
| 5 | 5 | Merged from 3.0.x branch: |
| 6 | 6 | |
| 7 | 7 | - [bug] JAVA-1371: Reintroduce connection pool timeout. |
| 8 | +- [bug] JAVA-1313: Copy SerialConsistencyLevel to PreparedStatement. | |
| 9 | +- [documentation] JAVA-1334: Clarify documentation of method `addContactPoints`. | |
| 10 | +- [improvement] JAVA-1357: Document that getReplicas only returns replicas of the last token in range. | |
| 8 | 11 | |
| 9 | 12 | |
| 10 | 13 | ### 3.1.3 |
modified driver-core/src/main/java/com/datastax/driver/core/AbstractSession.java +4 −1
| @@ -144,7 +144,10 @@ | ||
| 144 | 144 | ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry); |
| 145 | 145 | if (routingKey != null) |
| 146 | 146 | prepared.setRoutingKey(routingKey); |
| 147 | - prepared.setConsistencyLevel(statement.getConsistencyLevel()); | |
| 147 | + if (statement.getConsistencyLevel() != null) | |
| 148 | + prepared.setConsistencyLevel(statement.getConsistencyLevel()); | |
| 149 | + if (statement.getSerialConsistencyLevel() != null) | |
| 150 | + prepared.setSerialConsistencyLevel(statement.getSerialConsistencyLevel()); | |
| 148 | 151 | if (statement.isTracing()) |
| 149 | 152 | prepared.enableTracing(); |
| 150 | 153 | prepared.setRetryPolicy(statement.getRetryPolicy()); |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +29 −19
| @@ -809,7 +809,7 @@ | ||
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | /** |
| 812 | - * Adds a contact point - or many if it host resolves to multiple | |
| 812 | + * Adds a contact point - or many if the given address resolves to multiple | |
| 813 | 813 | * <code>InetAddress</code>s (A records). |
| 814 | 814 | * <p/> |
| 815 | 815 | * Contact points are addresses of Cassandra nodes that the driver uses |
| @@ -820,7 +820,7 @@ | ||
| 820 | 820 | * the driver cannot initialize itself correctly. |
| 821 | 821 | * <p/> |
| 822 | 822 | * Note that by default (that is, unless you use the {@link #withLoadBalancingPolicy}) |
| 823 | - * method of this builder), the first succesfully contacted host will be used | |
| 823 | + * method of this builder), the first successfully contacted host will be used | |
| 824 | 824 | * to define the local data-center for the client. If follows that if you are |
| 825 | 825 | * running Cassandra in a multiple data-center setting, it is a good idea to |
| 826 | 826 | * only provide contact points that are in the same datacenter than the client, |
| @@ -830,15 +830,15 @@ | ||
| 830 | 830 | * returned will be used. Make sure that all resulting <code>InetAddress</code>s returned |
| 831 | 831 | * point to the same cluster and datacenter. |
| 832 | 832 | * |
| 833 | - * @param address the address of the node(s) to connect to | |
| 833 | + * @param address the address of the node(s) to connect to. | |
| 834 | 834 | * @return this Builder. |
| 835 | - * @throws IllegalArgumentException if no IP address for {@code address} | |
| 836 | - * could be found | |
| 835 | + * @throws IllegalArgumentException if the given {@code address} | |
| 836 | + * could not be resolved. | |
| 837 | 837 | * @throws SecurityException if a security manager is present and |
| 838 | 838 | * permission to resolve the host name is denied. |
| 839 | 839 | */ |
| 840 | 840 | public Builder addContactPoint(String address) { |
| 841 | - // We explicitely check for nulls because InetAdress.getByName() will happily | |
| 841 | + // We explicitly check for nulls because InetAdress.getByName() will happily | |
| 842 | 842 | // accept it and use localhost (while a null here almost likely mean a user error, |
| 843 | 843 | // not "connect to localhost") |
| 844 | 844 | if (address == null) |
| @@ -857,11 +857,14 @@ | ||
| 857 | 857 | * <p/> |
| 858 | 858 | * See {@link Builder#addContactPoint} for more details on contact |
| 859 | 859 | * points. |
| 860 | + * <p/> | |
| 861 | + * Note that all contact points must be resolvable; | |
| 862 | + * if <em>any</em> of them cannot be resolved, this method will fail. | |
| 860 | 863 | * |
| 861 | - * @param addresses addresses of the nodes to add as contact point. | |
| 864 | + * @param addresses addresses of the nodes to add as contact points. | |
| 862 | 865 | * @return this Builder. |
| 863 | - * @throws IllegalArgumentException if no IP address for at least one | |
| 864 | - * of {@code addresses} could be found | |
| 866 | + * @throws IllegalArgumentException if any of the given {@code addresses} | |
| 867 | + * could not be resolved. | |
| 865 | 868 | * @throws SecurityException if a security manager is present and |
| 866 | 869 | * permission to resolve the host name is denied. |
| 867 | 870 | * @see Builder#addContactPoint |
| @@ -877,9 +880,16 @@ | ||
| 877 | 880 | * <p/> |
| 878 | 881 | * See {@link Builder#addContactPoint} for more details on contact |
| 879 | 882 | * points. |
| 883 | + * <p/> | |
| 884 | + * Note that all contact points must be resolvable; | |
| 885 | + * if <em>any</em> of them cannot be resolved, this method will fail. | |
| 880 | 886 | * |
| 881 | - * @param addresses addresses of the nodes to add as contact point. | |
| 887 | + * @param addresses addresses of the nodes to add as contact points. | |
| 882 | 888 | * @return this Builder. |
| 889 | + * @throws IllegalArgumentException if any of the given {@code addresses} | |
| 890 | + * could not be resolved. | |
| 891 | + * @throws SecurityException if a security manager is present and | |
| 892 | + * permission to resolve the host name is denied. | |
| 883 | 893 | * @see Builder#addContactPoint |
| 884 | 894 | */ |
| 885 | 895 | public Builder addContactPoints(InetAddress... addresses) { |
| @@ -893,7 +903,7 @@ | ||
| 893 | 903 | * See {@link Builder#addContactPoint} for more details on contact |
| 894 | 904 | * points. |
| 895 | 905 | * |
| 896 | - * @param addresses addresses of the nodes to add as contact point | |
| 906 | + * @param addresses addresses of the nodes to add as contact points. | |
| 897 | 907 | * @return this Builder |
| 898 | 908 | * @see Builder#addContactPoint |
| 899 | 909 | */ |
| @@ -907,19 +917,19 @@ | ||
| 907 | 917 | * <p/> |
| 908 | 918 | * See {@link Builder#addContactPoint} for more details on contact |
| 909 | 919 | * points. Contrarily to other {@code addContactPoints} methods, this method |
| 910 | - * allow to provide a different port for each contact points. Since Cassandra | |
| 911 | - * nodes must always all listen on the same port, this is rarelly what you | |
| 920 | + * allows to provide a different port for each contact point. Since Cassandra | |
| 921 | + * nodes must always all listen on the same port, this is rarely what you | |
| 912 | 922 | * want and most users should prefer other {@code addContactPoints} methods to |
| 913 | 923 | * this one. However, this can be useful if the Cassandra nodes are behind |
| 914 | 924 | * a router and are not accessed directly. Note that if you are in this |
| 915 | 925 | * situation (Cassandra nodes are behind a router, not directly accessible), |
| 916 | - * you almost surely want to provide a specific {@code AddressTranslator} | |
| 926 | + * you almost surely want to provide a specific {@link AddressTranslator} | |
| 917 | 927 | * (through {@link #withAddressTranslator}) to translate actual Cassandra node |
| 918 | 928 | * addresses to the addresses the driver should use, otherwise the driver |
| 919 | 929 | * will not be able to auto-detect new nodes (and will generally not function |
| 920 | 930 | * optimally). |
| 921 | 931 | * |
| 922 | - * @param addresses addresses of the nodes to add as contact point | |
| 932 | + * @param addresses addresses of the nodes to add as contact points. | |
| 923 | 933 | * @return this Builder |
| 924 | 934 | * @see Builder#addContactPoint |
| 925 | 935 | */ |
| @@ -933,19 +943,19 @@ | ||
| 933 | 943 | * <p/> |
| 934 | 944 | * See {@link Builder#addContactPoint} for more details on contact |
| 935 | 945 | * points. Contrarily to other {@code addContactPoints} methods, this method |
| 936 | - * allow to provide a different port for each contact points. Since Cassandra | |
| 937 | - * nodes must always all listen on the same port, this is rarelly what you | |
| 946 | + * allows to provide a different port for each contact point. Since Cassandra | |
| 947 | + * nodes must always all listen on the same port, this is rarely what you | |
| 938 | 948 | * want and most users should prefer other {@code addContactPoints} methods to |
| 939 | 949 | * this one. However, this can be useful if the Cassandra nodes are behind |
| 940 | 950 | * a router and are not accessed directly. Note that if you are in this |
| 941 | 951 | * situation (Cassandra nodes are behind a router, not directly accessible), |
| 942 | - * you almost surely want to provide a specific {@code AddressTranslator} | |
| 952 | + * you almost surely want to provide a specific {@link AddressTranslator} | |
| 943 | 953 | * (through {@link #withAddressTranslator}) to translate actual Cassandra node |
| 944 | 954 | * addresses to the addresses the driver should use, otherwise the driver |
| 945 | 955 | * will not be able to auto-detect new nodes (and will generally not function |
| 946 | 956 | * optimally). |
| 947 | 957 | * |
| 948 | - * @param addresses addresses of the nodes to add as contact point | |
| 958 | + * @param addresses addresses of the nodes to add as contact points. | |
| 949 | 959 | * @return this Builder |
| 950 | 960 | * @see Builder#addContactPoint |
| 951 | 961 | */ |
modified driver-core/src/main/java/com/datastax/driver/core/Metadata.java +6 −1
| @@ -305,7 +305,12 @@ | ||
| 305 | 305 | /** |
| 306 | 306 | * Returns the set of hosts that are replica for a given token range. |
| 307 | 307 | * <p/> |
| 308 | - * Note that this information is refreshed asynchronously by the control | |
| 308 | + * Note that it is assumed that the input range does not overlap across multiple host ranges. | |
| 309 | + * If the range extends over multiple hosts, it only returns the replicas for those hosts | |
| 310 | + * that are replicas for the last token of the range. This behavior may change in a future | |
| 311 | + * release, see <a href="https://datastax-oss.atlassian.net/browse/JAVA-1355">JAVA-1355</a>. | |
| 312 | + * <p/> | |
| 313 | + * Also note that this information is refreshed asynchronously by the control | |
| 309 | 314 | * connection, when schema or ring topology changes. It might occasionally |
| 310 | 315 | * be stale (or even empty). |
| 311 | 316 | * |
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +24 −3
| @@ -17,7 +17,10 @@ | ||
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 19 | 19 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
| 20 | +import com.datastax.driver.core.policies.FallthroughRetryPolicy; | |
| 21 | +import com.datastax.driver.core.utils.Bytes; | |
| 20 | 22 | import com.datastax.driver.core.utils.CassandraVersion; |
| 23 | +import com.google.common.collect.ImmutableMap; | |
| 21 | 24 | import com.google.common.util.concurrent.Uninterruptibles; |
| 22 | 25 | import org.testng.annotations.Test; |
| 23 | 26 | |
| @@ -25,6 +28,7 @@ | ||
| 25 | 28 | import java.util.*; |
| 26 | 29 | import java.util.concurrent.TimeUnit; |
| 27 | 30 | |
| 31 | +import static com.datastax.driver.core.ProtocolVersion.V4; | |
| 28 | 32 | import static com.datastax.driver.core.TestUtils.*; |
| 29 | 33 | import static org.assertj.core.api.Assertions.assertThat; |
| 30 | 34 | import static org.testng.Assert.*; |
| @@ -334,13 +338,30 @@ | ||
| 334 | 338 | |
| 335 | 339 | RegularStatement toPrepare = new SimpleStatement("SELECT * FROM test WHERE k=?"); |
| 336 | 340 | toPrepare.setConsistencyLevel(ConsistencyLevel.QUORUM); |
| 341 | + toPrepare.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); | |
| 342 | + toPrepare.setRetryPolicy(FallthroughRetryPolicy.INSTANCE); | |
| 343 | + if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 344 | + toPrepare.setOutgoingPayload(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); | |
| 345 | + toPrepare.setIdempotent(true); | |
| 337 | 346 | toPrepare.enableTracing(); |
| 338 | 347 | |
| 339 | 348 | PreparedStatement prepared = session().prepare(toPrepare); |
| 340 | - BoundStatement bs = prepared.bind("someValue"); | |
| 349 | + assertThat(prepared.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM); | |
| 350 | + assertThat(prepared.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL); | |
| 351 | + assertThat(prepared.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE); | |
| 352 | + if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 353 | + assertThat(prepared.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); | |
| 354 | + assertThat(prepared.isIdempotent()).isTrue(); | |
| 355 | + assertThat(prepared.isTracing()).isTrue(); | |
| 341 | 356 | |
| 342 | - assertEquals(ConsistencyLevel.QUORUM, bs.getConsistencyLevel()); | |
| 343 | - assertTrue(bs.isTracing()); | |
| 357 | + BoundStatement bs = prepared.bind("someValue"); | |
| 358 | + assertThat(bs.getConsistencyLevel()).isEqualTo(ConsistencyLevel.QUORUM); | |
| 359 | + assertThat(bs.getSerialConsistencyLevel()).isEqualTo(ConsistencyLevel.LOCAL_SERIAL); | |
| 360 | + assertThat(bs.getRetryPolicy()).isEqualTo(FallthroughRetryPolicy.INSTANCE); | |
| 361 | + if (TestUtils.getDesiredProtocolVersion().compareTo(V4) >= 0) | |
| 362 | + assertThat(bs.getOutgoingPayload()).isEqualTo(ImmutableMap.of("foo", Bytes.fromHexString("0xcafebabe"))); | |
| 363 | + assertThat(bs.isIdempotent()).isTrue(); | |
| 364 | + assertThat(bs.isTracing()).isTrue(); | |
| 344 | 365 | } |
| 345 | 366 | |
| 346 | 367 | /** |
modified manual/pooling/README.md +1 −0
| @@ -190,6 +190,7 @@ | ||
| 190 | 190 | |
| 191 | 191 | Two options control that queue: a maximum size ([PoolingOptions.setMaxQueueSize][smqs]) and a timeout |
| 192 | 192 | ([PoolingOptions.setPoolTimeoutMillis][sptm]). |
| 193 | + | |
| 193 | 194 | * if either option is set to zero, the attempt is rejected immediately; |
| 194 | 195 | * else if more than `maxQueueSize` requests are already waiting for a connection, the attempt is also rejected; |
| 195 | 196 | * otherwise, the attempt is enqueued; if a connection becomes available before `poolTimeoutMillis` has elapsed, |