Updated Branches:
  refs/heads/trunk 4e53d1e75 -> 231b345ff

implementing CL.LOCAL_ONE


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

Branch: refs/heads/trunk
Commit: 4a0f26c1315ef3a9c1fd7cac5d43bbdb91f36131
Parents: e655d62
Author: Jason Brown <jasedbr...@gmail.com>
Authored: Tue Oct 15 11:34:01 2013 -0700
Committer: Jason Brown <jasedbr...@gmail.com>
Committed: Wed Oct 16 13:38:27 2013 -0700

----------------------------------------------------------------------
 bin/cqlsh                                       |  3 ++-
 doc/cql3/CQL.textile                            |  1 +
 doc/native_protocol.spec                        |  1 +
 interface/cassandra.thrift                      |  5 +++-
 .../thrift/AuthenticationException.java         | 23 +++++++++++-----
 .../cassandra/thrift/AuthenticationRequest.java | 28 +++++++++++++-------
 .../thrift/AuthorizationException.java          | 23 +++++++++++-----
 .../cassandra/thrift/ConsistencyLevel.java      |  7 ++++-
 .../org/apache/cassandra/thrift/Constants.java  |  2 +-
 .../apache/cassandra/thrift/IndexClause.java    |  2 +-
 .../org/apache/cassandra/thrift/KsDef.java      |  8 +++---
 .../apache/cassandra/db/ConsistencyLevel.java   | 28 ++++++++++++++++----
 .../locator/AbstractReplicationStrategy.java    |  2 +-
 .../service/DatacenterWriteResponseHandler.java |  2 +-
 .../apache/cassandra/service/ReadCallback.java  |  2 +-
 .../cassandra/thrift/ThriftConversion.java      |  2 ++
 16 files changed, 99 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index b50bcf2..64e9b6f 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -248,6 +248,7 @@ cqlsh_extra_syntax_rules = r'''
                      | "THREE"
                      | "QUORUM"
                      | "ALL"
+                     | "LOCAL_ONE"
                      | "LOCAL_QUORUM"
                      | "EACH_QUORUM"
                      ;
@@ -2095,7 +2096,7 @@ class Shell(cmd.Cmd):
 
            Valid consistency levels:
 
-           ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM and EACH_QUORUM.
+           ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_ONE, LOCAL_QUORUM and 
EACH_QUORUM.
 
         CONSISTENCY
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/doc/cql3/CQL.textile
----------------------------------------------------------------------
diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile
index e0cea80..c4e39d1 100644
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@ -1011,6 +1011,7 @@ CQL distinguishes between _reserved_ and _non-reserved_ 
keywords. Reserved keywo
 | @KEYSPACE@     | yes |
 | @LEVEL@        | no  |
 | @LIMIT@        | yes |
+| @LOCAL_ONE@    | yes |
 | @LOCAL_QUORUM@ | yes |
 | @MODIFY@       | yes |
 | @NORECURSIVE@  | yes |

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/doc/native_protocol.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol.spec b/doc/native_protocol.spec
index b7a1de5..4b4e591 100644
--- a/doc/native_protocol.spec
+++ b/doc/native_protocol.spec
@@ -201,6 +201,7 @@ Table of Contents
                      0x0005    ALL
                      0x0006    LOCAL_QUORUM
                      0x0007    EACH_QUORUM
+                     0x0008    LOCAL_ONE
 
     [string map]      A [short] n, followed by n pair <k><v> where <k> and <v>
                       are [string].

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/cassandra.thrift
----------------------------------------------------------------------
diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift
index 1649229..d17428e 100644
--- a/interface/cassandra.thrift
+++ b/interface/cassandra.thrift
@@ -55,7 +55,7 @@ namespace rb CassandraThrift
 # An effort should be made not to break forward-client-compatibility either
 # (e.g. one should avoid removing obsolete fields from the IDL), but no
 # guarantees in this respect are made by the Cassandra project.
-const string VERSION = "19.36.0"
+const string VERSION = "19.37.0"
 
 
 #
@@ -205,6 +205,7 @@ exception SchemaDisagreementException {
  *   TWO          Ensure that the write has been written to at least 2 node's 
commit log and memory table
  *   THREE        Ensure that the write has been written to at least 3 node's 
commit log and memory table
  *   QUORUM       Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes
+ *   LOCAL_ONE    Ensure that the write has been written to 1 node within the 
local datacenter (requires NetworkTopologyStrategy)
  *   LOCAL_QUORUM Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes, within the local datacenter (requires 
NetworkTopologyStrategy)
  *   EACH_QUORUM  Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes in each datacenter (requires 
NetworkTopologyStrategy)
  *   ALL          Ensure that the write is written to 
<code>&lt;ReplicationFactor&gt;</code> nodes before responding to the client.
@@ -215,6 +216,7 @@ exception SchemaDisagreementException {
  *   TWO          Returns the record with the most recent timestamp once two 
replicas have replied.
  *   THREE        Returns the record with the most recent timestamp once three 
replicas have replied.
  *   QUORUM       Returns the record with the most recent timestamp once a 
majority of replicas have replied.
+ *   LOCAL_ONE    Returns the record with the most recent timestamp once a 
single replica within the local datacenter have replied.
  *   LOCAL_QUORUM Returns the record with the most recent timestamp once a 
majority of replicas within the local datacenter have replied.
  *   EACH_QUORUM  Returns the record with the most recent timestamp once a 
majority of replicas within each datacenter have replied.
  *   ALL          Returns the record with the most recent timestamp once all 
replicas have replied (implies no replica may be down)..
@@ -228,6 +230,7 @@ enum ConsistencyLevel {
     ANY = 6,
     TWO = 7,
     THREE = 8,
+    LOCAL_ONE = 9,
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java
 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java
index 4bea125..5d88cd9 100644
--- 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java
+++ 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationException.java
@@ -5,7 +5,7 @@
  */
 package org.apache.cassandra.thrift;
 /*
- *
+ * 
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -13,25 +13,34 @@ package org.apache.cassandra.thrift;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
+ * 
  *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
+ * 
  */
 
 
 import org.apache.commons.lang.builder.HashCodeBuilder;
+import java.util.List;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
 import java.util.EnumSet;
 import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * invalid authentication request (invalid keyspace, user does not exist, or 
credentials invalid)
@@ -106,7 +115,7 @@ public class AuthenticationException extends Exception 
implements org.apache.thr
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> 
metaDataMap;
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new 
EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.WHY, new 
org.apache.thrift.meta_data.FieldMetaData("why", 
org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.WHY, new 
org.apache.thrift.meta_data.FieldMetaData("why", 
org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthenticationException.class,
 metaDataMap);
@@ -267,14 +276,14 @@ public class AuthenticationException extends Exception 
implements org.apache.thr
     while (true)
     {
       field = iprot.readFieldBegin();
-      if (field.type == org.apache.thrift.protocol.TType.STOP) {
+      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
         break;
       }
       switch (field.id) {
         case 1: // WHY
           if (field.type == org.apache.thrift.protocol.TType.STRING) {
             this.why = iprot.readString();
-          } else {
+          } else { 
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
           }
           break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java
 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java
index 42cce37..0f68426 100644
--- 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java
+++ 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthenticationRequest.java
@@ -5,7 +5,7 @@
  */
 package org.apache.cassandra.thrift;
 /*
- *
+ * 
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -13,24 +13,34 @@ package org.apache.cassandra.thrift;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
+ * 
  *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
+ * 
  */
 
+
 import org.apache.commons.lang.builder.HashCodeBuilder;
+import java.util.List;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
 import java.util.EnumSet;
 import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Authentication requests can contain any data, dependent on the 
IAuthenticator used
@@ -105,9 +115,9 @@ public class AuthenticationRequest implements 
org.apache.thrift.TBase<Authentica
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> 
metaDataMap;
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new 
EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.CREDENTIALS, new 
org.apache.thrift.meta_data.FieldMetaData("credentials", 
org.apache.thrift.TFieldRequirementType.REQUIRED,
-        new 
org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
-            new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+    tmpMap.put(_Fields.CREDENTIALS, new 
org.apache.thrift.meta_data.FieldMetaData("credentials", 
org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new 
org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
+            new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
 
             new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthenticationRequest.class,
 metaDataMap);
@@ -291,7 +301,7 @@ public class AuthenticationRequest implements 
org.apache.thrift.TBase<Authentica
     while (true)
     {
       field = iprot.readFieldBegin();
-      if (field.type == org.apache.thrift.protocol.TType.STOP) {
+      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
         break;
       }
       switch (field.id) {
@@ -310,7 +320,7 @@ public class AuthenticationRequest implements 
org.apache.thrift.TBase<Authentica
               }
               iprot.readMapEnd();
             }
-          } else {
+          } else { 
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
           }
           break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java
 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java
index c3dd23b..76bc061 100644
--- 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java
+++ 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/AuthorizationException.java
@@ -5,7 +5,7 @@
  */
 package org.apache.cassandra.thrift;
 /*
- *
+ * 
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -13,25 +13,34 @@ package org.apache.cassandra.thrift;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
+ * 
  *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
+ * 
  */
 
 
 import org.apache.commons.lang.builder.HashCodeBuilder;
+import java.util.List;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
 import java.util.EnumSet;
 import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * invalid authorization request (user does not have access to keyspace)
@@ -106,7 +115,7 @@ public class AuthorizationException extends Exception 
implements org.apache.thri
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> 
metaDataMap;
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new 
EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.WHY, new 
org.apache.thrift.meta_data.FieldMetaData("why", 
org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.WHY, new 
org.apache.thrift.meta_data.FieldMetaData("why", 
org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new 
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthorizationException.class,
 metaDataMap);
@@ -267,14 +276,14 @@ public class AuthorizationException extends Exception 
implements org.apache.thri
     while (true)
     {
       field = iprot.readFieldBegin();
-      if (field.type == org.apache.thrift.protocol.TType.STOP) {
+      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
         break;
       }
       switch (field.id) {
         case 1: // WHY
           if (field.type == org.apache.thrift.protocol.TType.STRING) {
             this.why = iprot.readString();
-          } else {
+          } else { 
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
           }
           break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
index 2f4cf50..eb15e83 100644
--- 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
+++ 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
@@ -59,6 +59,7 @@ import org.apache.thrift.TEnum;
  *   TWO          Ensure that the write has been written to at least 2 node's 
commit log and memory table
  *   THREE        Ensure that the write has been written to at least 3 node's 
commit log and memory table
  *   QUORUM       Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes
+ *   LOCAL_ONE    Ensure that the write has been written to 1 node within the 
local datacenter (requires NetworkTopologyStrategy)
  *   LOCAL_QUORUM Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes, within the local datacenter (requires 
NetworkTopologyStrategy)
  *   EACH_QUORUM  Ensure that the write has been written to 
<ReplicationFactor> / 2 + 1 nodes in each datacenter (requires 
NetworkTopologyStrategy)
  *   ALL          Ensure that the write is written to 
<code>&lt;ReplicationFactor&gt;</code> nodes before responding to the client.
@@ -69,6 +70,7 @@ import org.apache.thrift.TEnum;
  *   TWO          Returns the record with the most recent timestamp once two 
replicas have replied.
  *   THREE        Returns the record with the most recent timestamp once three 
replicas have replied.
  *   QUORUM       Returns the record with the most recent timestamp once a 
majority of replicas have replied.
+ *   LOCAL_ONE    Returns the record with the most recent timestamp once a 
single replica within the local datacenter have replied.
  *   LOCAL_QUORUM Returns the record with the most recent timestamp once a 
majority of replicas within the local datacenter have replied.
  *   EACH_QUORUM  Returns the record with the most recent timestamp once a 
majority of replicas within each datacenter have replied.
  *   ALL          Returns the record with the most recent timestamp once all 
replicas have replied (implies no replica may be down)..
@@ -81,7 +83,8 @@ public enum ConsistencyLevel implements 
org.apache.thrift.TEnum {
   ALL(5),
   ANY(6),
   TWO(7),
-  THREE(8);
+  THREE(8),
+  LOCAL_ONE(9);
 
   private final int value;
 
@@ -118,6 +121,8 @@ public enum ConsistencyLevel implements 
org.apache.thrift.TEnum {
         return TWO;
       case 8:
         return THREE;
+      case 9:
+        return LOCAL_ONE;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
index d8ab801..c4a17a9 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
@@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory;
 
 public class Constants {
 
-  public static final String VERSION = "19.36.0";
+  public static final String VERSION = "19.37.0";
 
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/IndexClause.java
----------------------------------------------------------------------
diff --git 
a/interface/thrift/gen-java/org/apache/cassandra/thrift/IndexClause.java 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/IndexClause.java
index 1fcebf0..76c2606 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/IndexClause.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/IndexClause.java
@@ -43,7 +43,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @Deprecated: use a KeyRange with row_filter in get_range_slices instead
+ * @deprecated use a KeyRange with row_filter in get_range_slices instead
  */
 public class IndexClause implements org.apache.thrift.TBase<IndexClause, 
IndexClause._Fields>, java.io.Serializable, Cloneable {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new 
org.apache.thrift.protocol.TStruct("IndexClause");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
----------------------------------------------------------------------
diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java 
b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
index 8623cec..1004a6d 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java
@@ -56,7 +56,7 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, 
KsDef._Fields>, jav
   public String strategy_class; // required
   public Map<String,String> strategy_options; // required
   /**
-   * @deprecated, ignored
+   * @deprecated ignored
    */
   public int replication_factor; // required
   public List<CfDef> cf_defs; // required
@@ -68,7 +68,7 @@ public class KsDef implements org.apache.thrift.TBase<KsDef, 
KsDef._Fields>, jav
     STRATEGY_CLASS((short)2, "strategy_class"),
     STRATEGY_OPTIONS((short)3, "strategy_options"),
     /**
-     * @deprecated, ignored
+     * @deprecated ignored
      */
     REPLICATION_FACTOR((short)4, "replication_factor"),
     CF_DEFS((short)5, "cf_defs"),
@@ -319,14 +319,14 @@ public class KsDef implements 
org.apache.thrift.TBase<KsDef, KsDef._Fields>, jav
   }
 
   /**
-   * @deprecated, ignored
+   * @deprecated ignored
    */
   public int getReplication_factor() {
     return this.replication_factor;
   }
 
   /**
-   * @deprecated, ignored
+   * @deprecated ignored
    */
   public KsDef setReplication_factor(int replication_factor) {
     this.replication_factor = replication_factor;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/src/java/org/apache/cassandra/db/ConsistencyLevel.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ConsistencyLevel.java 
b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
index 56a7896..1ce019b 100644
--- a/src/java/org/apache/cassandra/db/ConsistencyLevel.java
+++ b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
@@ -46,13 +46,15 @@ public enum ConsistencyLevel
     THREE       (3),
     QUORUM      (4),
     ALL         (5),
-    LOCAL_QUORUM(6),
-    EACH_QUORUM (7);
+    LOCAL_QUORUM(6, true),
+    EACH_QUORUM (7),
+    LOCAL_ONE   (8, true);
 
     private static final Logger logger = 
LoggerFactory.getLogger(ConsistencyLevel.class);
 
     // Used by the binary protocol
     public final int code;
+    private final boolean isDCLocal;
     private static final ConsistencyLevel[] codeIdx;
     static
     {
@@ -70,7 +72,13 @@ public enum ConsistencyLevel
 
     private ConsistencyLevel(int code)
     {
+        this(code, false);
+    }
+
+    private ConsistencyLevel(int code, boolean isDCLocal)
+    {
         this.code = code;
+        this.isDCLocal = isDCLocal;
     }
 
     public static ConsistencyLevel fromCode(int code)
@@ -90,6 +98,7 @@ public enum ConsistencyLevel
         switch (this)
         {
             case ONE:
+            case LOCAL_ONE:
                 return 1;
             case ANY:
                 return 1;
@@ -114,6 +123,11 @@ public enum ConsistencyLevel
         }
     }
 
+    public boolean isDatacenterLocal()
+    {
+        return isDCLocal;
+    }
+
     private boolean isLocal(InetAddress endpoint)
     {
         return 
DatabaseDescriptor.getLocalDataCenter().equals(DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint));
@@ -153,11 +167,11 @@ public enum ConsistencyLevel
     {
         /*
          * Endpoints are expected to be restricted to live replicas, sorted by 
snitch preference.
-         * For LOCAL_QORUM, move local-DC replicas in front first as we need 
them there whether
+         * For LOCAL_QUORUM, move local-DC replicas in front first as we need 
them there whether
          * we do read repair (since the first replica gets the data read) or 
not (since we'll take
          * the blockFor first ones).
          */
-        if (this == LOCAL_QUORUM)
+        if (isDCLocal)
             Collections.sort(liveEndpoints, 
DatabaseDescriptor.getLocalComparator());
 
         switch (readRepair)
@@ -193,6 +207,8 @@ public enum ConsistencyLevel
             case ANY:
                 // local hint is acceptable, and local node is always live
                 return true;
+            case LOCAL_ONE:
+                    return countLocalEndpoints(liveEndpoints) >= 1;
             case LOCAL_QUORUM:
                 return countLocalEndpoints(liveEndpoints) >= blockFor(table);
             case EACH_QUORUM:
@@ -260,6 +276,7 @@ public enum ConsistencyLevel
             case ANY:
                 throw new InvalidRequestException("ANY ConsistencyLevel is 
only supported for writes");
             case LOCAL_QUORUM:
+            case LOCAL_ONE:
                 requireNetworkTopologyStrategy(table);
                 break;
             case EACH_QUORUM:
@@ -273,6 +290,7 @@ public enum ConsistencyLevel
         {
             case LOCAL_QUORUM:
             case EACH_QUORUM:
+            case LOCAL_ONE:
                 requireNetworkTopologyStrategy(table);
                 break;
         }
@@ -284,7 +302,7 @@ public enum ConsistencyLevel
         {
             throw new InvalidRequestException("Consistency level ANY is not 
yet supported for counter columnfamily " + metadata.cfName);
         }
-        else if (!metadata.getReplicateOnWrite() && this != 
ConsistencyLevel.ONE)
+        else if (!metadata.getReplicateOnWrite() && !(this == 
ConsistencyLevel.ONE || this == ConsistencyLevel.LOCAL_ONE))
         {
             throw new InvalidRequestException("cannot achieve CL > CL.ONE 
without replicate_on_write on columnfamily " + metadata.cfName);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java 
b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
index 5ebebcd..e17b0b4 100644
--- a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
+++ b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
@@ -122,7 +122,7 @@ public abstract class AbstractReplicationStrategy
 
     public AbstractWriteResponseHandler 
getWriteResponseHandler(Collection<InetAddress> naturalEndpoints, 
Collection<InetAddress> pendingEndpoints, ConsistencyLevel consistency_level, 
Runnable callback, WriteType writeType)
     {
-        if (consistency_level == ConsistencyLevel.LOCAL_QUORUM)
+        if (consistency_level.isDatacenterLocal())
         {
             // block for in this context will be localnodes block.
             return new DatacenterWriteResponseHandler(naturalEndpoints, 
pendingEndpoints, consistency_level, getTable(), callback, writeType);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/src/java/org/apache/cassandra/service/DatacenterWriteResponseHandler.java
----------------------------------------------------------------------
diff --git 
a/src/java/org/apache/cassandra/service/DatacenterWriteResponseHandler.java 
b/src/java/org/apache/cassandra/service/DatacenterWriteResponseHandler.java
index e63ebd1..11607da 100644
--- a/src/java/org/apache/cassandra/service/DatacenterWriteResponseHandler.java
+++ b/src/java/org/apache/cassandra/service/DatacenterWriteResponseHandler.java
@@ -42,7 +42,7 @@ public class DatacenterWriteResponseHandler extends 
WriteResponseHandler
                                           WriteType writeType)
     {
         super(naturalEndpoints, pendingEndpoints, consistencyLevel, table, 
callback, writeType);
-        assert consistencyLevel == ConsistencyLevel.LOCAL_QUORUM;
+        assert consistencyLevel.isDatacenterLocal();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/src/java/org/apache/cassandra/service/ReadCallback.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/ReadCallback.java 
b/src/java/org/apache/cassandra/service/ReadCallback.java
index ebda81b..64b9e76 100644
--- a/src/java/org/apache/cassandra/service/ReadCallback.java
+++ b/src/java/org/apache/cassandra/service/ReadCallback.java
@@ -120,7 +120,7 @@ public class ReadCallback<TMessage, TResolved> implements 
IAsyncCallback<TMessag
      */
     private boolean waitingFor(MessageIn message)
     {
-        return consistencyLevel == ConsistencyLevel.LOCAL_QUORUM
+        return consistencyLevel.isDatacenterLocal()
              ? 
DatabaseDescriptor.getLocalDataCenter().equals(DatabaseDescriptor.getEndpointSnitch().getDatacenter(message.from))
              : true;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4a0f26c1/src/java/org/apache/cassandra/thrift/ThriftConversion.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftConversion.java 
b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
index fe28743..eeba1b1 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
@@ -40,6 +40,7 @@ public class ThriftConversion
             case ALL: return ConsistencyLevel.ALL;
             case LOCAL_QUORUM: return ConsistencyLevel.LOCAL_QUORUM;
             case EACH_QUORUM: return ConsistencyLevel.EACH_QUORUM;
+            case LOCAL_ONE: return ConsistencyLevel.LOCAL_ONE;
         }
         throw new AssertionError();
     }
@@ -56,6 +57,7 @@ public class ThriftConversion
             case ALL: return org.apache.cassandra.db.ConsistencyLevel.ALL;
             case LOCAL_QUORUM: return 
org.apache.cassandra.db.ConsistencyLevel.LOCAL_QUORUM;
             case EACH_QUORUM: return 
org.apache.cassandra.db.ConsistencyLevel.EACH_QUORUM;
+            case LOCAL_ONE: return 
org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE;
         }
         throw new AssertionError();
     }

Reply via email to