cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/6] Finer grained exception hierarchy, and adds error codes
Date Wed, 05 Sep 2012 15:51:59 GMT
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index c9d4f45..3204e81 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -27,8 +27,8 @@ import org.apache.cassandra.db.marshal.CollectionType;
 import org.apache.cassandra.db.marshal.ColumnToCollectionType;
 import org.apache.cassandra.db.marshal.CompositeType;
 import org.apache.cassandra.db.marshal.CounterColumnType;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.MigrationManager;
-import org.apache.cassandra.thrift.InvalidRequestException;
 
 import static org.apache.cassandra.thrift.ThriftValidation.validateColumnFamily;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 3757981..c5ee187 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -26,11 +26,10 @@ import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.IMutation;
 import org.apache.cassandra.db.RowMutation;
 import org.apache.cassandra.db.CounterMutation;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.thrift.RequestType;
 import org.apache.cassandra.thrift.ThriftValidation;
-import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.utils.Pair;
 
 /**
@@ -63,7 +62,7 @@ public class BatchStatement extends ModificationStatement
     }
 
     @Override
-    public void checkAccess(ClientState state) throws InvalidRequestException
+    public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException
     {
         Set<String> cfamsSeen = new HashSet<String>();
         for (ModificationStatement statement : statements)
@@ -93,12 +92,12 @@ public class BatchStatement extends ModificationStatement
             if (statement.getTimeToLive() < 0)
                 throw new InvalidRequestException("A TTL must be greater or equal to 0");
 
-            ThriftValidation.validateConsistencyLevel(statement.keyspace(), getConsistencyLevel(), RequestType.WRITE);
+            getConsistencyLevel().validateForWrite(statement.keyspace());
         }
     }
 
     public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables)
-    throws UnavailableException, TimeoutException, InvalidRequestException
+    throws RequestExecutionException, RequestValidationException
     {
         Map<Pair<String, ByteBuffer>, RowAndCounterMutation> mutations = new HashMap<Pair<String, ByteBuffer>, RowAndCounterMutation>();
         for (ModificationStatement statement : statements)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/CFStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CFStatement.java b/src/java/org/apache/cassandra/cql3/statements/CFStatement.java
index dcc75b2..e9244ab 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CFStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CFStatement.java
@@ -19,7 +19,7 @@ package org.apache.cassandra.cql3.statements;
 
 import org.apache.cassandra.cql3.CFName;
 import org.apache.cassandra.service.ClientState;
-import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 
 /**
  * Abstract class for statements that apply on a given column family.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
index 3c97f90..b00cea5 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
@@ -30,7 +30,8 @@ import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.db.ColumnFamilyType;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.CollectionType;
@@ -38,10 +39,10 @@ import org.apache.cassandra.db.marshal.ColumnToCollectionType;
 import org.apache.cassandra.db.marshal.CompositeType;
 import org.apache.cassandra.db.marshal.ReversedType;
 import org.apache.cassandra.db.marshal.CounterColumnType;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.CqlResult;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /** A <code>CREATE COLUMNFAMILY</code> parsed from a CQL query statement. */
@@ -85,7 +86,7 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
         return columnDefs;
     }
 
-    public void announceMigration() throws InvalidRequestException, ConfigurationException
+    public void announceMigration() throws RequestValidationException
     {
         MigrationManager.announceNewColumnFamily(getCFMetaData());
     }
@@ -97,22 +98,15 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
      * @return a CFMetaData instance corresponding to the values parsed from this statement
      * @throws InvalidRequestException on failure to validate parsed parameters
      */
-    public CFMetaData getCFMetaData() throws InvalidRequestException
+    public CFMetaData getCFMetaData() throws RequestValidationException
     {
         CFMetaData newCFMD;
-        try
-        {
-            newCFMD = new CFMetaData(keyspace(),
-                                     columnFamily(),
-                                     ColumnFamilyType.Standard,
-                                     comparator,
-                                     null);
-            applyPropertiesTo(newCFMD);
-        }
-        catch (ConfigurationException e)
-        {
-            throw new InvalidRequestException(e.getMessage());
-        }
+        newCFMD = new CFMetaData(keyspace(),
+                                 columnFamily(),
+                                 ColumnFamilyType.Standard,
+                                 comparator,
+                                 null);
+        applyPropertiesTo(newCFMD);
         return newCFMD;
     }
 
@@ -148,162 +142,155 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
         /**
          * Transform this raw statement into a CreateColumnFamilyStatement.
          */
