You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2016/04/28 03:20:58 UTC

[1/6] cassandra git commit: JSON datetime formatting needs timezone (backported from trunk)

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 e5c402780 -> 88f22b969
  refs/heads/cassandra-3.0 7a2be8fa4 -> b360653fc
  refs/heads/trunk 4254de17f -> 2bb1bfcb9


JSON datetime formatting needs timezone (backported from trunk)

patch by Alex Petrov; reviewed by Stefania Alborghetti for CASSANDRA-11137


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/88f22b96
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/88f22b96
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/88f22b96

Branch: refs/heads/cassandra-2.2
Commit: 88f22b9692c6fdddf837556f13140d949afe0d28
Parents: e5c4027
Author: Alex Petrov <ol...@gmail.com>
Authored: Thu Apr 28 08:59:24 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:10:18 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 NEWS.txt                                                 |  8 ++++++++
 .../cassandra/serializers/TimestampSerializer.java       | 11 +++++++----
 .../cassandra/cql3/validation/entities/JsonTest.java     |  6 ++++--
 4 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3641816..91179b3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * JSON datetime formatting needs timezone (CASSANDRA-11137)
  * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
  * Remove unnescessary file existence check during anticompaction (CASSANDRA-11660)
  * Add missing files to debian packages (CASSANDRA-11642)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index e8f4e66..a3ba0dd 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,14 @@ restore snapshots created with the previous major version using the
 'sstableloader' tool. You can upgrade the file format of your snapshots
 using the provided 'sstableupgrade' tool.
 
+2.2.7
+=====
+
+New features
+------------
+    - JSON timestamps are now in UTC and contain the timezone information, see
+      CASSANDRA-11137 for more details.
+
 2.2.6
 =====
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index 78ee7e7..77a5df9 100644
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@ -22,7 +22,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import java.nio.ByteBuffer;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
-import java.util.Date;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.time.DateUtils;
@@ -48,11 +48,11 @@ public class TimestampSerializer implements TypeSerializer<Date>
             "yyyy-MM-dd HH:mm:ssX",
             "yyyy-MM-dd HH:mm:ssXX",
             "yyyy-MM-dd HH:mm:ssXXX",
-            "yyyy-MM-dd HH:mm:ss.SSS",   // TO_JSON_FORMAT
+            "yyyy-MM-dd HH:mm:ss.SSS",
             "yyyy-MM-dd HH:mm:ss.SSS z",
             "yyyy-MM-dd HH:mm:ss.SSS zz",
             "yyyy-MM-dd HH:mm:ss.SSS zzz",
-            "yyyy-MM-dd HH:mm:ss.SSSX",
+            "yyyy-MM-dd HH:mm:ss.SSSX", // TO_JSON_FORMAT
             "yyyy-MM-dd HH:mm:ss.SSSXX",
             "yyyy-MM-dd HH:mm:ss.SSSXXX",
             "yyyy-MM-dd'T'HH:mm",
@@ -96,11 +96,14 @@ public class TimestampSerializer implements TypeSerializer<Date>
         }
     };
 
+    private static final String TO_JSON_FORMAT = dateStringPatterns[19];
     private static final ThreadLocal<SimpleDateFormat> FORMATTER_TO_JSON = new ThreadLocal<SimpleDateFormat>()
     {
         protected SimpleDateFormat initialValue()
         {
-            return new SimpleDateFormat(dateStringPatterns[15]);
+            SimpleDateFormat sdf = new SimpleDateFormat(TO_JSON_FORMAT);
+            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+            return sdf;
         }
     };
     

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
index 2c471b0..824d436 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
@@ -618,8 +618,10 @@ public class JsonTest extends CQLTester
         assertRows(execute("SELECT k, toJson(timeval) FROM %s WHERE k = ?", 0), row(0, "\"00:00:00.000000123\""));
 
         // ================ timestamp ================
-        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, new SimpleDateFormat("y-M-d").parse("2014-01-01"));
-        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000\""));
+        SimpleDateFormat sdf = new SimpleDateFormat("y-M-d");
+        sdf.setTimeZone(TimeZone.getTimeZone("UDT"));
+        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, sdf.parse("2014-01-01"));
+        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000Z\""));
 
         // ================ timeuuid ================
         execute("INSERT INTO %s (k, timeuuidval) VALUES (?, ?)", 0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));


