Elffuss BraidHub

kikocis/java-driver public

Merge branch '3.0.x' into 3.1.x
Changesetbef68d1959a63134975d79a212bd68336ebfcb413178b3147e570df6c28d1f89
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-10 17:14 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2017-02-10 17:14 +01:00
Parentsd99db6eb7663, c41d2ad63311

Browse the files at this changeset

6 files changed

modified changelog/README.md +3 −0
@@ -5,6 +5,9 @@
55 Merged from 3.0.x branch:
66
77 - [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.
811
912
1013 ### 3.1.3
modified driver-core/src/main/java/com/datastax/driver/core/AbstractSession.java +4 −1
@@ -144,7 +144,10 @@
144144 ByteBuffer routingKey = statement.getRoutingKey(protocolVersion, codecRegistry);
145145 if (routingKey != null)
146146 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());
148151 if (statement.isTracing())
149152 prepared.enableTracing();
150153 prepared.setRetryPolicy(statement.getRetryPolicy());
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +29 −19
@@ -809,7 +809,7 @@
809809 }
810810
811811 /**
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
813813 * <code>InetAddress</code>s (A records).
814814 * <p/>
815815 * Contact points are addresses of Cassandra nodes that the driver uses
@@ -820,7 +820,7 @@
820820 * the driver cannot initialize itself correctly.
821821 * <p/>
822822 * 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
824824 * to define the local data-center for the client. If follows that if you are
825825 * running Cassandra in a multiple data-center setting, it is a good idea to
826826 * only provide contact points that are in the same datacenter than the client,
@@ -830,15 +830,15 @@
830830 * returned will be used. Make sure that all resulting <code>InetAddress</code>s returned
831831 * point to the same cluster and datacenter.
832832 *
833- * @param address the address of the node(s) to connect to
833+ * @param address the address of the node(s) to connect to.
834834 * @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.
837837 * @throws SecurityException if a security manager is present and
838838 * permission to resolve the host name is denied.
839839 */
840840 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
842842 // accept it and use localhost (while a null here almost likely mean a user error,
843843 // not "connect to localhost")
844844 if (address == null)
@@ -857,11 +857,14 @@
857857 * <p/>
858858 * See {@link Builder#addContactPoint} for more details on contact
859859 * 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.
860863 *
861- * @param addresses addresses of the nodes to add as contact point.
864+ * @param addresses addresses of the nodes to add as contact points.
862865 * @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.
865868 * @throws SecurityException if a security manager is present and
866869 * permission to resolve the host name is denied.
867870 * @see Builder#addContactPoint
@@ -877,9 +880,16 @@
877880 * <p/>
878881 * See {@link Builder#addContactPoint} for more details on contact
879882 * 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.
880886 *
881- * @param addresses addresses of the nodes to add as contact point.
887+ * @param addresses addresses of the nodes to add as contact points.
882888 * @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.
883893 * @see Builder#addContactPoint
884894 */
885895 public Builder addContactPoints(InetAddress... addresses) {
@@ -893,7 +903,7 @@
893903 * See {@link Builder#addContactPoint} for more details on contact
894904 * points.
895905 *
896- * @param addresses addresses of the nodes to add as contact point
906+ * @param addresses addresses of the nodes to add as contact points.
897907 * @return this Builder
898908 * @see Builder#addContactPoint
899909 */
@@ -907,19 +917,19 @@
907917 * <p/>
908918 * See {@link Builder#addContactPoint} for more details on contact
909919 * 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
912922 * want and most users should prefer other {@code addContactPoints} methods to
913923 * this one. However, this can be useful if the Cassandra nodes are behind
914924 * a router and are not accessed directly. Note that if you are in this
915925 * 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}
917927 * (through {@link #withAddressTranslator}) to translate actual Cassandra node
918928 * addresses to the addresses the driver should use, otherwise the driver
919929 * will not be able to auto-detect new nodes (and will generally not function
920930 * optimally).
921931 *
922- * @param addresses addresses of the nodes to add as contact point
932+ * @param addresses addresses of the nodes to add as contact points.
923933 * @return this Builder
924934 * @see Builder#addContactPoint
925935 */
@@ -933,19 +943,19 @@
933943 * <p/>
934944 * See {@link Builder#addContactPoint} for more details on contact
935945 * 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
938948 * want and most users should prefer other {@code addContactPoints} methods to
939949 * this one. However, this can be useful if the Cassandra nodes are behind
940950 * a router and are not accessed directly. Note that if you are in this
941951 * 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}
943953 * (through {@link #withAddressTranslator}) to translate actual Cassandra node
944954 * addresses to the addresses the driver should use, otherwise the driver
945955 * will not be able to auto-detect new nodes (and will generally not function
946956 * optimally).
947957 *
948- * @param addresses addresses of the nodes to add as contact point
958+ * @param addresses addresses of the nodes to add as contact points.
949959 * @return this Builder
950960 * @see Builder#addContactPoint
951961 */
modified driver-core/src/main/java/com/datastax/driver/core/Metadata.java +6 −1
@@ -305,7 +305,12 @@
305305 /**
306306 * Returns the set of hosts that are replica for a given token range.
307307 * <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
309314 * connection, when schema or ring topology changes. It might occasionally
310315 * be stale (or even empty).
311316 *
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +24 −3
@@ -17,7 +17,10 @@
1717
1818 import com.datastax.driver.core.exceptions.InvalidQueryException;
1919 import com.datastax.driver.core.exceptions.UnsupportedFeatureException;
20+import com.datastax.driver.core.policies.FallthroughRetryPolicy;
21+import com.datastax.driver.core.utils.Bytes;
2022 import com.datastax.driver.core.utils.CassandraVersion;
23+import com.google.common.collect.ImmutableMap;
2124 import com.google.common.util.concurrent.Uninterruptibles;
2225 import org.testng.annotations.Test;
2326
@@ -25,6 +28,7 @@
2528 import java.util.*;
2629 import java.util.concurrent.TimeUnit;
2730
31+import static com.datastax.driver.core.ProtocolVersion.V4;
2832 import static com.datastax.driver.core.TestUtils.*;
2933 import static org.assertj.core.api.Assertions.assertThat;
3034 import static org.testng.Assert.*;
@@ -334,13 +338,30 @@
334338
335339 RegularStatement toPrepare = new SimpleStatement("SELECT * FROM test WHERE k=?");
336340 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);
337346 toPrepare.enableTracing();
338347
339348 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();
341356
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();
344365 }
345366
346367 /**
modified manual/pooling/README.md +1 −0
@@ -190,6 +190,7 @@
190190
191191 Two options control that queue: a maximum size ([PoolingOptions.setMaxQueueSize][smqs]) and a timeout
192192 ([PoolingOptions.setPoolTimeoutMillis][sptm]).
193+
193194 * if either option is set to zero, the attempt is rejected immediately;
194195 * else if more than `maxQueueSize` requests are already waiting for a connection, the attempt is also rejected;
195196 * otherwise, the attempt is enqueued; if a connection becomes available before `poolTimeoutMillis` has elapsed,