cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/3] git commit: inline getTableDefinition -> getKSMetaData
Date Thu, 29 Nov 2012 13:01:45 GMT
Updated Branches:
  refs/heads/trunk 43f7a776f -> e4d5d3393


inline getTableDefinition -> getKSMetaData


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/853456da
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/853456da
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/853456da

Branch: refs/heads/trunk
Commit: 853456da588657e66285a1683ecd8dd6616d6f4d
Parents: 43f7a77
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Nov 29 21:32:00 2012 +0900
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Nov 29 22:01:30 2012 +0900

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/Schema.java   |   14 +----
 .../apache/cassandra/cql/DropIndexStatement.java   |    2 +-
 .../cql3/statements/DropIndexStatement.java        |    2 +-
 src/java/org/apache/cassandra/db/DefsTable.java    |    6 +-
 src/java/org/apache/cassandra/db/RowMutation.java  |    2 +-
 src/java/org/apache/cassandra/db/Table.java        |    2 +-
 .../apache/cassandra/service/MigrationManager.java |    4 +-
 .../apache/cassandra/service/StorageService.java   |    3 +-
 .../apache/cassandra/thrift/CassandraServer.java   |    2 +-
 .../cassandra/config/DatabaseDescriptorTest.java   |   16 +++---
 .../unit/org/apache/cassandra/config/DefsTest.java |   50 +++++++-------
 11 files changed, 45 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/config/Schema.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index 2f24d39..041b29a 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -284,18 +284,6 @@ public class Schema
     }
 
     /**
-     * Get metadata about table by its name
-     *
-     * @param table The name of the table
-     *
-     * @return The table metadata or null if it wasn't found
-     */
-    public KSMetaData getTableDefinition(String table)
-    {
-        return getKSMetaData(table);
-    }
-
-    /**
      * Get metadata about table inner ColumnFamilies
      *
      * @param tableName The name of the table
@@ -464,7 +452,7 @@ public class Schema
     {
         for (String table : getNonSystemTables())
         {
-            KSMetaData ksm = getTableDefinition(table);
+            KSMetaData ksm = getKSMetaData(table);
             for (CFMetaData cfm : ksm.cfMetaData().values())
                 purge(cfm);
             clearTableDefinition(ksm);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/cql/DropIndexStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/DropIndexStatement.java b/src/java/org/apache/cassandra/cql/DropIndexStatement.java
index 5114a41..502bdb0 100644
--- a/src/java/org/apache/cassandra/cql/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql/DropIndexStatement.java
@@ -59,7 +59,7 @@ public class DropIndexStatement
 
     private CFMetaData findIndexedCF() throws InvalidRequestException
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(keyspace);
+        KSMetaData ksm = Schema.instance.getKSMetaData(keyspace);
         for (CFMetaData cfm : ksm.cfMetaData().values())
         {
             if (findIndexedColumn(cfm) != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/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 827ba3a..6edb551 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
@@ -69,7 +69,7 @@ public class DropIndexStatement extends SchemaAlteringStatement
 
     private CFMetaData findIndexedCF() throws InvalidRequestException
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(keyspace());
+        KSMetaData ksm = Schema.instance.getKSMetaData(keyspace());
         for (CFMetaData cfm : ksm.cfMetaData().values())
         {
             if (findIndexedColumn(cfm) != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/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 8569553..2ea3433 100644
--- a/src/java/org/apache/cassandra/db/DefsTable.java
+++ b/src/java/org/apache/cassandra/db/DefsTable.java
@@ -493,7 +493,7 @@ public class DefsTable
     private static void addColumnFamily(CFMetaData cfm)
     {
         assert Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName) == null;
-        KSMetaData ksm = Schema.instance.getTableDefinition(cfm.ksName);
+        KSMetaData ksm = Schema.instance.getKSMetaData(cfm.ksName);
         ksm = KSMetaData.cloneWith(ksm, Iterables.concat(ksm.cfMetaData().values(), Collections.singleton(cfm)));
 
         Schema.instance.load(cfm);
@@ -550,7 +550,7 @@ public class DefsTable
 
     private static void dropKeyspace(String ksName) throws IOException
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(ksName);
+        KSMetaData ksm = Schema.instance.getKSMetaData(ksName);
         String snapshotName = Table.getTimestampedSnapshotName(ksName);
 
         CompactionManager.instance.stopCompactionFor(ksm.cfMetaData().values());
@@ -581,7 +581,7 @@ public class DefsTable
 
     private static void dropColumnFamily(String ksName, String cfName) throws IOException
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(ksName);
+        KSMetaData ksm = Schema.instance.getKSMetaData(ksName);
         assert ksm != null;
         ColumnFamilyStore cfs = Table.open(ksName).getColumnFamilyStore(cfName);
         assert cfs != null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index 4fcee8a..fdeb75e 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -258,7 +258,7 @@ public class RowMutation implements IMutation
      */
     public void apply()
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(getTable());
+        KSMetaData ksm = Schema.instance.getKSMetaData(getTable());
         Table.open(table).apply(this, ksm.durableWrites);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/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 18b7e4b..121b7bb 100644