[5/6] cassandra git commit: Merge branch 'cassandra-3.0' into trunk

Posted by st...@apache.org.
Merge branch 'cassandra-3.0' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2bb1bfcb
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2bb1bfcb
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2bb1bfcb

Branch: refs/heads/trunk
Commit: 2bb1bfcb9525b2f43a9f1297861662e528b3e96f
Parents: 4254de1 3fc1067
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Thu Apr 28 09:15:26 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:16:51 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt | 2 +-
 NEWS.txt    | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2bb1bfcb/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 6466310,46206b1..f78ea90
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,64 -1,4 +1,63 @@@
 -3.0.6
 +3.6
 + * Always perform collision check before joining ring (CASSANDRA-10134)
 + * SSTableWriter output discrepancy (CASSANDRA-11646)
 + * Fix potential timeout in NativeTransportService.testConcurrentDestroys (CASSANDRA-10756)
 + * Support large partitions on the 3.0 sstable format (CASSANDRA-11206)
-  * JSON datetime formatting needs timezone (CASSANDRA-11137)
 + * Add support to rebuild from specific range (CASSANDRA-10406)
 + * Optimize the overlapping lookup by calculating all the
 +   bounds in advance (CASSANDRA-11571)
 + * Support json/yaml output in noetool tablestats (CASSANDRA-5977)
 + * (stress) Add datacenter option to -node options (CASSANDRA-11591)
 + * Fix handling of empty slices (CASSANDRA-11513)
 + * Make number of cores used by cqlsh COPY visible to testing code (CASSANDRA-11437)
 + * Allow filtering on clustering columns for queries without secondary indexes (CASSANDRA-11310)
 + * Refactor Restriction hierarchy (CASSANDRA-11354)
 + * Eliminate allocations in R/W path (CASSANDRA-11421)
 + * Update Netty to 4.0.36 (CASSANDRA-11567)
 + * Fix PER PARTITION LIMIT for queries requiring post-query ordering (CASSANDRA-11556)
 + * Allow instantiation of UDTs and tuples in UDFs (CASSANDRA-10818)
 + * Support UDT in CQLSSTableWriter (CASSANDRA-10624)
 + * Support for non-frozen user-defined types, updating
 +   individual fields of user-defined types (CASSANDRA-7423)
 + * Make LZ4 compression level configurable (CASSANDRA-11051)
 + * Allow per-partition LIMIT clause in CQL (CASSANDRA-7017)
 + * Make custom filtering more extensible with UserExpression (CASSANDRA-11295)
 + * Improve field-checking and error reporting in cassandra.yaml (CASSANDRA-10649)
 + * Print CAS stats in nodetool proxyhistograms (CASSANDRA-11507)
 + * More user friendly error when providing an invalid token to nodetool (CASSANDRA-9348)
 + * Add static column support to SASI index (CASSANDRA-11183)
 + * Support EQ/PREFIX queries in SASI CONTAINS mode without tokenization (CASSANDRA-11434)
 + * Support LIKE operator in prepared statements (CASSANDRA-11456)
 + * Add a command to see if a Materialized View has finished building (CASSANDRA-9967)
 + * Log endpoint and port associated with streaming operation (CASSANDRA-8777)
 + * Print sensible units for all log messages (CASSANDRA-9692)
 + * Upgrade Netty to version 4.0.34 (CASSANDRA-11096)
 + * Break the CQL grammar into separate Parser and Lexer (CASSANDRA-11372)
 + * Compress only inter-dc traffic by default (CASSANDRA-8888)
 + * Add metrics to track write amplification (CASSANDRA-11420)
 + * cassandra-stress: cannot handle "value-less" tables (CASSANDRA-7739)
 + * Add/drop multiple columns in one ALTER TABLE statement (CASSANDRA-10411)
 + * Add require_endpoint_verification opt for internode encryption (CASSANDRA-9220)
 + * Add auto import java.util for UDF code block (CASSANDRA-11392)
 + * Add --hex-format option to nodetool getsstables (CASSANDRA-11337)
 + * sstablemetadata should print sstable min/max token (CASSANDRA-7159)
 + * Do not wrap CassandraException in TriggerExecutor (CASSANDRA-9421)
 + * COPY TO should have higher double precision (CASSANDRA-11255)
 + * Stress should exit with non-zero status after failure (CASSANDRA-10340)
 + * Add client to cqlsh SHOW_SESSION (CASSANDRA-8958)
 + * Fix nodetool tablestats keyspace level metrics (CASSANDRA-11226)
 + * Store repair options in parent_repair_history (CASSANDRA-11244)
 + * Print current leveling in sstableofflinerelevel (CASSANDRA-9588)
 + * Change repair message for keyspaces with RF 1 (CASSANDRA-11203)
 + * Remove hard-coded SSL cipher suites and protocols (CASSANDRA-10508)
 + * Improve concurrency in CompactionStrategyManager (CASSANDRA-10099)
 + * (cqlsh) interpret CQL type for formatting blobs (CASSANDRA-11274)
 + * Refuse to start and print txn log information in case of disk
 +   corruption (CASSANDRA-10112)
 + * Resolve some eclipse-warnings (CASSANDRA-11086)
 + * (cqlsh) Show static columns in a different color (CASSANDRA-11059)
 + * Allow to remove TTLs on table with default_time_to_live (CASSANDRA-11207)
 +Merged from 3.0:
   * Don't require HEAP_NEW_SIZE to be set when using G1 (CASSANDRA-11600)
   * Fix sstabledump not showing cells after tombstone marker (CASSANDRA-11654)
   * Ignore all LocalStrategy keyspaces for streaming and other related

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2bb1bfcb/NEWS.txt
----------------------------------------------------------------------
diff --cc NEWS.txt
index 7f24d2c,3dcb387..77d3dfd
--- a/NEWS.txt
+++ b/NEWS.txt
@@@ -18,22 -18,18 +18,24 @@@ using the provided 'sstableupgrade' too
  
  New features
  ------------
 -    - JSON timestamps are now in UTC and contain the timezone information, see
 -      CASSANDRA-11137 for more details.
 -
 -3.0.5
 -=====
 -
 -Upgrading
 ----------
 -   - Nothing specific to this release, but please see previous versions upgrading section,
 -     especially if you are upgrading from 2.2.
 -
 -3.0.4
