cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r1002402 - in /cassandra/trunk: interface/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/cli/ src/java/org/apache/cassandra/hadoop/ src/java/org/apache/cassandra/thrift/
Date Tue, 28 Sep 2010 23:01:03 GMT
Author: eevans
Date: Tue Sep 28 23:01:03 2010
New Revision: 1002402

URL: http://svn.apache.org/viewvc?rev=1002402&view=rev
Log:
Add authorization to describe_keyspace(s) and change Thrift exceptions.

Patch by Stu Hood; reviewed by eevans for CASSANDRA-1271

Modified:
    cassandra/trunk/interface/cassandra.thrift
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
    cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java

Modified: cassandra/trunk/interface/cassandra.thrift
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/cassandra.thrift?rev=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/interface/cassandra.thrift (original)
+++ cassandra/trunk/interface/cassandra.thrift Tue Sep 28 23:01:03 2010
@@ -46,7 +46,7 @@ namespace rb CassandraThrift
 #           for every edit that doesn't result in a change to major/minor.
 #
 # See the Semantic Versioning Specification (SemVer) http://semver.org.
-const string VERSION = "17.1.0"
+const string VERSION = "18.1.0"
 
 
 #
@@ -482,7 +482,8 @@ service Cassandra {
        throws (1: InvalidRequestException ire),
 
   /** list the defined keyspaces in this cluster */
-  list<KsDef> describe_keyspaces(),
+  list<KsDef> describe_keyspaces()
+    throws (1:InvalidRequestException ire),
 
   /** get the cluster name */
   string describe_cluster_name(),
@@ -509,7 +510,7 @@ service Cassandra {
 
   /** describe specified keyspace */
   KsDef describe_keyspace(1:required string keyspace)
-        throws (1:NotFoundException nfe),
+    throws (1:NotFoundException nfe, 2:InvalidRequestException ire),
 
   /** experimental API for hadoop/parallel query support.  
       may change violently and without warning. 

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java?rev=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java Tue
Sep 28 23:01:03 2010
@@ -182,7 +182,7 @@ public class Cassandra {
     /**
      * list the defined keyspaces in this cluster
      */
-    public List<KsDef> describe_keyspaces() throws TException;
+    public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException;
 
     /**
      * get the cluster name
@@ -223,7 +223,7 @@ public class Cassandra {
      * 
      * @param keyspace
      */
-    public KsDef describe_keyspace(String keyspace) throws NotFoundException, TException;
+    public KsDef describe_keyspace(String keyspace) throws NotFoundException, InvalidRequestException,
TException;
 
     /**
      * experimental API for hadoop/parallel query support.
@@ -1023,7 +1023,7 @@ public class Cassandra {
       throw new TApplicationException(TApplicationException.MISSING_RESULT, "describe_schema_versions
failed: unknown result");
     }
 
-    public List<KsDef> describe_keyspaces() throws TException
+    public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException
     {
       send_describe_keyspaces();
       return recv_describe_keyspaces();
@@ -1038,7 +1038,7 @@ public class Cassandra {
       oprot_.getTransport().flush();
     }
 
-    public List<KsDef> recv_describe_keyspaces() throws TException
+    public List<KsDef> recv_describe_keyspaces() throws InvalidRequestException, TException
     {
       TMessage msg = iprot_.readMessageBegin();
       if (msg.type == TMessageType.EXCEPTION) {
@@ -1055,6 +1055,9 @@ public class Cassandra {
       if (result.isSetSuccess()) {
         return result.success;
       }
+      if (result.ire != null) {
+        throw result.ire;
+      }
       throw new TApplicationException(TApplicationException.MISSING_RESULT, "describe_keyspaces
failed: unknown result");
     }
 
@@ -1237,7 +1240,7 @@ public class Cassandra {
       throw new TApplicationException(TApplicationException.MISSING_RESULT, "describe_snitch
failed: unknown result");
     }
 
-    public KsDef describe_keyspace(String keyspace) throws NotFoundException, TException
+    public KsDef describe_keyspace(String keyspace) throws NotFoundException, InvalidRequestException,
TException
     {
       send_describe_keyspace(keyspace);
       return recv_describe_keyspace();
@@ -1253,7 +1256,7 @@ public class Cassandra {
       oprot_.getTransport().flush();
     }
 
-    public KsDef recv_describe_keyspace() throws NotFoundException, TException
+    public KsDef recv_describe_keyspace() throws NotFoundException, InvalidRequestException,
TException
     {
       TMessage msg = iprot_.readMessageBegin();
       if (msg.type == TMessageType.EXCEPTION) {
@@ -1273,6 +1276,9 @@ public class Cassandra {
       if (result.nfe != null) {
         throw result.nfe;
       }
+      if (result.ire != null) {
+        throw result.ire;
+      }
       throw new TApplicationException(TApplicationException.MISSING_RESULT, "describe_keyspace
failed: unknown result");
     }
 
@@ -2177,7 +2183,7 @@ public class Cassandra {
         prot.writeMessageEnd();
       }
 
-      public List<KsDef> getResult() throws TException {
+      public List<KsDef> getResult() throws InvalidRequestException, TException {
         if (getState() != State.RESPONSE_READ) {
           throw new IllegalStateException("Method call not finished!");
         }
@@ -2351,7 +2357,7 @@ public class Cassandra {
         prot.writeMessageEnd();
       }
 
-      public KsDef getResult() throws NotFoundException, TException {
+      public KsDef getResult() throws NotFoundException, InvalidRequestException, TException
{
         if (getState() != State.RESPONSE_READ) {
           throw new IllegalStateException("Method call not finished!");
         }
@@ -3315,7 +3321,19 @@ public class Cassandra {
         }
         iprot.readMessageEnd();
         describe_keyspaces_result result = new describe_keyspaces_result();
-        result.success = iface_.describe_keyspaces();
+        try {
+          result.success = iface_.describe_keyspaces();
+        } catch (InvalidRequestException ire) {
+          result.ire = ire;
+        } catch (Throwable th) {
+          LOGGER.error("Internal error processing describe_keyspaces", th);
+          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR,
"Internal error processing describe_keyspaces");
+          oprot.writeMessageBegin(new TMessage("describe_keyspaces", TMessageType.EXCEPTION,
seqid));
+          x.write(oprot);
+          oprot.writeMessageEnd();
+          oprot.getTransport().flush();
+          return;
+        }
         oprot.writeMessageBegin(new TMessage("describe_keyspaces", TMessageType.REPLY, seqid));
         result.write(oprot);
         oprot.writeMessageEnd();
@@ -3487,6 +3505,8 @@ public class Cassandra {
           result.success = iface_.describe_keyspace(args.keyspace);
         } catch (NotFoundException nfe) {
           result.nfe = nfe;
+        } catch (InvalidRequestException ire) {
+          result.ire = ire;
         } catch (Throwable th) {
           LOGGER.error("Internal error processing describe_keyspace", th);
           TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR,
"Internal error processing describe_keyspace");
@@ -18228,12 +18248,15 @@ public class Cassandra {
     private static final TStruct STRUCT_DESC = new TStruct("describe_keyspaces_result");
 
     private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
+    private static final TField IRE_FIELD_DESC = new TField("ire", TType.STRUCT, (short)1);
 
     public List<KsDef> success;
+    public InvalidRequestException ire;
 
     /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
     public enum _Fields implements TFieldIdEnum {
-      SUCCESS((short)0, "success");
+      SUCCESS((short)0, "success"),
+      IRE((short)1, "ire");
 
       private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -18250,6 +18273,8 @@ public class Cassandra {
         switch(fieldId) {
           case 0: // SUCCESS
             return SUCCESS;
+          case 1: // IRE
+            return IRE;
           default:
             return null;
         }
@@ -18297,6 +18322,8 @@ public class Cassandra {
       tmpMap.put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,

           new ListMetaData(TType.LIST, 
               new StructMetaData(TType.STRUCT, KsDef.class))));
+      tmpMap.put(_Fields.IRE, new FieldMetaData("ire", TFieldRequirementType.DEFAULT, 
+          new FieldValueMetaData(TType.STRUCT)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
       FieldMetaData.addStructMetaDataMap(describe_keyspaces_result.class, metaDataMap);
     }
@@ -18305,10 +18332,12 @@ public class Cassandra {
     }
 
     public describe_keyspaces_result(
-      List<KsDef> success)
+      List<KsDef> success,
+      InvalidRequestException ire)
     {
       this();
       this.success = success;
+      this.ire = ire;
     }
 
     /**
@@ -18322,6 +18351,9 @@ public class Cassandra {
         }
         this.success = __this__success;
       }
+      if (other.isSetIre()) {
+        this.ire = new InvalidRequestException(other.ire);
+      }
     }
 
     public describe_keyspaces_result deepCopy() {
@@ -18372,6 +18404,30 @@ public class Cassandra {
       }
     }
 
+    public InvalidRequestException getIre() {
+      return this.ire;
+    }
+
+    public describe_keyspaces_result setIre(InvalidRequestException ire) {
+      this.ire = ire;
+      return this;
+    }
+
+    public void unsetIre() {
+      this.ire = null;
+    }
+
+    /** Returns true if field ire is set (has been asigned a value) and false otherwise */
+    public boolean isSetIre() {
+      return this.ire != null;
+    }
+
+    public void setIreIsSet(boolean value) {
+      if (!value) {
+        this.ire = null;
+      }
+    }
+
     public void setFieldValue(_Fields field, Object value) {
       switch (field) {
       case SUCCESS:
@@ -18382,6 +18438,14 @@ public class Cassandra {
         }
         break;
 
+      case IRE:
+        if (value == null) {
+          unsetIre();
+        } else {
+          setIre((InvalidRequestException)value);
+        }
+        break;
+
       }
     }
 
@@ -18394,6 +18458,9 @@ public class Cassandra {
       case SUCCESS:
         return getSuccess();
 
+      case IRE:
+        return getIre();
+
       }
       throw new IllegalStateException();
     }
@@ -18407,6 +18474,8 @@ public class Cassandra {
       switch (field) {
       case SUCCESS:
         return isSetSuccess();
+      case IRE:
+        return isSetIre();
       }
       throw new IllegalStateException();
     }
@@ -18437,6 +18506,15 @@ public class Cassandra {
           return false;
       }
 
+      boolean this_present_ire = true && this.isSetIre();
+      boolean that_present_ire = true && that.isSetIre();
+      if (this_present_ire || that_present_ire) {
+        if (!(this_present_ire && that_present_ire))
+          return false;
+        if (!this.ire.equals(that.ire))
+          return false;
+      }
+
       return true;
     }
 
