You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by gd...@apache.org on 2010/10/19 16:23:35 UTC

svn commit: r1024243 - in /cassandra/trunk: src/java/org/apache/cassandra/avro/CassandraServer.java src/java/org/apache/cassandra/thrift/CassandraServer.java test/system/test_avro_system.py test/system/test_thrift_server.py

Author: gdusbabek
Date: Tue Oct 19 14:23:34 2010
New Revision: 1024243

URL: http://svn.apache.org/viewvc?rev=1024243&view=rev
Log:
remove system_rename* methods from API. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1
630

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/trunk/test/system/test_avro_system.py
    cassandra/trunk/test/system/test_thrift_server.py

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=1024243&r1=1024242&r2=1024243&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Tue Oct 19 14:23:34 2010
@@ -881,26 +881,6 @@ public class CassandraServer implements 
         return ksDef;
     }
 
-    public CharSequence system_rename_column_family(CharSequence old_name, CharSequence new_name)
-    throws AvroRemoteException, InvalidRequestException
-    {
-        checkKeyspaceAndLoginAuthorized(Permission.WRITE);
-        
-        try
-        {
-            applyMigrationOnStage(new RenameColumnFamily(state().getKeyspace(), old_name.toString(), new_name.toString()));
-            return DatabaseDescriptor.getDefsVersion().toString();
-        }
-        catch (ConfigurationException e)
-        {
-            throw newInvalidRequestException(e);
-        }
-        catch (IOException e)
-        {
-            throw newInvalidRequestException(e);
-        }
-    }
-
     public CharSequence system_drop_column_family(CharSequence column_family) throws AvroRemoteException, InvalidRequestException
     {
         checkKeyspaceAndLoginAuthorized(Permission.WRITE);
@@ -940,25 +920,6 @@ public class CassandraServer implements 
         }
     }
 
-    public CharSequence system_rename_keyspace(CharSequence old_name, CharSequence new_name) throws AvroRemoteException, InvalidRequestException
-    {
-        checkKeyspaceAndLoginAuthorized(Permission.WRITE);
-        
-        try
-        {
-            applyMigrationOnStage(new RenameKeyspace(old_name.toString(), new_name.toString()));
-            return DatabaseDescriptor.getDefsVersion().toString();
-        }
-        catch (ConfigurationException e)
-        {
-            throw newInvalidRequestException(e);
-        }
-        catch (IOException e)
-        {
-            throw newInvalidRequestException(e);
-        }
-    }
-
     public CharSequence describe_partitioner() throws AvroRemoteException
     {
         return StorageService.getPartitioner().getClass().getName();

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=1024243&r1=1024242&r2=1024243&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Oct 19 14:23:34 2010
@@ -727,29 +727,6 @@ public class CassandraServer implements 
         }
     }
 
-    public String system_rename_column_family(String old_name, String new_name) throws InvalidRequestException, TException
-    {
-        state().hasColumnFamilyListAccess(Permission.WRITE);
-        
-        try
-        {
-            applyMigrationOnStage(new RenameColumnFamily(state().getKeyspace(), old_name, new_name));
-            return DatabaseDescriptor.getDefsVersion().toString();
-        }
-        catch (ConfigurationException e)
-        {
-            InvalidRequestException ex = new InvalidRequestException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        }
-        catch (IOException e)
-        {
-            InvalidRequestException ex = new InvalidRequestException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        }
-    }
-
     public String system_add_keyspace(KsDef ks_def) throws InvalidRequestException, TException
     {
         state().hasKeyspaceListAccess(Permission.WRITE);
@@ -816,29 +793,6 @@ public class CassandraServer implements 
         }
     }
 