++   - JSON timestamps are now in UTC and contain the timezone information, see
++     CASSANDRA-11137 for more details.
 +   - Collision checks are performed when joining the token ring, regardless of whether
 +     the node should bootstrap. Additionally, replace_address can legitimately be used
 +     without bootstrapping to help with recovery of nodes with partially failed disks.
 +     See CASSANDRA-10134 for more details.
 +   - Key cache will only hold indexed entries up to the size configured by
 +     column_index_cache_size_in_kb in cassandra.yaml in memory. Larger indexed entries
 +     will never go into memory. See CASSANDRA-11206 for more details.
 +   - For tables having a default_time_to_live specifying a TTL of 0 will remove the TTL
 +     from the inserted or updated values.
 +   - Startup is now aborted if corrupted transaction log files are found. The details
 +     of the affected log files are now logged, allowing the operator to decide how
 +     to resolve the situation.
 +   - Filtering expressions are made more pluggable and can be added programatically via
 +     a QueryHandler implementation. See CASSANDRA-11295 for more details.
 +
 +3.4
  =====
  
  New features


[4/6] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by st...@apache.org.
Merge branch 'cassandra-2.2' into cassandra-3.0


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3fc10676
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3fc10676
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3fc10676

Branch: refs/heads/trunk
Commit: 3fc106761ca2618f4a1af518ca7b51f182790976
Parents: 7a2be8f 88f22b9
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Thu Apr 28 09:12:56 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:13:41 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                                 | 1 +
 NEWS.txt                                                    | 8 ++++++++
 .../apache/cassandra/serializers/TimestampSerializer.java   | 9 ++++++---
 .../apache/cassandra/cql3/validation/entities/JsonTest.java | 6 ++++--
 4 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3fc10676/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 8877fa9,91179b3..46206b1
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,18 -1,5 +1,19 @@@
 -2.2.7
 +3.0.6
 + * Don't require HEAP_NEW_SIZE to be set when using G1 (CASSANDRA-11600)
 + * Fix sstabledump not showing cells after tombstone marker (CASSANDRA-11654)
 + * Ignore all LocalStrategy keyspaces for streaming and other related
 +   operations (CASSANDRA-11627)
 + * Ensure columnfilter covers indexed columns for thrift 2i queries (CASSANDRA-11523)
 + * Only open one sstable scanner per sstable (CASSANDRA-11412)
 + * Option to specify ProtocolVersion in cassandra-stress (CASSANDRA-11410)
 + * ArithmeticException in avgFunctionForDecimal (CASSANDRA-11485)
 + * LogAwareFileLister should only use OLD sstable files in current folder to determine disk consistency (CASSANDRA-11470)
 + * Notify indexers of expired rows during compaction (CASSANDRA-11329)
 + * Properly respond with ProtocolError when a v1/v2 native protocol
 +   header is received (CASSANDRA-11464)
 + * Validate that num_tokens and initial_token are consistent with one another (CASSANDRA-10120)
 +Merged from 2.2:
