Let DatabaseDescriptor not implicitly startup services

patch by Robert Stupp; reviewed by Blake Eggleston for CASSANDRA-9054


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

Branch: refs/heads/trunk
Commit: 9797511c56df4e9c7db964a6b83e67642df96c2d
Parents: 8580047
Author: Robert Stupp <sn...@snazy.de>
Authored: Thu Aug 18 11:44:03 2016 +1000
Committer: Robert Stupp <sn...@snazy.de>
Committed: Thu Aug 18 11:44:03 2016 +1000

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 NEWS.txt                                        |   6 +
 .../org/apache/cassandra/auth/AuthConfig.java   | 113 +++
 .../org/apache/cassandra/auth/AuthKeyspace.java |   7 +-
 .../cassandra/auth/CassandraAuthorizer.java     |  45 +-
 .../cassandra/auth/CassandraRoleManager.java    |  41 +-
 .../cassandra/auth/PasswordAuthenticator.java   |  11 +-
 .../cassandra/batchlog/BatchlogManager.java     |   7 +-
 .../batchlog/LegacyBatchlogMigrator.java        |   9 +-
 .../apache/cassandra/cache/AutoSavingCache.java |   4 +-
 .../org/apache/cassandra/config/CFMetaData.java |   6 +-
 .../org/apache/cassandra/config/Config.java     |  33 +-
 .../cassandra/config/DatabaseDescriptor.java    | 834 ++++++++++---------
 .../org/apache/cassandra/config/Schema.java     |  50 +-
 .../cassandra/config/SchemaConstants.java       |  74 ++
 .../config/YamlConfigurationLoader.java         |   4 +-
 .../apache/cassandra/cql3/QueryProcessor.java   |   4 +-
 .../cassandra/cql3/functions/FunctionName.java  |   8 +-
 .../cql3/statements/AlterKeyspaceStatement.java |   3 +-
 .../statements/CreateKeyspaceStatement.java     |   6 +-
 .../cql3/statements/CreateTableStatement.java   |   4 +-
 .../statements/ListPermissionsStatement.java    |   3 +-
 .../cql3/statements/ListRolesStatement.java     |   3 +-
 .../cql3/statements/ListUsersStatement.java     |   3 +-
 .../PermissionsManagementStatement.java         |   4 +-
 .../apache/cassandra/db/ColumnFamilyStore.java  |   4 +-
 src/java/org/apache/cassandra/db/Keyspace.java  |   4 +-
 .../org/apache/cassandra/db/LegacyLayout.java   |   5 +-
 src/java/org/apache/cassandra/db/Memtable.java  |  33 +-
 .../org/apache/cassandra/db/ReadCommand.java    |   2 +-
 .../org/apache/cassandra/db/SystemKeyspace.java |  43 +-
 .../db/commitlog/CommitLogReplayer.java         |  10 +-
 .../cassandra/hadoop/cql3/CqlInputFormat.java   |   3 +-
 .../apache/cassandra/hints/HintsDispatcher.java |   3 +-
 .../cassandra/hints/LegacyHintsMigrator.java    |  15 +-
 .../io/compress/DeflateCompressor.java          |  20 +-
 .../io/sstable/AbstractSSTableSimpleWriter.java |   6 +-
 .../apache/cassandra/io/sstable/Descriptor.java |   9 +
 .../io/sstable/format/SSTableFormat.java        |   5 +
 .../io/sstable/format/SSTableReader.java        |  15 +-
 .../locator/DynamicEndpointSnitch.java          |  25 +-
 .../apache/cassandra/metrics/TableMetrics.java  |   4 +-
 .../org/apache/cassandra/net/MessageIn.java     |   2 +-
 .../org/apache/cassandra/net/MessageOut.java    |   3 +-
 .../apache/cassandra/net/MessagingService.java  | 109 ++-
 .../apache/cassandra/repair/RepairRunnable.java |   3 +-
 .../repair/SystemDistributedKeyspace.java       |  37 +-
 .../cassandra/schema/KeyspaceMetadata.java      |   4 +-
 .../cassandra/schema/LegacySchemaMigrator.java  |  40 +-
 .../apache/cassandra/schema/SchemaKeyspace.java |  52 +-
 .../cassandra/service/CassandraDaemon.java      |  21 +-
 .../apache/cassandra/service/ClientState.java   |  23 +-
 .../service/EmbeddedCassandraService.java       |   5 +-
 .../cassandra/service/MigrationManager.java     |   3 +-
 .../apache/cassandra/service/StartupChecks.java |   3 +-
 .../apache/cassandra/service/StorageProxy.java  |  13 +-
 .../cassandra/service/StorageService.java       |  21 +-
 .../streaming/messages/FileMessageHeader.java   |   3 +-
 .../cassandra/thrift/TServerCustomFactory.java  |   6 +-
 .../apache/cassandra/thrift/ThriftServer.java   |  12 +-
 .../cassandra/thrift/ThriftValidation.java      |   3 +-
 .../org/apache/cassandra/tools/BulkLoader.java  |   3 +-
 .../org/apache/cassandra/tools/NodeProbe.java   |   4 +-
 .../apache/cassandra/tools/SSTableExport.java   |   4 +-
 .../tools/SSTableRepairedAtSetter.java          |   4 +-
 .../cassandra/tools/StandaloneSSTableUtil.java  |   2 +
 .../cassandra/tools/StandaloneScrubber.java     |   2 +-
 .../cassandra/tools/StandaloneSplitter.java     |   2 +-
 .../cassandra/tools/StandaloneUpgrader.java     |   3 +-
 .../cassandra/tools/StandaloneVerifier.java     |   2 +-
 src/java/org/apache/cassandra/tools/Util.java   |  13 +-
 .../cassandra/tools/nodetool/Cleanup.java       |   6 +-
 .../apache/cassandra/tools/nodetool/Repair.java |   6 +-
 .../apache/cassandra/tracing/TraceKeyspace.java |   7 +-
 .../org/apache/cassandra/transport/Client.java  |   4 +-
 .../org/apache/cassandra/utils/FBUtilities.java |  15 -
 .../utils/NativeSSTableLoaderClient.java        |   9 +-
 .../db/commitlog/CommitLogStressTest.java       |   5 +
 .../locator/DynamicEndpointSnitchLongTest.java  |   5 +
 .../cassandra/streaming/LongStreamingTest.java  |   3 +
 .../auth/jmx/AuthorizationProxyTest.java        |   8 +
 .../cassandra/batchlog/BatchlogManagerTest.java |  28 +-
 .../DebuggableThreadPoolExecutorTest.java       |   8 +
 .../apache/cassandra/config/CFMetaDataTest.java |   8 +-
 .../cassandra/config/ColumnDefinitionTest.java  |   7 +
 .../config/DatabaseDescriptorRefTest.java       | 251 ++++++
 .../config/DatabaseDescriptorTest.java          |   6 +
 .../org/apache/cassandra/cql3/CQLTester.java    |   7 +-
 .../cassandra/cql3/ColumnConditionTest.java     |   8 +
 .../cassandra/cql3/PstmtPersistenceTest.java    |   7 +-
 .../ClusteringColumnRestrictionsTest.java       |   8 +
 .../miscellaneous/TombstonesTest.java           |   1 +
 .../validation/operations/AggregationTest.java  |   4 +-
 .../cql3/validation/operations/AlterTest.java   |  11 +-
 .../cql3/validation/operations/CreateTest.java  |  13 +-
 .../operations/InsertUpdateIfConditionTest.java |  11 +-
 test/unit/org/apache/cassandra/db/CellTest.java |   6 +
 .../org/apache/cassandra/db/ColumnsTest.java    |   5 +
 .../apache/cassandra/db/DirectoriesTest.java    |   3 +
 .../apache/cassandra/db/LegacyCellNameTest.java |   8 +
 .../apache/cassandra/db/ReadCommandTest.java    |   3 +
 .../apache/cassandra/db/ReadMessageTest.java    |   7 +-
 .../db/RecoveryManagerFlushedTest.java          |   6 +-
 test/unit/org/apache/cassandra/db/RowTest.java  |   2 +
 .../db/SinglePartitionSliceCommandTest.java     |   3 +
 .../apache/cassandra/db/SystemKeyspaceTest.java |  15 +-
 .../apache/cassandra/db/TransformerTest.java    |   5 +
 .../db/aggregation/GroupMakerTest.java          |   7 +
 .../commitlog/CommitLogSegmentManagerTest.java  |   5 +-
 .../db/commitlog/CommitLogUpgradeTest.java      |   5 +
 .../db/commitlog/SegmentReaderTest.java         |   8 +
 .../db/commitlog/SnapshotDeletingTest.java      |   2 +
 .../db/compaction/CompactionIteratorTest.java   |   7 +-
 .../db/context/CounterContextTest.java          |   8 +
 .../cassandra/db/lifecycle/HelpersTest.java     |   2 +
 .../cassandra/db/lifecycle/TrackerTest.java     |   1 +
 .../apache/cassandra/db/lifecycle/ViewTest.java |   2 +
 .../cassandra/db/marshal/TypeParserTest.java    |   7 +
 .../rows/RowAndDeletionMergeIteratorTest.java   |   3 +
 .../org/apache/cassandra/db/rows/RowsTest.java  |   2 +
 .../rows/UnfilteredRowIteratorsMergeTest.java   |   5 +
 .../apache/cassandra/db/view/ViewUtilsTest.java |   1 +
 .../apache/cassandra/dht/BootStrapperTest.java  |   1 +
 .../apache/cassandra/dht/KeyCollisionTest.java  |   1 +
 .../cassandra/dht/PartitionerTestCase.java      |   8 +
 .../org/apache/cassandra/dht/RangeTest.java     |   9 +
 .../cassandra/dht/StreamStateStoreTest.java     |  10 +-
 .../apache/cassandra/gms/EndpointStateTest.java |   7 +
 .../cassandra/gms/FailureDetectorTest.java      |   2 +
 .../org/apache/cassandra/gms/GossiperTest.java  |   5 +
 .../cassandra/gms/SerializationsTest.java       |   8 +
 .../hints/ChecksummedDataInputTest.java         |   8 +
 .../hints/LegacyHintsMigratorTest.java          |   5 +-
 .../index/internal/CassandraIndexTest.java      |   5 +-
 .../index/sasi/disk/OnDiskIndexTest.java        |   9 +
 .../index/sasi/disk/TokenTreeTest.java          |  10 +
 .../CompressedRandomAccessReaderTest.java       |   9 +
 .../CompressedSequentialWriterTest.java         |   8 +
 .../io/sstable/CQLSSTableWriterClientTest.java  |   4 +-
 .../io/sstable/CQLSSTableWriterTest.java        |   7 +
 .../cassandra/io/sstable/IndexSummaryTest.java  |   8 +
 .../io/sstable/SSTableWriterTestBase.java       |   2 +
 .../sstable/format/ClientModeSSTableTest.java   |   4 +-
 .../format/SSTableFlushObserverTest.java        |  10 +-
 .../metadata/MetadataSerializerTest.java        |   9 +-
 .../io/util/BufferedRandomAccessFileTest.java   |  14 +-
 .../util/ChecksummedRandomAccessReaderTest.java |   9 +
 .../util/ChecksummedSequentialWriterTest.java   |   8 +
 .../cassandra/io/util/DataOutputTest.java       |   8 +
 .../apache/cassandra/io/util/FileUtilsTest.java |   7 +
 .../cassandra/io/util/MmappedRegionsTest.java   |   8 +
 .../io/util/RandomAccessReaderTest.java         |   8 +
 .../cassandra/io/util/SequentialWriterTest.java |   8 +
 .../cassandra/locator/CloudstackSnitchTest.java |   2 +
 .../locator/DynamicEndpointSnitchTest.java      |   8 +
 .../apache/cassandra/locator/EC2SnitchTest.java |   2 +
 .../locator/GoogleCloudSnitchTest.java          |   2 +
 .../GossipingPropertyFileSnitchTest.java        |   9 +
 .../locator/NetworkTopologyStrategyTest.java    |   7 +
 .../locator/OldNetworkTopologyStrategyTest.java |   8 +
 .../locator/PropertyFileSnitchTest.java         |   8 +
 .../cassandra/locator/TokenMetadataTest.java    |   1 +
 .../metrics/HintedHandOffMetricsTest.java       |   7 +
 .../cassandra/net/MessagingServiceTest.java     |   9 +
 .../cassandra/net/WriteCallbackInfoTest.java    |   7 +
 .../cassandra/repair/RepairSessionTest.java     |   8 +
 .../schema/LegacySchemaMigratorTest.java        |   7 +-
 .../cassandra/schema/SchemaKeyspaceTest.java    |   9 +-
 .../cassandra/security/EncryptionUtilsTest.java |   8 +
 .../cassandra/service/DataResolverTest.java     |   2 +
 .../service/LeaveAndBootstrapTest.java          |   2 +
 .../org/apache/cassandra/service/MoveTest.java  |   1 +
 .../service/NativeTransportServiceTest.java     |   6 +
 .../apache/cassandra/service/RemoveTest.java    |   5 +
 .../cassandra/service/SerializationsTest.java   |   2 +
 .../cassandra/service/StartupChecksTest.java    |   5 +-
 .../cassandra/service/StorageProxyTest.java     |   1 +
 .../service/StorageServiceServerTest.java       |   6 +-
 .../service/pager/PagingStateTest.java          |   8 +
 .../streaming/StreamingTransferTest.java        |   5 +
 .../compression/CompressedInputStreamTest.java  |   9 +
 .../apache/cassandra/tools/BulkLoaderTest.java  |  66 ++
 .../apache/cassandra/tools/GetVersionTest.java  |  40 +
 .../tools/SSTableExpiredBlockersTest.java       |  50 ++
 .../cassandra/tools/SSTableExportTest.java      |  51 ++
 .../tools/SSTableLevelResetterTest.java         |  49 ++
 .../tools/SSTableMetadataViewerTest.java        |  52 ++
 .../tools/SSTableOfflineRelevelTest.java        |  50 ++
 .../tools/SSTableRepairedAtSetterTest.java      |  52 ++
 .../tools/StandaloneSSTableUtilTest.java        |  49 ++
 .../cassandra/tools/StandaloneScrubberTest.java |  49 ++
 .../cassandra/tools/StandaloneSplitterTest.java |  52 ++
 .../cassandra/tools/StandaloneUpgraderTest.java |  49 ++
 .../cassandra/tools/StandaloneVerifierTest.java |  49 ++
 .../org/apache/cassandra/tools/ToolsTester.java | 296 +++++++
 .../apache/cassandra/tracing/TracingTest.java   |   7 +
 .../cassandra/transport/ProtocolErrorTest.java  |   8 +
 .../cassandra/triggers/TriggerExecutorTest.java |   8 +
 .../utils/JVMStabilityInspectorTest.java        |   7 +
 .../apache/cassandra/utils/MerkleTreesTest.java |   3 +
 .../cassandra/utils/SerializationsTest.java     |   8 +
 .../concurrent/AbstractTransactionalTest.java   |   7 +
 .../cassandra/utils/memory/BufferPoolTest.java  |   8 +
 .../src/org/apache/cassandra/stress/Stress.java |   3 +
 204 files changed, 2979 insertions(+), 872 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index fa7ec69..07c18c5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * Let DatabaseDescriptor not implicitly startup services (CASSANDRA-9054)
  * Fix clustering indexes in presence of static columns in SASI 
