Author: jbellis
Date: Wed Aug 31 19:26:21 2011
New Revision: 1163753

URL: http://svn.apache.org/viewvc?rev=1163753&view=rev
Log:
merge from 0.8

Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/   (props changed)
    
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
   (props changed)
    
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
   (props changed)
    
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
   (props changed)
    
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
   (props changed)
    
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
   (props changed)
    cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/Bounds.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java
    
cassandra/trunk/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
    cassandra/trunk/src/java/org/apache/cassandra/service/ClientState.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7:1026516-1163266
+/cassandra/branches/cassandra-0.7:1026516-1163280
 /cassandra/branches/cassandra-0.7.0:1053690-1055654
-/cassandra/branches/cassandra-0.8:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8:1090934-1125013,1125019-1163752
 /cassandra/branches/cassandra-0.8.0:1125021-1130369
 /cassandra/branches/cassandra-0.8.1:1101014-1125018
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689

Modified: cassandra/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Wed Aug 31 19:26:21 2011
@@ -99,6 +99,10 @@
  * make repair report failure when a node participating dies (instead of
    hanging forever) (CASSANDRA-2433)
  * fix handling of the empty byte buffer by ReversedType (CASSANDRA-3111)
+ * Add validation that Keyspace names are case-insensitively unique 
(CASSANDRA-3066)
+ * catch invalid key_validation_class before instantiating UpdateColumnFamily 
(CASSANDRA-3102)
+ * make Range and Bounds objects client-safe (CASSANDRA-3108)
+ * optionally skip log4j configuration (CASSANDRA-3061)
 
 0.8.4
  * include files-to-be-streamed in StreamInSession.getSources (CASSANDRA-2972)

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/contrib:922689-1052356,1052358-1053452,1053454,1053456-1068009
-/cassandra/branches/cassandra-0.7/contrib:1026516-1163266
+/cassandra/branches/cassandra-0.7/contrib:1026516-1163280
 /cassandra/branches/cassandra-0.7.0/contrib:1053690-1055654
-/cassandra/branches/cassandra-0.8/contrib:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/contrib:1090934-1125013,1125019-1163752
 /cassandra/branches/cassandra-0.8.0/contrib:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/contrib:1101014-1125018
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689

Propchange: 
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1163266
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1163280
 
/cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090934-1125013,1125019-1163752
 
/cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1125021-1130369
 
/cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1101014-1125018
 
/cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689

Propchange: 
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1163266
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1163280
 
/cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090934-1125013,1125019-1163752
 
/cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1125021-1130369
 
/cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1101014-1125018
 
/cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689

Propchange: 
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1163266
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1163280
 
/cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090934-1125013,1125019-1163752
 
/cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1125021-1130369
 
/cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1101014-1125018
 
/cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689

Propchange: 
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1163266
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1163280
 
/cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090934-1125013,1125019-1163752
 
/cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1125021-1130369
 
/cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1101014-1125018
 
/cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689

Propchange: 
cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 31 19:26:21 2011
@@ -1,7 +1,7 @@
 
/cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1052356,1052358-1053452,1053454,1053456-1131291
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1163266
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1163280
 
/cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090934-1125013,1125019-1163272,1163677,1163695
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090934-1125013,1125019-1163752
 
/cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1125021-1130369
 
/cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1101014-1125018
 
/cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689

Modified: cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cql/QueryProcessor.java Wed 
Aug 31 19:26:21 2011
@@ -664,7 +664,7 @@ public class QueryProcessor
             case CREATE_KEYSPACE:
                 CreateKeyspaceStatement create = 
(CreateKeyspaceStatement)statement.statement;
                 create.validate();
-                clientState.hasKeyspaceListAccess(Permission.WRITE);
+                clientState.hasKeyspaceSchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 
                 try
@@ -674,6 +674,7 @@ public class QueryProcessor
                                           Collections.<CfDef>emptyList())
                                 
.setStrategy_options(create.getStrategyOptions());
                     ThriftValidation.validateKsDef(ksd);
+                    
ThriftValidation.validateKeyspaceNotYetExisting(create.getName());
                     applyMigrationOnStage(new 
AddKeyspace(KSMetaData.fromThrift(ksd)));
                 }
                 catch (ConfigurationException e)
@@ -694,7 +695,7 @@ public class QueryProcessor
                
             case CREATE_COLUMNFAMILY:
                 CreateColumnFamilyStatement createCf = 
(CreateColumnFamilyStatement)statement.statement;
-                clientState.hasColumnFamilyListAccess(Permission.WRITE);
+                clientState.hasColumnFamilySchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 
                 try
@@ -719,7 +720,7 @@ public class QueryProcessor
                 
             case CREATE_INDEX:
                 CreateIndexStatement createIdx = 