+  * JSON datetime formatting needs timezone (CASSANDRA-11137)
   * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
   * Remove unnescessary file existence check during anticompaction (CASSANDRA-11660)
   * Add missing files to debian packages (CASSANDRA-11642)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3fc10676/NEWS.txt
----------------------------------------------------------------------
diff --cc NEWS.txt
index 1b982cb,a3ba0dd..3dcb387
--- a/NEWS.txt
+++ b/NEWS.txt
@@@ -13,7 -13,15 +13,15 @@@ restore snapshots created with the prev
  'sstableloader' tool. You can upgrade the file format of your snapshots
  using the provided 'sstableupgrade' tool.
  
 -2.2.7
++3.0.6
+ =====
+ 
+ New features
+ ------------
+     - JSON timestamps are now in UTC and contain the timezone information, see
+       CASSANDRA-11137 for more details.
+ 
 -2.2.6
 +3.0.5
  =====
  
  Upgrading

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3fc10676/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index fbd98d1,77a5df9..9bd9a8d
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@@ -97,26 -96,16 +97,29 @@@ public class TimestampSerializer implem
          }
      };
  
 +    private static final String UTC_FORMAT = dateStringPatterns[40];
 +    private static final ThreadLocal<SimpleDateFormat> FORMATTER_UTC = new ThreadLocal<SimpleDateFormat>()
 +    {
 +        protected SimpleDateFormat initialValue()
 +        {
 +            SimpleDateFormat sdf = new SimpleDateFormat(UTC_FORMAT);
 +            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
 +            return sdf;
 +        }
 +    };
 +    
+     private static final String TO_JSON_FORMAT = dateStringPatterns[19];
      private static final ThreadLocal<SimpleDateFormat> FORMATTER_TO_JSON = new ThreadLocal<SimpleDateFormat>()
      {
          protected SimpleDateFormat initialValue()
          {
-             return new SimpleDateFormat(dateStringPatterns[15]);
+             SimpleDateFormat sdf = new SimpleDateFormat(TO_JSON_FORMAT);
+             sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+             return sdf;
          }
      };
 +
 +
      
      public static final TimestampSerializer instance = new TimestampSerializer();
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3fc10676/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------


[2/6] cassandra git commit: JSON datetime formatting needs timezone (backported from trunk)

Posted by st...@apache.org.
JSON datetime formatting needs timezone (backported from trunk)

patch by Alex Petrov; reviewed by Stefania Alborghetti for CASSANDRA-11137


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/88f22b96
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/88f22b96
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/88f22b96