-    public String system_rename_keyspace(String old_name, String new_name) throws InvalidRequestException, TException
-    {
-        state().hasKeyspaceListAccess(Permission.WRITE);
-        
-        try
-        {
-            applyMigrationOnStage(new RenameKeyspace(old_name, new_name));
-            return DatabaseDescriptor.getDefsVersion().toString();
-        }
-        catch (ConfigurationException e)
-        {
-            InvalidRequestException ex = new InvalidRequestException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        }
-        catch (IOException e)
-        {
-            InvalidRequestException ex = new InvalidRequestException(e.getMessage());
-            ex.initCause(e);
-            throw ex;
-        }
-    }
-
     /** update an existing keyspace, but do not allow column family modifications. */
     public String system_update_keyspace(KsDef ks_def) throws InvalidRequestException, TException
     {

Modified: cassandra/trunk/test/system/test_avro_system.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_avro_system.py?rev=1024243&r1=1024242&r2=1024243&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_avro_system.py (original)
+++ cassandra/trunk/test/system/test_avro_system.py Tue Oct 19 14:23:34 2010
@@ -67,23 +67,13 @@ class TestSystemOperations(AvroTester):
         assert modks['replication_factor'] == modified_keyspace['replication_factor']
         assert modks['strategy_class'] == modified_keyspace['strategy_class']
         
-        # rename
-        self.client.request('set_keyspace', {'keyspace' : 'CreateKeyspace'})
-        s = self.client.request(
-                'system_rename_keyspace', {'old_name' : 'CreateKeyspace', 'new_name' : 'RenameKeyspace'})
-        assert isinstance(s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
-        renameks = self.client.request('describe_keyspace',
-                {'keyspace': 'RenameKeyspace'})
-        assert renameks['name'] == 'RenameKeyspace'
-        assert renameks['cf_defs'][0]['name'] == 'CreateKsCf'
-        
         # drop
-        s = self.client.request('system_drop_keyspace', {'keyspace' : 'RenameKeyspace'})
+        s = self.client.request('system_drop_keyspace', {'keyspace' : 'CreateKeyspace'})
         assert isinstance(s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
         avro_utils.assert_raises(AvroRemoteException,
                       self.client.request,
                       'describe_keyspace',
-                      {'keyspace' : 'RenameKeyspace'})
+                      {'keyspace' : 'CreateKeyspace'})
         
     def test_system_column_family_operations(self):
         "adding, renaming, and removing column families"
@@ -126,20 +116,12 @@ class TestSystemOperations(AvroTester):
         assert server_cf
         assert server_cf['row_cache_size'] == 25
         assert server_cf['gc_grace_seconds'] == 1
-        
-        # rename
-        self.client.request('system_rename_column_family',
-            {'old_name' : 'NewColumnFamily', 'new_name': 'RenameColumnFamily'})
-        ks1 = self.client.request(
-            'describe_keyspace', {'keyspace' : 'Keyspace1'})
-        assert 'RenameColumnFamily' in [x['name'] for x in ks1['cf_defs']]
 
         # drop
         self.client.request('system_drop_column_family',
-            {'column_family' : 'RenameColumnFamily'})
+            {'column_family' : 'NewColumnFamily'})
         ks1 = self.client.request(
                 'describe_keyspace', {'keyspace' : 'Keyspace1'})
-        assert 'RenameColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
         assert 'NewColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
         assert 'Standard1' in [x['name'] for x in ks1['cf_defs']]
     
@@ -176,29 +158,6 @@ class TestSystemOperations(AvroTester):
             assert len(cosc_list) == 0 , 'cosc length test failed'
             
             self.client.request('system_drop_keyspace', {'keyspace': keyspace})
-    
-    def test_create_rename_recreate(self):
-        # create
-        cf = {'keyspace': 'CreateRenameRecreate', 'name': 'CF_1'}
-        keyspace1 = {'name': 'CreateRenameRecreate',
-                'strategy_class': 'org.apache.cassandra.locator.SimpleStrategy',
-                'strategy_options': {},
-                'replication_factor': 1,
-                'cf_defs': [cf]}
-        self.client.request('set_keyspace', {'keyspace': 'system'})
-        self.client.request('system_add_keyspace', {'ks_def': keyspace1})
-        assert self.client.request('describe_keyspace', {'keyspace': keyspace1['name']})
-        
-        # rename
-        self.client.request('system_rename_keyspace', {'old_name': keyspace1['name'], 'new_name': keyspace1['name'] + '_renamed'})
-        assert self.client.request('describe_keyspace', {'keyspace': keyspace1['name'] + '_renamed'}) 
-        avro_utils.assert_raises(AvroRemoteException,
-                self.client.request,
-                'describe_keyspace',
-                {'keyspace': keyspace1['name']})
-        
-        # recreate
-        self.client.request('system_add_keyspace', {'ks_def': keyspace1})
-        assert self.client.request('describe_keyspace', {'keyspace': keyspace1['name']})
+
 
 

Modified: cassandra/trunk/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_thrift_server.py?rev=1024243&r1=1024242&r2=1024243&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_thrift_server.py (original)
+++ cassandra/trunk/test/system/test_thrift_server.py Tue Oct 19 14:23:34 2010
@@ -1109,10 +1109,6 @@ class TestMutations(ThriftTester):
         def invalid_keyspace():
             client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, []))
         _expect_exception(invalid_keyspace, InvalidRequestException)
-        
-        def invalid_rename():
-            client.system_rename_keyspace('Keyspace1', 'in-valid')
-        _expect_exception(invalid_rename, InvalidRequestException)
 
     def test_invalid_strategy_class(self):
         def add_invalid_keyspace():
@@ -1143,11 +1139,6 @@ class TestMutations(ThriftTester):
             _set_keyspace('system')
             client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, [cf]))
         _expect_exception(invalid_cf_inside_new_ks, InvalidRequestException)