@@ -18449,6 +18527,11 @@ public class Cassandra {
       if (present_success)
         builder.append(success);
 
+      boolean present_ire = true && (isSetIre());
+      builder.append(present_ire);
+      if (present_ire)
+        builder.append(ire);
+
       return builder.toHashCode();
     }
 
@@ -18469,6 +18552,15 @@ public class Cassandra {
           return lastComparison;
         }
       }
+      lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIre()) {        lastComparison = TBaseHelper.compareTo(this.ire, typedOther.ire);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
@@ -18500,6 +18592,14 @@ public class Cassandra {
               TProtocolUtil.skip(iprot, field.type);
             }
             break;
+          case 1: // IRE
+            if (field.type == TType.STRUCT) {
+              this.ire = new InvalidRequestException();
+              this.ire.read(iprot);
+            } else { 
+              TProtocolUtil.skip(iprot, field.type);
+            }
+            break;
           default:
             TProtocolUtil.skip(iprot, field.type);
         }
@@ -18525,6 +18625,10 @@ public class Cassandra {
           oprot.writeListEnd();
         }
         oprot.writeFieldEnd();
+      } else if (this.isSetIre()) {
+        oprot.writeFieldBegin(IRE_FIELD_DESC);
+        this.ire.write(oprot);
+        oprot.writeFieldEnd();
       }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