Branch: refs/heads/cassandra-3.0
Commit: 88f22b9692c6fdddf837556f13140d949afe0d28
Parents: e5c4027
Author: Alex Petrov <ol...@gmail.com>
Authored: Thu Apr 28 08:59:24 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:10:18 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 NEWS.txt                                                 |  8 ++++++++
 .../cassandra/serializers/TimestampSerializer.java       | 11 +++++++----
 .../cassandra/cql3/validation/entities/JsonTest.java     |  6 ++++--
 4 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3641816..91179b3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * JSON datetime formatting needs timezone (CASSANDRA-11137)
  * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
  * Remove unnescessary file existence check during anticompaction (CASSANDRA-11660)
  * Add missing files to debian packages (CASSANDRA-11642)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index e8f4e66..a3ba0dd 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,14 @@ restore snapshots created with the previous major version using the
 'sstableloader' tool. You can upgrade the file format of your snapshots
 using the provided 'sstableupgrade' tool.
 
+2.2.7
+=====
+
+New features
+------------
+    - JSON timestamps are now in UTC and contain the timezone information, see
+      CASSANDRA-11137 for more details.
+
 2.2.6
 =====
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index 78ee7e7..77a5df9 100644
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@ -22,7 +22,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import java.nio.ByteBuffer;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
-import java.util.Date;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.time.DateUtils;
@@ -48,11 +48,11 @@ public class TimestampSerializer implements TypeSerializer<Date>
             "yyyy-MM-dd HH:mm:ssX",
             "yyyy-MM-dd HH:mm:ssXX",
             "yyyy-MM-dd HH:mm:ssXXX",
-            "yyyy-MM-dd HH:mm:ss.SSS",   // TO_JSON_FORMAT
+            "yyyy-MM-dd HH:mm:ss.SSS",
             "yyyy-MM-dd HH:mm:ss.SSS z",
             "yyyy-MM-dd HH:mm:ss.SSS zz",
             "yyyy-MM-dd HH:mm:ss.SSS zzz",
-            "yyyy-MM-dd HH:mm:ss.SSSX",
+            "yyyy-MM-dd HH:mm:ss.SSSX", // TO_JSON_FORMAT
             "yyyy-MM-dd HH:mm:ss.SSSXX",
             "yyyy-MM-dd HH:mm:ss.SSSXXX",
             "yyyy-MM-dd'T'HH:mm",
@@ -96,11 +96,14 @@ public class TimestampSerializer implements TypeSerializer<Date>
         }
     };
 
+    private static final String TO_JSON_FORMAT = dateStringPatterns[19];
     private static final ThreadLocal<SimpleDateFormat> FORMATTER_TO_JSON = new ThreadLocal<SimpleDateFormat>()
     {
         protected SimpleDateFormat initialValue()
         {
-            return new SimpleDateFormat(dateStringPatterns[15]);
+            SimpleDateFormat sdf = new SimpleDateFormat(TO_JSON_FORMAT);
+            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+            return sdf;
         }
     };
     

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
index 2c471b0..824d436 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
@@ -618,8 +618,10 @@ public class JsonTest extends CQLTester
         assertRows(execute("SELECT k, toJson(timeval) FROM %s WHERE k = ?", 0), row(0, "\"00:00:00.000000123\""));
 
         // ================ timestamp ================
-        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, new SimpleDateFormat("y-M-d").parse("2014-01-01"));
-        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000\""));
+        SimpleDateFormat sdf = new SimpleDateFormat("y-M-d");
+        sdf.setTimeZone(TimeZone.getTimeZone("UDT"));
+        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, sdf.parse("2014-01-01"));
+        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000Z\""));
 
         // ================ timeuuid ================
         execute("INSERT INTO %s (k, timeuuidval) VALUES (?, ?)", 0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));


[6/6] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by st...@apache.org.
Merge branch 'cassandra-2.2' into cassandra-3.0


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b360653f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b360653f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b360653f