--- a/src/java/org/apache/cassandra/db/Table.java
+++ b/src/java/org/apache/cassandra/db/Table.java
@@ -267,7 +267,7 @@ public class Table
         for (int i = 0; i < indexLocks.length; i++)
             indexLocks[i] = new Object();
 
-        for (CFMetaData cfm : new ArrayList<CFMetaData>(Schema.instance.getTableDefinition(table).cfMetaData().values()))
+        for (CFMetaData cfm : new ArrayList<CFMetaData>(Schema.instance.getKSMetaData(table).cfMetaData().values()))
         {
             logger.debug("Initializing {}.{}", name, cfm.cfName);
             initCf(cfm.cfId, cfm.cfName, loadSSTables);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 76250a4..52f88c5 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -164,7 +164,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     {
         ksm.validate();
 
-        if (Schema.instance.getTableDefinition(ksm.name) != null)
+        if (Schema.instance.getKSMetaData(ksm.name) != null)
             throw new AlreadyExistsException(ksm.name);
 
         logger.info(String.format("Create new Keyspace: %s", ksm));
@@ -175,7 +175,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     {
         cfm.validate();
 
-        KSMetaData ksm = Schema.instance.getTableDefinition(cfm.ksName);
+        KSMetaData ksm = Schema.instance.getKSMetaData(cfm.ksName);
         if (ksm == null)
             throw new ConfigurationException(String.format("Cannot add column family '%s'
to non existing keyspace '%s'.", cfm.cfName, cfm.ksName));
         else if (ksm.cfMetaData().containsKey(cfm.cfName))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 4bf6ba7..3bba88e 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -62,7 +62,6 @@ import org.apache.cassandra.net.IAsyncResult;
 import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.net.ResponseVerbHandler;
-import org.apache.cassandra.service.AntiEntropyService.RepairFuture;
 import org.apache.cassandra.service.AntiEntropyService.TreeRequestVerbHandler;
 import org.apache.cassandra.streaming.*;
 import org.apache.cassandra.thrift.Constants;
@@ -2416,7 +2415,7 @@ public class StorageService implements IEndpointStateChangeSubscriber,
StorageSe
      */
     public List<InetAddress> getNaturalEndpoints(String table, String cf, String key)
     {
-        CFMetaData cfMetaData = Schema.instance.getTableDefinition(table).cfMetaData().get(cf);
+        CFMetaData cfMetaData = Schema.instance.getKSMetaData(table).cfMetaData().get(cf);
         return getNaturalEndpoints(table, getPartitioner().getToken(cfMetaData.getKeyValidator().fromString(key)));
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 5f05057..3cf2d68 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -880,7 +880,7 @@ public class CassandraServer implements Cassandra.Iface
 
     public KsDef describe_keyspace(String table) throws NotFoundException, InvalidRequestException
     {
-        KSMetaData ksm = Schema.instance.getTableDefinition(table);
+        KSMetaData ksm = Schema.instance.getKSMetaData(table);
         if (ksm == null)
             throw new NotFoundException();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
index 4273662..a357ed6 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
@@ -75,19 +75,19 @@ public class DatabaseDescriptorTest
             MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks0", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
             MigrationManager.announceNewKeyspace(KSMetaData.testMetadata("ks1", SimpleStrategy.class,
KSMetaData.optsWithRF(3)));
 
-            assert Schema.instance.getTableDefinition("ks0") != null;
-            assert Schema.instance.getTableDefinition("ks1") != null;
+            assert Schema.instance.getKSMetaData("ks0") != null;
+            assert Schema.instance.getKSMetaData("ks1") != null;
 
-            Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks0"));
-            Schema.instance.clearTableDefinition(Schema.instance.getTableDefinition("ks1"));
+            Schema.instance.clearTableDefinition(Schema.instance.getKSMetaData("ks0"));
+            Schema.instance.clearTableDefinition(Schema.instance.getKSMetaData("ks1"));
 
-            assert Schema.instance.getTableDefinition("ks0") == null;
-            assert Schema.instance.getTableDefinition("ks1") == null;
+            assert Schema.instance.getKSMetaData("ks0") == null;
+            assert Schema.instance.getKSMetaData("ks1") == null;
 
             DatabaseDescriptor.loadSchemas();
 
-            assert Schema.instance.getTableDefinition("ks0") != null;
-            assert Schema.instance.getTableDefinition("ks1") != null;
+            assert Schema.instance.getKSMetaData("ks0") != null;
+            assert Schema.instance.getKSMetaData("ks1") != null;
         }
         finally
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/853456da/test/unit/org/apache/cassandra/config/DefsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DefsTest.java b/test/unit/org/apache/cassandra/config/DefsTest.java
index 5bb16a0..804cb29 100644
--- a/test/unit/org/apache/cassandra/config/DefsTest.java
+++ b/test/unit/org/apache/cassandra/config/DefsTest.java
@@ -159,15 +159,15 @@ public class DefsTest extends SchemaLoader
     {
         final String ks = "Keyspace1";
         final String cf = "BrandNewCfWithNull";
-        KSMetaData original = Schema.instance.getTableDefinition(ks);
+        KSMetaData original = Schema.instance.getKSMetaData(ks);
 
         CFMetaData newCf = addTestCF(original.name, cf, null);
 
-        assert !Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
+        assert !Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName);
         MigrationManager.announceNewColumnFamily(newCf);
 
-        assert Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
-        assert Schema.instance.getTableDefinition(ks).cfMetaData().get(newCf.cfName).equals(newCf);
+        assert Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName);
+        assert Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName).equals(newCf);
     }
 
     @Test
@@ -175,15 +175,15 @@ public class DefsTest extends SchemaLoader
     {
         final String ks = "Keyspace1";
         final String cf = "BrandNewCf";
-        KSMetaData original = Schema.instance.getTableDefinition(ks);
+        KSMetaData original = Schema.instance.getKSMetaData(ks);
 
         CFMetaData newCf = addTestCF(original.name, cf, "A New Column Family");
 
-        assert !Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
+        assert !Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName);
         MigrationManager.announceNewColumnFamily(newCf);
 
-        assert Schema.instance.getTableDefinition(ks).cfMetaData().containsKey(newCf.cfName);
-        assert Schema.instance.getTableDefinition(ks).cfMetaData().get(newCf.cfName).equals(newCf);
+        assert Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName);
+        assert Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName).equals(newCf);
 
         // now read and write to it.
         DecoratedKey dk = Util.dk("key0");
@@ -205,7 +205,7 @@ public class DefsTest extends SchemaLoader
     {
         DecoratedKey dk = Util.dk("dropCf");
         // sanity
-        final KSMetaData ks = Schema.instance.getTableDefinition("Keyspace1");
+        final KSMetaData ks = Schema.instance.getKSMetaData("Keyspace1");
         assert ks != null;
         final CFMetaData cfm = ks.cfMetaData().get("Standard1");
         assert cfm != null;
@@ -222,7 +222,7 @@ public class DefsTest extends SchemaLoader
 
         MigrationManager.announceColumnFamilyDrop(ks.name, cfm.cfName);
 
-        assert !Schema.instance.getTableDefinition(ks.name).cfMetaData().containsKey(cfm.cfName);
+        assert !Schema.instance.getKSMetaData(ks.name).cfMetaData().containsKey(cfm.cfName);
 
         // any write should fail.
         rm = new RowMutation(ks.name, dk.key);
@@ -256,8 +256,8 @@ public class DefsTest extends SchemaLoader
 
         MigrationManager.announceNewKeyspace(newKs);
 
-        assert Schema.instance.getTableDefinition(newCf.ksName) != null;
-        assert Schema.instance.getTableDefinition(newCf.ksName).equals(newKs);
+        assert Schema.instance.getKSMetaData(newCf.ksName) != null;
+        assert Schema.instance.getKSMetaData(newCf.ksName).equals(newKs);
 
         // test reads and writes.
         RowMutation rm = new RowMutation(newCf.ksName, dk.key);
@@ -278,7 +278,7 @@ public class DefsTest extends SchemaLoader
     {
         DecoratedKey dk = Util.dk("dropKs");
         // sanity
-        final KSMetaData ks = Schema.instance.getTableDefinition("Keyspace1");
+        final KSMetaData ks = Schema.instance.getKSMetaData("Keyspace1");
         assert ks != null;
         final CFMetaData cfm = ks.cfMetaData().get("Standard2");
         assert cfm != null;
@@ -295,7 +295,7 @@ public class DefsTest extends SchemaLoader
 
         MigrationManager.announceKeyspaceDrop(ks.name);
 
-        assert Schema.instance.getTableDefinition(ks.name) == null;
+        assert Schema.instance.getKSMetaData(ks.name) == null;
 
         // write should fail.
         rm = new RowMutation(ks.name, dk.key);
@@ -329,7 +329,7 @@ public class DefsTest extends SchemaLoader
     {
         DecoratedKey dk = Util.dk("dropKs");
         // sanity
-        final KSMetaData ks = Schema.instance.getTableDefinition("Keyspace3");
+        final KSMetaData ks = Schema.instance.getKSMetaData("Keyspace3");
         assert ks != null;
         final CFMetaData cfm = ks.cfMetaData().get("Standard1");
         assert cfm != null;
@@ -342,29 +342,29 @@ public class DefsTest extends SchemaLoader
 
         MigrationManager.announceKeyspaceDrop(ks.name);
 
-        assert Schema.instance.getTableDefinition(ks.name) == null;
+        assert Schema.instance.getKSMetaData(ks.name) == null;
     }
 
     @Test
     public void createEmptyKsAddNewCf() throws ConfigurationException, IOException, ExecutionException,
InterruptedException
     {
-        assert Schema.instance.getTableDefinition("EmptyKeyspace") == null;
+        assert Schema.instance.getKSMetaData("EmptyKeyspace") == null;
 
         KSMetaData newKs = KSMetaData.testMetadata("EmptyKeyspace", SimpleStrategy.class,
KSMetaData.optsWithRF(5));
 
         MigrationManager.announceNewKeyspace(newKs);
-        assert Schema.instance.getTableDefinition("EmptyKeyspace") != null;
+        assert Schema.instance.getKSMetaData("EmptyKeyspace") != null;
 
         CFMetaData newCf = addTestCF("EmptyKeyspace", "AddedLater", "A new CF to add to an
empty KS");
 
         //should not exist until apply
-        assert !Schema.instance.getTableDefinition(newKs.name).cfMetaData().containsKey(newCf.cfName);
+        assert !Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName);
 
         //add the new CF to the empty space
         MigrationManager.announceNewColumnFamily(newCf);
 
-        assert Schema.instance.getTableDefinition(newKs.name).cfMetaData().containsKey(newCf.cfName);
-        assert Schema.instance.getTableDefinition(newKs.name).cfMetaData().get(newCf.cfName).equals(newCf);
+        assert Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName);
+        assert Schema.instance.getKSMetaData(newKs.name).cfMetaData().get(newCf.cfName).equals(newCf);
 
         // now read and write to it.
         DecoratedKey dk = Util.dk("key0");
@@ -390,8 +390,8 @@ public class DefsTest extends SchemaLoader
 
         MigrationManager.announceNewKeyspace(oldKs);
 
-        assert Schema.instance.getTableDefinition(cf.ksName) != null;
-        assert Schema.instance.getTableDefinition(cf.ksName).equals(oldKs);
+        assert Schema.instance.getKSMetaData(cf.ksName) != null;
+        assert Schema.instance.getKSMetaData(cf.ksName).equals(oldKs);
 
         // names should match.
         KSMetaData newBadKs2 = KSMetaData.testMetadata(cf.ksName + "trash", SimpleStrategy.class,
KSMetaData.optsWithRF(4));
@@ -421,8 +421,8 @@ public class DefsTest extends SchemaLoader
         KSMetaData ksm = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(1),
cf);
         MigrationManager.announceNewKeyspace(ksm);
 
-        assert Schema.instance.getTableDefinition(cf.ksName) != null;
-        assert Schema.instance.getTableDefinition(cf.ksName).equals(ksm);
+        assert Schema.instance.getKSMetaData(cf.ksName) != null;
+        assert Schema.instance.getKSMetaData(cf.ksName).equals(ksm);
         assert Schema.instance.getCFMetaData(cf.ksName, cf.cfName) != null;
 
         // updating certain fields should fail.


Mime
View raw message