You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2014/07/25 20:15:53 UTC

git commit: Use "keyspace updated" message for UDT changes in v1/2 protocols

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1.0 5544ecbf6 -> 908228192


Use "keyspace updated" message for UDT changes in v1/2 protocols

Patch by Tyler Hobbs; review by Aleksey Yeschenko for CASSANDRA-7617


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

Branch: refs/heads/cassandra-2.1.0
Commit: 90822819290d9df8143d08e3869141beffd15695
Parents: 5544ecb
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Fri Jul 25 13:14:27 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Fri Jul 25 13:15:40 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 doc/native_protocol_v1.spec                     |  9 ++++++--
 doc/native_protocol_v2.spec                     |  9 ++++++--
 .../org/apache/cassandra/transport/Event.java   | 23 +++++++++++++++++---
 4 files changed, 36 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/90822819/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e940931..1278c56 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,8 @@
    dropping non-existent index with IF EXISTS (CASSANDRA-7590)
  * Fix sstablelevelresetter hang (CASSANDRA-7614)
  * (cqlsh) Fix deserialization of blobs (CASSANDRA-7603)
+ * Use "keyspace updated" schema change message for UDT changes in v1 and
+   v2 protocols (CASSANDRA-7617)
 Merged from 2.0:
  * Fix ReversedType(DateType) mapping to native protocol (CASSANDRA-7576)
  * Always merge ranges owned by a single node (CASSANDRA-6930)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/90822819/doc/native_protocol_v1.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v1.spec b/doc/native_protocol_v1.spec
index 08cb91e..83154fc 100644
--- a/doc/native_protocol_v1.spec
+++ b/doc/native_protocol_v1.spec
@@ -472,8 +472,10 @@ Table of Contents
       the empty string "") if the change was affecting a keyspace and not a
       table.
 
-  Note that queries to create and drop an index are considered as change
-  updating the table the index is on.
+  Note that queries to create and drop an index are considered changes
+  updating the table the index is on.  Queries that create, alter, or drop
+  user-defined types (availble in Cassandra 2.1+) are considered changes
+  updating the keyspace the type is defined in.
 
 
 4.2.6. EVENT
@@ -499,6 +501,9 @@ Table of Contents
       followed by the name of the affected keyspace and the name of the
       affected table within that keyspace. For changes that affect a keyspace
       directly, the table name will be empty (i.e. the empty string "").
+      Changes to user-defined types (available in Cassandra 2.1+) will result
+      in an "UPDATED" change for the keyspace containing the type, and the
+      table name will be empty.
 
   All EVENT message have a streamId of -1 (Section 2.3).
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/90822819/doc/native_protocol_v2.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v2.spec b/doc/native_protocol_v2.spec
index 11d380f..0f0cbcb 100644
--- a/doc/native_protocol_v2.spec
+++ b/doc/native_protocol_v2.spec
@@ -590,8 +590,10 @@ Table of Contents
       the empty string "") if the change was affecting a keyspace and not a
       table.
 
-  Note that queries to create and drop an index are considered as change
-  updating the table the index is on.
+  Note that queries to create and drop an index are considered changes
+  updating the table the index is on.  Queries that create, alter, or drop
+  user-defined types (availble in Cassandra 2.1+) are considered changes
+  updating the keyspace the type is defined in.
 
 
 4.2.6. EVENT
@@ -617,6 +619,9 @@ Table of Contents
       followed by the name of the affected keyspace and the name of the
       affected table within that keyspace. For changes that affect a keyspace
       directly, the table name will be empty (i.e. the empty string "").
+      Changes to user-defined types (available in Cassandra 2.1+) will result
+      in an "UPDATED" change for the keyspace containing the type, and the
+      table name will be empty.
 
   All EVENT message have a streamId of -1 (Section 2.3).
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/90822819/src/java/org/apache/cassandra/transport/Event.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Event.java b/src/java/org/apache/cassandra/transport/Event.java
index 1b7e487..b7c5e68 100644
--- a/src/java/org/apache/cassandra/transport/Event.java
+++ b/src/java/org/apache/cassandra/transport/Event.java
@@ -258,9 +258,20 @@ public abstract class Event
             }
             else
             {
-                CBUtil.writeEnumValue(change, dest);
-                CBUtil.writeString(keyspace, dest);
-                CBUtil.writeString(target == Target.KEYSPACE ? "" : tableOrType, dest);
+                if (target == Target.TYPE)
+                {
+                    // For the v1/v2 protocol, we have no way to represent type changes, so we simply say the keyspace
+                    // was updated.  See CASSANDRA-7617.
+                    CBUtil.writeEnumValue(Change.UPDATED, dest);
+                    CBUtil.writeString(keyspace, dest);
+                    CBUtil.writeString("", dest);
+                }
+                else
+                {
+                    CBUtil.writeEnumValue(change, dest);
+                    CBUtil.writeString(keyspace, dest);
+                    CBUtil.writeString(target == Target.KEYSPACE ? "" : tableOrType, dest);
+                }
             }
         }
 
@@ -279,6 +290,12 @@ public abstract class Event
             }
             else
             {
+                if (target == Target.TYPE)
+                {
+                    return CBUtil.sizeOfEnumValue(Change.UPDATED)
+                         + CBUtil.sizeOfString(keyspace)
+                         + CBUtil.sizeOfString("");
+                }
                 return CBUtil.sizeOfEnumValue(change)
                      + CBUtil.sizeOfString(keyspace)
                      + CBUtil.sizeOfString(target == Target.KEYSPACE ? "" : tableOrType);