Branch: refs/heads/cassandra-3.0
Commit: b360653fcfe07a7af66107ef9e55fdc9e33c1d0a
Parents: 7a2be8f 88f22b9
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Thu Apr 28 09:12:56 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:18:07 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                                 | 1 +
 NEWS.txt                                                    | 8 ++++++++
 .../apache/cassandra/serializers/TimestampSerializer.java   | 9 ++++++---
 .../apache/cassandra/cql3/validation/entities/JsonTest.java | 6 ++++--
 4 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b360653f/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 8877fa9,91179b3..46206b1
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,18 -1,5 +1,19 @@@
 -2.2.7
 +3.0.6
 + * Don't require HEAP_NEW_SIZE to be set when using G1 (CASSANDRA-11600)
 + * Fix sstabledump not showing cells after tombstone marker (CASSANDRA-11654)
 + * Ignore all LocalStrategy keyspaces for streaming and other related
 +   operations (CASSANDRA-11627)
 + * Ensure columnfilter covers indexed columns for thrift 2i queries (CASSANDRA-11523)
 + * Only open one sstable scanner per sstable (CASSANDRA-11412)
 + * Option to specify ProtocolVersion in cassandra-stress (CASSANDRA-11410)
 + * ArithmeticException in avgFunctionForDecimal (CASSANDRA-11485)
 + * LogAwareFileLister should only use OLD sstable files in current folder to determine disk consistency (CASSANDRA-11470)
 + * Notify indexers of expired rows during compaction (CASSANDRA-11329)
 + * Properly respond with ProtocolError when a v1/v2 native protocol
 +   header is received (CASSANDRA-11464)
 + * Validate that num_tokens and initial_token are consistent with one another (CASSANDRA-10120)
 +Merged from 2.2:
+  * JSON datetime formatting needs timezone (CASSANDRA-11137)
   * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
   * Remove unnescessary file existence check during anticompaction (CASSANDRA-11660)
   * Add missing files to debian packages (CASSANDRA-11642)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b360653f/NEWS.txt
----------------------------------------------------------------------
diff --cc NEWS.txt
index 1b982cb,a3ba0dd..d13f94f
--- a/NEWS.txt
+++ b/NEWS.txt
@@@ -13,7 -13,15 +13,15 @@@ restore snapshots created with the prev
  'sstableloader' tool. You can upgrade the file format of your snapshots
  using the provided 'sstableupgrade' tool.
  
 -2.2.7
++3.0.6
+ =====
+ 
+ New features
+ ------------
 -    - JSON timestamps are now in UTC and contain the timezone information, see
 -      CASSANDRA-11137 for more details.
++   - JSON timestamps are now in UTC and contain the timezone information, see
++     CASSANDRA-11137 for more details.
+ 
 -2.2.6
 +3.0.5
  =====
  
  Upgrading

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b360653f/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index fbd98d1,77a5df9..9bd9a8d
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@@ -97,26 -96,16 +97,29 @@@ public class TimestampSerializer implem
          }
      };
  
 +    private static final String UTC_FORMAT = dateStringPatterns[40];
 +    private static final ThreadLocal<SimpleDateFormat> FORMATTER_UTC = new ThreadLocal<SimpleDateFormat>()
 +    {
 +        protected SimpleDateFormat initialValue()
 +        {
 +            SimpleDateFormat sdf = new SimpleDateFormat(UTC_FORMAT);
 +            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
 +            return sdf;
 +        }
 +    };
 +    
+     private static final String TO_JSON_FORMAT = dateStringPatterns[19];
      private static final ThreadLocal<SimpleDateFormat> FORMATTER_TO_JSON = new ThreadLocal<SimpleDateFormat>()
      {
          protected SimpleDateFormat initialValue()
          {
-             return new SimpleDateFormat(dateStringPatterns[15]);
+             SimpleDateFormat sdf = new SimpleDateFormat(TO_JSON_FORMAT);
+             sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+             return sdf;
          }
      };
 +
 +
      
      public static final TimestampSerializer instance = new TimestampSerializer();
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b360653f/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------


[3/6] cassandra git commit: JSON datetime formatting needs timezone (backported from trunk)

Posted by st...@apache.org.
JSON datetime formatting needs timezone (backported from trunk)

patch by Alex Petrov; reviewed by Stefania Alborghetti for CASSANDRA-11137


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/88f22b96
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/88f22b96
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/88f22b96

