You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ja...@apache.org on 2013/10/17 23:10:45 UTC
[1/8] git commit: implementing CL.LOCAL_ONE
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 <ja...@gmail.com>
Authored: Tue Oct 15 11:34:01 2013 -0700
Committer: Jason Brown <ja...@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><ReplicationFactor></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><ReplicationFactor></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();
}
[4/8] git commit: implementing CL.LOCAL_ONE
Posted by ja...@apache.org.
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/5c0c84b3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5c0c84b3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5c0c84b3
Branch: refs/heads/trunk
Commit: 5c0c84b3d115880e786063df3b6e5f59eff402a0
Parents: e655d62
Author: Jason Brown <ja...@gmail.com>
Authored: Tue Oct 15 11:34:01 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Oct 17 13:37:12 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 +++---
lib/cql-internal-only-1.4.0.zip | Bin 91982 -> 92738 bytes
.../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 ++
17 files changed, 99 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c0c84b3/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/5c0c84b3/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/5c0c84b3/doc/native_protocol.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol.spec b/doc/native_protocol.spec
index b7a1de5..0d2ff05 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
+ 0x0010 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/5c0c84b3/interface/cassandra.thrift
----------------------------------------------------------------------
diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift
index 1649229..c64b2d7 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.36.1"
#
@@ -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><ReplicationFactor></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 = 11,
}
/**
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c0c84b3/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/5c0c84b3/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/5c0c84b3/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/5c0c84b3/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..bb15faf 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><ReplicationFactor></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(11);
private final int value;
@@ -118,6 +121,8 @@ public enum ConsistencyLevel implements org.apache.thrift.TEnum {
return TWO;
case 8:
return THREE;
+ case 11:
+ return LOCAL_ONE;
default:
return null;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c0c84b3/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..1315a5b 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.36.1";
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c0c84b3/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/5c0c84b3/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/5c0c84b3/lib/cql-internal-only-1.4.0.zip
----------------------------------------------------------------------
diff --git a/lib/cql-internal-only-1.4.0.zip b/lib/cql-internal-only-1.4.0.zip
index d800b92..fa33a3a 100644
Binary files a/lib/cql-internal-only-1.4.0.zip and b/lib/cql-internal-only-1.4.0.zip differ
http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c0c84b3/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/5c0c84b3/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/5c0c84b3/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/5c0c84b3/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/5c0c84b3/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();
}
[8/8] git commit: Merge branch 'cassandra-2.0' into trunk
Posted by ja...@apache.org.
Merge branch 'cassandra-2.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/231b345f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/231b345f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/231b345f
Branch: refs/heads/trunk
Commit: 231b345ffd1fe2d8927866b81ef94276e67fd8f2
Parents: 4e53d1e 20d91b0
Author: Jason Brown <ja...@gmail.com>
Authored: Thu Oct 17 14:09:45 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Oct 17 14:09:45 2013 -0700
----------------------------------------------------------------------
bin/cqlsh | 3 +-
doc/cql3/CQL.textile | 1 +
doc/native_protocol_v1.spec | 1 +
doc/native_protocol_v2.spec | 1 +
interface/cassandra.thrift | 5 +++-
.../cassandra/thrift/ConsistencyLevel.java | 7 ++++-
.../cassandra/thrift/cassandraConstants.java | 2 +-
lib/cql-internal-only-1.4.0.zip | Bin 91982 -> 92738 bytes
.../apache/cassandra/db/ConsistencyLevel.java | 29 +++++++++++++++----
.../locator/AbstractReplicationStrategy.java | 2 +-
.../service/DatacenterWriteResponseHandler.java | 2 +-
.../apache/cassandra/service/ReadCallback.java | 2 +-
.../cassandra/thrift/ThriftConversion.java | 1 +
13 files changed, 44 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/231b345f/src/java/org/apache/cassandra/thrift/ThriftConversion.java
----------------------------------------------------------------------
[2/8] git commit: Merge branch '6202' into 6202_2.0
Posted by ja...@apache.org.
Merge branch '6202' into 6202_2.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b8b56c97
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b8b56c97
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b8b56c97
Branch: refs/heads/trunk
Commit: b8b56c97314c514e51a79180f1df35410fd873c1
Parents: 96c0256 4a0f26c
Author: Jason Brown <ja...@gmail.com>
Authored: Wed Oct 16 13:40:02 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Wed Oct 16 13:40:02 2013 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------
[5/8] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0
Posted by ja...@apache.org.
Merge branch 'cassandra-1.2' into cassandra-2.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b0590c44
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b0590c44
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b0590c44
Branch: refs/heads/trunk
Commit: b0590c4480dbb5bb05c0ad28e223d20a0d9c9f09
Parents: 886f16c 5c0c84b
Author: Jason Brown <ja...@gmail.com>
Authored: Thu Oct 17 14:00:33 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Oct 17 14:00:33 2013 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------
[3/8] git commit: apply local_one changes to 2.0
Posted by ja...@apache.org.
apply local_one changes to 2.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c9528f9c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c9528f9c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c9528f9c
Branch: refs/heads/trunk
Commit: c9528f9c9c6c53779959419625ac6aaf3ed86025
Parents: b8b56c9
Author: Jason Brown <ja...@gmail.com>
Authored: Wed Oct 16 15:09:07 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Wed Oct 16 15:44:33 2013 -0700
----------------------------------------------------------------------
bin/cqlsh | 3 +-
doc/cql3/CQL.textile | 1 +
doc/native_protocol_v1.spec | 1 +
doc/native_protocol_v2.spec | 1 +
interface/cassandra.thrift | 5 +++-
.../cassandra/thrift/ConsistencyLevel.java | 7 ++++-
.../cassandra/thrift/cassandraConstants.java | 2 +-
.../apache/cassandra/db/ConsistencyLevel.java | 29 ++++++++++++++++----
.../locator/AbstractReplicationStrategy.java | 2 +-
.../service/DatacenterWriteResponseHandler.java | 2 +-
.../apache/cassandra/service/ReadCallback.java | 2 +-
.../cassandra/thrift/ThriftConversion.java | 1 +
12 files changed, 44 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 7883f9f..a062dcd 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -240,6 +240,7 @@ cqlsh_extra_syntax_rules = r'''
| "THREE"
| "QUORUM"
| "ALL"
+ | "LOCAL_ONE"
| "LOCAL_QUORUM"
| "EACH_QUORUM"
;
@@ -1757,7 +1758,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/c9528f9c/doc/cql3/CQL.textile
----------------------------------------------------------------------
diff --git a/doc/cql3/CQL.textile b/doc/cql3/CQL.textile
index 63ec71a..c90b585 100644
--- a/doc/cql3/CQL.textile
+++ b/doc/cql3/CQL.textile
@@ -1039,6 +1039,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/c9528f9c/doc/native_protocol_v1.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v1.spec b/doc/native_protocol_v1.spec
index b7a1de5..9e77276 100644
--- a/doc/native_protocol_v1.spec
+++ b/doc/native_protocol_v1.spec
@@ -201,6 +201,7 @@ Table of Contents
0x0005 ALL
0x0006 LOCAL_QUORUM
0x0007 EACH_QUORUM
+ 0x0010 EACH_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/c9528f9c/doc/native_protocol_v2.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v2.spec b/doc/native_protocol_v2.spec
index b0449bb..28c769a 100644
--- a/doc/native_protocol_v2.spec
+++ b/doc/native_protocol_v2.spec
@@ -220,6 +220,7 @@ Table of Contents
0x0007 EACH_QUORUM
0x0008 SERIAL
0x0009 LOCAL_SERIAL
+ 0x0010 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/c9528f9c/interface/cassandra.thrift
----------------------------------------------------------------------
diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift
index c42554d..0948140 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.37.0"
+const string VERSION = "19.38.0"
#
@@ -212,6 +212,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><ReplicationFactor></code> nodes before responding to the client.
@@ -222,6 +223,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)..
@@ -237,6 +239,7 @@ enum ConsistencyLevel {
THREE = 8,
SERIAL = 9,
LOCAL_SERIAL = 10,
+ LOCAL_ONE = 11,
}
/**
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/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 ea92479..ec5080a 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/ConsistencyLevel.java
@@ -60,6 +60,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><ReplicationFactor></code> nodes before responding to the client.
@@ -70,6 +71,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)..
@@ -84,7 +86,8 @@ public enum ConsistencyLevel implements org.apache.thrift.TEnum {
TWO(7),
THREE(8),
SERIAL(9),
- LOCAL_SERIAL(10);
+ LOCAL_SERIAL(10),
+ LOCAL_ONE(11);
private final int value;
@@ -125,6 +128,8 @@ public enum ConsistencyLevel implements org.apache.thrift.TEnum {
return SERIAL;
case 10:
return LOCAL_SERIAL;
+ case 11:
+ return LOCAL_ONE;
default:
return null;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
----------------------------------------------------------------------
diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
index c28519a..a2c482e 100644
--- a/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
+++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/cassandraConstants.java
@@ -56,6 +56,6 @@ import org.slf4j.LoggerFactory;
public class cassandraConstants {
- public static final String VERSION = "19.37.0";
+ public static final String VERSION = "19.38.0";
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/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 956ab58..5f17907 100644
--- a/src/java/org/apache/cassandra/db/ConsistencyLevel.java
+++ b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
@@ -46,15 +46,17 @@ public enum ConsistencyLevel
THREE (3),
QUORUM (4),
ALL (5),
- LOCAL_QUORUM(6),
+ LOCAL_QUORUM(6, true),
EACH_QUORUM (7),
SERIAL (8),
- LOCAL_SERIAL(9);
+ LOCAL_SERIAL(9),
+ LOCAL_ONE (10, 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
{
@@ -72,7 +74,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)
@@ -92,6 +100,7 @@ public enum ConsistencyLevel
switch (this)
{
case ONE:
+ case LOCAL_ONE:
return 1;
case ANY:
return 1;
@@ -116,6 +125,11 @@ public enum ConsistencyLevel
}
}
+ public boolean isDatacenterLocal()
+ {
+ return isDCLocal;
+ }
+
private boolean isLocal(InetAddress endpoint)
{
return DatabaseDescriptor.getLocalDataCenter().equals(DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint));
@@ -155,11 +169,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)
@@ -195,6 +209,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(keyspace);
case EACH_QUORUM:
@@ -260,6 +276,7 @@ public enum ConsistencyLevel
switch (this)
{
case LOCAL_QUORUM:
+ case LOCAL_ONE:
requireNetworkTopologyStrategy(keyspaceName);
break;
case ANY:
@@ -275,6 +292,7 @@ public enum ConsistencyLevel
{
case LOCAL_QUORUM:
case EACH_QUORUM:
+ case LOCAL_ONE:
requireNetworkTopologyStrategy(keyspaceName);
break;
case SERIAL:
@@ -290,6 +308,7 @@ public enum ConsistencyLevel
{
case LOCAL_QUORUM:
case EACH_QUORUM:
+ case LOCAL_ONE:
requireNetworkTopologyStrategy(keyspaceName);
break;
case SERIAL:
@@ -315,7 +334,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/c9528f9c/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 2a01fed..f83c889 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, getKeyspace(), callback, writeType);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/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 2455655..5530374 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, keyspace, callback, writeType);
- assert consistencyLevel == ConsistencyLevel.LOCAL_QUORUM;
+ assert consistencyLevel.isDatacenterLocal();
}
@Override
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c9528f9c/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 7f9c192..b7d5380 100644
--- a/src/java/org/apache/cassandra/service/ReadCallback.java
+++ b/src/java/org/apache/cassandra/service/ReadCallback.java
@@ -127,7 +127,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/c9528f9c/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 8a9ab59..0d92641 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
@@ -41,6 +41,7 @@ public class ThriftConversion
case LOCAL_QUORUM: return org.apache.cassandra.db.ConsistencyLevel.LOCAL_QUORUM;
case EACH_QUORUM: return org.apache.cassandra.db.ConsistencyLevel.EACH_QUORUM;
case SERIAL: return org.apache.cassandra.db.ConsistencyLevel.SERIAL;
+ case LOCAL_ONE: return org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE;
}
throw new AssertionError();
}
[6/8] git commit: Merge branch '6202_2.0' into cassandra-2.0
Posted by ja...@apache.org.
Merge branch '6202_2.0' into cassandra-2.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/23a530c6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/23a530c6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/23a530c6
Branch: refs/heads/trunk
Commit: 23a530c612c7999d4df3275ba5e47a67d318953c
Parents: b0590c4 c9528f9
Author: Jason Brown <ja...@gmail.com>
Authored: Thu Oct 17 14:01:02 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Oct 17 14:01:02 2013 -0700
----------------------------------------------------------------------
bin/cqlsh | 3 +-
doc/cql3/CQL.textile | 1 +
doc/native_protocol_v1.spec | 1 +
doc/native_protocol_v2.spec | 1 +
interface/cassandra.thrift | 5 +++-
.../cassandra/thrift/ConsistencyLevel.java | 7 ++++-
.../cassandra/thrift/cassandraConstants.java | 2 +-
.../apache/cassandra/db/ConsistencyLevel.java | 29 ++++++++++++++++----
.../locator/AbstractReplicationStrategy.java | 2 +-
.../service/DatacenterWriteResponseHandler.java | 2 +-
.../apache/cassandra/service/ReadCallback.java | 2 +-
.../cassandra/thrift/ThriftConversion.java | 1 +
12 files changed, 44 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
[7/8] git commit: add update cql-internal-only zip
Posted by ja...@apache.org.
add update cql-internal-only zip
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/20d91b0b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/20d91b0b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/20d91b0b
Branch: refs/heads/trunk
Commit: 20d91b0ba9aa22b8a04ade054901d5f5f6733588
Parents: 23a530c
Author: Jason Brown <ja...@gmail.com>
Authored: Thu Oct 17 14:06:29 2013 -0700
Committer: Jason Brown <ja...@gmail.com>
Committed: Thu Oct 17 14:06:29 2013 -0700
----------------------------------------------------------------------
doc/native_protocol_v1.spec | 2 +-
lib/cql-internal-only-1.4.0.zip | Bin 91982 -> 92738 bytes
2 files changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/20d91b0b/doc/native_protocol_v1.spec
----------------------------------------------------------------------
diff --git a/doc/native_protocol_v1.spec b/doc/native_protocol_v1.spec
index 9e77276..0d2ff05 100644
--- a/doc/native_protocol_v1.spec
+++ b/doc/native_protocol_v1.spec
@@ -201,7 +201,7 @@ Table of Contents
0x0005 ALL
0x0006 LOCAL_QUORUM
0x0007 EACH_QUORUM
- 0x0010 EACH_ONE
+ 0x0010 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/20d91b0b/lib/cql-internal-only-1.4.0.zip
----------------------------------------------------------------------
diff --git a/lib/cql-internal-only-1.4.0.zip b/lib/cql-internal-only-1.4.0.zip
index d800b92..fa33a3a 100644
Binary files a/lib/cql-internal-only-1.4.0.zip and b/lib/cql-internal-only-1.4.0.zip differ