-        public ParsedStatement.Prepared prepare() throws InvalidRequestException
+        public ParsedStatement.Prepared prepare() throws RequestValidationException
         {
-            try
-            {
-                // Column family name
-                if (!columnFamily().matches("\\w+"))
-                    throw new InvalidRequestException(String.format("\"%s\" is not a valid column family name (must be alphanumeric character only: [0-9A-Za-z]+)", columnFamily()));
-                if (columnFamily().length() > Schema.NAME_LENGTH)
-                    throw new InvalidRequestException(String.format("Column family names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, columnFamily()));
+            // Column family name
+            if (!columnFamily().matches("\\w+"))
+                throw new InvalidRequestException(String.format("\"%s\" is not a valid column family name (must be alphanumeric character only: [0-9A-Za-z]+)", columnFamily()));
+            if (columnFamily().length() > Schema.NAME_LENGTH)
+                throw new InvalidRequestException(String.format("Column family names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, columnFamily()));
 
-                for (Multiset.Entry<ColumnIdentifier> entry : definedNames.entrySet())
-                    if (entry.getCount() > 1)
-                        throw new InvalidRequestException(String.format("Multiple definition of identifier %s", entry.getElement()));
+            for (Multiset.Entry<ColumnIdentifier> entry : definedNames.entrySet())
+                if (entry.getCount() > 1)
+                    throw new InvalidRequestException(String.format("Multiple definition of identifier %s", entry.getElement()));
 
-                properties.validate();
+            properties.validate();
 
-                CreateColumnFamilyStatement stmt = new CreateColumnFamilyStatement(cfName, properties);
-                stmt.setBoundTerms(getBoundsTerms());
+            CreateColumnFamilyStatement stmt = new CreateColumnFamilyStatement(cfName, properties);
+            stmt.setBoundTerms(getBoundsTerms());
 
-                Map<ByteBuffer, CollectionType> definedCollections = null;
-                for (Map.Entry<ColumnIdentifier, ParsedType> entry : definitions.entrySet())
+            Map<ByteBuffer, CollectionType> definedCollections = null;
+            for (Map.Entry<ColumnIdentifier, ParsedType> entry : definitions.entrySet())
+            {
+                ColumnIdentifier id = entry.getKey();
+                ParsedType pt = entry.getValue();
+                if (pt.isCollection())
                 {
-                    ColumnIdentifier id = entry.getKey();
-                    ParsedType pt = entry.getValue();
-                    if (pt.isCollection())
-                    {
-                        if (definedCollections == null)
-                            definedCollections = new HashMap<ByteBuffer, CollectionType>();
-                        definedCollections.put(id.key, (CollectionType)pt.getType());
-                    }
-                    stmt.columns.put(id, pt.getType()); // we'll remove what is not a column below
+                    if (definedCollections == null)
+                        definedCollections = new HashMap<ByteBuffer, CollectionType>();
+                    definedCollections.put(id.key, (CollectionType)pt.getType());
                 }
+                stmt.columns.put(id, pt.getType()); // we'll remove what is not a column below
+            }
 
-                if (keyAliases.size() != 1)
-                    throw new InvalidRequestException("You must specify one and only one PRIMARY KEY");
+            if (keyAliases.size() != 1)
+                throw new InvalidRequestException("You must specify one and only one PRIMARY KEY");
 
-                List<ColumnIdentifier> kAliases = keyAliases.get(0);
+            List<ColumnIdentifier> kAliases = keyAliases.get(0);
 
-                List<AbstractType<?>> keyTypes = new ArrayList<AbstractType<?>>(kAliases.size());
-                for (ColumnIdentifier alias : kAliases)
-                {
-                    stmt.keyAliases.add(alias.key);
-                    AbstractType<?> t = getTypeAndRemove(stmt.columns, alias);
-                    if (t instanceof CounterColumnType)
-                        throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", alias));
-                    keyTypes.add(t);
-                }
-                stmt.keyValidator = keyTypes.size() == 1 ? keyTypes.get(0) : CompositeType.getInstance(keyTypes);
+            List<AbstractType<?>> keyTypes = new ArrayList<AbstractType<?>>(kAliases.size());
+            for (ColumnIdentifier alias : kAliases)
+            {
+                stmt.keyAliases.add(alias.key);
+                AbstractType<?> t = getTypeAndRemove(stmt.columns, alias);
+                if (t instanceof CounterColumnType)
+                    throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", alias));
+                keyTypes.add(t);
+            }
+            stmt.keyValidator = keyTypes.size() == 1 ? keyTypes.get(0) : CompositeType.getInstance(keyTypes);
 
-                // Handle column aliases
-                if (columnAliases.isEmpty())
+            // Handle column aliases
+            if (columnAliases.isEmpty())
+            {
+                if (useCompactStorage)
                 {
-                    if (useCompactStorage)
-                    {
-                        // There should remain some column definition since it is a non-composite "static" CF
-                        if (stmt.columns.isEmpty())
-                            throw new InvalidRequestException("No definition found that is not part of the PRIMARY KEY");
+                    // There should remain some column definition since it is a non-composite "static" CF
+                    if (stmt.columns.isEmpty())
+                        throw new InvalidRequestException("No definition found that is not part of the PRIMARY KEY");
 
-                        stmt.comparator = CFDefinition.definitionType;
-                    }
-                    else
-                    {
-                        List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(definedCollections == null ? 1 : 2);
-                        types.add(CFDefinition.definitionType);
-                        if (definedCollections != null)
-                            types.add(ColumnToCollectionType.getInstance(definedCollections));
-                        stmt.comparator = CompositeType.getInstance(types);
-                    }
+                    stmt.comparator = CFDefinition.definitionType;
+                }
+                else
+                {
+                    List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(definedCollections == null ? 1 : 2);
+                    types.add(CFDefinition.definitionType);
+                    if (definedCollections != null)
+                        types.add(ColumnToCollectionType.getInstance(definedCollections));
+                    stmt.comparator = CompositeType.getInstance(types);
+                }
+            }
+            else
+            {
+                // If we use compact storage and have only one alias, it is a
+                // standard "dynamic" CF, otherwise it's a composite
+                if (useCompactStorage && columnAliases.size() == 1)
+                {
+                    if (definedCollections != null)
+                        throw new InvalidRequestException("Collection types are not supported with COMPACT STORAGE");
+                    stmt.columnAliases.add(columnAliases.get(0).key);
+                    stmt.comparator = getTypeAndRemove(stmt.columns, columnAliases.get(0));
+                    if (stmt.comparator instanceof CounterColumnType)
+                        throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", stmt.columnAliases.get(0)));
                 }
                 else
                 {
-                    // If we use compact storage and have only one alias, it is a
-                    // standard "dynamic" CF, otherwise it's a composite
-                    if (useCompactStorage && columnAliases.size() == 1)
+                    List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(columnAliases.size() + 1);
+                    for (ColumnIdentifier t : columnAliases)
+                    {
+                        stmt.columnAliases.add(t.key);
+
+                        AbstractType<?> type = getTypeAndRemove(stmt.columns, t);
+                        if (type instanceof CounterColumnType)
+                            throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", t.key));
+                        types.add(type);
+                    }
+
+                    if (useCompactStorage)
                     {
                         if (definedCollections != null)
                             throw new InvalidRequestException("Collection types are not supported with COMPACT STORAGE");
-                        stmt.columnAliases.add(columnAliases.get(0).key);
-                        stmt.comparator = getTypeAndRemove(stmt.columns, columnAliases.get(0));
-                        if (stmt.comparator instanceof CounterColumnType)
-                            throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", stmt.columnAliases.get(0)));
                     }
                     else
                     {
-                        List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(columnAliases.size() + 1);
-                        for (ColumnIdentifier t : columnAliases)
-                        {
-                            stmt.columnAliases.add(t.key);
-
-                            AbstractType<?> type = getTypeAndRemove(stmt.columns, t);
-                            if (type instanceof CounterColumnType)
-                                throw new InvalidRequestException(String.format("counter type is not supported for PRIMARY KEY part %s", t.key));
-                            types.add(type);
-                        }
-
-                        if (useCompactStorage)
-                        {
-                            if (definedCollections != null)
-                                throw new InvalidRequestException("Collection types are not supported with COMPACT STORAGE");
-                        }
-                        else
-                        {
-                            // For sparse, we must add the last UTF8 component
-                            // and the collection type if there is one
-                            types.add(CFDefinition.definitionType);
-                            if (definedCollections != null)
-                                types.add(ColumnToCollectionType.getInstance(definedCollections));
-                        }
-
-                        if (types.isEmpty())
-                            throw new IllegalStateException("Nonsensical empty parameter list for CompositeType");
-                        stmt.comparator = CompositeType.getInstance(types);
+                        // For sparse, we must add the last UTF8 component
+                        // and the collection type if there is one
+                        types.add(CFDefinition.definitionType);
+                        if (definedCollections != null)
+                            types.add(ColumnToCollectionType.getInstance(definedCollections));
                     }
+
+                    if (types.isEmpty())
+                        throw new IllegalStateException("Nonsensical empty parameter list for CompositeType");
+                    stmt.comparator = CompositeType.getInstance(types);
                 }
+            }
 
-                if (useCompactStorage && stmt.columns.size() <= 1)
+            if (useCompactStorage && stmt.columns.size() <= 1)
+            {
+                if (stmt.columns.isEmpty())
                 {
-                    if (stmt.columns.isEmpty())
-                    {
-                        if (columnAliases.isEmpty())
-                            throw new InvalidRequestException(String.format("COMPACT STORAGE with non-composite PRIMARY KEY require one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
-
-                        // The only value we'll insert will be the empty one, so the default validator don't matter
-                        stmt.defaultValidator = CFDefinition.definitionType;
-                        // We need to distinguish between
-                        //   * I'm upgrading from thrift so the valueAlias is null
-                        //   * I've define my table with only a PK (and the column value will be empty)
-                        // So, we use an empty valueAlias (rather than null) for the second case
-                        stmt.valueAlias = ByteBufferUtil.EMPTY_BYTE_BUFFER;
-                    }
-                    else
-                    {
-                        Map.Entry<ColumnIdentifier, AbstractType> lastEntry = stmt.columns.entrySet().iterator().next();
-                        stmt.defaultValidator = lastEntry.getValue();
-                        stmt.valueAlias = lastEntry.getKey().key;
-                        stmt.columns.remove(lastEntry.getKey());
-                    }
+                    if (columnAliases.isEmpty())
+                        throw new InvalidRequestException(String.format("COMPACT STORAGE with non-composite PRIMARY KEY require one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
+
+                    // The only value we'll insert will be the empty one, so the default validator don't matter
+                    stmt.defaultValidator = CFDefinition.definitionType;
+                    // We need to distinguish between
+                    //   * I'm upgrading from thrift so the valueAlias is null
+                    //   * I've define my table with only a PK (and the column value will be empty)
+                    // So, we use an empty valueAlias (rather than null) for the second case
+                    stmt.valueAlias = ByteBufferUtil.EMPTY_BYTE_BUFFER;
                 }
                 else
                 {
-                    if (useCompactStorage && !columnAliases.isEmpty())
-                        throw new InvalidRequestException(String.format("COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
-
-                    // There is no way to insert/access a column that is not defined for non-compact storage, so
-                    // the actual validator don't matter much (except that we want to recognize counter CF as limitation apply to them).
-                    stmt.defaultValidator = !stmt.columns.isEmpty() && (stmt.columns.values().iterator().next() instanceof CounterColumnType)
-                                          ? CounterColumnType.instance
-                                          : CFDefinition.definitionType;
+                    Map.Entry<ColumnIdentifier, AbstractType> lastEntry = stmt.columns.entrySet().iterator().next();
+                    stmt.defaultValidator = lastEntry.getValue();
+                    stmt.valueAlias = lastEntry.getKey().key;
+                    stmt.columns.remove(lastEntry.getKey());
                 }
-
-                return new ParsedStatement.Prepared(stmt);
             }
-            catch (ConfigurationException e)
+            else
             {
-                throw new InvalidRequestException(e.getMessage());
+                if (useCompactStorage && !columnAliases.isEmpty())
+                    throw new InvalidRequestException(String.format("COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
+
+                // There is no way to insert/access a column that is not defined for non-compact storage, so
+                // the actual validator don't matter much (except that we want to recognize counter CF as limitation apply to them).
+                stmt.defaultValidator = !stmt.columns.isEmpty() && (stmt.columns.values().iterator().next() instanceof CounterColumnType)
+                    ? CounterColumnType.instance
+                    : CFDefinition.definitionType;
             }
+
+            return new ParsedStatement.Prepared(stmt);
         }
 
         private AbstractType<?> getTypeAndRemove(Map<ColumnIdentifier, AbstractType> columns, ColumnIdentifier t) throws InvalidRequestException, ConfigurationException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
index 6dc3a9f..8f933ee 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateIndexStatement.java
@@ -26,13 +26,13 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.index.composites.CompositesIndex;
 import org.apache.cassandra.db.marshal.CompositeType;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.IndexType;
-import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.thrift.ThriftValidation;
 
 /** A <code>CREATE INDEX</code> statement parsed from a CQL query. */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
index 0c426b3..34d52bd 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
@@ -20,15 +20,16 @@ package org.apache.cassandra.cql3.statements;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.thrift.ThriftValidation;
 
 /** A <code>CREATE KEYSPACE</code> statement parsed from a CQL query. */
@@ -64,7 +65,7 @@ public class CreateKeyspaceStatement extends SchemaAlteringStatement
      * @throws InvalidRequestException if arguments are missing or unacceptable
      */
     @Override
-    public void validate(ClientState state) throws InvalidRequestException
+    public void validate(ClientState state) throws RequestValidationException
     {
         super.validate(state);
         ThriftValidation.validateKeyspaceNotSystem(name);
@@ -94,24 +95,16 @@ public class CreateKeyspaceStatement extends SchemaAlteringStatement
         }
 
         // trial run to let ARS validate class + per-class options
-        try
-        {
-            AbstractReplicationStrategy.createReplicationStrategy(name,
-                                                                  AbstractReplicationStrategy.getClass(strategyClass),
-                                                                  StorageService.instance.getTokenMetadata(),
-                                                                  DatabaseDescriptor.getEndpointSnitch(),
-                                                                  strategyOptions);
-        }
-        catch (ConfigurationException e)
-        {
-            throw new InvalidRequestException(e.getMessage());
-        }
+        AbstractReplicationStrategy.createReplicationStrategy(name,
+                                                              AbstractReplicationStrategy.getClass(strategyClass),
+                                                              StorageService.instance.getTokenMetadata(),
+                                                              DatabaseDescriptor.getEndpointSnitch(),
+                                                              strategyOptions);
     }
 
     public void announceMigration() throws InvalidRequestException, ConfigurationException
     {
         KSMetaData ksm = KSMetaData.newKeyspace(name, strategyClass, strategyOptions);
-        ThriftValidation.validateKeyspaceNotYetExisting(name);
         MigrationManager.announceNewKeyspace(ksm);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index 0fb97fc..cd0293a 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -35,9 +35,8 @@ import org.apache.cassandra.db.marshal.CollectionType;
 import org.apache.cassandra.db.marshal.CompositeType;
 import org.apache.cassandra.db.marshal.ListType;
 import org.apache.cassandra.db.marshal.MapType;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
-import org.apache.cassandra.thrift.InvalidRequestException;
-import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.thrift.ThriftValidation;
 import org.apache.cassandra.utils.Pair;
 
@@ -63,7 +62,8 @@ public class DeleteStatement extends ModificationStatement
         this.toRemove = new ArrayList<Pair<CFDefinition.Name, Term>>(columns.size());
     }
 
-    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables) throws UnavailableException, TimeoutException, InvalidRequestException
+    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables)
+    throws RequestExecutionException, RequestValidationException
     {
         // keys
         List<ByteBuffer> keys = UpdateStatement.buildKeyNames(cfDef, processedKeys, variables);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/DropColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropColumnFamilyStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropColumnFamilyStatement.java
index 4f0135f..fe84ad4 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropColumnFamilyStatement.java
@@ -17,7 +17,7 @@
  */
 package org.apache.cassandra.cql3.statements;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.cql3.CFName;
 import org.apache.cassandra.service.MigrationManager;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
index 87ef79a..5fb2883 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
@@ -20,8 +20,8 @@ package org.apache.cassandra.cql3.statements;
 
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.config.*;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.MigrationManager;
-import org.apache.cassandra.thrift.InvalidRequestException;
 
 public class DropIndexStatement extends SchemaAlteringStatement
 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java
index af9b0a2..788ffc1 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropKeyspaceStatement.java
@@ -18,10 +18,10 @@
 package org.apache.cassandra.cql3.statements;
 
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.thrift.ThriftValidation;
 
 public class DropKeyspaceStatement extends SchemaAlteringStatement
@@ -35,7 +35,7 @@ public class DropKeyspaceStatement extends SchemaAlteringStatement
     }
 
     @Override
-    public void validate(ClientState state) throws InvalidRequestException
+    public void validate(ClientState state) throws RequestValidationException
     {
         super.validate(state);
         ThriftValidation.validateKeyspaceNotSystem(keyspace);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index a74a179..8ed22e1 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -21,7 +21,6 @@ import java.io.IOError;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.*;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.cql3.*;
@@ -29,14 +28,12 @@ import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.CompositeType;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.StorageProxy;
-import org.apache.cassandra.thrift.ConsistencyLevel;
-import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.thrift.RequestType;
 import org.apache.cassandra.thrift.ThriftValidation;
-import org.apache.cassandra.thrift.TimedOutException;
-import org.apache.cassandra.thrift.UnavailableException;
 
 /**
  * Abstract class for statements that apply on a given column family.
@@ -62,7 +59,7 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt
         this.timeToLive = timeToLive;
     }
 
-    public void checkAccess(ClientState state) throws InvalidRequestException
+    public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException
     {
         state.hasColumnFamilyAccess(keyspace(), columnFamily(), Permission.WRITE);
     }
@@ -72,20 +69,13 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt
         if (timeToLive < 0)
             throw new InvalidRequestException("A TTL must be greater or equal to 0");
 
-        ThriftValidation.validateConsistencyLevel(keyspace(), getConsistencyLevel(), RequestType.WRITE);
+        getConsistencyLevel().validateForWrite(keyspace());
     }
 
-    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException, UnavailableException, TimedOutException
+    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
     {
-        try
-        {
-            StorageProxy.mutate(getMutations(state, variables), getConsistencyLevel());
-            return null;
-        }
-        catch (TimeoutException e)
-        {
-            throw new TimedOutException();
-        }
+        StorageProxy.mutate(getMutations(state, variables), getConsistencyLevel());
+        return null;
     }
 
     public ConsistencyLevel getConsistencyLevel()
@@ -118,7 +108,8 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt
         return timeToLive;
     }
 
-    public Map<ByteBuffer, ColumnGroupMap> readRows(List<ByteBuffer> keys, ColumnNameBuilder builder, CompositeType composite) throws UnavailableException, TimeoutException, InvalidRequestException
+    public Map<ByteBuffer, ColumnGroupMap> readRows(List<ByteBuffer> keys, ColumnNameBuilder builder, CompositeType composite)
+    throws RequestExecutionException, RequestValidationException
     {
         List<ReadCommand> commands = new ArrayList<ReadCommand>(keys.size());
         for (ByteBuffer key : keys)
@@ -167,7 +158,8 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt
      * @return list of the mutations
      * @throws InvalidRequestException on invalid requests
      */
-    public abstract List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables) throws UnavailableException, TimeoutException, InvalidRequestException;
+    public abstract List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables)
+    throws RequestExecutionException, RequestValidationException;
 
     public abstract ParsedStatement.Prepared prepare(CFDefinition.Name[] boundNames) throws InvalidRequestException;
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java b/src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java
index 1b8663e..ffcb7ae 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java
@@ -21,7 +21,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.cassandra.cql3.*;
-import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestValidationException;
 
 public abstract class ParsedStatement
 {
@@ -38,7 +38,7 @@ public abstract class ParsedStatement
         this.boundTerms = boundTerms;
     }
 
-    public abstract Prepared prepare() throws InvalidRequestException;
+    public abstract Prepared prepare() throws RequestValidationException;
 
     public static class Prepared
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java b/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
index 8d85351..f00086b 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java
@@ -24,12 +24,14 @@ import java.util.Map;
 import org.apache.cassandra.cql3.CQLStatement;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.auth.Permission;
-import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.CFName;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.RequestValidationException;
+import org.apache.cassandra.exceptions.UnauthorizedException;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.StorageProxy;
-import org.apache.cassandra.thrift.InvalidRequestException;
 
 import com.google.common.base.Predicates;
 import com.google.common.collect.Maps;
@@ -67,9 +69,9 @@ public abstract class SchemaAlteringStatement extends CFStatement implements CQL
         return new Prepared(this);
     }
 
-    public abstract void announceMigration() throws InvalidRequestException, ConfigurationException;
+    public abstract void announceMigration() throws RequestValidationException;
 
-    public void checkAccess(ClientState state) throws InvalidRequestException
+    public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
     {
         if (isColumnFamilyLevel)
             state.hasColumnFamilySchemaAccess(keyspace(), Permission.WRITE);
@@ -78,10 +80,10 @@ public abstract class SchemaAlteringStatement extends CFStatement implements CQL
     }
 
     @Override
-    public void validate(ClientState state) throws InvalidRequestException
+    public void validate(ClientState state) throws RequestValidationException
     {}
 
-    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException
+    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws RequestValidationException
     {
         try
         {
@@ -93,7 +95,6 @@ public abstract class SchemaAlteringStatement extends CFStatement implements CQL
             ex.initCause(e);
             throw ex;
         }
-
         return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index adc8b34..23cf2a0 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.cql3.statements;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.*;
-import java.util.concurrent.TimeoutException;
 
 import com.google.common.collect.AbstractIterator;
 import org.slf4j.Logger;
@@ -31,7 +30,7 @@ import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.context.CounterContext;
 import org.apache.cassandra.db.filter.*;
@@ -39,17 +38,15 @@ import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexManager;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.dht.*;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.StorageProxy;
 import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.thrift.ConsistencyLevel;
+import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.thrift.IndexExpression;
 import org.apache.cassandra.thrift.IndexOperator;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.thrift.RequestType;
-import org.apache.cassandra.thrift.TimedOutException;
 import org.apache.cassandra.thrift.ThriftValidation;
-import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
@@ -103,7 +100,7 @@ public class SelectStatement implements CQLStatement
         return boundTerms;
     }
 
-    public void checkAccess(ClientState state) throws InvalidRequestException
+    public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException
     {
         state.hasColumnFamilyAccess(keyspace(), columnFamily(), Permission.READ);
     }
@@ -113,34 +110,27 @@ public class SelectStatement implements CQLStatement
         // Nothing to do, all validation has been done by RawStatement.prepare()
     }
 
-    public ResultMessage.Rows execute(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException, UnavailableException, TimedOutException
+    public ResultMessage.Rows execute(ClientState state, List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
     {
         return new ResultMessage.Rows(executeInternal(state, variables));
     }
 
-    public ResultSet executeInternal(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException, UnavailableException, TimedOutException
+    public ResultSet executeInternal(ClientState state, List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
     {
-        try
+        List<Row> rows;
+        if (isKeyRange)
         {
-            List<Row> rows;
-            if (isKeyRange)
-            {
-                rows = multiRangeSlice(variables);
-            }
-            else
-            {
-                rows = getSlice(variables);
-            }
-
-            // Even for count, we need to process the result as it'll group some column together in sparse column families
-            ResultSet rset = process(rows, variables);
-            rset = parameters.isCount ? rset.makeCountResult() : rset;
-            return rset;
+            rows = multiRangeSlice(variables);
         }
-        catch (TimeoutException e)
+        else
         {
-            throw new TimedOutException();
+            rows = getSlice(variables);
         }
+
+        // Even for count, we need to process the result as it'll group some column together in sparse column families
+        ResultSet rset = process(rows, variables);
+        rset = parameters.isCount ? rset.makeCountResult() : rset;
+        return rset;
     }
 
     public ResultSet process(List<Row> rows) throws InvalidRequestException
@@ -159,7 +149,7 @@ public class SelectStatement implements CQLStatement
         return cfDef.cfm.cfName;
     }
 
-    private List<Row> getSlice(List<ByteBuffer> variables) throws InvalidRequestException, TimeoutException, UnavailableException
+    private List<Row> getSlice(List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
     {
         QueryPath queryPath = new QueryPath(columnFamily());
         Collection<ByteBuffer> keys = getKeys(variables);
@@ -198,7 +188,7 @@ public class SelectStatement implements CQLStatement
         }
     }
 
-    private List<Row> multiRangeSlice(List<ByteBuffer> variables) throws InvalidRequestException, TimeoutException, UnavailableException
+    private List<Row> multiRangeSlice(List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
     {
         List<Row> rows;
         IFilter filter = makeFilter(variables);
@@ -896,7 +886,7 @@ public class SelectStatement implements CQLStatement
         public ParsedStatement.Prepared prepare() throws InvalidRequestException
         {
             CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
-            ThriftValidation.validateConsistencyLevel(keyspace(), parameters.consistencyLevel, RequestType.READ);
+            parameters.consistencyLevel.validateForRead(keyspace());
 
             if (parameters.limit <= 0)
                 throw new InvalidRequestException("LIMIT must be strictly positive");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java b/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java
index 451fa50..fceaebc 100644
--- a/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java
@@ -24,12 +24,11 @@ import java.util.concurrent.TimeoutException;
 
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.cql3.*;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.StorageProxy;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.thrift.ThriftValidation;
-import org.apache.cassandra.thrift.UnavailableException;
 
 public class TruncateStatement extends CFStatement implements CQLStatement
 {
@@ -43,7 +42,7 @@ public class TruncateStatement extends CFStatement implements CQLStatement
         return new Prepared(this);
     }
 
-    public void checkAccess(ClientState state) throws InvalidRequestException
+    public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException
     {
         state.hasColumnFamilyAccess(keyspace(), columnFamily(), Permission.WRITE);
     }
@@ -53,19 +52,23 @@ public class TruncateStatement extends CFStatement implements CQLStatement
         ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
     }
 
-    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException, UnavailableException
+    public ResultMessage execute(ClientState state, List<ByteBuffer> variables) throws InvalidRequestException, TruncateException
     {
         try
         {
             StorageProxy.truncateBlocking(keyspace(), columnFamily());
         }
+        catch (UnavailableException e)
+        {
+            throw new TruncateException(e);
+        }
         catch (TimeoutException e)
         {
-            throw (UnavailableException) new UnavailableException().initCause(e);
+            throw new TruncateException(e);
         }
         catch (IOException e)
         {
-            throw (UnavailableException) new UnavailableException().initCause(e);
+            throw new TruncateException(e);
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
index d34e294..7d49988 100644
--- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
@@ -29,16 +29,14 @@ import org.apache.cassandra.cql3.operations.ColumnOperation;
 import org.apache.cassandra.cql3.operations.Operation;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.service.ClientState;
-import org.apache.cassandra.thrift.InvalidRequestException;
-import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.Pair;
 
 import static org.apache.cassandra.cql.QueryProcessor.validateKey;
 
 import static org.apache.cassandra.thrift.ThriftValidation.validateColumnFamily;
-import static org.apache.cassandra.thrift.ThriftValidation.validateCommutativeForWrite;
 
 /**
  * An <code>UPDATE</code> statement parsed from a CQL query statement.
@@ -102,7 +100,8 @@ public class UpdateStatement extends ModificationStatement
 
 
     /** {@inheritDoc} */
-    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables) throws UnavailableException, TimeoutException, InvalidRequestException
+    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables)
+    throws RequestExecutionException, RequestValidationException
     {
         List<ByteBuffer> keys = buildKeyNames(cfDef, processedKeys, variables);
 
@@ -305,7 +304,7 @@ public class UpdateStatement extends ModificationStatement
         // Deal here with the keyspace overwrite thingy to avoid mistake
         CFMetaData metadata = validateColumnFamily(keyspace(), columnFamily(), hasCommutativeOperation);
         if (hasCommutativeOperation)
-            validateCommutativeForWrite(metadata, cLevel);
+            cLevel.validateCounterForWrite(metadata);
 
         cfDef = metadata.getCfDef();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/cql3/statements/UseStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/UseStatement.java b/src/java/org/apache/cassandra/cql3/statements/UseStatement.java
index bab7a99..f56c6f2 100644
--- a/src/java/org/apache/cassandra/cql3/statements/UseStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/UseStatement.java
@@ -21,9 +21,9 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.cassandra.cql3.CQLStatement;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.transport.messages.ResultMessage;
 import org.apache.cassandra.service.ClientState;
-import org.apache.cassandra.thrift.InvalidRequestException;
 
 public class UseStatement extends ParsedStatement implements CQLStatement
 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index adb73cc..caa8dbc 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -60,6 +60,7 @@ import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexManager;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.dht.*;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.io.sstable.*;
 import org.apache.cassandra.io.sstable.Descriptor;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
index 8e7fd9d..b9fee05 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
@@ -21,7 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 
 /**
  * The MBean interface for ColumnFamilyStore

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/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
new file mode 100644
index 0000000..c7c5136
--- /dev/null
+++ b/src/java/org/apache/cassandra/db/ConsistencyLevel.java
@@ -0,0 +1,114 @@
+/*
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+package org.apache.cassandra.db;
+
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.NetworkTopologyStrategy;
+import org.apache.cassandra.utils.FBUtilities;
+
+public enum ConsistencyLevel
+{
+    ANY,
+    ONE,
+    TWO,
+    THREE,
+    QUORUM,
+    ALL,
+    LOCAL_QUORUM,
+    EACH_QUORUM;
+
+    private static final String LOCAL_DC = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress());
+
+    public int blockFor(String table)
+    {
+        NetworkTopologyStrategy strategy = null;
+        switch (this)
+        {
+            case ONE:
+                return 1;
+            case ANY:
+                return 1;
+            case TWO:
+                return 2;
+            case THREE:
+                return 3;
+            case QUORUM:
+                return (Table.open(table).getReplicationStrategy().getReplicationFactor() / 2) + 1;
+            case ALL:
+                return Table.open(table).getReplicationStrategy().getReplicationFactor();
+            case LOCAL_QUORUM:
+                strategy = (NetworkTopologyStrategy) Table.open(table).getReplicationStrategy();
+                return (strategy.getReplicationFactor(LOCAL_DC) / 2) + 1;
+            case EACH_QUORUM:
+                strategy = (NetworkTopologyStrategy) Table.open(table).getReplicationStrategy();
+                int n = 0;
+                for (String dc : strategy.getDatacenters())
+                    n += (strategy.getReplicationFactor(dc) / 2) + 1;
+                return n;
+            default:
+                throw new UnsupportedOperationException("Invalid consistency level: " + toString());
+        }
+    }
+
+    public void validateForRead(String table) throws InvalidRequestException
+    {
+        switch (this)
+        {
+            case ANY:
+                throw new InvalidRequestException("ANY ConsistencyLevel is only supported for writes");
+            case LOCAL_QUORUM:
+                requireNetworkTopologyStrategy(table);
+                break;
+            case EACH_QUORUM:
+                throw new InvalidRequestException("EACH_QUORUM ConsistencyLevel is only supported for writes");
+        }
+    }
+
+    public void validateForWrite(String table) throws InvalidRequestException
+    {
+        switch (this)
+        {
+            case LOCAL_QUORUM:
+            case EACH_QUORUM:
+                requireNetworkTopologyStrategy(table);
+                break;
+        }
+    }
+
+    public void validateCounterForWrite(CFMetaData metadata) throws InvalidRequestException
+    {
+        if (this == ConsistencyLevel.ANY)
+        {
+            throw new InvalidRequestException("Consistency level ANY is not yet supported for counter columnfamily " + metadata.cfName);
+        }
+        else if (!metadata.getReplicateOnWrite() && this != ConsistencyLevel.ONE)
+        {
+            throw new InvalidRequestException("cannot achieve CL > CL.ONE without replicate_on_write on columnfamily " + metadata.cfName);
+        }
+    }
+
+    private void requireNetworkTopologyStrategy(String table) throws InvalidRequestException
+    {
+        AbstractReplicationStrategy strategy = Table.open(table).getReplicationStrategy();
+        if (!(strategy instanceof NetworkTopologyStrategy))
+            throw new InvalidRequestException(String.format("consistency level %s not compatible with replication strategy (%s)", this, strategy.getClass().getName()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/CounterColumn.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CounterColumn.java b/src/java/org/apache/cassandra/db/CounterColumn.java
index 0aa22ec..9829917 100644
--- a/src/java/org/apache/cassandra/db/CounterColumn.java
+++ b/src/java/org/apache/cassandra/db/CounterColumn.java
@@ -33,13 +33,14 @@ import org.apache.cassandra.db.context.CounterContext;
 import org.apache.cassandra.db.context.IContext.ContextRelationship;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.MarshalException;
+import org.apache.cassandra.exceptions.OverloadedException;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.io.IColumnSerializer;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.utils.Allocator;
 import org.apache.cassandra.service.IWriteResponseHandler;
 import org.apache.cassandra.service.StorageProxy;
-import org.apache.cassandra.thrift.ConsistencyLevel;
-import org.apache.cassandra.thrift.UnavailableException;
+import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.utils.*;
 
 /**
@@ -357,7 +358,7 @@ public class CounterColumn extends Column
         return new CounterColumn(name, contextManager.markDeltaToBeCleared(value), timestamp, timestampOfLastDelete);
     }
 
-    private static void sendToOtherReplica(DecoratedKey key, ColumnFamily cf) throws UnavailableException, TimeoutException, IOException
+    private static void sendToOtherReplica(DecoratedKey key, ColumnFamily cf) throws RequestExecutionException, IOException
     {
         RowMutation rm = new RowMutation(cf.metadata().ksName, key.key);
         rm.add(cf);
@@ -368,7 +369,7 @@ public class CounterColumn extends Column
         StorageProxy.performWrite(rm, ConsistencyLevel.ANY, localDataCenter, new StorageProxy.WritePerformer()
         {
             public void apply(IMutation mutation, Collection<InetAddress> targets, IWriteResponseHandler responseHandler, String localDataCenter, ConsistencyLevel consistency_level)
-            throws IOException, UnavailableException
+            throws IOException, OverloadedException
             {
                 // We should only send to the remote replica, not the local one
                 targets.remove(local);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/CounterMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CounterMutation.java b/src/java/org/apache/cassandra/db/CounterMutation.java
index 601df94..b1e48e6 100644
--- a/src/java/org/apache/cassandra/db/CounterMutation.java
+++ b/src/java/org/apache/cassandra/db/CounterMutation.java
@@ -30,7 +30,7 @@ import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
-import org.apache.cassandra.thrift.ConsistencyLevel;
+import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.HeapAllocator;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/CounterMutationVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/CounterMutationVerbHandler.java b/src/java/org/apache/cassandra/db/CounterMutationVerbHandler.java
index edd4fe3..f94495d 100644
--- a/src/java/org/apache/cassandra/db/CounterMutationVerbHandler.java
+++ b/src/java/org/apache/cassandra/db/CounterMutationVerbHandler.java
@@ -23,12 +23,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.net.IVerbHandler;
 import org.apache.cassandra.net.MessageIn;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.service.StorageProxy;
-import org.apache.cassandra.thrift.TimedOutException;
-import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.utils.FBUtilities;
 
 public class CounterMutationVerbHandler implements IVerbHandler<CounterMutation>
@@ -48,17 +47,10 @@ public class CounterMutationVerbHandler implements IVerbHandler<CounterMutation>
             WriteResponse response = new WriteResponse();
             MessagingService.instance().sendReply(response.createMessage(), id, message.from);
         }
-        catch (UnavailableException e)
+        catch (RequestExecutionException e)
         {
-            // We check for UnavailableException in the coordinator now. It is
-            // hence reasonable to let the coordinator timeout in the very
-            // unlikely case we arrive here
-            logger.debug("counter unavailable", e);
-        }
-        catch (TimedOutException e)
-        {
-            // The coordinator node will have timeout itself so we let that goes
-            logger.debug("counter timeout", e);
+            // The coordinator will timeout on itself, so let that go
+            logger.debug("counter error", e);
         }
         catch (IOException e)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/DefsTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DefsTable.java b/src/java/org/apache/cassandra/db/DefsTable.java
index 0c296e6..8abe76a 100644
--- a/src/java/org/apache/cassandra/db/DefsTable.java
+++ b/src/java/org/apache/cassandra/db/DefsTable.java
@@ -41,6 +41,7 @@ import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.AsciiType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.migration.avro.KsDef;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index bf6f594..22052ad 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -44,6 +44,7 @@ import org.apache.cassandra.db.marshal.UUIDType;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.exceptions.WriteTimeoutException;
 import org.apache.cassandra.gms.ApplicationState;
 import org.apache.cassandra.gms.FailureDetector;
 import org.apache.cassandra.gms.Gossiper;
@@ -125,7 +126,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
         StorageService.optionalTasks.scheduleWithFixedDelay(runnable, 10, 10, TimeUnit.MINUTES);
     }
 
-    private static void sendMutation(InetAddress endpoint, MessageOut<?> message) throws TimedOutException
+    private static void sendMutation(InetAddress endpoint, MessageOut<?> message) throws WriteTimeoutException
     {
         IWriteResponseHandler responseHandler = WriteResponseHandler.create(endpoint);
         MessagingService.instance().sendRR(message, endpoint, responseHandler);
@@ -364,7 +365,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
                     }
                     deleteHint(hostIdBytes, hint.name(), hint.maxTimestamp());
                 }
-                catch (TimedOutException e)
+                catch (WriteTimeoutException e)
                 {
                     logger.info(String.format("Timed out replaying hints to %s; aborting further deliveries", endpoint));
                     break delivery;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/KeyspaceNotDefinedException.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/KeyspaceNotDefinedException.java b/src/java/org/apache/cassandra/db/KeyspaceNotDefinedException.java
index 07f6ece..9d07f5e 100644
--- a/src/java/org/apache/cassandra/db/KeyspaceNotDefinedException.java
+++ b/src/java/org/apache/cassandra/db/KeyspaceNotDefinedException.java
@@ -17,7 +17,7 @@
  */
 package org.apache.cassandra.db;
 
-import org.apache.cassandra.thrift.InvalidRequestException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
 
 public class KeyspaceNotDefinedException extends InvalidRequestException
 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/RangeSliceCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RangeSliceCommand.java b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
index 6632f39..2274818 100644
--- a/src/java/org/apache/cassandra/db/RangeSliceCommand.java
+++ b/src/java/org/apache/cassandra/db/RangeSliceCommand.java
@@ -50,11 +50,19 @@ import org.apache.cassandra.db.filter.NamesQueryFilter;
 import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.dht.AbstractBounds;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.service.IReadCommand;
-import org.apache.cassandra.thrift.*;
+import org.apache.cassandra.thrift.ColumnParent;
+import org.apache.cassandra.thrift.IndexClause;
+import org.apache.cassandra.thrift.IndexExpression;
+import org.apache.cassandra.thrift.IndexOperator;
+import org.apache.cassandra.thrift.SlicePredicate;
+import org.apache.cassandra.thrift.SliceRange;
+import org.apache.cassandra.thrift.TBinaryProtocol;
+import org.apache.cassandra.thrift.ThriftValidation;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.thrift.TDeserializer;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/SystemTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java
index cd64d2c..18dead3 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -28,7 +28,7 @@ import com.google.common.collect.Multimap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.cql3.UntypedResultSet;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/Table.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Table.java b/src/java/org/apache/cassandra/db/Table.java
index 66fab5b..b700ef6 100644
--- a/src/java/org/apache/cassandra/db/Table.java
+++ b/src/java/org/apache/cassandra/db/Table.java
@@ -37,6 +37,7 @@ import org.apache.cassandra.db.filter.ColumnSlice;
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexManager;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.service.StorageService;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
index 82b6697..b0ffe3a 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndex.java
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.IColumn;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
index 70a9164..a01b0f9 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.filter.IFilter;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java b/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java
index f9db99f..552d75f 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesIndex.java
@@ -21,12 +21,12 @@ import java.nio.ByteBuffer;
 import java.util.Set;
 
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.index.AbstractSimplePerColumnSecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexSearcher;
 import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.exceptions.ConfigurationException;
 
 /**
  * Implements a secondary index for a column family using a second column family

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java b/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
index e9c805d..dbc32ce 100644
--- a/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
+++ b/src/java/org/apache/cassandra/db/index/keys/KeysIndex.java
@@ -23,7 +23,7 @@ import java.util.concurrent.ExecutionException;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.index.AbstractSimplePerColumnSecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexSearcher;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/AbstractType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractType.java b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
index 2aa9578..5393c0c 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
@@ -22,7 +22,7 @@ import java.util.Collection;
 import java.util.Comparator;
 import java.util.Map;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.db.IColumn;
 import org.apache.cassandra.db.OnDiskAtom;
 import org.apache.cassandra.db.RangeTombstone;
@@ -174,7 +174,7 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer>
         return false;
     }
 
-    public static AbstractType<?> parseDefaultParameters(AbstractType<?> baseType, TypeParser parser) throws ConfigurationException
+    public static AbstractType<?> parseDefaultParameters(AbstractType<?> baseType, TypeParser parser) throws SyntaxException
     {
         Map<String, String> parameters = parser.getKeyValueParameters();
         String reversed = parameters.get("reversed");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java b/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
index 4ba73aa..bb5d2fa 100644
--- a/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ColumnToCollectionType.java
@@ -23,7 +23,8 @@ import java.util.Map;
 
 import com.google.common.collect.ImmutableMap;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 public class ColumnToCollectionType extends AbstractType<ByteBuffer>
@@ -33,7 +34,7 @@ public class ColumnToCollectionType extends AbstractType<ByteBuffer>
 
     public final Map<ByteBuffer, CollectionType> defined;
 
-    public static ColumnToCollectionType getInstance(TypeParser parser) throws ConfigurationException
+    public static ColumnToCollectionType getInstance(TypeParser parser) throws SyntaxException, ConfigurationException
     {
         return getInstance(parser.getCollectionsParameters());
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/CompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CompositeType.java b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
index 83603ea..fb80906 100644
--- a/src/java/org/apache/cassandra/db/marshal/CompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CompositeType.java
@@ -27,12 +27,13 @@ import java.util.Map;
 
 import com.google.common.collect.ImmutableList;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.cql3.ColumnNameBuilder;
 import org.apache.cassandra.cql3.Relation;
 import org.apache.cassandra.cql3.Term;
 import org.apache.cassandra.io.util.DataOutputBuffer;
-import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /*
@@ -62,7 +63,7 @@ public class CompositeType extends AbstractCompositeType
     // interning instances
     private static final Map<List<AbstractType<?>>, CompositeType> instances = new HashMap<List<AbstractType<?>>, CompositeType>();
 
-    public static CompositeType getInstance(TypeParser parser) throws ConfigurationException
+    public static CompositeType getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
         return getInstance(parser.getTypeParameters());
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
index 5eeccfd..36a3ee2 100644
--- a/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/DynamicCompositeType.java
@@ -22,7 +22,8 @@ import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /*
@@ -51,7 +52,7 @@ public class DynamicCompositeType extends AbstractCompositeType
     // interning instances
     private static final Map<Map<Byte, AbstractType<?>>, DynamicCompositeType> instances = new HashMap<Map<Byte, AbstractType<?>>, DynamicCompositeType>();
 
-    public static synchronized DynamicCompositeType getInstance(TypeParser parser) throws ConfigurationException
+    public static synchronized DynamicCompositeType getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
         return getInstance(parser.getAliasParameters());
     }
@@ -95,6 +96,10 @@ public class DynamicCompositeType extends AbstractCompositeType
         {
             throw new RuntimeException(e);
         }
+        catch (SyntaxException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     protected AbstractType<?> getComparator(int i, ByteBuffer bb)
@@ -155,6 +160,10 @@ public class DynamicCompositeType extends AbstractCompositeType
         {
             throw new RuntimeException(e);
         }
+        catch (SyntaxException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 
     protected ParsedComparator parseComparator(int i, String part)
@@ -259,6 +268,10 @@ public class DynamicCompositeType extends AbstractCompositeType
                 }
                 type = t;
             }
+            catch (SyntaxException e)
+            {
+                throw new IllegalArgumentException(e);
+            }
             catch (ConfigurationException e)
             {
                 throw new IllegalArgumentException(e);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/ListType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ListType.java b/src/java/org/apache/cassandra/db/marshal/ListType.java
index f18fc00..c7b6817 100644
--- a/src/java/org/apache/cassandra/db/marshal/ListType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ListType.java
@@ -21,7 +21,8 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import org.apache.cassandra.db.IColumn;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
@@ -33,7 +34,7 @@ public class ListType<T> extends CollectionType<List<T>>
 
     public final AbstractType<T> elements;
 
-    public static ListType<?> getInstance(TypeParser parser) throws ConfigurationException
+    public static ListType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
         List<AbstractType<?>> l = parser.getTypeParameters();
         if (l.size() != 1)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/MapType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/MapType.java b/src/java/org/apache/cassandra/db/marshal/MapType.java
index 2ac65cf..54c130e 100644
--- a/src/java/org/apache/cassandra/db/marshal/MapType.java
+++ b/src/java/org/apache/cassandra/db/marshal/MapType.java
@@ -21,7 +21,8 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import org.apache.cassandra.db.IColumn;
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
@@ -34,7 +35,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
     public final AbstractType<K> keys;
     public final AbstractType<V> values;
 
-    public static MapType<?, ?> getInstance(TypeParser parser) throws ConfigurationException
+    public static MapType<?, ?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
         List<AbstractType<?>> l = parser.getTypeParameters();
         if (l.size() != 2)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a2faf94/src/java/org/apache/cassandra/db/marshal/ReversedType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index 131b978..d5db1e7 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -22,7 +22,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.List;
 
-import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.exceptions.SyntaxException;
 
 public class ReversedType<T> extends AbstractType<T>
 {
@@ -32,7 +33,7 @@ public class ReversedType<T> extends AbstractType<T>
     // package protected for unit tests sake
     final AbstractType<T> baseType;
 
-    public static <T> ReversedType<T> getInstance(TypeParser parser) throws ConfigurationException
+    public static <T> ReversedType<T> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
     {
         List<AbstractType<?>> types = parser.getTypeParameters();
         if (types.size() != 1)


Mime
View raw message