cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject svn commit: r944044 - in /cassandra/trunk: interface/cassandra.avpr interface/cassandra.genavro src/java/org/apache/cassandra/avro/CassandraServer.java test/system/test_avro_server.py
Date Thu, 13 May 2010 22:58:58 GMT
Author: eevans
Date: Thu May 13 22:58:58 2010
New Revision: 944044

URL: http://svn.apache.org/viewvc?rev=944044&view=rev
Log:
describe_keyspaces() for avro

Patch by eevans

Modified:
    cassandra/trunk/interface/cassandra.avpr
    cassandra/trunk/interface/cassandra.genavro
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
    cassandra/trunk/test/system/test_avro_server.py

Modified: cassandra/trunk/interface/cassandra.avpr
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/cassandra.avpr?rev=944044&r1=944043&r2=944044&view=diff
==============================================================================
--- cassandra/trunk/interface/cassandra.avpr (original)
+++ cassandra/trunk/interface/cassandra.avpr Thu May 13 22:58:58 2010
@@ -182,6 +182,11 @@
         "request": [{"name": "keyspace", "type": "string"}],
         "response": "null",
         "errors": ["InvalidRequestException"]
+    },
+    "describe_keyspaces": {
+        "request": [],
+        "response": {"type": "array", "items": "string"},
+        "errors": []
     }
   }
 }

Modified: cassandra/trunk/interface/cassandra.genavro
URL: http://svn.apache.org/viewvc/cassandra/trunk/interface/cassandra.genavro?rev=944044&r1=944043&r2=944044&view=diff
==============================================================================
--- cassandra/trunk/interface/cassandra.genavro (original)
+++ cassandra/trunk/interface/cassandra.genavro Thu May 13 22:58:58 2010
@@ -127,4 +127,6 @@ protocol Cassandra {
     void system_add_keyspace(KsDef ks_def) throws InvalidRequestException;
 
     void set_keyspace(string keyspace) throws InvalidRequestException;
+
+    array<string> describe_keyspaces();
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java?rev=944044&r1=944043&r2=944044&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Thu May 13 22:58:58
2010
@@ -30,6 +30,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeoutException;
 import org.apache.avro.Schema;
 import org.apache.avro.generic.GenericArray;
@@ -551,4 +552,17 @@ public class CassandraServer implements 
         
         return null;
     }
+
+    @Override
+    public GenericArray<Utf8> describe_keyspaces() throws AvroRemoteException
+    {
+        Set<String> keyspaces = DatabaseDescriptor.getTables();
+        Schema schema = Schema.createArray(Schema.create(Schema.Type.STRING));
+        GenericArray<Utf8> avroResults = new GenericData.Array<Utf8>(keyspaces.size(),
schema);
+        
+        for (String ksp : keyspaces)
+            avroResults.add(new Utf8(ksp));
+        
+        return avroResults;
+    }
 }

Modified: cassandra/trunk/test/system/test_avro_server.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_server.py?rev=944044&r1=944043&r2=944044&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_server.py (original)
+++ cassandra/trunk/test/system/test_avro_server.py Thu May 13 22:58:58 2010
@@ -91,6 +91,11 @@ class TestRpcOperations(AvroTester):
         assert_cosc(cosc)
         assert_columns_match(cosc['column'], params['column'])
 
+    def test_describe_keyspaces(self):
+        "retrieving a list of all keyspaces"
+        keyspaces = self.client.request('describe_keyspaces', {})
+        assert 'Keyspace1' in keyspaces, "Keyspace1 not in " + keyspaces
+
     def test_get_api_version(self):
         "getting the remote api version string"
         vers = self.client.request('get_api_version', {})



Mime
View raw message