@@ -18542,6 +18646,14 @@ public class Cassandra {
         sb.append(this.success);
       }
       first = false;
+      if (!first) sb.append(", ");
+      sb.append("ire:");
+      if (this.ire == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ire);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -21497,14 +21609,17 @@ public class Cassandra {
 
     private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT,
(short)0);
     private static final TField NFE_FIELD_DESC = new TField("nfe", TType.STRUCT, (short)1);
+    private static final TField IRE_FIELD_DESC = new TField("ire", TType.STRUCT, (short)2);
 
     public KsDef success;
     public NotFoundException nfe;
+    public InvalidRequestException ire;
 
     /** The set of fields this struct contains, along with convenience methods for finding
and manipulating them. */
     public enum _Fields implements TFieldIdEnum {
       SUCCESS((short)0, "success"),
-      NFE((short)1, "nfe");
+      NFE((short)1, "nfe"),
+      IRE((short)2, "ire");
 
       private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -21523,6 +21638,8 @@ public class Cassandra {
             return SUCCESS;
           case 1: // NFE
             return NFE;
+          case 2: // IRE
+            return IRE;
           default:
             return null;
         }
@@ -21571,6 +21688,8 @@ public class Cassandra {
           new StructMetaData(TType.STRUCT, KsDef.class)));
       tmpMap.put(_Fields.NFE, new FieldMetaData("nfe", TFieldRequirementType.DEFAULT, 
           new FieldValueMetaData(TType.STRUCT)));
