cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/2] cassandra git commit: Rename and move config.KSMetaData to schema.KeyspaceMetadata
Date Wed, 01 Jul 2015 15:55:46 GMT
Rename and move config.KSMetaData to schema.KeyspaceMetadata

patch by Aleksey Yeschenko; reviewed by Robert Stupp for CASSANDRA-9677


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

Branch: refs/heads/trunk
Commit: a89597da137ad55a5a1b5268ff414c3c1effce10
Parents: 31e3f61
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Jul 1 17:18:12 2015 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Jul 1 18:55:10 2015 +0300

----------------------------------------------------------------------
 .../org/apache/cassandra/auth/AuthKeyspace.java |   6 +-
 .../org/apache/cassandra/config/KSMetaData.java | 125 ------------------
 .../org/apache/cassandra/config/Schema.java     |  54 ++++----
 .../org/apache/cassandra/cql3/CQL3Type.java     |   9 +-
 .../cassandra/cql3/functions/UDFunction.java    |   4 +-
 .../cql3/statements/AlterKeyspaceStatement.java |   8 +-
 .../cql3/statements/AlterTypeStatement.java     |   4 +-
 .../statements/CreateKeyspaceStatement.java     |   4 +-
 .../cql3/statements/CreateTypeStatement.java    |   5 +-
 .../cql3/statements/DropFunctionStatement.java  |   4 +-
 .../cql3/statements/DropIndexStatement.java     |   4 +-
 .../cql3/statements/DropTypeStatement.java      |   5 +-
 src/java/org/apache/cassandra/db/Keyspace.java  |  13 +-
 .../org/apache/cassandra/db/SystemKeyspace.java |   6 +-
 .../cassandra/io/sstable/CQLSSTableWriter.java  |   9 +-
 .../repair/SystemDistributedKeyspace.java       |   6 +-
 .../cassandra/schema/KeyspaceMetadata.java      | 126 +++++++++++++++++++
 .../cassandra/schema/LegacySchemaTables.java    |  44 +++----
 .../cassandra/service/MigrationManager.java     |  40 +++---
 .../cassandra/service/StorageService.java       |  15 +--
 .../cassandra/thrift/CassandraServer.java       |   3 +-
 .../cassandra/thrift/ThriftConversion.java      |   7 +-
 .../apache/cassandra/tracing/TraceKeyspace.java |   6 +-
 test/unit/org/apache/cassandra/MockSchema.java  |   4 +-
 .../unit/org/apache/cassandra/SchemaLoader.java |  35 +++---
 .../apache/cassandra/config/CFMetaDataTest.java |   3 +-
 .../config/DatabaseDescriptorTest.java          |  13 +-
 .../config/LegacySchemaTablesTest.java          |   3 +-
 .../cql3/validation/entities/UFTest.java        |   6 +-
 .../validation/operations/AggregationTest.java  |   6 +-
 .../apache/cassandra/db/SystemKeyspaceTest.java |   2 +-
 .../db/compaction/AntiCompactionTest.java       |   6 -
 .../compaction/BlacklistingCompactionsTest.java |   5 -
 .../db/compaction/CompactionsPurgeTest.java     |   2 -
 .../db/compaction/CompactionsTest.java          |   2 -
 .../io/sstable/SSTableRewriterTest.java         |   6 -
 .../io/sstable/SSTableScannerTest.java          |   2 -
 .../cassandra/locator/SimpleStrategyTest.java   |   4 +-
 .../org/apache/cassandra/schema/DefsTest.java   |  23 ++--
 .../service/LeaveAndBootstrapTest.java          |   4 +-
 .../org/apache/cassandra/service/MoveTest.java  |   4 +-
 .../service/StorageServiceServerTest.java       |  34 ++---
 .../cassandra/triggers/TriggersSchemaTest.java  |  10 +-
 43 files changed, 334 insertions(+), 347 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/auth/AuthKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/AuthKeyspace.java b/src/java/org/apache/cassandra/auth/AuthKeyspace.java
index 17a9f72..7ba083c 100644
--- a/src/java/org/apache/cassandra/auth/AuthKeyspace.java
+++ b/src/java/org/apache/cassandra/auth/AuthKeyspace.java
@@ -20,7 +20,7 @@ package org.apache.cassandra.auth;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 
@@ -83,8 +83,8 @@ public final class AuthKeyspace
                          .gcGraceSeconds((int) TimeUnit.DAYS.toSeconds(90));
     }
 