(CreateIndexStatement)statement.statement;
-                clientState.hasColumnFamilyListAccess(Permission.WRITE);
+                clientState.hasColumnFamilySchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 CFMetaData oldCfm = Schema.instance.getCFMetaData(keyspace, 
createIdx.getColumnFamily());
                 if (oldCfm == null)
@@ -779,7 +780,7 @@ public class QueryProcessor
 
             case DROP_INDEX:
                 DropIndexStatement dropIdx = 
(DropIndexStatement)statement.statement;
-                clientState.hasColumnFamilyListAccess(Permission.WRITE);
+                clientState.hasColumnFamilySchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
 
                 try
@@ -804,7 +805,7 @@ public class QueryProcessor
 
             case DROP_KEYSPACE:
                 String deleteKeyspace = (String)statement.statement;
-                clientState.hasKeyspaceListAccess(Permission.WRITE);
+                clientState.hasKeyspaceSchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                 
                 try
@@ -829,7 +830,7 @@ public class QueryProcessor
             
             case DROP_COLUMNFAMILY:
                 String deleteColumnFamily = (String)statement.statement;
-                clientState.hasColumnFamilyListAccess(Permission.WRITE);
+                clientState.hasColumnFamilySchemaAccess(Permission.WRITE);
                 validateSchemaAgreement();
                     
                 try

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/Bounds.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/Bounds.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/Bounds.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/Bounds.java Wed Aug 31 
19:26:21 2011
@@ -47,7 +47,7 @@ public class Bounds extends AbstractBoun
 
     public AbstractBounds createFrom(Token token)
     {
-        return new Bounds(left, token);
+        return new Bounds(left, token, partitioner);
     }
 
     public List<AbstractBounds> unwrap()

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/Range.java Wed Aug 31 
19:26:21 2011
@@ -146,7 +146,8 @@ public class Range extends AbstractBound
             if (!(left.compareTo(that.right) < 0 && that.left.compareTo(right) 
< 0))
                 return Collections.emptySet();
             return rangeSet(new Range((Token)ObjectUtils.max(this.left, 
that.left),
-                                      (Token)ObjectUtils.min(this.right, 
that.right)));
+                                      (Token)ObjectUtils.min(this.right, 
that.right),
+                                      partitioner));
         }
         if (thiswraps && thatwraps)
         {
@@ -174,8 +175,8 @@ public class Range extends AbstractBound
     {
         Set<Range> intersection = new HashSet<Range>(2);
         if (that.right.compareTo(first.left) > 0)
-            intersection.add(new Range(first.left, that.right));
-        intersection.add(new Range(that.left, first.right));
+            intersection.add(new Range(first.left, that.right, 
first.partitioner));
+        intersection.add(new Range(that.left, first.right, first.partitioner));
         return Collections.unmodifiableSet(intersection);
     }
 
@@ -183,10 +184,10 @@ public class Range extends AbstractBound
     {
         Set<Range> intersection = new HashSet<Range>(2);
         if (other.contains(wrapping.right))
-            intersection.add(new Range(other.left, wrapping.right));
+            intersection.add(new Range(other.left, wrapping.right, 
wrapping.partitioner));
         // need the extra compareto here because ranges are asymmetrical; 
wrapping.left _is not_ contained by the wrapping range
         if (other.contains(wrapping.left) && 
wrapping.left.compareTo(other.right) < 0)
-            intersection.add(new Range(wrapping.left, other.right));
+            intersection.add(new Range(wrapping.left, other.right, 
wrapping.partitioner));
         return Collections.unmodifiableSet(intersection);
     }
 
@@ -194,7 +195,7 @@ public class Range extends AbstractBound
     {
         if (token.equals(left))
             return null;
-        return new Range(left, token);
+        return new Range(left, token, partitioner);
     }
 
     public List<AbstractBounds> unwrap()
@@ -202,8 +203,8 @@ public class Range extends AbstractBound
         if (!isWrapAround() || right.equals(partitioner.getMinimumToken()))
             return (List)Arrays.asList(this);
         List<AbstractBounds> unwrapped = new ArrayList<AbstractBounds>(2);
-        unwrapped.add(new Range(left, partitioner.getMinimumToken()));
-        unwrapped.add(new Range(partitioner.getMinimumToken(), right));
+        unwrapped.add(new Range(left, partitioner.getMinimumToken(), 
partitioner));
+        unwrapped.add(new Range(partitioner.getMinimumToken(), right, 
partitioner));
         return unwrapped;
     }
 
@@ -272,9 +273,9 @@ public class Range extends AbstractBound
         ArrayList<Range> difference = new ArrayList<Range>();
 
         if (!left.equals(contained.left))