+      tmpMap.put(_Fields.IRE, new FieldMetaData("ire", TFieldRequirementType.DEFAULT, 
+          new FieldValueMetaData(TType.STRUCT)));
       metaDataMap = Collections.unmodifiableMap(tmpMap);
       FieldMetaData.addStructMetaDataMap(describe_keyspace_result.class, metaDataMap);
     }
@@ -21580,11 +21699,13 @@ public class Cassandra {
 
     public describe_keyspace_result(
       KsDef success,
-      NotFoundException nfe)
+      NotFoundException nfe,
+      InvalidRequestException ire)
     {
       this();
       this.success = success;
       this.nfe = nfe;
+      this.ire = ire;
     }
 
     /**
@@ -21597,6 +21718,9 @@ public class Cassandra {
       if (other.isSetNfe()) {
         this.nfe = new NotFoundException(other.nfe);
       }
+      if (other.isSetIre()) {
+        this.ire = new InvalidRequestException(other.ire);
+      }
     }
 
     public describe_keyspace_result deepCopy() {
@@ -21656,6 +21780,30 @@ public class Cassandra {
       }
     }
 
+    public InvalidRequestException getIre() {
+      return this.ire;
+    }
+
+    public describe_keyspace_result setIre(InvalidRequestException ire) {
+      this.ire = ire;
+      return this;
+    }
+
+    public void unsetIre() {
+      this.ire = null;
+    }
+
+    /** Returns true if field ire is set (has been asigned a value) and false otherwise */
+    public boolean isSetIre() {
+      return this.ire != null;
+    }
+
+    public void setIreIsSet(boolean value) {
+      if (!value) {
+        this.ire = null;
+      }
+    }
+
     public void setFieldValue(_Fields field, Object value) {
       switch (field) {
       case SUCCESS:
@@ -21674,6 +21822,14 @@ public class Cassandra {
         }
         break;
 
+      case IRE:
+        if (value == null) {
+          unsetIre();
+        } else {
+          setIre((InvalidRequestException)value);
+        }
+        break;
+
       }
     }
 
@@ -21689,6 +21845,9 @@ public class Cassandra {
       case NFE:
         return getNfe();
 
+      case IRE:
+        return getIre();
+
       }
       throw new IllegalStateException();
     }
@@ -21704,6 +21863,8 @@ public class Cassandra {
         return isSetSuccess();
       case NFE:
         return isSetNfe();
+      case IRE:
+        return isSetIre();
       }
       throw new IllegalStateException();
     }
@@ -21743,6 +21904,15 @@ public class Cassandra {
           return false;
       }
 
+      boolean this_present_ire = true && this.isSetIre();
+      boolean that_present_ire = true && that.isSetIre();
+      if (this_present_ire || that_present_ire) {
+        if (!(this_present_ire && that_present_ire))
+          return false;
+        if (!this.ire.equals(that.ire))
+          return false;
+      }
+
       return true;
     }
 
@@ -21760,6 +21930,11 @@ public class Cassandra {
       if (present_nfe)
         builder.append(nfe);
 
+      boolean present_ire = true && (isSetIre());
+      builder.append(present_ire);
+      if (present_ire)
+        builder.append(ire);
+
       return builder.toHashCode();
     }
 
@@ -21789,6 +21964,15 @@ public class Cassandra {
           return lastComparison;
         }
       }
+      lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIre()) {        lastComparison = TBaseHelper.compareTo(this.ire, typedOther.ire);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
@@ -21818,6 +22002,14 @@ public class Cassandra {
               TProtocolUtil.skip(iprot, field.type);
             }
             break;
+          case 2: // IRE
+            if (field.type == TType.STRUCT) {
+              this.ire = new InvalidRequestException();
+              this.ire.read(iprot);
+            } else { 
+              TProtocolUtil.skip(iprot, field.type);
+            }
+            break;
           default:
             TProtocolUtil.skip(iprot, field.type);
         }
@@ -21840,6 +22032,10 @@ public class Cassandra {
         oprot.writeFieldBegin(NFE_FIELD_DESC);
         this.nfe.write(oprot);
         oprot.writeFieldEnd();
+      } else if (this.isSetIre()) {
+        oprot.writeFieldBegin(IRE_FIELD_DESC);
+        this.ire.write(oprot);
+        oprot.writeFieldEnd();
       }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
@@ -21865,6 +22061,14 @@ public class Cassandra {
         sb.append(this.nfe);
       }
       first = false;