-        
-        def invalid_rename():
-            _set_keyspace('Keyspace1')
-            client.system_rename_column_family('Standard1', 'in-validcf')
-        _expect_exception(invalid_rename, InvalidRequestException)
     
     def test_system_cf_recreate(self):
         "ensures that keyspaces and column familes can be dropped and recreated in short order"
@@ -1197,18 +1188,10 @@ class TestMutations(ThriftTester):
         assert modks.replication_factor == modified_keyspace.replication_factor
         assert modks.strategy_class == modified_keyspace.strategy_class
         
-        # rename
-        client.system_rename_keyspace('CreateKeyspace', 'RenameKeyspace')
-        renameks = client.describe_keyspace('RenameKeyspace')
-        assert 'CreateKsCf' in [x.name for x in renameks.cf_defs]
-        def get_first_ks():
-            client.describe_keyspace('CreateKeyspace')
-        _expect_exception(get_first_ks, NotFoundException)
-        
         # drop
-        client.system_drop_keyspace('RenameKeyspace')
+        client.system_drop_keyspace('CreateKeyspace')
         def get_second_ks():
-            client.describe_keyspace('RenameKeyspace')
+            client.describe_keyspace('CreateKeyspace')
         _expect_exception(get_second_ks, NotFoundException)
         
     def test_create_then_drop_ks(self):
@@ -1223,28 +1206,7 @@ class TestMutations(ThriftTester):
         client.system_add_keyspace(keyspace)
         test_existence()
         client.system_drop_keyspace(keyspace.name)
-
-    def test_create_rename_recreate(self):
-        # create
-        keyspace1 = KsDef('CreateRenameRecreate',
-                strategy_class='org.apache.cassandra.locator.SimpleStrategy',
-                replication_factor=1,
-                cf_defs=[CfDef('CreateRenameRecreate','CF_1', column_metadata=[])])
-        client.set_keyspace('system')
-        client.system_add_keyspace(keyspace1)
-        def test_ks1_existence():
-            client.describe_keyspace(keyspace1.name)
-        test_ks1_existence()
-        
-        # rename
-        client.system_rename_keyspace(keyspace1.name, keyspace1.name + '_renamed')
-        _expect_exception(test_ks1_existence, NotFoundException)
-        keyspace2 = client.describe_keyspace(keyspace1.name + '_renamed')
-        
-        # recreate
-        client.system_add_keyspace(keyspace1)
-        test_ks1_existence()
-        
+  
     def test_column_validators(self):
         # columndef validation for regular CF
         ks = 'Keyspace1'
@@ -1324,16 +1286,9 @@ class TestMutations(ThriftTester):
         assert server_cf.row_cache_size == 25
         assert server_cf.gc_grace_seconds == 1
         
-        # rename
-        client.system_rename_column_family('NewColumnFamily', 'RenameColumnFamily')
-        ks1 = client.describe_keyspace('Keyspace1')
-        assert 'RenameColumnFamily' in [x.name for x in ks1.cf_defs]
-        assert 'NewColumnFamily' not in [x.name for x in ks1.cf_defs]
-        
         # drop
-        client.system_drop_column_family('RenameColumnFamily')
+        client.system_drop_column_family('NewColumnFamily')
         ks1 = client.describe_keyspace('Keyspace1')
-        assert 'RenameColumnFamily' not in [x.name for x in ks1.cf_defs]
         assert 'NewColumnFamily' not in [x.name for x in ks1.cf_defs]
         assert 'Standard1' in [x.name for x in ks1.cf_defs]
 
@@ -1387,16 +1342,9 @@ class TestMutations(ThriftTester):
         ks1 = client.describe_keyspace('Keyspace1')
         assert 'NewSuperColumnFamily' in [x.name for x in ks1.cf_defs]
         
-        # rename
-        client.system_rename_column_family('NewSuperColumnFamily', 'RenameSuperColumnFamily')
-        ks1 = client.describe_keyspace('Keyspace1')
-        assert 'RenameSuperColumnFamily' in [x.name for x in ks1.cf_defs]
-        assert 'NewSuperColumnFamily' not in [x.name for x in ks1.cf_defs]
-        
         # drop
-        client.system_drop_column_family('RenameSuperColumnFamily')
+        client.system_drop_column_family('NewSuperColumnFamily')
         ks1 = client.describe_keyspace('Keyspace1')
-        assert 'RenameSuperColumnFamily' not in [x.name for x in ks1.cf_defs]
         assert 'NewSuperColumnFamily' not in [x.name for x in ks1.cf_defs]
         assert 'Standard1' in [x.name for x in ks1.cf_defs]