-    public static KSMetaData definition()
+    public static KeyspaceMetadata metadata()
     {
-        return KSMetaData.create(NAME, KeyspaceParams.simple(1), Tables.of(Roles, RoleMembers, RolePermissions, ResourceRoleIndex));
+        return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(1), Tables.of(Roles, RoleMembers, RolePermissions, ResourceRoleIndex));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/config/KSMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/KSMetaData.java b/src/java/org/apache/cassandra/config/KSMetaData.java
deleted file mode 100644
index 8683cfa..0000000
--- a/src/java/org/apache/cassandra/config/KSMetaData.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.config;
-
-import com.google.common.base.Objects;
-
-import org.apache.cassandra.exceptions.ConfigurationException;
-import org.apache.cassandra.schema.*;
-
-/**
- * An immutable representation of keyspace metadata (name, params, tables, types, and functions).
- */
-public final class KSMetaData
-{
-    public final String name;
-    public final KeyspaceParams params;
-    public final Tables tables;
-    public final Types types;
-    public final Functions functions;
-
-    private KSMetaData(String name, KeyspaceParams params, Tables tables, Types types, Functions functions)
-    {
-        this.name = name;
-        this.params = params;
-        this.tables = tables;
-        this.types = types;
-        this.functions = functions;
-    }
-
-    public static KSMetaData create(String name, KeyspaceParams params)
-    {
-        return new KSMetaData(name, params, Tables.none(), Types.none(), Functions.none());
-    }
-
-    public static KSMetaData create(String name, KeyspaceParams params, Tables tables)
-    {
-        return new KSMetaData(name, params, tables, Types.none(), Functions.none());
-    }
-
-    public static KSMetaData create(String name, KeyspaceParams params, Tables tables, Types types, Functions functions)
-    {
-        return new KSMetaData(name, params, tables, types, functions);
-    }
-
-    public KSMetaData withSwapped(KeyspaceParams params)
-    {
-        return new KSMetaData(name, params, tables, types, functions);
-    }
-
-    public KSMetaData withSwapped(Tables tables)
-    {
-        return new KSMetaData(name, params, tables, types, functions);
-    }
-
-    public KSMetaData withSwapped(Types types)
-    {
-        return new KSMetaData(name, params, tables, types, functions);
-    }
-
-    public KSMetaData withSwapped(Functions functions)
-    {
-        return new KSMetaData(name, params, tables, types, functions);
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return Objects.hashCode(name, params, tables, functions, types);
-    }
-
-    @Override
-    public boolean equals(Object o)
-    {
-        if (this == o)
-            return true;
-
-        if (!(o instanceof KSMetaData))
-            return false;
-
-        KSMetaData other = (KSMetaData) o;
-
-        return name.equals(other.name)
-            && params.equals(other.params)
-            && tables.equals(other.tables)
-            && functions.equals(other.functions)
-            && types.equals(other.types);
-    }
-
-    @Override
-    public String toString()
-    {
-        return Objects.toStringHelper(this)
-                      .add("name", name)
-                      .add("params", params)
-                      .add("tables", tables)
-                      .add("functions", functions)
-                      .add("types", types)
-                      .toString();
-    }
-
-    public void validate()
-    {
-        if (!CFMetaData.isNameValid(name))
-            throw new ConfigurationException(String.format("Keyspace name must not be empty, more than %s characters long, "
-                                                           + "or contain non-alphanumeric-underscore characters (got \"%s\")",
-                                                           Schema.NAME_LENGTH,
-                                                           name));
-        tables.forEach(CFMetaData::validate);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 aba9240..2178f0e 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -37,9 +37,7 @@ import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.UserType;
 import org.apache.cassandra.io.sstable.Descriptor;
-import org.apache.cassandra.schema.KeyspaceParams;
-import org.apache.cassandra.schema.LegacySchemaTables;
-import org.apache.cassandra.schema.Tables;
+import org.apache.cassandra.schema.*;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.utils.ConcurrentBiMap;
 import org.apache.cassandra.utils.Pair;
@@ -60,7 +58,7 @@ public class Schema
     public static final int NAME_LENGTH = 48;
 
     /* metadata map for faster keyspace lookup */
-    private final Map<String, KSMetaData> keyspaces = new NonBlockingHashMap<>();
+    private final Map<String, KeyspaceMetadata> keyspaces = new NonBlockingHashMap<>();
 
     /* Keyspace objects, one per keyspace. Only one instance should ever exist for any given keyspace. */
     private final Map<String, Keyspace> keyspaceInstances = new NonBlockingHashMap<>();
@@ -90,7 +88,7 @@ public class Schema
      */
     public Schema()
     {
-        load(SystemKeyspace.definition());
+        load(SystemKeyspace.metadata());
     }
 
     /**
@@ -122,7 +120,7 @@ public class Schema
      *
      * @return self to support chaining calls
      */
-    public Schema load(Collection<KSMetaData> keyspaceDefs)
+    public Schema load(Collection<KeyspaceMetadata> keyspaceDefs)
     {
         keyspaceDefs.forEach(this::load);
         return this;
@@ -135,10 +133,10 @@ public class Schema
      *
      * @return self to support chaining calls
      */
-    public Schema load(KSMetaData keyspaceDef)
+    public Schema load(KeyspaceMetadata keyspaceDef)
     {
         keyspaceDef.tables.forEach(this::load);
-        setKeyspaceDefinition(keyspaceDef);
+        setKeyspaceMetadata(keyspaceDef);
         return this;
     }
 
@@ -197,7 +195,7 @@ public class Schema
      *
      * @param ksm The keyspace definition to remove
      */
-    public void clearKeyspaceDefinition(KSMetaData ksm)
+    public void clearKeyspaceMetadata(KeyspaceMetadata ksm)
     {
         keyspaces.remove(ksm.name);
     }
@@ -215,7 +213,7 @@ public class Schema
     public CFMetaData getCFMetaData(String keyspaceName, String cfName)
     {
         assert keyspaceName != null;
-        KSMetaData ksm = keyspaces.get(keyspaceName);
+        KeyspaceMetadata ksm = keyspaces.get(keyspaceName);
         return (ksm == null) ? null : ksm.tables.getNullable(cfName);
     }
 
@@ -244,7 +242,7 @@ public class Schema
      *
      * @return The keyspace metadata or null if it wasn't found
      */
-    public KSMetaData getKSMetaData(String keyspaceName)
+    public KeyspaceMetadata getKSMetaData(String keyspaceName)
     {
         assert keyspaceName != null;
         return keyspaces.get(keyspaceName);
@@ -268,7 +266,7 @@ public class Schema
     public Tables getTables(String keyspaceName)
     {
         assert keyspaceName != null;
-        KSMetaData ksm = keyspaces.get(keyspaceName);
+        KeyspaceMetadata ksm = keyspaces.get(keyspaceName);
         assert ksm != null;
         return ksm.tables;
     }
@@ -286,7 +284,7 @@ public class Schema
      *
      * @param ksm The metadata about keyspace
      */
-    public void setKeyspaceDefinition(KSMetaData ksm)
+    public void setKeyspaceMetadata(KeyspaceMetadata ksm)
     {
         assert ksm != null;
 
@@ -371,7 +369,7 @@ public class Schema
         if (!name.hasKeyspace())
             throw new IllegalArgumentException(String.format("Function name must be fully quallified: got %s", name));
 
-        KSMetaData ksm = getKSMetaData(name.keyspace);
+        KeyspaceMetadata ksm = getKSMetaData(name.keyspace);
         return ksm == null
              ? Collections.emptyList()
              : ksm.functions.get(name);
@@ -390,7 +388,7 @@ public class Schema
         if (!name.hasKeyspace())
             throw new IllegalArgumentException(String.format("Function name must be fully quallified: got %s", name));
 
-        KSMetaData ksm = getKSMetaData(name.keyspace);
+        KeyspaceMetadata ksm = getKSMetaData(name.keyspace);
         return ksm == null
              ? Optional.empty()
              : ksm.functions.find(name, argTypes);
@@ -432,15 +430,15 @@ public class Schema
     {
         for (String keyspaceName : getNonSystemKeyspaces())
         {
-            KSMetaData ksm = getKSMetaData(keyspaceName);
+            KeyspaceMetadata ksm = getKSMetaData(keyspaceName);
             ksm.tables.forEach(this::purge);
-            clearKeyspaceDefinition(ksm);
+            clearKeyspaceMetadata(ksm);
         }
 
         updateVersionAndAnnounce();
     }
 
-    public void addKeyspace(KSMetaData ksm)
+    public void addKeyspace(KeyspaceMetadata ksm)
     {
         assert getKSMetaData(ksm.name) == null;
         load(ksm);
@@ -451,14 +449,14 @@ public class Schema
 
     public void updateKeyspace(String ksName, KeyspaceParams newParams)
     {
-        KSMetaData ksm = update(ksName, ks -> ks.withSwapped(newParams));
+        KeyspaceMetadata ksm = update(ksName, ks -> ks.withSwapped(newParams));
         Keyspace.open(ksName).createReplicationStrategy(ksm);
         MigrationManager.instance.notifyUpdateKeyspace(ksm);
     }
 
     public void dropKeyspace(String ksName)
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(ksName);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName);
         String snapshotName = Keyspace.getTimestampedSnapshotName(ksName);
 
         CompactionManager.instance.interruptCompactionFor(ksm.tables, true);
@@ -482,7 +480,7 @@ public class Schema
 
         // remove the keyspace from the static instances.
         Keyspace.clear(ksm.name);
-        clearKeyspaceDefinition(ksm);
+        clearKeyspaceMetadata(ksm);
 
         keyspace.writeOrder.awaitNewBarrier();
 
@@ -524,17 +522,17 @@ public class Schema
 
     public void dropTable(String ksName, String tableName)
     {
-        KSMetaData oldKsm = getKSMetaData(ksName);
+        KeyspaceMetadata oldKsm = getKSMetaData(ksName);
         assert oldKsm != null;
         ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName);
         assert cfs != null;
 
         // reinitialize the keyspace.
         CFMetaData cfm = oldKsm.tables.get(tableName).get();
-        KSMetaData newKsm = oldKsm.withSwapped(oldKsm.tables.without(tableName));
+        KeyspaceMetadata newKsm = oldKsm.withSwapped(oldKsm.tables.without(tableName));
 
         purge(cfm);
-        setKeyspaceDefinition(newKsm);
+        setKeyspaceMetadata(newKsm);
 
         CompactionManager.instance.interruptCompactionFor(Collections.singleton(cfm), true);
 
@@ -600,14 +598,14 @@ public class Schema
         MigrationManager.instance.notifyDropAggregate(uda);
     }
 
-    private KSMetaData update(String keyspaceName, java.util.function.Function<KSMetaData, KSMetaData> transformation)
+    private KeyspaceMetadata update(String keyspaceName, java.util.function.Function<KeyspaceMetadata, KeyspaceMetadata> transformation)
     {
-        KSMetaData current = getKSMetaData(keyspaceName);
+        KeyspaceMetadata current = getKSMetaData(keyspaceName);
         if (current == null)
             throw new IllegalStateException(String.format("Keyspace %s doesn't exist", keyspaceName));
 
-        KSMetaData transformed = transformation.apply(current);
-        setKeyspaceDefinition(transformed);
+        KeyspaceMetadata transformed = transformation.apply(current);
+        setKeyspaceMetadata(transformed);
 
         return transformed;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/CQL3Type.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/CQL3Type.java b/src/java/org/apache/cassandra/cql3/CQL3Type.java
index c24f6fe..749b989 100644
--- a/src/java/org/apache/cassandra/cql3/CQL3Type.java
+++ b/src/java/org/apache/cassandra/cql3/CQL3Type.java
@@ -20,15 +20,16 @@ package org.apache.cassandra.cql3;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cassandra.config.KSMetaData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.SyntaxException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 
 public interface CQL3Type
 {
@@ -525,7 +526,7 @@ public interface CQL3Type
                     name.setKeyspace(keyspace);
                 }
 
-                KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+                KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
                 if (ksm == null)
                     throw new InvalidRequestException("Unknown keyspace " + name.getKeyspace());
                 UserType type = ksm.types.getNullable(name.getUserTypeName());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/UDFunction.java b/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
index 14a8ff2..a4b1aec 100644
--- a/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/UDFunction.java
@@ -28,12 +28,12 @@ import com.datastax.driver.core.DataType;
 import com.datastax.driver.core.ProtocolVersion;
 import com.datastax.driver.core.UserType;
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.schema.Functions;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
@@ -292,7 +292,7 @@ public abstract class UDFunction extends AbstractFunction implements ScalarFunct
                 UserType userType = (UserType) dataType;
                 if (userType.getKeyspace().equals(ksName) && userType.getTypeName().equals(typeName))
                 {
-                    KSMetaData ksm = Schema.instance.getKSMetaData(ksName);
+                    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName);
                     assert ksm != null;
 
                     org.apache.cassandra.db.marshal.UserType ut = ksm.types.get(ByteBufferUtil.bytes(typeName)).get();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java
index 502160d..3e1bca5 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterKeyspaceStatement.java
@@ -18,11 +18,11 @@
 package org.apache.cassandra.cql3.statements;
 
 import org.apache.cassandra.auth.Permission;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.locator.LocalStrategy;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
@@ -53,7 +53,7 @@ public class AlterKeyspaceStatement extends SchemaAlteringStatement
 
     public void validate(ClientState state) throws RequestValidationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name);
         if (ksm == null)
             throw new InvalidRequestException("Unknown keyspace " + name);
         if (ksm.name.equalsIgnoreCase(SystemKeyspace.NAME))
@@ -78,12 +78,12 @@ public class AlterKeyspaceStatement extends SchemaAlteringStatement
 
     public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
     {
-        KSMetaData oldKsm = Schema.instance.getKSMetaData(name);
+        KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(name);
         // In the (very) unlikely case the keyspace was dropped since validate()
         if (oldKsm == null)
             throw new InvalidRequestException("Unknown keyspace " + name);
 
-        KSMetaData newKsm = oldKsm.withSwapped(attrs.asAlteredKeyspaceParams(oldKsm.params));
+        KeyspaceMetadata newKsm = oldKsm.withSwapped(attrs.asAlteredKeyspaceParams(oldKsm.params));
         MigrationManager.announceKeyspaceUpdate(newKsm, isLocalOnly);
         return true;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java
index 5579839..4298c22 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTypeStatement.java
@@ -23,9 +23,9 @@ import java.util.*;
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.config.*;
 import org.apache.cassandra.cql3.*;
-import org.apache.cassandra.db.ClusteringComparator;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.transport.Event;
@@ -91,7 +91,7 @@ public abstract class AlterTypeStatement extends SchemaAlteringStatement
 
     public boolean announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
         if (ksm == null)
             throw new InvalidRequestException(String.format("Cannot alter type in unknown keyspace %s", name.getKeyspace()));
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
index ac00222..9577af8 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateKeyspaceStatement.java
@@ -19,10 +19,10 @@ package org.apache.cassandra.cql3.statements;
 
 import org.apache.cassandra.auth.*;
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.locator.LocalStrategy;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.service.*;
 import org.apache.cassandra.thrift.ThriftValidation;
@@ -94,7 +94,7 @@ public class CreateKeyspaceStatement extends SchemaAlteringStatement
 
     public boolean announceMigration(boolean isLocalOnly) throws RequestValidationException
     {
-        KSMetaData ksm = KSMetaData.create(name, attrs.asNewKeyspaceParams());
+        KeyspaceMetadata ksm = KeyspaceMetadata.create(name, attrs.asNewKeyspaceParams());
         try
         {
             MigrationManager.announceNewKeyspace(ksm, isLocalOnly);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
index 97f3ed6..465f0f1 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateTypeStatement.java
@@ -27,6 +27,7 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.db.marshal.UserType;
 import org.apache.cassandra.exceptions.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.transport.Event;
@@ -65,7 +66,7 @@ public class CreateTypeStatement extends SchemaAlteringStatement
 
     public void validate(ClientState state) throws RequestValidationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
         if (ksm == null)
             throw new InvalidRequestException(String.format("Cannot add type in unknown keyspace %s", name.getKeyspace()));
 
@@ -118,7 +119,7 @@ public class CreateTypeStatement extends SchemaAlteringStatement
 
     public boolean announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
         assert ksm != null; // should haven't validate otherwise
 
         // Can happen with ifNotExists

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
index d6d7925..59864df 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropFunctionStatement.java
@@ -25,7 +25,6 @@ import com.google.common.base.Joiner;
 
 import org.apache.cassandra.auth.FunctionResource;
 import org.apache.cassandra.auth.Permission;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.CQL3Type;
 import org.apache.cassandra.cql3.functions.*;
@@ -33,6 +32,7 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.exceptions.UnauthorizedException;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.ThriftValidation;
@@ -145,7 +145,7 @@ public final class DropFunctionStatement extends SchemaAlteringStatement
                 throw new InvalidRequestException(getMissingFunctionError());
         }
 
-        KSMetaData ksm = Schema.instance.getKSMetaData(old.name().keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(old.name().keyspace);
         Collection<UDAggregate> referrers = ksm.functions.aggregatesUsingFunction(old);
         if (!referrers.isEmpty())
             throw new InvalidRequestException(String.format("Function '%s' still referenced by %s", old, referrers));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 704a07f..4aae9ac 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropIndexStatement.java
@@ -20,11 +20,11 @@ package org.apache.cassandra.cql3.statements;
 import org.apache.cassandra.auth.Permission;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.db.KeyspaceNotDefinedException;
 import org.apache.cassandra.exceptions.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.service.QueryState;
@@ -115,7 +115,7 @@ public class DropIndexStatement extends SchemaAlteringStatement
 
     private CFMetaData findIndexedCF() throws InvalidRequestException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(keyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace());
         if (ksm == null)
             throw new KeyspaceNotDefinedException("Keyspace " + keyspace() + " does not exist");
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java b/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
index 81055d5..75f6200 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DropTypeStatement.java
@@ -23,6 +23,7 @@ import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.marshal.*;
 import org.apache.cassandra.exceptions.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.transport.Event;
@@ -53,7 +54,7 @@ public class DropTypeStatement extends SchemaAlteringStatement
 
     public void validate(ClientState state) throws RequestValidationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
         if (ksm == null)
             throw new InvalidRequestException(String.format("Cannot drop type in unknown keyspace %s", name.getKeyspace()));
 
@@ -136,7 +137,7 @@ public class DropTypeStatement extends SchemaAlteringStatement
 
     public boolean announceMigration(boolean isLocalOnly) throws InvalidRequestException, ConfigurationException
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(name.getKeyspace());
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name.getKeyspace());
         assert ksm != null;
 
         UserType toDrop = ksm.types.getNullable(name.getUserTypeName());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java
index 3c5a8c8..af79ed8 100644
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@ -39,6 +39,7 @@ import org.apache.cassandra.db.index.SecondaryIndexManager;
 import org.apache.cassandra.db.partitions.PartitionUpdate;
 import org.apache.cassandra.io.sstable.format.SSTableReader;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.utils.concurrent.OpOrder;
@@ -65,7 +66,7 @@ public class Keyspace
             DatabaseDescriptor.createAllDirectories();
     }
 
-    private volatile KSMetaData metadata;
+    private volatile KeyspaceMetadata metadata;
     public final OpOrder writeOrder = new OpOrder();
 
     /* ColumnFamilyStore per column family */
@@ -166,12 +167,12 @@ public class Keyspace
         }
     }
 
-    public void setMetadata(KSMetaData metadata)
+    public void setMetadata(KeyspaceMetadata metadata)
     {
         this.metadata = metadata;
     }
 
-    public KSMetaData getMetadata()
+    public KeyspaceMetadata getMetadata()
     {
         return metadata;
     }
@@ -290,19 +291,19 @@ public class Keyspace
         }
     }
 
-    private Keyspace(KSMetaData metadata)
+    private Keyspace(KeyspaceMetadata metadata)
     {
         this.metadata = metadata;
         createReplicationStrategy(metadata);
         this.metric = new KeyspaceMetrics(this);
     }
 
-    public static Keyspace mockKS(KSMetaData metadata)
+    public static Keyspace mockKS(KeyspaceMetadata metadata)
     {
         return new Keyspace(metadata);
     }
 
-    public void createReplicationStrategy(KSMetaData ksm)
+    public void createReplicationStrategy(KeyspaceMetadata ksm)
     {
         replicationStrategy = AbstractReplicationStrategy.createReplicationStrategy(ksm.name,
                                                                                     ksm.params.replication.klass,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 85e1263..ffbc1eb 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.cql3.functions.*;
@@ -52,6 +51,7 @@ import org.apache.cassandra.locator.IEndpointSnitch;
 import org.apache.cassandra.metrics.RestorableMeter;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.schema.Functions;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.LegacySchemaTables;
 import org.apache.cassandra.schema.Tables;
@@ -266,9 +266,9 @@ public final class SystemKeyspace
                          .comment(description);
     }
 
-    public static KSMetaData definition()
+    public static KeyspaceMetadata metadata()
     {
-        return KSMetaData.create(NAME, KeyspaceParams.local(), tables(), Types.none(), functions());
+        return KeyspaceMetadata.create(NAME, KeyspaceParams.local(), tables(), Types.none(), functions());
     }
 
     private static Tables tables()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java
index 44651be..124547a 100644
--- a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java
@@ -36,6 +36,7 @@ import org.apache.cassandra.dht.Murmur3Partitioner;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.io.sstable.format.SSTableFormat;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 import org.apache.cassandra.service.ClientState;
@@ -348,7 +349,7 @@ public class CQLSSTableWriter implements Closeable
 
                     // We need to register the keyspace/table metadata through Schema, otherwise we won't be able to properly
                     // build the insert statement in using().
-                    KSMetaData ksm = Schema.instance.getKSMetaData(this.schema.ksName);
+                    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(this.schema.ksName);
                     if (ksm == null)
                     {
                         createKeyspaceWithTable(this.schema);
@@ -373,7 +374,7 @@ public class CQLSSTableWriter implements Closeable
          */
         private static void createKeyspaceWithTable(CFMetaData table)
         {
-            Schema.instance.load(KSMetaData.create(table.ksName, KeyspaceParams.simple(1), Tables.of(table)));
+            Schema.instance.load(KeyspaceMetadata.create(table.ksName, KeyspaceParams.simple(1), Tables.of(table)));
         }
 
         /**
@@ -382,10 +383,10 @@ public class CQLSSTableWriter implements Closeable
          * @param keyspace the keyspace to add to
          * @param table the table to add
          */
-        private static void addTableToKeyspace(KSMetaData keyspace, CFMetaData table)
+        private static void addTableToKeyspace(KeyspaceMetadata keyspace, CFMetaData table)
         {
             Schema.instance.load(table);
-            Schema.instance.setKeyspaceDefinition(keyspace.withSwapped(keyspace.tables.with(table)));
+            Schema.instance.setKeyspaceMetadata(keyspace.withSwapped(keyspace.tables.with(table)));
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java b/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
index 1fec76f..70e74db 100644
--- a/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
+++ b/src/java/org/apache/cassandra/repair/SystemDistributedKeyspace.java
@@ -34,11 +34,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -98,9 +98,9 @@ public final class SystemDistributedKeyspace
                          .comment(description);
     }
 
-    public static KSMetaData definition()
+    public static KeyspaceMetadata metadata()
     {
-        return KSMetaData.create(NAME, KeyspaceParams.simple(3), Tables.of(RepairHistory, ParentRepairHistory));
+        return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(3), Tables.of(RepairHistory, ParentRepairHistory));
     }
 
     public static void startParentRepair(UUID parent_id, String keyspaceName, String[] cfnames, Collection<Range<Token>> ranges)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/schema/KeyspaceMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/KeyspaceMetadata.java b/src/java/org/apache/cassandra/schema/KeyspaceMetadata.java
new file mode 100644
index 0000000..0ce22fb
--- /dev/null
+++ b/src/java/org/apache/cassandra/schema/KeyspaceMetadata.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.schema;
+
+import com.google.common.base.Objects;
+
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+/**
+ * An immutable representation of keyspace metadata (name, params, tables, types, and functions).
+ */
+public final class KeyspaceMetadata
+{
+    public final String name;
+    public final KeyspaceParams params;
+    public final Tables tables;
+    public final Types types;
+    public final Functions functions;
+
+    private KeyspaceMetadata(String name, KeyspaceParams params, Tables tables, Types types, Functions functions)
+    {
+        this.name = name;
+        this.params = params;
+        this.tables = tables;
+        this.types = types;
+        this.functions = functions;
+    }
+
+    public static KeyspaceMetadata create(String name, KeyspaceParams params)
+    {
+        return new KeyspaceMetadata(name, params, Tables.none(), Types.none(), Functions.none());
+    }
+
+    public static KeyspaceMetadata create(String name, KeyspaceParams params, Tables tables)
+    {
+        return new KeyspaceMetadata(name, params, tables, Types.none(), Functions.none());
+    }
+
+    public static KeyspaceMetadata create(String name, KeyspaceParams params, Tables tables, Types types, Functions functions)
+    {
+        return new KeyspaceMetadata(name, params, tables, types, functions);
+    }
+
+    public KeyspaceMetadata withSwapped(KeyspaceParams params)
+    {
+        return new KeyspaceMetadata(name, params, tables, types, functions);
+    }
+
+    public KeyspaceMetadata withSwapped(Tables tables)
+    {
+        return new KeyspaceMetadata(name, params, tables, types, functions);
+    }
+
+    public KeyspaceMetadata withSwapped(Types types)
+    {
+        return new KeyspaceMetadata(name, params, tables, types, functions);
+    }
+
+    public KeyspaceMetadata withSwapped(Functions functions)
+    {
+        return new KeyspaceMetadata(name, params, tables, types, functions);
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return Objects.hashCode(name, params, tables, functions, types);
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof KeyspaceMetadata))
+            return false;
+
+        KeyspaceMetadata other = (KeyspaceMetadata) o;
+
+        return name.equals(other.name)
+            && params.equals(other.params)
+            && tables.equals(other.tables)
+            && functions.equals(other.functions)
+            && types.equals(other.types);
+    }
+
+    @Override
+    public String toString()
+    {
+        return Objects.toStringHelper(this)
+                      .add("name", name)
+                      .add("params", params)
+                      .add("tables", tables)
+                      .add("functions", functions)
+                      .add("types", types)
+                      .toString();
+    }
+
+    public void validate()
+    {
+        if (!CFMetaData.isNameValid(name))
+            throw new ConfigurationException(String.format("Keyspace name must not be empty, more than %s characters long, "
+                                                           + "or contain non-alphanumeric-underscore characters (got \"%s\")",
+                                                           Schema.NAME_LENGTH,
+                                                           name));
+        tables.forEach(CFMetaData::validate);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
index ffc3537..c8e163c 100644
--- a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
+++ b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java
@@ -193,7 +193,7 @@ public final class LegacySchemaTables
     /** add entries to system.schema_* for the hardcoded system definitions */
     public static void saveSystemKeyspaceSchema()
     {
-        KSMetaData keyspace = Schema.instance.getKSMetaData(SystemKeyspace.NAME);
+        KeyspaceMetadata keyspace = Schema.instance.getKSMetaData(SystemKeyspace.NAME);
         long timestamp = FBUtilities.timestampMicros();
         // delete old, possibly obsolete entries in schema tables
         for (String table : ALL)
@@ -206,12 +206,12 @@ public final class LegacySchemaTables
         makeCreateKeyspaceMutation(keyspace, timestamp + 1).apply();
     }
 
-    public static Collection<KSMetaData> readSchemaFromSystemTables()
+    public static Collection<KeyspaceMetadata> readSchemaFromSystemTables()
     {
         ReadCommand cmd = getReadCommandForTableSchema(KEYSPACES);
         try (ReadOrderGroup orderGroup = cmd.startOrderGroup(); PartitionIterator schema = cmd.executeInternal(orderGroup))
         {
-            List<KSMetaData> keyspaces = new ArrayList<>();
+            List<KeyspaceMetadata> keyspaces = new ArrayList<>();
 
             while (schema.hasNext())
             {
@@ -464,7 +464,7 @@ public final class LegacySchemaTables
 
             FilteredPartition oldPartition = before.remove(newPartition.partitionKey());
             if (oldPartition == null || oldPartition.isEmpty())
-                Schema.instance.addKeyspace(KSMetaData.create(name, params));
+                Schema.instance.addKeyspace(KeyspaceMetadata.create(name, params));
             else
                 Schema.instance.updateKeyspace(name, params);
         }
@@ -640,12 +640,12 @@ public final class LegacySchemaTables
      * Keyspace metadata serialization/deserialization.
      */
 
-    public static Mutation makeCreateKeyspaceMutation(KSMetaData keyspace, long timestamp)
+    public static Mutation makeCreateKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp)
     {
         return makeCreateKeyspaceMutation(keyspace, timestamp, true);
     }
 
-    public static Mutation makeCreateKeyspaceMutation(KSMetaData keyspace, long timestamp, boolean withTablesAndTypesAndFunctions)
+    public static Mutation makeCreateKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp, boolean withTablesAndTypesAndFunctions)
     {
         // Note that because Keyspaces is a COMPACT TABLE, we're really only setting static columns internally and shouldn't set any clustering.
         RowUpdateBuilder adder = new RowUpdateBuilder(Keyspaces, timestamp, keyspace.name);
@@ -667,7 +667,7 @@ public final class LegacySchemaTables
         return mutation;
     }
 
-    public static Mutation makeDropKeyspaceMutation(KSMetaData keyspace, long timestamp)
+    public static Mutation makeDropKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp)
     {
         int nowInSec = FBUtilities.nowInSeconds();
         Mutation mutation = new Mutation(SystemKeyspace.NAME, getSchemaKSDecoratedKey(keyspace.name));
@@ -677,11 +677,11 @@ public final class LegacySchemaTables
         return mutation;
     }
 
-    private static KSMetaData createKeyspaceFromSchemaPartitions(RowIterator serializedParams,
-                                                                 RowIterator serializedTables,
-                                                                 RowIterator serializedTypes,
-                                                                 RowIterator serializedFunctions,
-                                                                 RowIterator serializedAggregates)
+    private static KeyspaceMetadata createKeyspaceFromSchemaPartitions(RowIterator serializedParams,
+                                                                       RowIterator serializedTables,
+                                                                       RowIterator serializedTypes,
+                                                                       RowIterator serializedFunctions,
+                                                                       RowIterator serializedAggregates)
     {
         String name = AsciiType.instance.compose(serializedParams.partitionKey().getKey());
 
@@ -693,7 +693,7 @@ public final class LegacySchemaTables
         Collection<UDAggregate> udas = createAggregatesFromAggregatesPartition(serializedAggregates);
         Functions functions = org.apache.cassandra.schema.Functions.builder().add(udfs).add(udas).build();
 
-        return KSMetaData.create(name, params, tables, types, functions);
+        return KeyspaceMetadata.create(name, params, tables, types, functions);
     }
 
     /**
@@ -718,7 +718,7 @@ public final class LegacySchemaTables
      * User type metadata serialization/deserialization.
      */
 
-    public static Mutation makeCreateTypeMutation(KSMetaData keyspace, UserType type, long timestamp)
+    public static Mutation makeCreateTypeMutation(KeyspaceMetadata keyspace, UserType type, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -743,7 +743,7 @@ public final class LegacySchemaTables
         adder.build();
     }
 
-    public static Mutation dropTypeFromSchemaMutation(KSMetaData keyspace, UserType type, long timestamp)
+    public static Mutation dropTypeFromSchemaMutation(KeyspaceMetadata keyspace, UserType type, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -780,7 +780,7 @@ public final class LegacySchemaTables
      * Table metadata serialization/deserialization.
      */
 
-    public static Mutation makeCreateTableMutation(KSMetaData keyspace, CFMetaData table, long timestamp)
+    public static Mutation makeCreateTableMutation(KeyspaceMetadata keyspace, CFMetaData table, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -854,7 +854,7 @@ public final class LegacySchemaTables
         adder.build();
     }
 
-    public static Mutation makeUpdateTableMutation(KSMetaData keyspace,
+    public static Mutation makeUpdateTableMutation(KeyspaceMetadata keyspace,
                                                    CFMetaData oldTable,
                                                    CFMetaData newTable,
                                                    long timestamp,
@@ -899,7 +899,7 @@ public final class LegacySchemaTables
         return mutation;
     }
 
-    public static Mutation makeDropTableMutation(KSMetaData keyspace, CFMetaData table, long timestamp)
+    public static Mutation makeDropTableMutation(KeyspaceMetadata keyspace, CFMetaData table, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -1280,7 +1280,7 @@ public final class LegacySchemaTables
      * UDF metadata serialization/deserialization.
      */
 
-    public static Mutation makeCreateFunctionMutation(KSMetaData keyspace, UDFunction function, long timestamp)
+    public static Mutation makeCreateFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -1308,7 +1308,7 @@ public final class LegacySchemaTables
         adder.build();
     }
 
-    public static Mutation makeDropFunctionMutation(KSMetaData keyspace, UDFunction function, long timestamp)
+    public static Mutation makeDropFunctionMutation(KeyspaceMetadata keyspace, UDFunction function, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -1381,7 +1381,7 @@ public final class LegacySchemaTables
      * Aggregate UDF metadata serialization/deserialization.
      */
 
-    public static Mutation makeCreateAggregateMutation(KSMetaData keyspace, UDAggregate aggregate, long timestamp)
+    public static Mutation makeCreateAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);
@@ -1473,7 +1473,7 @@ public final class LegacySchemaTables
         return new FunctionName(ks, f);
     }
 
-    public static Mutation makeDropAggregateMutation(KSMetaData keyspace, UDAggregate aggregate, long timestamp)
+    public static Mutation makeDropAggregateMutation(KeyspaceMetadata keyspace, UDAggregate aggregate, long timestamp)
     {
         // Include the serialized keyspace in case the target node missed a CREATE KEYSPACE migration (see CASSANDRA-5631).
         Mutation mutation = makeCreateKeyspaceMutation(keyspace, timestamp, false);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 26d3b47..9deb313 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -36,7 +36,6 @@ import org.apache.cassandra.concurrent.ScheduledExecutors;
 import org.apache.cassandra.concurrent.Stage;
 import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.cql3.functions.UDAggregate;
 import org.apache.cassandra.cql3.functions.UDFunction;
@@ -49,6 +48,7 @@ import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.LegacySchemaTables;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.WrappedRunnable;
@@ -158,7 +158,7 @@ public class MigrationManager
         return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
     }
 
-    public void notifyCreateKeyspace(KSMetaData ksm)
+    public void notifyCreateKeyspace(KeyspaceMetadata ksm)
     {
         for (MigrationListener listener : listeners)
             listener.onCreateKeyspace(ksm.name);
@@ -188,7 +188,7 @@ public class MigrationManager
             listener.onCreateAggregate(udf.name().keyspace, udf.name().name, udf.argTypes());
     }
 
-    public void notifyUpdateKeyspace(KSMetaData ksm)
+    public void notifyUpdateKeyspace(KeyspaceMetadata ksm)
     {
         for (MigrationListener listener : listeners)
             listener.onUpdateKeyspace(ksm.name);
@@ -221,7 +221,7 @@ public class MigrationManager
             listener.onUpdateAggregate(udf.name().keyspace, udf.name().name, udf.argTypes());
     }
 
-    public void notifyDropKeyspace(KSMetaData ksm)
+    public void notifyDropKeyspace(KeyspaceMetadata ksm)
     {
         for (MigrationListener listener : listeners)
             listener.onDropKeyspace(ksm.name);
@@ -251,17 +251,17 @@ public class MigrationManager
             listener.onDropAggregate(udf.name().keyspace, udf.name().name, udf.argTypes());
     }
 
-    public static void announceNewKeyspace(KSMetaData ksm) throws ConfigurationException
+    public static void announceNewKeyspace(KeyspaceMetadata ksm) throws ConfigurationException
     {
         announceNewKeyspace(ksm, false);
     }
 
-    public static void announceNewKeyspace(KSMetaData ksm, boolean announceLocally) throws ConfigurationException
+    public static void announceNewKeyspace(KeyspaceMetadata ksm, boolean announceLocally) throws ConfigurationException
     {
         announceNewKeyspace(ksm, FBUtilities.timestampMicros(), announceLocally);
     }
 
-    public static void announceNewKeyspace(KSMetaData ksm, long timestamp, boolean announceLocally) throws ConfigurationException
+    public static void announceNewKeyspace(KeyspaceMetadata ksm, long timestamp, boolean announceLocally) throws ConfigurationException
     {
         ksm.validate();
 
@@ -281,7 +281,7 @@ public class MigrationManager
     {
         cfm.validate();
 
-        KSMetaData ksm = Schema.instance.getKSMetaData(cfm.ksName);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(cfm.ksName);
         if (ksm == null)
             throw new ConfigurationException(String.format("Cannot add table '%s' to non existing keyspace '%s'.", cfm.cfName, cfm.ksName));
         else if (ksm.tables.get(cfm.cfName).isPresent())
@@ -293,34 +293,34 @@ public class MigrationManager
 
     public static void announceNewType(UserType newType, boolean announceLocally)
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(newType.keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(newType.keyspace);
         announce(LegacySchemaTables.makeCreateTypeMutation(ksm, newType, FBUtilities.timestampMicros()), announceLocally);
     }
 
     public static void announceNewFunction(UDFunction udf, boolean announceLocally)
     {
         logger.info(String.format("Create scalar function '%s'", udf.name()));
-        KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
         announce(LegacySchemaTables.makeCreateFunctionMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally);
     }
 
     public static void announceNewAggregate(UDAggregate udf, boolean announceLocally)
     {
         logger.info(String.format("Create aggregate function '%s'", udf.name()));
-        KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
         announce(LegacySchemaTables.makeCreateAggregateMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally);
     }
 
-    public static void announceKeyspaceUpdate(KSMetaData ksm) throws ConfigurationException
+    public static void announceKeyspaceUpdate(KeyspaceMetadata ksm) throws ConfigurationException
     {
         announceKeyspaceUpdate(ksm, false);
     }
 
-    public static void announceKeyspaceUpdate(KSMetaData ksm, boolean announceLocally) throws ConfigurationException
+    public static void announceKeyspaceUpdate(KeyspaceMetadata ksm, boolean announceLocally) throws ConfigurationException
     {
         ksm.validate();
 
-        KSMetaData oldKsm = Schema.instance.getKSMetaData(ksm.name);
+        KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(ksm.name);
         if (oldKsm == null)
             throw new ConfigurationException(String.format("Cannot update non existing keyspace '%s'.", ksm.name));
 
@@ -340,7 +340,7 @@ public class MigrationManager
         CFMetaData oldCfm = Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName);
         if (oldCfm == null)
             throw new ConfigurationException(String.format("Cannot update non existing table '%s' in keyspace '%s'.", cfm.cfName, cfm.ksName));
-        KSMetaData ksm = Schema.instance.getKSMetaData(cfm.ksName);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(cfm.ksName);
 
         oldCfm.validateCompatility(cfm);
 
@@ -360,7 +360,7 @@ public class MigrationManager
 
     public static void announceKeyspaceDrop(String ksName, boolean announceLocally) throws ConfigurationException
     {
-        KSMetaData oldKsm = Schema.instance.getKSMetaData(ksName);
+        KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(ksName);
         if (oldKsm == null)
             throw new ConfigurationException(String.format("Cannot drop non existing keyspace '%s'.", ksName));
 
@@ -378,7 +378,7 @@ public class MigrationManager
         CFMetaData oldCfm = Schema.instance.getCFMetaData(ksName, cfName);
         if (oldCfm == null)
             throw new ConfigurationException(String.format("Cannot drop non existing table '%s' in keyspace '%s'.", cfName, ksName));
-        KSMetaData ksm = Schema.instance.getKSMetaData(ksName);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName);
 
         logger.info(String.format("Drop table '%s/%s'", oldCfm.ksName, oldCfm.cfName));
         announce(LegacySchemaTables.makeDropTableMutation(ksm, oldCfm, FBUtilities.timestampMicros()), announceLocally);
@@ -391,21 +391,21 @@ public class MigrationManager
 
     public static void announceTypeDrop(UserType droppedType, boolean announceLocally)
     {
-        KSMetaData ksm = Schema.instance.getKSMetaData(droppedType.keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(droppedType.keyspace);
         announce(LegacySchemaTables.dropTypeFromSchemaMutation(ksm, droppedType, FBUtilities.timestampMicros()), announceLocally);
     }
 
     public static void announceFunctionDrop(UDFunction udf, boolean announceLocally)
     {
         logger.info(String.format("Drop scalar function overload '%s' args '%s'", udf.name(), udf.argTypes()));
-        KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
         announce(LegacySchemaTables.makeDropFunctionMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally);
     }
 
     public static void announceAggregateDrop(UDAggregate udf, boolean announceLocally)
     {
         logger.info(String.format("Drop aggregate function overload '%s' args '%s'", udf.name(), udf.argTypes()));
-        KSMetaData ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(udf.name().keyspace);
         announce(LegacySchemaTables.makeDropAggregateMutation(ksm, udf, FBUtilities.timestampMicros()), announceLocally);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 401057c..8b612b7 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -111,6 +111,7 @@ import org.apache.cassandra.repair.RepairParallelism;
 import org.apache.cassandra.repair.RepairRunnable;
 import org.apache.cassandra.repair.SystemDistributedKeyspace;
 import org.apache.cassandra.repair.messages.RepairOption;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.service.paxos.CommitVerbHandler;
 import org.apache.cassandra.service.paxos.PrepareVerbHandler;
 import org.apache.cassandra.service.paxos.ProposeVerbHandler;
@@ -644,7 +645,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
                 List<Future<?>> flushes = new ArrayList<>();
                 for (Keyspace keyspace : Keyspace.all())
                 {
-                    KSMetaData ksm = Schema.instance.getKSMetaData(keyspace.getName());
+                    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace.getName());
                     if (!ksm.params.durableWrites)
                         for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores())
                             flushes.add(cfs.forceFlush());
@@ -944,10 +945,10 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
         // if we don't have system_traces keyspace at this point, then create it manually
         if (Schema.instance.getKSMetaData(TraceKeyspace.NAME) == null)
-            maybeAddKeyspace(TraceKeyspace.definition());
+            maybeAddKeyspace(TraceKeyspace.metadata());
 
         if (Schema.instance.getKSMetaData(SystemDistributedKeyspace.NAME) == null)
-            MigrationManager.announceNewKeyspace(SystemDistributedKeyspace.definition(), 0, false);
+            MigrationManager.announceNewKeyspace(SystemDistributedKeyspace.metadata(), 0, false);
 
         if (!isSurveyMode)
         {
@@ -1017,7 +1018,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             // if we don't have system_auth keyspace at this point, then create it
             if (Schema.instance.getKSMetaData(AuthKeyspace.NAME) == null)
-                maybeAddKeyspace(AuthKeyspace.definition());
+                maybeAddKeyspace(AuthKeyspace.metadata());
         }
         catch (Exception e)
         {
@@ -1028,7 +1029,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         // the ks exists with the only the legacy tables defined.
         // Also, the addKeyspace above can be racy if multiple nodes are started
         // concurrently - see CASSANDRA-9201
-        for (CFMetaData table : AuthKeyspace.definition().tables)
+        for (CFMetaData table : AuthKeyspace.metadata().tables)
             if (Schema.instance.getCFMetaData(table.ksName, table.cfName) == null)
                 maybeAddTable(table);
 
@@ -1050,7 +1051,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         }
     }
 
-    private void maybeAddKeyspace(KSMetaData ksm)
+    private void maybeAddKeyspace(KeyspaceMetadata ksm)
     {
         try
         {
@@ -3118,7 +3119,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
      */
     public List<InetAddress> getNaturalEndpoints(String keyspaceName, String cf, String key)
     {
-        KSMetaData ksMetaData = Schema.instance.getKSMetaData(keyspaceName);
+        KeyspaceMetadata ksMetaData = Schema.instance.getKSMetaData(keyspaceName);
         if (ksMetaData == null)
             throw new IllegalArgumentException("Unknown keyspace '" + keyspaceName + "'");
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 d6f0757..21049d4 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -52,6 +52,7 @@ import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.locator.DynamicEndpointSnitch;
 import org.apache.cassandra.metrics.ClientMetrics;
 import org.apache.cassandra.scheduler.IRequestScheduler;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.serializers.MarshalException;
 import org.apache.cassandra.service.*;
 import org.apache.cassandra.service.pager.QueryPagers;
@@ -1429,7 +1430,7 @@ public class CassandraServer implements Cassandra.Iface
     {
         validateLogin();
 
-        KSMetaData ksm = Schema.instance.getKSMetaData(keyspaceName);
+        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspaceName);
         if (ksm == null)
             throw new NotFoundException();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/thrift/ThriftConversion.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftConversion.java b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
index 9c761d7..f60ea48 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftConversion.java
@@ -38,6 +38,7 @@ import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.locator.LocalStrategy;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 import org.apache.cassandra.serializers.MarshalException;
@@ -153,7 +154,7 @@ public class ThriftConversion
         return converted;
     }
 
-    public static KSMetaData fromThrift(KsDef ksd, CFMetaData... cfDefs) throws ConfigurationException
+    public static KeyspaceMetadata fromThrift(KsDef ksd, CFMetaData... cfDefs) throws ConfigurationException
     {
         Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ksd.strategy_class);
         if (cls.equals(LocalStrategy.class))
@@ -164,10 +165,10 @@ public class ThriftConversion
             replicationMap.putAll(ksd.strategy_options);
         replicationMap.put(KeyspaceParams.Replication.CLASS, cls.getName());
 
-        return KSMetaData.create(ksd.name, KeyspaceParams.create(ksd.durable_writes, replicationMap), Tables.of(cfDefs));
+        return KeyspaceMetadata.create(ksd.name, KeyspaceParams.create(ksd.durable_writes, replicationMap), Tables.of(cfDefs));
     }
 
-    public static KsDef toThrift(KSMetaData ksm)
+    public static KsDef toThrift(KeyspaceMetadata ksm)
     {
         List<CfDef> cfDefs = new ArrayList<>();
         for (CFMetaData cfm : ksm.tables)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/src/java/org/apache/cassandra/tracing/TraceKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tracing/TraceKeyspace.java b/src/java/org/apache/cassandra/tracing/TraceKeyspace.java
index 8eab93c..d7b804a 100644
--- a/src/java/org/apache/cassandra/tracing/TraceKeyspace.java
+++ b/src/java/org/apache/cassandra/tracing/TraceKeyspace.java
@@ -22,9 +22,9 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.db.Mutation;
 import org.apache.cassandra.db.RowUpdateBuilder;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 import org.apache.cassandra.utils.FBUtilities;
@@ -73,9 +73,9 @@ public final class TraceKeyspace
                          .comment(description);
     }
 
-    public static KSMetaData definition()
+    public static KeyspaceMetadata metadata()
     {
-        return KSMetaData.create(NAME, KeyspaceParams.simple(2), Tables.of(Sessions, Events));
+        return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(2), Tables.of(Sessions, Events));
     }
 
     static Mutation makeStartSessionMutation(ByteBuffer sessionId,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/test/unit/org/apache/cassandra/MockSchema.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/MockSchema.java b/test/unit/org/apache/cassandra/MockSchema.java
index 6aa40d2..104e88f 100644
--- a/test/unit/org/apache/cassandra/MockSchema.java
+++ b/test/unit/org/apache/cassandra/MockSchema.java
@@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableSet;
 import org.apache.cassandra.cache.CachingOptions;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.dht.Murmur3Partitioner;
@@ -45,6 +44,7 @@ import org.apache.cassandra.io.util.ChannelProxy;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.Memory;
 import org.apache.cassandra.io.util.SegmentedFile;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.utils.AlwaysPresentFilter;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -58,7 +58,7 @@ public class MockSchema
         indexSummary = new IndexSummary(Murmur3Partitioner.instance, offsets, 0, Memory.allocate(4), 0, 0, 0, 1);
     }
     private static final AtomicInteger id = new AtomicInteger();
-    public static final Keyspace ks = Keyspace.mockKS(KSMetaData.create("mockks", KeyspaceParams.simpleTransient(1)));
+    public static final Keyspace ks = Keyspace.mockKS(KeyspaceMetadata.create("mockks", KeyspaceParams.simpleTransient(1)));
 
     private static final IndexSummary indexSummary;
     private static final SegmentedFile segmentedFile = new BufferedSegmentedFile(new ChannelProxy(temp("mocksegmentedfile")), 0);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/test/unit/org/apache/cassandra/SchemaLoader.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/SchemaLoader.java b/test/unit/org/apache/cassandra/SchemaLoader.java
index b3b4a64..bd213a5 100644
--- a/test/unit/org/apache/cassandra/SchemaLoader.java
+++ b/test/unit/org/apache/cassandra/SchemaLoader.java
@@ -41,6 +41,7 @@ import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.io.compress.SnappyCompressor;
 import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
 import org.apache.cassandra.service.MigrationManager;
@@ -83,7 +84,7 @@ public class SchemaLoader
 
     public static void schemaDefinition(String testName) throws ConfigurationException
     {
-        List<KSMetaData> schema = new ArrayList<KSMetaData>();
+        List<KeyspaceMetadata> schema = new ArrayList<KeyspaceMetadata>();
 
         // A whole bucket of shorthand
         String ks1 = testName + "Keyspace1";
@@ -117,7 +118,7 @@ public class SchemaLoader
         leveledOptions.put("sstable_size_in_mb", "1");
 
         // Keyspace 1
-        schema.add(KSMetaData.create(ks1,
+        schema.add(KeyspaceMetadata.create(ks1,
                 KeyspaceParams.simple(1),
                 Tables.of(
                 // Column Families
@@ -166,7 +167,7 @@ public class SchemaLoader
         )));
 
         // Keyspace 2
-        schema.add(KSMetaData.create(ks2,
+        schema.add(KeyspaceMetadata.create(ks2,
                 KeyspaceParams.simple(1),
                 Tables.of(
                 // Column Families
@@ -179,14 +180,14 @@ public class SchemaLoader
                 compositeIndexCFMD(ks2, "Indexed3", true).gcGraceSeconds(0))));
 
         // Keyspace 3
-        schema.add(KSMetaData.create(ks3,
+        schema.add(KeyspaceMetadata.create(ks3,
                 KeyspaceParams.simple(5),
                 Tables.of(
                 standardCFMD(ks3, "Standard1"),
                 keysIndexCFMD(ks3, "Indexed1", true))));
 
         // Keyspace 4
-        schema.add(KSMetaData.create(ks4,
+        schema.add(KeyspaceMetadata.create(ks4,
                 KeyspaceParams.simple(3),
                 Tables.of(
                 standardCFMD(ks4, "Standard1"),
@@ -196,16 +197,16 @@ public class SchemaLoader
                 superCFMD(ks4, "Super5", TimeUUIDType.instance, BytesType.instance))));
 
         // Keyspace 5
-        schema.add(KSMetaData.create(ks5,
+        schema.add(KeyspaceMetadata.create(ks5,
                 KeyspaceParams.simple(2),
                 Tables.of(standardCFMD(ks5, "Standard1"))));
         // Keyspace 6
-        schema.add(KSMetaData.create(ks6,
+        schema.add(KeyspaceMetadata.create(ks6,
                 KeyspaceParams.simple(1),
                 Tables.of(keysIndexCFMD(ks6, "Indexed1", true))));
 
         // KeyCacheSpace
-        schema.add(KSMetaData.create(ks_kcs,
+        schema.add(KeyspaceMetadata.create(ks_kcs,
                 KeyspaceParams.simple(1),
                 Tables.of(
                 standardCFMD(ks_kcs, "Standard1"),
@@ -213,7 +214,7 @@ public class SchemaLoader
                 standardCFMD(ks_kcs, "Standard3"))));
 
         // RowCacheSpace
-        schema.add(KSMetaData.create(ks_rcs,
+        schema.add(KeyspaceMetadata.create(ks_rcs,
                 KeyspaceParams.simple(1),
                 Tables.of(
                 standardCFMD(ks_rcs, "CFWithoutCache").caching(CachingOptions.NONE),
@@ -223,21 +224,21 @@ public class SchemaLoader
                                 new CachingOptions.RowCache(CachingOptions.RowCache.Type.HEAD, 100))))));
 
         // CounterCacheSpace
-        /*schema.add(KSMetaData.testMetadata(ks_ccs,
+        /*schema.add(KeyspaceMetadata.testMetadata(ks_ccs,
                 simple,
                 opts_rf1,
                 CFMetaData.Builder.create(ks_ccs, "Counter1", false, false, true).build(),
                 CFMetaData.Builder.create(ks_ccs, "Counter1", false, false, true).build()));*/
 
-        schema.add(KSMetaData.create(ks_nocommit, KeyspaceParams.simpleTransient(1), Tables.of(
+        schema.add(KeyspaceMetadata.create(ks_nocommit, KeyspaceParams.simpleTransient(1), Tables.of(
                 standardCFMD(ks_nocommit, "Standard1"))));
 
         // PerRowSecondaryIndexTest
-        schema.add(KSMetaData.create(ks_prsi, KeyspaceParams.simple(1), Tables.of(
+        schema.add(KeyspaceMetadata.create(ks_prsi, KeyspaceParams.simple(1), Tables.of(
                 perRowIndexedCFMD(ks_prsi, "Indexed1"))));
 
         // CQLKeyspace
-        schema.add(KSMetaData.create(ks_cql, KeyspaceParams.simple(1), Tables.of(
+        schema.add(KeyspaceMetadata.create(ks_cql, KeyspaceParams.simple(1), Tables.of(
 
                 // Column Families
                 CFMetaData.compile("CREATE TABLE table1 ("
@@ -273,13 +274,13 @@ public class SchemaLoader
 
         // if you're messing with low-level sstable stuff, it can be useful to inject the schema directly
         // Schema.instance.load(schemaDefinition());
-        for (KSMetaData ksm : schema)
+        for (KeyspaceMetadata ksm : schema)
             MigrationManager.announceNewKeyspace(ksm, false);
     }
 
     public static void createKeyspace(String name, KeyspaceParams params, CFMetaData... tables)
     {
-        MigrationManager.announceNewKeyspace(KSMetaData.create(name, params, Tables.of(tables)), true);
+        MigrationManager.announceNewKeyspace(KeyspaceMetadata.create(name, params, Tables.of(tables)), true);
     }
 
     public static ColumnDefinition integerColumn(String ksName, String cfName)
@@ -322,9 +323,9 @@ public class SchemaLoader
                                                                 .setIndex("indexe1", IndexType.CUSTOM, indexOptions));
     }
 
-    private static void useCompression(List<KSMetaData> schema)
+    private static void useCompression(List<KeyspaceMetadata> schema)
     {
-        for (KSMetaData ksm : schema)
+        for (KeyspaceMetadata ksm : schema)
             for (CFMetaData cfm : ksm.tables)
                 cfm.compressionParameters(new CompressionParameters(SnappyCompressor.instance));
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
index c302f4b..1238464 100644
--- a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
+++ b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java
@@ -31,6 +31,7 @@ import org.apache.cassandra.db.rows.UnfilteredRowIterators;
 import org.apache.cassandra.db.partitions.PartitionUpdate;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.io.compress.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.LegacySchemaTables;
 import org.apache.cassandra.service.StorageService;
@@ -134,7 +135,7 @@ public class CFMetaDataTest
     private void checkInverses(CFMetaData cfm) throws Exception
     {
         DecoratedKey k = StorageService.getPartitioner().decorateKey(ByteBufferUtil.bytes(cfm.ksName));
-        KSMetaData keyspace = Schema.instance.getKSMetaData(cfm.ksName);
+        KeyspaceMetadata keyspace = Schema.instance.getKSMetaData(cfm.ksName);
 
         // Test thrift conversion
         CFMetaData before = cfm;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/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 ecffd6f..100a432 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java
@@ -34,6 +34,7 @@ import org.apache.cassandra.db.Keyspace;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.gms.Gossiper;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.service.MigrationManager;
 import org.apache.cassandra.thrift.ThriftConversion;
@@ -66,8 +67,8 @@ public class DatabaseDescriptorTest
         for (String ks : Schema.instance.getNonSystemKeyspaces())
         {
             // Not testing round-trip on the KsDef via serDe() because maps
-            KSMetaData ksm = Schema.instance.getKSMetaData(ks);
-            KSMetaData ksmDupe = ThriftConversion.fromThrift(ThriftConversion.toThrift(ksm));
+            KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ks);
+            KeyspaceMetadata ksmDupe = ThriftConversion.fromThrift(ThriftConversion.toThrift(ksm));
             assertNotNull(ksmDupe);
             assertEquals(ksm, ksmDupe);
         }
@@ -87,14 +88,14 @@ public class DatabaseDescriptorTest
         try
         {
             // add a few.
-            MigrationManager.announceNewKeyspace(KSMetaData.create("ks0", KeyspaceParams.simple(3)));
-            MigrationManager.announceNewKeyspace(KSMetaData.create("ks1", KeyspaceParams.simple(3)));
+            MigrationManager.announceNewKeyspace(KeyspaceMetadata.create("ks0", KeyspaceParams.simple(3)));
+            MigrationManager.announceNewKeyspace(KeyspaceMetadata.create("ks1", KeyspaceParams.simple(3)));
 
             assertNotNull(Schema.instance.getKSMetaData("ks0"));
             assertNotNull(Schema.instance.getKSMetaData("ks1"));
 
-            Schema.instance.clearKeyspaceDefinition(Schema.instance.getKSMetaData("ks0"));
-            Schema.instance.clearKeyspaceDefinition(Schema.instance.getKSMetaData("ks1"));
+            Schema.instance.clearKeyspaceMetadata(Schema.instance.getKSMetaData("ks0"));
+            Schema.instance.clearKeyspaceMetadata(Schema.instance.getKSMetaData("ks1"));
 
             assertNull(Schema.instance.getKSMetaData("ks0"));
             assertNull(Schema.instance.getKSMetaData("ks1"));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a89597da/test/unit/org/apache/cassandra/config/LegacySchemaTablesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/LegacySchemaTablesTest.java b/test/unit/org/apache/cassandra/config/LegacySchemaTablesTest.java
index a9aca36..aabc392 100644
--- a/test/unit/org/apache/cassandra/config/LegacySchemaTablesTest.java
+++ b/test/unit/org/apache/cassandra/config/LegacySchemaTablesTest.java
@@ -31,6 +31,7 @@ import org.apache.cassandra.db.marshal.AsciiType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.io.compress.*;
+import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.LegacySchemaTables;
 import org.apache.cassandra.service.StorageService;
@@ -134,7 +135,7 @@ public class LegacySchemaTablesTest
     private void checkInverses(CFMetaData cfm) throws Exception
     {
         DecoratedKey k = StorageService.getPartitioner().decorateKey(ByteBufferUtil.bytes(cfm.ksName));
-        KSMetaData keyspace = Schema.instance.getKSMetaData(cfm.ksName);
+        KeyspaceMetadata keyspace = Schema.instance.getKSMetaData(cfm.ksName);
 
         // Test thrift conversion
         CFMetaData before = cfm;


Mime
View raw message