+      if (!first) sb.append(", ");
+      sb.append("ire:");
+      if (this.ire == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ire);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }

Modified: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java?rev=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java (original)
+++ cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java Tue
Sep 28 23:01:03 2010
@@ -43,6 +43,6 @@ import org.slf4j.LoggerFactory;
 
 public class Constants {
 
-  public static final String VERSION = "17.1.0";
+  public static final String VERSION = "18.1.0";
 
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java?rev=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/cli/CliClient.java Tue Sep 28 23:01:03 2010
@@ -362,7 +362,7 @@ public class CliClient 
         System.exit(0);
     }
     
-    KsDef getKSMetaData(String keyspace) throws NotFoundException, TException
+    KsDef getKSMetaData(String keyspace) throws NotFoundException, InvalidRequestException,
TException
     {
         // Lazily lookup keyspace meta-data.
         if (!(keyspacesMap.containsKey(keyspace)))
@@ -869,7 +869,7 @@ public class CliClient 
     }
 
     // process "show tables" statement
-    private void executeShowTables(CommonTree ast) throws TException
+    private void executeShowTables(CommonTree ast) throws TException, InvalidRequestException
     {
         if (!CliMain.isConnected())
             return;
@@ -895,7 +895,7 @@ public class CliClient 
         return keySpace == null ? "unknown" : keySpace;
     }
     
-    public void setKeyspace(String keySpace) throws NotFoundException, TException 
+    public void setKeyspace(String keySpace) throws NotFoundException, InvalidRequestException,
TException 
     {
         this.keySpace = keySpace;
         //We do nothing with the return value, but it hits a cache and
@@ -1032,6 +1032,10 @@ public class CliClient 
                 css_.out.println("    }");
             }
         }
+        catch (InvalidRequestException e)
+        {
+            css_.out.println("Invalid request: " + e);
+        }
         catch (NotFoundException e)
         {
             css_.out.println("Keyspace " + tableName + " could not be found.");

Modified: cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java?rev=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java Tue
Sep 28 23:01:03 2010
@@ -210,9 +210,9 @@ public class ColumnFamilyRecordReader ex
             {
                 throw new RuntimeException("error communicating via Thrift", e);
             }
-            catch (NotFoundException e)
+            catch (Exception e)
             {
-                throw new RuntimeException("server reports no such keyspace " + keyspace,
e);
+                throw new RuntimeException("unable to load keyspace " + keyspace, e);
             }
         }
 

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=1002402&r1=1002401&r2=1002402&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Sep 28 23:01:03
2010
@@ -456,8 +456,10 @@ public class CassandraServer implements 
         }
     }
 
-    public KsDef describe_keyspace(String table) throws NotFoundException
+    public KsDef describe_keyspace(String table) throws NotFoundException, InvalidRequestException
     {
+        state().hasKeyspaceListAccess(Permission.READ);
+        
         KSMetaData ksm = DatabaseDescriptor.getTableDefinition(table);
         if (ksm == null)
             throw new NotFoundException();
@@ -560,15 +562,20 @@ public class CassandraServer implements 
         return thriftifyKeySlices(rows, column_parent, column_predicate);
     }
 
-    public List<KsDef> describe_keyspaces() throws TException
+    public List<KsDef> describe_keyspaces() throws TException, InvalidRequestException
     {
+        state().hasKeyspaceListAccess(Permission.READ);
+        
         Set<String> keyspaces = DatabaseDescriptor.getTables();
         List<KsDef> ksset = new ArrayList<KsDef>();
-        for (String ks : keyspaces) {
-            try {
+        for (String ks : keyspaces)
+        {
+            try
+            {
                 ksset.add(describe_keyspace(ks));
             }
-            catch (NotFoundException nfe) {
+            catch (NotFoundException nfe)
+            {
                 logger.info("Failed to find metadata for keyspace '" + ks + "'. Continuing...
");
             }
         }
@@ -614,6 +621,7 @@ public class CassandraServer implements 
 
     public List<String> describe_splits(String cfName, String start_token, String end_token,
int keys_per_split) throws TException
     {
+        // TODO: add keyspace authorization call post CASSANDRA-1425
         Token.TokenFactory tf = StorageService.getPartitioner().getTokenFactory();
         List<Token> tokens = StorageService.instance.getSplits(state().getKeyspace(),
cfName, new Range(tf.fromString(start_token), tf.fromString(end_token)), keys_per_split);
         List<String> splits = new ArrayList<String>(tokens.size());



Mime
View raw message