-            difference.add(new Range(left, contained.left));
+            difference.add(new Range(left, contained.left, partitioner));
         if (!right.equals(contained.right))
-            difference.add(new Range(contained.right, right));
+            difference.add(new Range(contained.right, right, partitioner));
         return difference;
     }
 

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- 
cassandra/trunk/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
 (original)
+++ 
cassandra/trunk/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
 Wed Aug 31 19:26:21 2011
@@ -61,40 +61,43 @@ public abstract class AbstractCassandraD
      */
     public static void initLog4j()
     {
-        String config = System.getProperty("log4j.configuration", 
"log4j-server.properties");
-        URL configLocation = null;
-        try
-        {
-            // try loading from a physical location first.
-            configLocation = new URL(config);
-        }
-        catch (MalformedURLException ex)
+        if 
(System.getProperty("log4j.defaultInitOverride","false").equalsIgnoreCase("true"))
         {
-            // then try loading from the classpath.
-            configLocation = 
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
-        }
+            String config = System.getProperty("log4j.configuration", 
"log4j-server.properties");
+            URL configLocation = null;
+            try
+            {
+                // try loading from a physical location first.
+                configLocation = new URL(config);
+            }
+            catch (MalformedURLException ex)
+            {
+                // then try loading from the classpath.
+                configLocation = 
AbstractCassandraDaemon.class.getClassLoader().getResource(config);
+            }
         
-        if (configLocation == null)
-            throw new RuntimeException("Couldn't figure out log4j 
configuration: "+config);
+            if (configLocation == null)
+                throw new RuntimeException("Couldn't figure out log4j 
configuration: "+config);
 
-        // Now convert URL to a filename
-        String configFileName = null;
-        try
-        {
-            // first try URL.getFile() which works for opaque URLs (file:foo) 
and paths without spaces
-            configFileName = configLocation.getFile();
-            File configFile = new File(configFileName);
-            // then try alternative approach which works for all hierarchical 
URLs with or without spaces
-            if (!configFile.exists())
-                configFileName = new 
File(configLocation.toURI()).getCanonicalPath();
-        }
-        catch (Exception e)
-        {
-            throw new RuntimeException("Couldn't convert log4j configuration 
location to a valid file", e);
-        }
+            // Now convert URL to a filename
+            String configFileName = null;
+            try
+            {
+                // first try URL.getFile() which works for opaque URLs 
(file:foo) and paths without spaces
+                configFileName = configLocation.getFile();
+                File configFile = new File(configFileName);
+                // then try alternative approach which works for all 
hierarchical URLs with or without spaces
+                if (!configFile.exists())
+                    configFileName = new 
File(configLocation.toURI()).getCanonicalPath();
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Couldn't convert log4j 
configuration location to a valid file", e);
+            }
 
-        PropertyConfigurator.configureAndWatch(configFileName, 10000);
-        
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging 
initialized");
+            PropertyConfigurator.configureAndWatch(configFileName, 10000);
+            
org.apache.log4j.Logger.getLogger(AbstractCassandraDaemon.class).info("Logging 
initialized");
+        }
     }
 
     private static Logger logger = 
LoggerFactory.getLogger(AbstractCassandraDaemon.class);

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/ClientState.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/ClientState.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/ClientState.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/ClientState.java Wed 
Aug 31 19:26:21 2011
@@ -30,6 +30,7 @@ import org.apache.cassandra.auth.Authent
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.auth.Resources;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.Table;
 import org.apache.cassandra.thrift.AuthenticationException;
 import org.apache.cassandra.thrift.InvalidRequestException;
 
@@ -111,7 +112,7 @@ public class ClientState
     /**
      * Confirms that the client thread has the given Permission for the 
Keyspace list.
      */
-    public void hasKeyspaceListAccess(Permission perm) throws 
InvalidRequestException
+    public void hasKeyspaceSchemaAccess(Permission perm) throws 
InvalidRequestException
     {
         validateLogin();
         
@@ -125,13 +126,13 @@ public class ClientState
      * Confirms that the client thread has the given Permission for the 
ColumnFamily list of
      * the current keyspace.
      */
-    public void hasColumnFamilyListAccess(Permission perm) throws 
InvalidRequestException
+    public void hasColumnFamilySchemaAccess(Permission perm) throws 
InvalidRequestException
     {
         validateLogin();
         validateKeyspace();
 
         // hardcode disallowing messing with system keyspace
-        if (keyspace.equalsIgnoreCase("system"))
+        if (keyspace.equalsIgnoreCase(Table.SYSTEM_TABLE) && perm == 
Permission.WRITE)
             throw new InvalidRequestException("system keyspace is not 
user-modifiable");
 
         resourceClear();

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java 
Wed Aug 31 19:26:21 2011
@@ -647,7 +647,7 @@ public class CassandraServer implements 
 
     public KsDef describe_keyspace(String table) throws NotFoundException, 
InvalidRequestException
     {
-        state().hasKeyspaceListAccess(Permission.READ);
+        state().hasKeyspaceSchemaAccess(Permission.READ);
 
         KSMetaData ksm = Schema.instance.getTableDefinition(table);
         if (ksm == null)
@@ -752,7 +752,7 @@ public class CassandraServer implements 
 
     public List<KsDef> describe_keyspaces() throws TException, 
InvalidRequestException
     {
-        state().hasKeyspaceListAccess(Permission.READ);
+        state().hasKeyspaceSchemaAccess(Permission.READ);
 
         Set<String> keyspaces = Schema.instance.getTables();
         List<KsDef> ksset = new ArrayList<KsDef>();
@@ -873,7 +873,7 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("add_column_family");
-        state().hasColumnFamilyListAccess(Permission.WRITE);
+        state().hasColumnFamilySchemaAccess(Permission.WRITE);
         CFMetaData.addDefaultIndexNames(cf_def);
         ThriftValidation.validateCfDef(cf_def, null);
         validateSchemaAgreement();
@@ -901,7 +901,7 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("drop_column_family");
-        state().hasColumnFamilyListAccess(Permission.WRITE);
+        state().hasColumnFamilySchemaAccess(Permission.WRITE);
         validateSchemaAgreement();
         
         try
@@ -927,9 +927,10 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("add_keyspace");
-        state().hasKeyspaceListAccess(Permission.WRITE);
+        state().hasKeyspaceSchemaAccess(Permission.WRITE);
         validateSchemaAgreement();
-        
+        ThriftValidation.validateKeyspaceNotYetExisting(ks_def.name);
+
         // generate a meaningful error if the user setup keyspace and/or 
column definition incorrectly
         for (CfDef cf : ks_def.cf_defs) 
         {
@@ -971,7 +972,7 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("drop_keyspace");
-        state().hasKeyspaceListAccess(Permission.WRITE);
+        state().hasKeyspaceSchemaAccess(Permission.WRITE);
         validateSchemaAgreement();
         
         try
@@ -999,7 +1000,7 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("update_keyspace");
-        state().hasKeyspaceListAccess(Permission.WRITE);
+        state().hasKeyspaceSchemaAccess(Permission.WRITE);
         ThriftValidation.validateTable(ks_def.name);
         if (ks_def.getCf_defs() != null && ks_def.getCf_defs().size() > 0)
             throw new InvalidRequestException("Keyspace update must not 
contain any column family definitions.");
@@ -1029,7 +1030,7 @@ public class CassandraServer implements 
     throws InvalidRequestException, SchemaDisagreementException, TException
     {
         logger.debug("update_column_family");
-        state().hasColumnFamilyListAccess(Permission.WRITE);
+        state().hasColumnFamilySchemaAccess(Permission.WRITE);
         if (cf_def.keyspace == null || cf_def.name == null)
             throw new InvalidRequestException("Keyspace and CF name must be 
set.");
         CFMetaData oldCfm = Schema.instance.getCFMetaData(cf_def.keyspace, 
cf_def.name);

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1163753&r1=1163752&r2=1163753&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java 
Wed Aug 31 19:26:21 2011
@@ -562,6 +562,7 @@ public class ThriftValidation
             if (cfType == null)
                 throw new InvalidRequestException("invalid column type " + 
cf_def.column_type);
 
+            TypeParser.parse(cf_def.key_validation_class);
             TypeParser.parse(cf_def.comparator_type);
             TypeParser.parse(cf_def.subcomparator_type);
             TypeParser.parse(cf_def.default_validation_class);
@@ -718,4 +719,16 @@ public class ThriftValidation
         if (cf_def.isSetMemtable_operations_in_millions())
             
DatabaseDescriptor.validateMemtableOperations(cf_def.memtable_operations_in_millions);
     }
+
+    public static void validateKeyspaceNotYetExisting(String newKsName) throws 
InvalidRequestException
+    {
+        // keyspace names must be unique case-insensitively because the 
keyspace name becomes the directory
+        // where we store CF sstables.  Names that differ only in case would 
thus cause problems on
+        // case-insensitive filesystems (NTFS, most installations of HFS+).
+        for (String ksName : DatabaseDescriptor.getTables())
+        {
+            if (ksName.equalsIgnoreCase(newKsName))
+                throw new InvalidRequestException("Keyspace names must be 
case-insensitively unique");
+        }
+    }
 }


Reply via email to