Branch: refs/heads/trunk
Commit: 88f22b9692c6fdddf837556f13140d949afe0d28
Parents: e5c4027
Author: Alex Petrov <ol...@gmail.com>
Authored: Thu Apr 28 08:59:24 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Thu Apr 28 09:10:18 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 NEWS.txt                                                 |  8 ++++++++
 .../cassandra/serializers/TimestampSerializer.java       | 11 +++++++----
 .../cassandra/cql3/validation/entities/JsonTest.java     |  6 ++++--
 4 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3641816..91179b3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * JSON datetime formatting needs timezone (CASSANDRA-11137)
  * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
  * Remove unnescessary file existence check during anticompaction (CASSANDRA-11660)
  * Add missing files to debian packages (CASSANDRA-11642)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index e8f4e66..a3ba0dd 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,14 @@ restore snapshots created with the previous major version using the
 'sstableloader' tool. You can upgrade the file format of your snapshots
 using the provided 'sstableupgrade' tool.
 
+2.2.7
+=====
+
+New features
+------------
+    - JSON timestamps are now in UTC and contain the timezone information, see
+      CASSANDRA-11137 for more details.
+
 2.2.6
 =====
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
index 78ee7e7..77a5df9 100644
--- a/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
+++ b/src/java/org/apache/cassandra/serializers/TimestampSerializer.java
@@ -22,7 +22,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import java.nio.ByteBuffer;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
-import java.util.Date;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.time.DateUtils;
@@ -48,11 +48,11 @@ public class TimestampSerializer implements TypeSerializer<Date>
             "yyyy-MM-dd HH:mm:ssX",
             "yyyy-MM-dd HH:mm:ssXX",
             "yyyy-MM-dd HH:mm:ssXXX",
-            "yyyy-MM-dd HH:mm:ss.SSS",   // TO_JSON_FORMAT
+            "yyyy-MM-dd HH:mm:ss.SSS",
             "yyyy-MM-dd HH:mm:ss.SSS z",
             "yyyy-MM-dd HH:mm:ss.SSS zz",
             "yyyy-MM-dd HH:mm:ss.SSS zzz",
-            "yyyy-MM-dd HH:mm:ss.SSSX",
+            "yyyy-MM-dd HH:mm:ss.SSSX", // TO_JSON_FORMAT
             "yyyy-MM-dd HH:mm:ss.SSSXX",
             "yyyy-MM-dd HH:mm:ss.SSSXXX",
             "yyyy-MM-dd'T'HH:mm",
@@ -96,11 +96,14 @@ public class TimestampSerializer implements TypeSerializer<Date>
         }
     };
 
+    private static final String TO_JSON_FORMAT = dateStringPatterns[19];
     private static final ThreadLocal<SimpleDateFormat> FORMATTER_TO_JSON = new ThreadLocal<SimpleDateFormat>()
     {
         protected SimpleDateFormat initialValue()
         {
-            return new SimpleDateFormat(dateStringPatterns[15]);
+            SimpleDateFormat sdf = new SimpleDateFormat(TO_JSON_FORMAT);
+            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+            return sdf;
         }
     };
     

http://git-wip-us.apache.org/repos/asf/cassandra/blob/88f22b96/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
index 2c471b0..824d436 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
@@ -618,8 +618,10 @@ public class JsonTest extends CQLTester
         assertRows(execute("SELECT k, toJson(timeval) FROM %s WHERE k = ?", 0), row(0, "\"00:00:00.000000123\""));
 
         // ================ timestamp ================
-        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, new SimpleDateFormat("y-M-d").parse("2014-01-01"));
-        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000\""));
+        SimpleDateFormat sdf = new SimpleDateFormat("y-M-d");
+        sdf.setTimeZone(TimeZone.getTimeZone("UDT"));
+        execute("INSERT INTO %s (k, timestampval) VALUES (?, ?)", 0, sdf.parse("2014-01-01"));
+        assertRows(execute("SELECT k, toJson(timestampval) FROM %s WHERE k = ?", 0), row(0, "\"2014-01-01 00:00:00.000Z\""));
 
         // ================ timeuuid ================
         execute("INSERT INTO %s (k, timeuuidval) VALUES (?, ?)", 0, UUID.fromString("6bddc89a-5644-11e4-97fc-56847afe9799"));