kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | e24e5cd01927f95befaf5e35322038fa7509e1ecf55b1d55284f3b8e5fda44d2 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-10-07 18:14 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-10-08 10:45 +02:00 |
| Parents | 19ceb74cd6c4 |
6 files changed
modified driver-core/src/main/java/com/datastax/driver/core/Requests.java +3 −3
| @@ -206,7 +206,7 @@ | ||
| 206 | 206 | -1, |
| 207 | 207 | null, |
| 208 | 208 | ConsistencyLevel.SERIAL, |
| 209 | - 0); | |
| 209 | + Long.MIN_VALUE); | |
| 210 | 210 | |
| 211 | 211 | private final EnumSet<QueryFlag> flags = EnumSet.noneOf(QueryFlag.class); |
| 212 | 212 | public final ConsistencyLevel consistency; |
| @@ -244,7 +244,7 @@ | ||
| 244 | 244 | flags.add(QueryFlag.PAGING_STATE); |
| 245 | 245 | if (serialConsistency != ConsistencyLevel.SERIAL) |
| 246 | 246 | flags.add(QueryFlag.SERIAL_CONSISTENCY); |
| 247 | - if (defaultTimestamp != 0L) | |
| 247 | + if (defaultTimestamp != Long.MIN_VALUE) | |
| 248 | 248 | flags.add(QueryFlag.DEFAULT_TIMESTAMP); |
| 249 | 249 | } |
| 250 | 250 | |
| @@ -394,7 +394,7 @@ | ||
| 394 | 394 | |
| 395 | 395 | if (serialConsistency != ConsistencyLevel.SERIAL) |
| 396 | 396 | flags.add(QueryFlag.SERIAL_CONSISTENCY); |
| 397 | - if (defaultTimestamp != 0L) | |
| 397 | + if (defaultTimestamp != Long.MIN_VALUE) | |
| 398 | 398 | flags.add(QueryFlag.DEFAULT_TIMESTAMP); |
| 399 | 399 | } |
| 400 | 400 |
modified driver-core/src/main/java/com/datastax/driver/core/ServerSideTimestampGenerator.java +3 −3
| @@ -16,8 +16,8 @@ | ||
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * A timestamp generator that always returns 0, in order to let Cassandra assign | |
| 20 | - * server-side timestamps. | |
| 19 | + * A timestamp generator that always returns {@link Long#MIN_VALUE}, in order to let Cassandra | |
| 20 | + * assign server-side timestamps. | |
| 21 | 21 | */ |
| 22 | 22 | public class ServerSideTimestampGenerator implements TimestampGenerator { |
| 23 | 23 | /** |
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | |
| 28 | 28 | @Override |
| 29 | 29 | public long next() { |
| 30 | - return 0; | |
| 30 | + return Long.MIN_VALUE; | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | private ServerSideTimestampGenerator() { |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +2 −2
| @@ -378,10 +378,10 @@ | ||
| 378 | 378 | } else if (serialConsistency == null) |
| 379 | 379 | serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel(); |
| 380 | 380 | |
| 381 | - long defaultTimestamp = 0; | |
| 381 | + long defaultTimestamp = Long.MIN_VALUE; | |
| 382 | 382 | if (cluster.manager.protocolVersion().compareTo(ProtocolVersion.V3) >= 0) { |
| 383 | 383 | defaultTimestamp = statement.getDefaultTimestamp(); |
| 384 | - if (defaultTimestamp <= 0) | |
| 384 | + if (defaultTimestamp == Long.MIN_VALUE) | |
| 385 | 385 | defaultTimestamp = cluster.getConfiguration().getPolicies().getTimestampGenerator().next(); |
| 386 | 386 | } |
| 387 | 387 |
modified driver-core/src/main/java/com/datastax/driver/core/Statement.java +4 −3
| @@ -42,7 +42,7 @@ | ||
| 42 | 42 | private volatile ConsistencyLevel serialConsistency; |
| 43 | 43 | private volatile boolean traceQuery; |
| 44 | 44 | private volatile int fetchSize; |
| 45 | - private volatile long defaultTimestamp; | |
| 45 | + private volatile long defaultTimestamp = Long.MIN_VALUE; | |
| 46 | 46 | |
| 47 | 47 | private volatile RetryPolicy retryPolicy; |
| 48 | 48 | |
| @@ -266,9 +266,10 @@ | ||
| 266 | 266 | * <ul> |
| 267 | 267 | * <li>the timestamp specified directly in the CQL query string (using the |
| 268 | 268 | * {@code USING TIMESTAMP} syntax);</li> |
| 269 | - * <li>the timestamp specified through this method, if strictly positive;</li> | |
| 269 | + * <li>the timestamp specified through this method, if different from | |
| 270 | + * {@link Long#MIN_VALUE};</li> | |
| 270 | 271 | * <li>the timestamp returned by the {@link TimestampGenerator} currently in use, |
| 271 | - * if strictly positive.</li> | |
| 272 | + * if different from {@link Long#MIN_VALUE}.</li> | |
| 272 | 273 | * </ul> |
| 273 | 274 | * If none of these apply, no timestamp will be sent with the query and Cassandra |
| 274 | 275 | * will generate a server-side one (similar to the pre-V3 behavior). |
modified driver-core/src/main/java/com/datastax/driver/core/TimestampGenerator.java +2 −2
| @@ -25,8 +25,8 @@ | ||
| 25 | 25 | /** |
| 26 | 26 | * Returns the next timestamp. |
| 27 | 27 | * |
| 28 | - * @return the next timestamp (in microseconds). If this is 0, it won't be sent by the driver, | |
| 29 | - * letting Cassandra generate a server-side timestamp. | |
| 28 | + * @return the next timestamp (in microseconds). If it equals {@link Long#MIN_VALUE}, it won't be | |
| 29 | + * sent by the driver, letting Cassandra generate a server-side timestamp. | |
| 30 | 30 | */ |
| 31 | 31 | long next(); |
| 32 | 32 | } |
modified driver-core/src/test/java/com/datastax/driver/core/QueryTimestampTest.java +2 −2
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | |
| 78 | 78 | @Test(groups = "short") |
| 79 | 79 | public void should_use_server_side_timestamp_if_none_specified() { |
| 80 | - timestampFromGenerator = 0; | |
| 80 | + timestampFromGenerator = Long.MIN_VALUE; | |
| 81 | 81 | long clientTime = System.currentTimeMillis() * 1000; |
| 82 | 82 | String query = "INSERT INTO foo (k, v) VALUES (1, 1)"; |
| 83 | 83 | session.execute(query); |
| @@ -116,7 +116,7 @@ | ||
| 116 | 116 | |
| 117 | 117 | @Test(groups = "short") |
| 118 | 118 | public void should_apply_server_side_timestamp_only_to_batched_queries_without_timestamp() { |
| 119 | - timestampFromGenerator = 0; | |
| 119 | + timestampFromGenerator = Long.MIN_VALUE; | |
| 120 | 120 | long clientTime = System.currentTimeMillis() * 1000; |
| 121 | 121 | BatchStatement batch = new BatchStatement(); |
| 122 | 122 | batch.add(new SimpleStatement("INSERT INTO foo (k, v) VALUES (1, 1)")); |