(CASSANDRA-12378)
  * Fix queries on columns with reversed type on SASI indexes (CASSANDRA-12223)
  * Added slow query log (CASSANDRA-12403)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 53cb389..a22fdd8 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -82,6 +82,12 @@ Upgrading
       that jar, but if you need that jar for backward compatiblity until you 
do so, you should use the version provided
       on previous Cassandra branch, like the 3.0 branch (by design, the 
functionality provided by that jar are stable
       accross versions so using the 3.0 jar for a client connecting to 3.x 
should work without issues).
+    - (Tools development) DatabaseDescriptor no longer implicitly startups 
components/services like
+      commit log replay. This may break existing 3rd party tools and clients. 
In order to startup
+      a standalone tool or client application, use the 
DatabaseDescriptor.toolInitialization() or
+      DatabaseDescriptor.clientInitialization() methods. Tool initialization 
sets up partitioner,
+      snitch, encryption context. Client initialization just applies the 
configuration but does not
+      setup anything.
 
 3.8
 ===

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/auth/AuthConfig.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/AuthConfig.java 
b/src/java/org/apache/cassandra/auth/AuthConfig.java
new file mode 100644
index 0000000..c3dd9a9
--- /dev/null
+++ b/src/java/org/apache/cassandra/auth/AuthConfig.java
@@ -0,0 +1,113 @@
+/*
+ * 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.auth;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.config.Config;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.utils.FBUtilities;
+
+/**
+ * Only purpose is to Initialize authentication/authorization via {@link 
#applyAuthz()}.
+ * This is in this separate class as it implicitly initializes schema stuff 
(via classes referenced in here).
+ */
+public final class AuthConfig
+{
+    private static final Logger logger = 
LoggerFactory.getLogger(AuthConfig.class);
+
+    private static boolean initialized;
+
+    public static void applyAuthz()
+    {
+        // some tests need this
+        if (initialized)
+            return;
+
+        initialized = true;
+
+        Config conf = DatabaseDescriptor.getRawConfig();
+
+        IAuthenticator authenticator = new AllowAllAuthenticator();
+
+        /* Authentication, authorization and role management backend, 
implementing IAuthenticator, IAuthorizer & IRoleMapper*/
+        if (conf.authenticator != null)
+            authenticator = FBUtilities.newAuthenticator(conf.authenticator);
+
+        // the configuration options regarding credentials caching are only 
guaranteed to
+        // work with PasswordAuthenticator, so log a message if some other 
authenticator
+        // is in use and non-default values are detected
+        if (!(authenticator instanceof PasswordAuthenticator)
+            && (conf.credentials_update_interval_in_ms != -1
+                || conf.credentials_validity_in_ms != 2000
+                || conf.credentials_cache_max_entries != 1000))
+        {
+            logger.info("Configuration options 
credentials_update_interval_in_ms, credentials_validity_in_ms and " +
+                        "credentials_cache_max_entries may not be applicable 
for the configured authenticator ({})",
+                        authenticator.getClass().getName());
+        }
+
+        DatabaseDescriptor.setAuthenticator(authenticator);
+
+        // authorizer
+
+        IAuthorizer authorizer = new AllowAllAuthorizer();
+
+        if (conf.authorizer != null)
+            authorizer = FBUtilities.newAuthorizer(conf.authorizer);
+
+        if (!authenticator.requireAuthentication() && 
authorizer.requireAuthorization())
+            throw new ConfigurationException(conf.authenticator + " can't be 
used with " + conf.authorizer, false);
+
+        DatabaseDescriptor.setAuthorizer(authorizer);
+
+        // role manager
+
+        IRoleManager roleManager;
+        if (conf.role_manager != null)
+            roleManager = FBUtilities.newRoleManager(conf.role_manager);
+        else
+            roleManager = new CassandraRoleManager();
+
+        if (authenticator instanceof PasswordAuthenticator && !(roleManager 
instanceof CassandraRoleManager))
+            throw new ConfigurationException("CassandraRoleManager must be 
used with PasswordAuthenticator", false);
+
+        DatabaseDescriptor.setRoleManager(roleManager);
+
+        // authenticator
+
+        IInternodeAuthenticator internodeAuthenticator;
+        if (conf.internode_authenticator != null)
+            internodeAuthenticator = 
FBUtilities.construct(conf.internode_authenticator, "internode_authenticator");
+        else
+            internodeAuthenticator = new AllowAllInternodeAuthenticator();
+
+        DatabaseDescriptor.setInternodeAuthenticator(internodeAuthenticator);
+
+        // Validate at last to have authenticator, authorizer, role-manager 
and internode-auth setup
+        // in case these rely on each other.
+
+        authenticator.validateConfiguration();
+        authorizer.validateConfiguration();
+        roleManager.validateConfiguration();
+        internodeAuthenticator.validateConfiguration();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/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 7ba083c..a5add9a 100644
--- a/src/java/org/apache/cassandra/auth/AuthKeyspace.java
+++ b/src/java/org/apache/cassandra/auth/AuthKeyspace.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.auth;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.schema.KeyspaceMetadata;
 import org.apache.cassandra.schema.KeyspaceParams;
 import org.apache.cassandra.schema.Tables;
@@ -30,8 +31,6 @@ public final class AuthKeyspace
     {
     }
 
-    public static final String NAME = "system_auth";
-
     public static final String ROLES = "roles";
     public static final String ROLE_MEMBERS = "role_members";
     public static final String ROLE_PERMISSIONS = "role_permissions";
@@ -78,13 +77,13 @@ public final class AuthKeyspace
 
     private static CFMetaData compile(String name, String description, String 
schema)
     {
-        return CFMetaData.compile(String.format(schema, name), NAME)
+        return CFMetaData.compile(String.format(schema, name), 
SchemaConstants.AUTH_KEYSPACE_NAME)
                          .comment(description)
                          .gcGraceSeconds((int) TimeUnit.DAYS.toSeconds(90));
     }
 
     public static KeyspaceMetadata metadata()
     {
-        return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(1), 
Tables.of(Roles, RoleMembers, RolePermissions, ResourceRoleIndex));
+        return KeyspaceMetadata.create(SchemaConstants.AUTH_KEYSPACE_NAME, 
KeyspaceParams.simple(1), Tables.of(Roles, RoleMembers, RolePermissions, 
ResourceRoleIndex));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java 
b/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
index 65ee7ec..8c3485d 100644
--- a/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
+++ b/src/java/org/apache/cassandra/auth/CassandraAuthorizer.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.concurrent.ScheduledExecutors;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.statements.BatchStatement;
 import org.apache.cassandra.cql3.statements.ModificationStatement;
@@ -123,7 +124,7 @@ public class CassandraAuthorizer implements IAuthorizer
         try
         {
             UntypedResultSet rows = process(String.format("SELECT resource 
FROM %s.%s WHERE role = '%s'",
-                                                          AuthKeyspace.NAME,
+                                                          
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                           
AuthKeyspace.ROLE_PERMISSIONS,
                                                           
escape(revokee.getRoleName())));
 
@@ -132,7 +133,7 @@ public class CassandraAuthorizer implements IAuthorizer
             {
                 statements.add(
                     QueryProcessor.getStatement(String.format("DELETE FROM 
%s.%s WHERE resource = '%s' AND role = '%s'",
-                                                              
AuthKeyspace.NAME,
+                                                              
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                               
AuthKeyspace.RESOURCE_ROLE_INDEX,
                                                               
escape(row.getString("resource")),
                                                               
escape(revokee.getRoleName())),
@@ -141,7 +142,7 @@ public class CassandraAuthorizer implements IAuthorizer
             }
 
             statements.add(QueryProcessor.getStatement(String.format("DELETE 
FROM %s.%s WHERE role = '%s'",
-                                                                     
AuthKeyspace.NAME,
+                                                                     
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                                      
AuthKeyspace.ROLE_PERMISSIONS,
                                                                      
escape(revokee.getRoleName())),
                                                        
ClientState.forInternalCalls()).statement);
@@ -162,7 +163,7 @@ public class CassandraAuthorizer implements IAuthorizer
         try
         {
             UntypedResultSet rows = process(String.format("SELECT role FROM 
%s.%s WHERE resource = '%s'",
-                                                          AuthKeyspace.NAME,
+                                                          
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                           
AuthKeyspace.RESOURCE_ROLE_INDEX,
                                                           
escape(droppedResource.getName())));
 
@@ -170,7 +171,7 @@ public class CassandraAuthorizer implements IAuthorizer
             for (UntypedResultSet.Row row : rows)
             {
                 
statements.add(QueryProcessor.getStatement(String.format("DELETE FROM %s.%s 
WHERE role = '%s' AND resource = '%s'",
-                                                                         
AuthKeyspace.NAME,
+                                                                         
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                                          
AuthKeyspace.ROLE_PERMISSIONS,
                                                                          
escape(row.getString("role")),
                                                                          
escape(droppedResource.getName())),
@@ -178,9 +179,9 @@ public class CassandraAuthorizer implements IAuthorizer
             }
 
             statements.add(QueryProcessor.getStatement(String.format("DELETE 
FROM %s.%s WHERE resource = '%s'",
-                                                                               
             AuthKeyspace.NAME,
-                                                                               
             AuthKeyspace.RESOURCE_ROLE_INDEX,
-                                                                               
             escape(droppedResource.getName())),
+                                                                     
SchemaConstants.AUTH_KEYSPACE_NAME,
+                                                                     
AuthKeyspace.RESOURCE_ROLE_INDEX,
+                                                                     
escape(droppedResource.getName())),
                                                                                
ClientState.forInternalCalls()).statement);
 
             executeLoggedBatch(statements);
@@ -216,7 +217,7 @@ public class CassandraAuthorizer implements IAuthorizer
 
         // If it exists, read from the legacy user permissions table to handle 
the case where the cluster
         // is being upgraded and so is running with mixed versions of the 
authz schema
-        SelectStatement statement = 
Schema.instance.getCFMetaData(AuthKeyspace.NAME, USER_PERMISSIONS) == null
+        SelectStatement statement = 
Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
USER_PERMISSIONS) == null
                                     ? authorizeRoleStatement
                                     : legacyAuthorizeRoleStatement;
         ResultMessage.Rows rows = 
statement.execute(QueryState.forInternalCalls(), options, System.nanoTime());
@@ -236,7 +237,7 @@ public class CassandraAuthorizer implements IAuthorizer
             throws RequestExecutionException
     {
         process(String.format("UPDATE %s.%s SET permissions = permissions %s 
{%s} WHERE role = '%s' AND resource = '%s'",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLE_PERMISSIONS,
                               op,
                               "'" + StringUtils.join(permissions, "','") + "'",
@@ -248,17 +249,17 @@ public class CassandraAuthorizer implements IAuthorizer
     private void removeLookupEntry(IResource resource, RoleResource role) 
throws RequestExecutionException
     {
         process(String.format("DELETE FROM %s.%s WHERE resource = '%s' and 
role = '%s'",
-                AuthKeyspace.NAME,
-                AuthKeyspace.RESOURCE_ROLE_INDEX,
-                escape(resource.getName()),
-                escape(role.getRoleName())));
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
+                              AuthKeyspace.RESOURCE_ROLE_INDEX,
+                              escape(resource.getName()),
+                              escape(role.getRoleName())));
     }
 
     // Adds an entry to the inverted index table (from resource -> role with 
defined permissions)
     private void addLookupEntry(IResource resource, RoleResource role) throws 
RequestExecutionException
     {
         process(String.format("INSERT INTO %s.%s (resource, role) VALUES 
('%s','%s')",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.RESOURCE_ROLE_INDEX,
                               escape(resource.getName()),
                               escape(role.getRoleName())));
@@ -297,7 +298,7 @@ public class CassandraAuthorizer implements IAuthorizer
         Set<PermissionDetails> details = new HashSet<>();
         // If it exists, try the legacy user permissions table first. This is 
to handle the case
         // where the cluster is being upgraded and so is running with mixed 
versions of the perms table
-        boolean useLegacyTable = 
Schema.instance.getCFMetaData(AuthKeyspace.NAME, USER_PERMISSIONS) != null;
+        boolean useLegacyTable = 
Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
USER_PERMISSIONS) != null;
         String entityColumnName = useLegacyTable ? USERNAME : ROLE;
         for (UntypedResultSet.Row row : process(buildListQuery(resource, role, 
useLegacyTable)))
         {
@@ -320,7 +321,7 @@ public class CassandraAuthorizer implements IAuthorizer
     {
         String tableName = useLegacyTable ? USER_PERMISSIONS : 
AuthKeyspace.ROLE_PERMISSIONS;
         String entityName = useLegacyTable ? USERNAME : ROLE;
-        List<String> vars = Lists.newArrayList(AuthKeyspace.NAME, tableName);
+        List<String> vars = 
Lists.newArrayList(SchemaConstants.AUTH_KEYSPACE_NAME, tableName);
         List<String> conditions = new ArrayList<>();
 
         if (resource != null)
@@ -349,7 +350,7 @@ public class CassandraAuthorizer implements IAuthorizer
 
     public Set<DataResource> protectedResources()
     {
-        return ImmutableSet.of(DataResource.table(AuthKeyspace.NAME, 
AuthKeyspace.ROLE_PERMISSIONS));
+        return 
ImmutableSet.of(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, 
AuthKeyspace.ROLE_PERMISSIONS));
     }
 
     public void validateConfiguration() throws ConfigurationException
@@ -362,7 +363,7 @@ public class CassandraAuthorizer implements IAuthorizer
 
         // If old user permissions table exists, migrate the legacy authz data 
to the new table
         // The delay is to give the node a chance to see its peers before 
attempting the conversion
-        if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "permissions") != 
null)
+        if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
"permissions") != null)
         {
             legacyAuthorizeRoleStatement = prepare(USERNAME, USER_PERMISSIONS);
 
@@ -379,7 +380,7 @@ public class CassandraAuthorizer implements IAuthorizer
     private SelectStatement prepare(String entityname, String permissionsTable)
     {
         String query = String.format("SELECT permissions FROM %s.%s WHERE %s = 
? AND resource = ?",
-                                     AuthKeyspace.NAME,
+                                     SchemaConstants.AUTH_KEYSPACE_NAME,
                                      permissionsTable,
                                      entityname);
         return (SelectStatement) QueryProcessor.getStatement(query, 
ClientState.forInternalCalls()).statement;
@@ -402,12 +403,12 @@ public class CassandraAuthorizer implements IAuthorizer
                 CQLStatement insertStatement =
                     QueryProcessor.getStatement(String.format("INSERT INTO 
%s.%s (role, resource, permissions) " +
                                                               "VALUES (?, ?, 
?)",
-                                                              
AuthKeyspace.NAME,
+                                                              
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                               
AuthKeyspace.ROLE_PERMISSIONS),
                                                 
ClientState.forInternalCalls()).statement;
                 CQLStatement indexStatement =
                     QueryProcessor.getStatement(String.format("INSERT INTO 
%s.%s (resource, role) VALUES (?,?)",
-                                                              
AuthKeyspace.NAME,
+                                                              
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                               
AuthKeyspace.RESOURCE_ROLE_INDEX),
                                                 
ClientState.forInternalCalls()).statement;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/auth/CassandraRoleManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/CassandraRoleManager.java 
b/src/java/org/apache/cassandra/auth/CassandraRoleManager.java
index f2a2cfb..14f0e58 100644
--- a/src/java/org/apache/cassandra/auth/CassandraRoleManager.java
+++ b/src/java/org/apache/cassandra/auth/CassandraRoleManager.java
@@ -33,6 +33,7 @@ import org.apache.cassandra.concurrent.ScheduledExecutors;
 import org.apache.cassandra.config.Config;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.statements.SelectStatement;
 import org.apache.cassandra.db.ConsistencyLevel;
@@ -142,17 +143,17 @@ public class CassandraRoleManager implements IRoleManager
     public void setup()
     {
         loadRoleStatement = (SelectStatement) prepare("SELECT * from %s.%s 
WHERE role = ?",
-                                                      AuthKeyspace.NAME,
+                                                      
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                       AuthKeyspace.ROLES);
         // If the old users table exists, we may need to migrate the legacy 
authn
         // data to the new table. We also need to prepare a statement to read 
from
         // it, so we can continue to use the old tables while the cluster is 
upgraded.
         // Otherwise, we may need to create a default superuser role to enable 
others
         // to be added.
-        if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "users") != null)
+        if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
"users") != null)
         {
              legacySelectUserStatement = (SelectStatement) prepare("SELECT * 
FROM %s.%s WHERE name = ?",
-                                                                   
AuthKeyspace.NAME,
+                                                                   
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                                    
LEGACY_USERS_TABLE);
             scheduleSetupTask(() -> {
                 convertLegacyData();
@@ -183,14 +184,14 @@ public class CassandraRoleManager implements IRoleManager
     {
         String insertCql = options.getPassword().isPresent()
                          ? String.format("INSERT INTO %s.%s (role, 
is_superuser, can_login, salted_hash) VALUES ('%s', %s, %s, '%s')",
-                                         AuthKeyspace.NAME,
+                                         SchemaConstants.AUTH_KEYSPACE_NAME,
                                          AuthKeyspace.ROLES,
                                          escape(role.getRoleName()),
                                          options.getSuperuser().or(false),
                                          options.getLogin().or(false),
                                          
escape(hashpw(options.getPassword().get())))
                          : String.format("INSERT INTO %s.%s (role, 
is_superuser, can_login) VALUES ('%s', %s, %s)",
-                                         AuthKeyspace.NAME,
+                                         SchemaConstants.AUTH_KEYSPACE_NAME,
                                          AuthKeyspace.ROLES,
                                          escape(role.getRoleName()),
                                          options.getSuperuser().or(false),
@@ -201,7 +202,7 @@ public class CassandraRoleManager implements IRoleManager
     public void dropRole(AuthenticatedUser performer, RoleResource role) 
throws RequestValidationException, RequestExecutionException
     {
         process(String.format("DELETE FROM %s.%s WHERE role = '%s'",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLES,
                               escape(role.getRoleName())),
                 consistencyForRole(role.getRoleName()));
@@ -217,7 +218,7 @@ public class CassandraRoleManager implements IRoleManager
         if (!Strings.isNullOrEmpty(assignments))
         {
             process(String.format("UPDATE %s.%s SET %s WHERE role = '%s'",
-                                  AuthKeyspace.NAME,
+                                  SchemaConstants.AUTH_KEYSPACE_NAME,
                                   AuthKeyspace.ROLES,
                                   assignments,
                                   escape(role.getRoleName())),
@@ -239,7 +240,7 @@ public class CassandraRoleManager implements IRoleManager
 
         modifyRoleMembership(grantee.getRoleName(), role.getRoleName(), "+");
         process(String.format("INSERT INTO %s.%s (role, member) values ('%s', 
'%s')",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLE_MEMBERS,
                               escape(role.getRoleName()),
                               escape(grantee.getRoleName())),
@@ -256,7 +257,7 @@ public class CassandraRoleManager implements IRoleManager
 
         modifyRoleMembership(revokee.getRoleName(), role.getRoleName(), "-");
         process(String.format("DELETE FROM %s.%s WHERE role = '%s' and member 
= '%s'",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLE_MEMBERS,
                               escape(role.getRoleName()),
                               escape(revokee.getRoleName())),
@@ -277,7 +278,7 @@ public class CassandraRoleManager implements IRoleManager
 
     public Set<RoleResource> getAllRoles() throws RequestValidationException, 
RequestExecutionException
     {
-        UntypedResultSet rows = process(String.format("SELECT role from 
%s.%s", AuthKeyspace.NAME, AuthKeyspace.ROLES), ConsistencyLevel.QUORUM);
+        UntypedResultSet rows = process(String.format("SELECT role from 
%s.%s", SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES), 
ConsistencyLevel.QUORUM);
         Iterable<RoleResource> roles = Iterables.transform(rows, new 
Function<UntypedResultSet.Row, RoleResource>()
         {
             public RoleResource apply(UntypedResultSet.Row row)
@@ -310,8 +311,8 @@ public class CassandraRoleManager implements IRoleManager
 
     public Set<? extends IResource> protectedResources()
     {
-        return ImmutableSet.of(DataResource.table(AuthKeyspace.NAME, 
AuthKeyspace.ROLES),
-                               DataResource.table(AuthKeyspace.NAME, 
AuthKeyspace.ROLE_MEMBERS));
+        return 
ImmutableSet.of(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, 
AuthKeyspace.ROLES),
+                               
DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, 
AuthKeyspace.ROLE_MEMBERS));
     }
 
     public void validateConfiguration() throws ConfigurationException
@@ -331,7 +332,7 @@ public class CassandraRoleManager implements IRoleManager
             {
                 QueryProcessor.process(String.format("INSERT INTO %s.%s (role, 
is_superuser, can_login, salted_hash) " +
                                                      "VALUES ('%s', true, 
true, '%s')",
-                                                     AuthKeyspace.NAME,
+                                                     
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                      AuthKeyspace.ROLES,
                                                      DEFAULT_SUPERUSER_NAME,
                                                      
escape(hashpw(DEFAULT_SUPERUSER_PASSWORD))),
@@ -349,8 +350,8 @@ public class CassandraRoleManager implements IRoleManager
     private static boolean hasExistingRoles() throws RequestExecutionException
     {
         // Try looking up the 'cassandra' default role first, to avoid the 
range query if possible.
-        String defaultSUQuery = String.format("SELECT * FROM %s.%s WHERE role 
= '%s'", AuthKeyspace.NAME, AuthKeyspace.ROLES, DEFAULT_SUPERUSER_NAME);
-        String allUsersQuery = String.format("SELECT * FROM %s.%s LIMIT 1", 
AuthKeyspace.NAME, AuthKeyspace.ROLES);
+        String defaultSUQuery = String.format("SELECT * FROM %s.%s WHERE role 
= '%s'", SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES, 
DEFAULT_SUPERUSER_NAME);
+        String allUsersQuery = String.format("SELECT * FROM %s.%s LIMIT 1", 
SchemaConstants.AUTH_KEYSPACE_NAME, AuthKeyspace.ROLES);
         return !QueryProcessor.process(defaultSUQuery, 
ConsistencyLevel.ONE).isEmpty()
                || !QueryProcessor.process(defaultSUQuery, 
ConsistencyLevel.QUORUM).isEmpty()
                || !QueryProcessor.process(allUsersQuery, 
ConsistencyLevel.QUORUM).isEmpty();
@@ -421,7 +422,7 @@ public class CassandraRoleManager implements IRoleManager
                 {
                     // Write the password directly into the table to avoid 
doubly encrypting it
                     QueryProcessor.process(String.format("UPDATE %s.%s SET 
salted_hash = '%s' WHERE role = '%s'",
-                                                         AuthKeyspace.NAME,
+                                                         
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                          AuthKeyspace.ROLES,
                                                          
row.getString("salted_hash"),
                                                          
row.getString("username")),
@@ -480,7 +481,7 @@ public class CassandraRoleManager implements IRoleManager
             // If it exists, try the legacy users table in case the cluster
             // is in the process of being upgraded and so is running with mixed
             // versions of the authn schema.
-            return (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "users") 
!= null)
+            return 
(Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "users") != 
null)
                     ? getRoleFromTable(name, legacySelectUserStatement, 
LEGACY_ROW_TO_ROLE)
                     : getRoleFromTable(name, loadRoleStatement, ROW_TO_ROLE);
         }
@@ -512,7 +513,7 @@ public class CassandraRoleManager implements IRoleManager
     throws RequestExecutionException
     {
         process(String.format("UPDATE %s.%s SET member_of = member_of %s 
{'%s'} WHERE role = '%s'",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLES,
                               op,
                               escape(role),
@@ -527,7 +528,7 @@ public class CassandraRoleManager implements IRoleManager
     {
         // Get the membership list of the the given role
         UntypedResultSet rows = process(String.format("SELECT member FROM 
%s.%s WHERE role = '%s'",
-                                                      AuthKeyspace.NAME,
+                                                      
SchemaConstants.AUTH_KEYSPACE_NAME,
                                                       
AuthKeyspace.ROLE_MEMBERS,
                                                       escape(role)),
                                         consistencyForRole(role));
@@ -540,7 +541,7 @@ public class CassandraRoleManager implements IRoleManager
 
         // Finally, remove the membership list for the dropped role
         process(String.format("DELETE FROM %s.%s WHERE role = '%s'",
-                              AuthKeyspace.NAME,
+                              SchemaConstants.AUTH_KEYSPACE_NAME,
                               AuthKeyspace.ROLE_MEMBERS,
                               escape(role)),
                 consistencyForRole(role));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java 
b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
index 0f79cd2..b0317f3 100644
--- a/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
+++ b/src/java/org/apache/cassandra/auth/PasswordAuthenticator.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.cql3.QueryOptions;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.cql3.UntypedResultSet;
@@ -114,7 +115,7 @@ public class PasswordAuthenticator implements IAuthenticator
         {
             // If the legacy users table exists try to verify credentials 
there. This is to handle the case
             // where the cluster is being upgraded and so is running with 
mixed versions of the authn tables
-            SelectStatement authenticationStatement = 
Schema.instance.getCFMetaData(AuthKeyspace.NAME, LEGACY_CREDENTIALS_TABLE) == 
null
+            SelectStatement authenticationStatement = 
Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
LEGACY_CREDENTIALS_TABLE) == null
                                                     ? authenticateStatement
                                                     : 
legacyAuthenticateStatement;
 
@@ -146,7 +147,7 @@ public class PasswordAuthenticator implements IAuthenticator
     public Set<DataResource> protectedResources()
     {
         // Also protected by CassandraRoleManager, but the duplication doesn't 
hurt and is more explicit
-        return ImmutableSet.of(DataResource.table(AuthKeyspace.NAME, 
AuthKeyspace.ROLES));
+        return 
ImmutableSet.of(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, 
AuthKeyspace.ROLES));
     }
 
     public void validateConfiguration() throws ConfigurationException
@@ -157,15 +158,15 @@ public class PasswordAuthenticator implements 
IAuthenticator
     {
         String query = String.format("SELECT %s FROM %s.%s WHERE role = ?",
                                      SALTED_HASH,
-                                     AuthKeyspace.NAME,
+                                     SchemaConstants.AUTH_KEYSPACE_NAME,
                                      AuthKeyspace.ROLES);
         authenticateStatement = prepare(query);
 
-        if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, 
LEGACY_CREDENTIALS_TABLE) != null)
+        if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, 
LEGACY_CREDENTIALS_TABLE) != null)
         {
             query = String.format("SELECT %s from %s.%s WHERE username = ?",
                                   SALTED_HASH,
-                                  AuthKeyspace.NAME,
+                                  SchemaConstants.AUTH_KEYSPACE_NAME,
                                   LEGACY_CREDENTIALS_TABLE);
             legacyAuthenticateStatement = prepare(query);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/batchlog/BatchlogManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/batchlog/BatchlogManager.java 
b/src/java/org/apache/cassandra/batchlog/BatchlogManager.java
index ffff235..9cb3b10 100644
--- a/src/java/org/apache/cassandra/batchlog/BatchlogManager.java
+++ b/src/java/org/apache/cassandra/batchlog/BatchlogManager.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.BytesType;
@@ -150,7 +151,7 @@ public class BatchlogManager implements BatchlogManagerMBean
     @VisibleForTesting
     public int countAllBatches()
     {
-        String query = String.format("SELECT count(*) FROM %s.%s", 
SystemKeyspace.NAME, SystemKeyspace.BATCHES);
+        String query = String.format("SELECT count(*) FROM %s.%s", 
SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.BATCHES);
         UntypedResultSet results = executeInternal(query);
         if (results == null || results.isEmpty())
             return 0;
@@ -196,13 +197,13 @@ public class BatchlogManager implements 
BatchlogManagerMBean
         RateLimiter rateLimiter = RateLimiter.create(throttleInKB == 0 ? 
Double.MAX_VALUE : throttleInKB * 1024);
 
         UUID limitUuid = UUIDGen.maxTimeUUID(System.currentTimeMillis() - 
getBatchlogTimeout());
-        ColumnFamilyStore store = 
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES);
+        ColumnFamilyStore store = 
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES);
         int pageSize = calculatePageSize(store);
         // There cannot be any live content where token(id) <= 
token(lastReplayedUuid) as every processed batch is
         // deleted, but the tombstoned content may still be present in the 
tables. To avoid walking over it we specify
         // token(id) > token(lastReplayedUuid) as part of the query.
         String query = String.format("SELECT id, mutations, version FROM %s.%s 
WHERE token(id) > token(?) AND token(id) <= token(?)",
-                                     SystemKeyspace.NAME,
+                                     SchemaConstants.SYSTEM_KEYSPACE_NAME,
                                      SystemKeyspace.BATCHES);
         UntypedResultSet batches = executeInternalWithPaging(query, pageSize, 
lastReplayedUuid, limitUuid);
         processBatchlogEntries(batches, pageSize, rateLimiter);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/batchlog/LegacyBatchlogMigrator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/batchlog/LegacyBatchlogMigrator.java 
b/src/java/org/apache/cassandra/batchlog/LegacyBatchlogMigrator.java
index 1a70f9f..4592488 100644
--- a/src/java/org/apache/cassandra/batchlog/LegacyBatchlogMigrator.java
+++ b/src/java/org/apache/cassandra/batchlog/LegacyBatchlogMigrator.java
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.cql3.QueryProcessor;
 import org.apache.cassandra.cql3.UntypedResultSet;
 import org.apache.cassandra.db.*;
@@ -53,7 +54,7 @@ public final class LegacyBatchlogMigrator
     @SuppressWarnings("deprecation")
     public static void migrate()
     {
-        ColumnFamilyStore store = 
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG);
+        ColumnFamilyStore store = 
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG);
 
         // nothing to migrate
         if (store.isEmpty())
@@ -63,7 +64,7 @@ public final class LegacyBatchlogMigrator
 
         int convertedBatches = 0;
         String query = String.format("SELECT id, data, written_at, version 
FROM %s.%s",
-                                     SystemKeyspace.NAME,
+                                     SchemaConstants.SYSTEM_KEYSPACE_NAME,
                                      SystemKeyspace.LEGACY_BATCHLOG);
 
         int pageSize = BatchlogManager.calculatePageSize(store);
@@ -82,7 +83,7 @@ public final class LegacyBatchlogMigrator
     @SuppressWarnings("deprecation")
     public static boolean isLegacyBatchlogMutation(Mutation mutation)
     {
-        return mutation.getKeyspaceName().equals(SystemKeyspace.NAME)
+        return 
mutation.getKeyspaceName().equals(SchemaConstants.SYSTEM_KEYSPACE_NAME)
             && mutation.getPartitionUpdate(SystemKeyspace.LegacyBatchlog.cfId) 
!= null;
     }
 
@@ -142,7 +143,7 @@ public final class LegacyBatchlogMigrator
         AbstractWriteResponseHandler<IMutation> handler = new 
WriteResponseHandler<>(endpoints,
                                                                                
      Collections.<InetAddress>emptyList(),
                                                                                
      ConsistencyLevel.ANY,
-                                                                               
      Keyspace.open(SystemKeyspace.NAME),
+                                                                               
      Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME),
                                                                                
      null,
                                                                                
      WriteType.SIMPLE,
                                                                                
      queryStartNanoTime);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/cache/AutoSavingCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java 
b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
index b98ad53..d7b30fe 100644
--- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java
+++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
@@ -37,8 +37,8 @@ import org.apache.cassandra.concurrent.ScheduledExecutors;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.config.SchemaConstants;
 import org.apache.cassandra.db.ColumnFamilyStore;
-import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.db.compaction.CompactionInfo;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.compaction.OperationType;
@@ -307,7 +307,7 @@ public class AutoSavingCache<K extends CacheKey, V> extends 
InstrumentingCache<K
             else
                 type = OperationType.UNKNOWN;
 
-            info = new 
CompactionInfo(CFMetaData.createFake(SystemKeyspace.NAME, cacheType.toString()),
+            info = new 
CompactionInfo(CFMetaData.createFake(SchemaConstants.SYSTEM_KEYSPACE_NAME, 
cacheType.toString()),
                                       type,
                                       0,
                                       keysEstimate,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java 
b/src/java/org/apache/cassandra/config/CFMetaData.java
index 0aaf064..90d8b58 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -858,7 +858,7 @@ public final class CFMetaData
 
     public static boolean isNameValid(String name) {
         return name != null && !name.isEmpty()
-                && name.length() <= Schema.NAME_LENGTH && 
PATTERN_WORD_CHARS.matcher(name).matches();
+               && name.length() <= SchemaConstants.NAME_LENGTH && 
PATTERN_WORD_CHARS.matcher(name).matches();
     }
 
     public CFMetaData validate() throws ConfigurationException
@@ -866,9 +866,9 @@ public final class CFMetaData
         rebuild();
 
         if (!isNameValid(ksName))
-            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, 
ksName));
+            throw new ConfigurationException(String.format("Keyspace name must 
not be empty, more than %s characters long, or contain 
non-alphanumeric-underscore characters (got \"%s\")", 
SchemaConstants.NAME_LENGTH, ksName));
         if (!isNameValid(cfName))
-            throw new ConfigurationException(String.format("ColumnFamily name 
must not be empty, more than %s characters long, or contain 
non-alphanumeric-underscore characters (got \"%s\")", Schema.NAME_LENGTH, 
cfName));
+            throw new ConfigurationException(String.format("ColumnFamily name 
must not be empty, more than %s characters long, or contain 
non-alphanumeric-underscore characters (got \"%s\")", 
SchemaConstants.NAME_LENGTH, cfName));
 
         params.validate();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9797511c/src/java/org/apache/cassandra/config/Config.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Config.java 
b/src/java/org/apache/cassandra/config/Config.java
index fdf27d9..7248031 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -32,9 +32,6 @@ import com.google.common.collect.Sets;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.cassandra.config.EncryptionOptions.ClientEncryptionOptions;
-import org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions;
-
 /**
  * A class that contains configuration properties for the cassandra node it 
runs within.
  *
@@ -224,10 +221,10 @@ public class Config
     public RequestSchedulerId request_scheduler_id;
     public RequestSchedulerOptions request_scheduler_options;
 
-    public ServerEncryptionOptions server_encryption_options = new 
ServerEncryptionOptions();
-    public ClientEncryptionOptions client_encryption_options = new 
ClientEncryptionOptions();
+    public EncryptionOptions.ServerEncryptionOptions server_encryption_options 
= new EncryptionOptions.ServerEncryptionOptions();
+    public EncryptionOptions.ClientEncryptionOptions client_encryption_options 
= new EncryptionOptions.ClientEncryptionOptions();
     // this encOptions is for backward compatibility (a warning is logged by 
DatabaseDescriptor)
-    public ServerEncryptionOptions encryption_options;
+    public EncryptionOptions.ServerEncryptionOptions encryption_options;
 
     public InternodeCompression internode_compression = 
InternodeCompression.none;
 
@@ -260,6 +257,7 @@ public class Config
     public volatile int counter_cache_keys_to_save = Integer.MAX_VALUE;
 
     private static boolean isClientMode = false;
+    private static boolean isToolsMode = false;
 
     public Integer file_cache_size_in_mb;
 
@@ -367,11 +365,34 @@ public class Config
         return isClientMode;
     }
 
+    /**
+     * Client mode means that the process is a pure client, that uses C* code 
base but does
+     * not read or write local C* database files.
+     */
     public static void setClientMode(boolean clientMode)
     {
         isClientMode = clientMode;
     }
 
+    public static boolean isToolsMode()
+    {
+        return isToolsMode;
+    }
+
+    /**
+     * Tools mode means that the process is a standalone (offline) C* tool 
that may (or may not)
+     * read or write local C* database files.
+     */
+    public static void setToolsMode(boolean toolsMode)
+    {
+        isToolsMode = toolsMode;
+    }
+
+    public static boolean isClientOrToolsMode()
+    {
+        return isClientMode() || isToolsMode();
+    }
+
     public enum CommitLogSync
     {
         periodic,

Reply via email to