mirror of https://github.com/apache/cassandra
Let DatabaseDescriptor not implicitly startup services
patch by Robert Stupp; reviewed by Blake Eggleston for CASSANDRA-9054
This commit is contained in:
parent
8580047919
commit
9797511c56
|
|
@ -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)
|
||||
|
|
|
|||
6
NEWS.txt
6
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
|
||||
===
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -35,30 +35,31 @@ import com.google.common.primitives.Longs;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.auth.AuthConfig;
|
||||
import org.apache.cassandra.auth.IAuthenticator;
|
||||
import org.apache.cassandra.auth.IAuthorizer;
|
||||
import org.apache.cassandra.auth.IInternodeAuthenticator;
|
||||
import org.apache.cassandra.auth.IRoleManager;
|
||||
import org.apache.cassandra.config.Config.CommitLogSync;
|
||||
import org.apache.cassandra.config.Config.RequestSchedulerId;
|
||||
import org.apache.cassandra.config.EncryptionOptions.ClientEncryptionOptions;
|
||||
import org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.io.FSWriteError;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableFormat;
|
||||
import org.apache.cassandra.io.util.DiskOptimizationStrategy;
|
||||
import org.apache.cassandra.io.util.FileUtils;
|
||||
import org.apache.cassandra.io.util.SpinningDiskOptimizationStrategy;
|
||||
import org.apache.cassandra.io.util.SsdDiskOptimizationStrategy;
|
||||
import org.apache.cassandra.locator.*;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
import org.apache.cassandra.locator.DynamicEndpointSnitch;
|
||||
import org.apache.cassandra.locator.EndpointSnitchInfo;
|
||||
import org.apache.cassandra.locator.IEndpointSnitch;
|
||||
import org.apache.cassandra.locator.SeedProvider;
|
||||
import org.apache.cassandra.scheduler.IRequestScheduler;
|
||||
import org.apache.cassandra.scheduler.NoScheduler;
|
||||
import org.apache.cassandra.security.EncryptionContext;
|
||||
import org.apache.cassandra.service.CacheService;
|
||||
import org.apache.cassandra.thrift.ThriftServer;
|
||||
import org.apache.cassandra.service.CacheService.CacheType;
|
||||
import org.apache.cassandra.thrift.ThriftServer.ThriftServerType;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.memory.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class DatabaseDescriptor
|
||||
|
|
@ -71,6 +72,8 @@ public class DatabaseDescriptor
|
|||
*/
|
||||
private static final int MAX_NUM_TOKENS = 1536;
|
||||
|
||||
private static Config conf;
|
||||
|
||||
private static IEndpointSnitch snitch;
|
||||
private static InetAddress listenAddress; // leave null so we can fall through to getLocalHost
|
||||
private static InetAddress broadcastAddress;
|
||||
|
|
@ -85,12 +88,8 @@ public class DatabaseDescriptor
|
|||
|
||||
private static Config.DiskAccessMode indexAccessMode;
|
||||
|
||||
private static Config conf;
|
||||
|
||||
private static SSTableFormat.Type sstable_format = SSTableFormat.Type.BIG;
|
||||
|
||||
private static IAuthenticator authenticator = new AllowAllAuthenticator();
|
||||
private static IAuthorizer authorizer = new AllowAllAuthorizer();
|
||||
private static IAuthenticator authenticator;
|
||||
private static IAuthorizer authorizer;
|
||||
// Don't initialize the role manager until applying config. The options supported by CassandraRoleManager
|
||||
// depend on the configured IAuthenticator, so defer creating it until that's been set.
|
||||
private static IRoleManager roleManager;
|
||||
|
|
@ -113,36 +112,63 @@ public class DatabaseDescriptor
|
|||
|
||||
private static DiskOptimizationStrategy diskOptimizationStrategy;
|
||||
|
||||
public static void forceStaticInitialization() {}
|
||||
static
|
||||
private static boolean clientInitialized;
|
||||
private static boolean toolInitialized;
|
||||
private static boolean daemonInitialized;
|
||||
|
||||
public static void daemonInitialization() throws ConfigurationException
|
||||
{
|
||||
// In client mode, we use a default configuration. Note that the fields of this class will be
|
||||
// left unconfigured however (the partitioner or localDC will be null for instance) so this
|
||||
// should be used with care.
|
||||
try
|
||||
{
|
||||
if (Config.isClientMode())
|
||||
{
|
||||
conf = new Config();
|
||||
}
|
||||
else
|
||||
{
|
||||
applyConfig(loadConfig());
|
||||
}
|
||||
switch (conf.disk_optimization_strategy)
|
||||
{
|
||||
case ssd:
|
||||
diskOptimizationStrategy = new SsdDiskOptimizationStrategy(conf.disk_optimization_page_cross_chance);
|
||||
break;
|
||||
case spinning:
|
||||
diskOptimizationStrategy = new SpinningDiskOptimizationStrategy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
assert !toolInitialized;
|
||||
assert !clientInitialized;
|
||||
|
||||
// Some unit tests require this :(
|
||||
if (daemonInitialized)
|
||||
return;
|
||||
daemonInitialized = true;
|
||||
|
||||
setConfig(loadConfig());
|
||||
applyAll();
|
||||
AuthConfig.applyAuthz();
|
||||
}
|
||||
|
||||
public static void toolInitialization()
|
||||
{
|
||||
assert !daemonInitialized;
|
||||
assert !clientInitialized;
|
||||
|
||||
if (toolInitialized)
|
||||
return;
|
||||
toolInitialized = true;
|
||||
|
||||
Config.setToolsMode(true);
|
||||
|
||||
setConfig(loadConfig());
|
||||
|
||||
applySimpleConfig();
|
||||
|
||||
applyPartitioner();
|
||||
|
||||
applySnitch();
|
||||
|
||||
applyEncryptionContext();
|
||||
}
|
||||
|
||||
public static void clientInitialization()
|
||||
{
|
||||
assert !daemonInitialized;
|
||||
assert !toolInitialized;
|
||||
|
||||
if (clientInitialized)
|
||||
return;
|
||||
clientInitialized = true;
|
||||
|
||||
Config.setClientMode(true);
|
||||
conf = new Config();
|
||||
}
|
||||
|
||||
public static Config getRawConfig()
|
||||
{
|
||||
return conf;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
@ -193,105 +219,34 @@ public class DatabaseDescriptor
|
|||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void applyAddressConfig(Config config) throws ConfigurationException
|
||||
{
|
||||
listenAddress = null;
|
||||
rpcAddress = null;
|
||||
broadcastAddress = null;
|
||||
broadcastRpcAddress = null;
|
||||
|
||||
/* Local IP, hostname or interface to bind services to */
|
||||
if (config.listen_address != null && config.listen_interface != null)
|
||||
{
|
||||
throw new ConfigurationException("Set listen_address OR listen_interface, not both", false);
|
||||
}
|
||||
else if (config.listen_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
listenAddress = InetAddress.getByName(config.listen_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown listen_address '" + config.listen_address + "'", false);
|
||||
}
|
||||
|
||||
if (listenAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("listen_address cannot be a wildcard address (" + config.listen_address + ")!", false);
|
||||
}
|
||||
else if (config.listen_interface != null)
|
||||
{
|
||||
listenAddress = getNetworkInterfaceAddress(config.listen_interface, "listen_interface", config.listen_interface_prefer_ipv6);
|
||||
}
|
||||
|
||||
/* Gossip Address to broadcast */
|
||||
if (config.broadcast_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
broadcastAddress = InetAddress.getByName(config.broadcast_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown broadcast_address '" + config.broadcast_address + "'", false);
|
||||
}
|
||||
|
||||
if (broadcastAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("broadcast_address cannot be a wildcard address (" + config.broadcast_address + ")!", false);
|
||||
}
|
||||
|
||||
/* Local IP, hostname or interface to bind RPC server to */
|
||||
if (config.rpc_address != null && config.rpc_interface != null)
|
||||
{
|
||||
throw new ConfigurationException("Set rpc_address OR rpc_interface, not both", false);
|
||||
}
|
||||
else if (config.rpc_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rpcAddress = InetAddress.getByName(config.rpc_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown host in rpc_address " + config.rpc_address, false);
|
||||
}
|
||||
}
|
||||
else if (config.rpc_interface != null)
|
||||
{
|
||||
rpcAddress = getNetworkInterfaceAddress(config.rpc_interface, "rpc_interface", config.rpc_interface_prefer_ipv6);
|
||||
}
|
||||
else
|
||||
{
|
||||
rpcAddress = FBUtilities.getLocalAddress();
|
||||
}
|
||||
|
||||
/* RPC address to broadcast */
|
||||
if (config.broadcast_rpc_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
broadcastRpcAddress = InetAddress.getByName(config.broadcast_rpc_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown broadcast_rpc_address '" + config.broadcast_rpc_address + "'", false);
|
||||
}
|
||||
|
||||
if (broadcastRpcAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("broadcast_rpc_address cannot be a wildcard address (" + config.broadcast_rpc_address + ")!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rpcAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("If rpc_address is set to a wildcard address (" + config.rpc_address + "), then " +
|
||||
"you must set broadcast_rpc_address to a value other than " + config.rpc_address, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyConfig(Config config) throws ConfigurationException
|
||||
private static void setConfig(Config config)
|
||||
{
|
||||
conf = config;
|
||||
}
|
||||
|
||||
private static void applyAll() throws ConfigurationException
|
||||
{
|
||||
applySimpleConfig();
|
||||
|
||||
applyPartitioner();
|
||||
|
||||
applyAddressConfig();
|
||||
|
||||
applyThriftHSHA();
|
||||
|
||||
applySnitch();
|
||||
|
||||
applyRequestScheduler();
|
||||
|
||||
applyInitialTokens();
|
||||
|
||||
applySeedProvider();
|
||||
|
||||
applyEncryptionContext();
|
||||
}
|
||||
|
||||
private static void applySimpleConfig()
|
||||
{
|
||||
|
||||
if (conf.commitlog_sync == null)
|
||||
{
|
||||
|
|
@ -342,67 +297,6 @@ public class DatabaseDescriptor
|
|||
logger.info("DiskAccessMode is {}, indexAccessMode is {}", conf.disk_access_mode, indexAccessMode);
|
||||
}
|
||||
|
||||
/* 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());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
if (conf.internode_authenticator != null)
|
||||
internodeAuthenticator = FBUtilities.construct(conf.internode_authenticator, "internode_authenticator");
|
||||
else
|
||||
internodeAuthenticator = new AllowAllInternodeAuthenticator();
|
||||
|
||||
authenticator.validateConfiguration();
|
||||
authorizer.validateConfiguration();
|
||||
roleManager.validateConfiguration();
|
||||
internodeAuthenticator.validateConfiguration();
|
||||
|
||||
/* Hashing strategy */
|
||||
if (conf.partitioner == null)
|
||||
{
|
||||
throw new ConfigurationException("Missing directive: partitioner", false);
|
||||
}
|
||||
try
|
||||
{
|
||||
partitioner = FBUtilities.newPartitioner(System.getProperty("cassandra.partitioner", conf.partitioner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ConfigurationException("Invalid partitioner class " + conf.partitioner, false);
|
||||
}
|
||||
paritionerName = partitioner.getClass().getCanonicalName();
|
||||
|
||||
if (config.gc_log_threshold_in_ms < 0)
|
||||
{
|
||||
throw new ConfigurationException("gc_log_threshold_in_ms must be a positive integer");
|
||||
}
|
||||
|
||||
if (conf.gc_warn_threshold_in_ms < 0)
|
||||
{
|
||||
throw new ConfigurationException("gc_warn_threshold_in_ms must be a positive integer");
|
||||
|
|
@ -454,83 +348,12 @@ public class DatabaseDescriptor
|
|||
else
|
||||
logger.info("Global memtable off-heap threshold is enabled at {}MB", conf.memtable_offheap_space_in_mb);
|
||||
|
||||
applyAddressConfig(config);
|
||||
|
||||
if (conf.thrift_framed_transport_size_in_mb <= 0)
|
||||
throw new ConfigurationException("thrift_framed_transport_size_in_mb must be positive, but was " + conf.thrift_framed_transport_size_in_mb, false);
|
||||
|
||||
if (conf.native_transport_max_frame_size_in_mb <= 0)
|
||||
throw new ConfigurationException("native_transport_max_frame_size_in_mb must be positive, but was " + conf.native_transport_max_frame_size_in_mb, false);
|
||||
|
||||
// fail early instead of OOMing (see CASSANDRA-8116)
|
||||
if (ThriftServer.HSHA.equals(conf.rpc_server_type) && conf.rpc_max_threads == Integer.MAX_VALUE)
|
||||
throw new ConfigurationException("The hsha rpc_server_type is not compatible with an rpc_max_threads " +
|
||||
"setting of 'unlimited'. Please see the comments in cassandra.yaml " +
|
||||
"for rpc_server_type and rpc_max_threads.",
|
||||
false);
|
||||
if (ThriftServer.HSHA.equals(conf.rpc_server_type) && conf.rpc_max_threads > (FBUtilities.getAvailableProcessors() * 2 + 1024))
|
||||
logger.warn("rpc_max_threads setting of {} may be too high for the hsha server and cause unnecessary thread contention, reducing performance", conf.rpc_max_threads);
|
||||
|
||||
/* end point snitch */
|
||||
if (conf.endpoint_snitch == null)
|
||||
{
|
||||
throw new ConfigurationException("Missing endpoint_snitch directive", false);
|
||||
}
|
||||
snitch = createEndpointSnitch(conf.dynamic_snitch, conf.endpoint_snitch);
|
||||
EndpointSnitchInfo.create();
|
||||
|
||||
localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress());
|
||||
localComparator = new Comparator<InetAddress>()
|
||||
{
|
||||
public int compare(InetAddress endpoint1, InetAddress endpoint2)
|
||||
{
|
||||
boolean local1 = localDC.equals(snitch.getDatacenter(endpoint1));
|
||||
boolean local2 = localDC.equals(snitch.getDatacenter(endpoint2));
|
||||
if (local1 && !local2)
|
||||
return -1;
|
||||
if (local2 && !local1)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/* Request Scheduler setup */
|
||||
requestSchedulerOptions = conf.request_scheduler_options;
|
||||
if (conf.request_scheduler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (requestSchedulerOptions == null)
|
||||
{
|
||||
requestSchedulerOptions = new RequestSchedulerOptions();
|
||||
}
|
||||
Class<?> cls = Class.forName(conf.request_scheduler);
|
||||
requestScheduler = (IRequestScheduler) cls.getConstructor(RequestSchedulerOptions.class).newInstance(requestSchedulerOptions);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
throw new ConfigurationException("Invalid Request Scheduler class " + conf.request_scheduler, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ConfigurationException("Unable to instantiate request scheduler", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
requestScheduler = new NoScheduler();
|
||||
}
|
||||
|
||||
if (conf.request_scheduler_id == RequestSchedulerId.keyspace)
|
||||
{
|
||||
requestSchedulerId = conf.request_scheduler_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to Keyspace
|
||||
requestSchedulerId = RequestSchedulerId.keyspace;
|
||||
}
|
||||
|
||||
// if data dirs, commitlog dir, or saved caches dir are set in cassandra.yaml, use that. Otherwise,
|
||||
// use -Dcassandra.storagedir (set in cassandra-env.sh) as the parent dir for data/, commitlog/, and saved_caches/
|
||||
if (conf.commitlog_directory == null)
|
||||
|
|
@ -700,17 +523,6 @@ public class DatabaseDescriptor
|
|||
else if (conf.num_tokens > MAX_NUM_TOKENS)
|
||||
throw new ConfigurationException(String.format("A maximum number of %d tokens per node is supported", MAX_NUM_TOKENS), false);
|
||||
|
||||
if (conf.initial_token != null)
|
||||
{
|
||||
Collection<String> tokens = tokensFromString(conf.initial_token);
|
||||
if (tokens.size() != conf.num_tokens)
|
||||
throw new ConfigurationException("The number of initial tokens (by initial_token) specified is different from num_tokens value", false);
|
||||
|
||||
for (String token : tokens)
|
||||
partitioner.getTokenFactory().validate(token);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// if prepared_statements_cache_size_mb option was set to "auto" then size of the cache should be "max(1/256 of Heap (in MB), 10MB)"
|
||||
|
|
@ -747,8 +559,8 @@ public class DatabaseDescriptor
|
|||
{
|
||||
// if key_cache_size_in_mb option was set to "auto" then size of the cache should be "min(5% of Heap (in MB), 100MB)
|
||||
keyCacheSizeInMB = (conf.key_cache_size_in_mb == null)
|
||||
? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024)), 100)
|
||||
: conf.key_cache_size_in_mb;
|
||||
? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024)), 100)
|
||||
: conf.key_cache_size_in_mb;
|
||||
|
||||
if (keyCacheSizeInMB < 0)
|
||||
throw new NumberFormatException(); // to escape duplicating error message
|
||||
|
|
@ -756,15 +568,15 @@ public class DatabaseDescriptor
|
|||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new ConfigurationException("key_cache_size_in_mb option was set incorrectly to '"
|
||||
+ conf.key_cache_size_in_mb + "', supported values are <integer> >= 0.", false);
|
||||
+ conf.key_cache_size_in_mb + "', supported values are <integer> >= 0.", false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// if counter_cache_size_in_mb option was set to "auto" then size of the cache should be "min(2.5% of Heap (in MB), 50MB)
|
||||
counterCacheSizeInMB = (conf.counter_cache_size_in_mb == null)
|
||||
? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.025 / 1024 / 1024)), 50)
|
||||
: conf.counter_cache_size_in_mb;
|
||||
? Math.min(Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.025 / 1024 / 1024)), 50)
|
||||
: conf.counter_cache_size_in_mb;
|
||||
|
||||
if (counterCacheSizeInMB < 0)
|
||||
throw new NumberFormatException(); // to escape duplicating error message
|
||||
|
|
@ -772,17 +584,17 @@ public class DatabaseDescriptor
|
|||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new ConfigurationException("counter_cache_size_in_mb option was set incorrectly to '"
|
||||
+ conf.counter_cache_size_in_mb + "', supported values are <integer> >= 0.", false);
|
||||
+ conf.counter_cache_size_in_mb + "', supported values are <integer> >= 0.", false);
|
||||
}
|
||||
|
||||
// if set to empty/"auto" then use 5% of Heap size
|
||||
indexSummaryCapacityInMB = (conf.index_summary_capacity_in_mb == null)
|
||||
? Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024))
|
||||
: conf.index_summary_capacity_in_mb;
|
||||
? Math.max(1, (int) (Runtime.getRuntime().totalMemory() * 0.05 / 1024 / 1024))
|
||||
: conf.index_summary_capacity_in_mb;
|
||||
|
||||
if (indexSummaryCapacityInMB < 0)
|
||||
throw new ConfigurationException("index_summary_capacity_in_mb option was set incorrectly to '"
|
||||
+ conf.index_summary_capacity_in_mb + "', it should be a non-negative integer.", false);
|
||||
+ conf.index_summary_capacity_in_mb + "', it should be a non-negative integer.", false);
|
||||
|
||||
if(conf.encryption_options != null)
|
||||
{
|
||||
|
|
@ -791,6 +603,162 @@ public class DatabaseDescriptor
|
|||
conf.server_encryption_options = conf.encryption_options;
|
||||
}
|
||||
|
||||
if (conf.user_defined_function_fail_timeout < 0)
|
||||
throw new ConfigurationException("user_defined_function_fail_timeout must not be negative", false);
|
||||
if (conf.user_defined_function_warn_timeout < 0)
|
||||
throw new ConfigurationException("user_defined_function_warn_timeout must not be negative", false);
|
||||
|
||||
if (conf.user_defined_function_fail_timeout < conf.user_defined_function_warn_timeout)
|
||||
throw new ConfigurationException("user_defined_function_warn_timeout must less than user_defined_function_fail_timeout", false);
|
||||
|
||||
if (conf.max_mutation_size_in_kb == null)
|
||||
conf.max_mutation_size_in_kb = conf.commitlog_segment_size_in_mb * 1024 / 2;
|
||||
else if (conf.commitlog_segment_size_in_mb * 1024 < 2 * conf.max_mutation_size_in_kb)
|
||||
throw new ConfigurationException("commitlog_segment_size_in_mb must be at least twice the size of max_mutation_size_in_kb / 1024", false);
|
||||
|
||||
// native transport encryption options
|
||||
if (conf.native_transport_port_ssl != null
|
||||
&& conf.native_transport_port_ssl.intValue() != conf.native_transport_port.intValue()
|
||||
&& !conf.client_encryption_options.enabled)
|
||||
{
|
||||
throw new ConfigurationException("Encryption must be enabled in client_encryption_options for native_transport_port_ssl", false);
|
||||
}
|
||||
|
||||
if (conf.max_value_size_in_mb == null || conf.max_value_size_in_mb <= 0)
|
||||
throw new ConfigurationException("max_value_size_in_mb must be positive", false);
|
||||
|
||||
switch (conf.disk_optimization_strategy)
|
||||
{
|
||||
case ssd:
|
||||
diskOptimizationStrategy = new SsdDiskOptimizationStrategy(conf.disk_optimization_page_cross_chance);
|
||||
break;
|
||||
case spinning:
|
||||
diskOptimizationStrategy = new SpinningDiskOptimizationStrategy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyAddressConfig() throws ConfigurationException
|
||||
{
|
||||
applyAddressConfig(conf);
|
||||
}
|
||||
|
||||
public static void applyAddressConfig(Config config) throws ConfigurationException
|
||||
{
|
||||
listenAddress = null;
|
||||
rpcAddress = null;
|
||||
broadcastAddress = null;
|
||||
broadcastRpcAddress = null;
|
||||
|
||||
/* Local IP, hostname or interface to bind services to */
|
||||
if (config.listen_address != null && config.listen_interface != null)
|
||||
{
|
||||
throw new ConfigurationException("Set listen_address OR listen_interface, not both", false);
|
||||
}
|
||||
else if (config.listen_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
listenAddress = InetAddress.getByName(config.listen_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown listen_address '" + config.listen_address + "'", false);
|
||||
}
|
||||
|
||||
if (listenAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("listen_address cannot be a wildcard address (" + config.listen_address + ")!", false);
|
||||
}
|
||||
else if (config.listen_interface != null)
|
||||
{
|
||||
listenAddress = getNetworkInterfaceAddress(config.listen_interface, "listen_interface", config.listen_interface_prefer_ipv6);
|
||||
}
|
||||
|
||||
/* Gossip Address to broadcast */
|
||||
if (config.broadcast_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
broadcastAddress = InetAddress.getByName(config.broadcast_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown broadcast_address '" + config.broadcast_address + "'", false);
|
||||
}
|
||||
|
||||
if (broadcastAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("broadcast_address cannot be a wildcard address (" + config.broadcast_address + ")!", false);
|
||||
}
|
||||
|
||||
/* Local IP, hostname or interface to bind RPC server to */
|
||||
if (config.rpc_address != null && config.rpc_interface != null)
|
||||
{
|
||||
throw new ConfigurationException("Set rpc_address OR rpc_interface, not both", false);
|
||||
}
|
||||
else if (config.rpc_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rpcAddress = InetAddress.getByName(config.rpc_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown host in rpc_address " + config.rpc_address, false);
|
||||
}
|
||||
}
|
||||
else if (config.rpc_interface != null)
|
||||
{
|
||||
rpcAddress = getNetworkInterfaceAddress(config.rpc_interface, "rpc_interface", config.rpc_interface_prefer_ipv6);
|
||||
}
|
||||
else
|
||||
{
|
||||
rpcAddress = FBUtilities.getLocalAddress();
|
||||
}
|
||||
|
||||
/* RPC address to broadcast */
|
||||
if (config.broadcast_rpc_address != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
broadcastRpcAddress = InetAddress.getByName(config.broadcast_rpc_address);
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
throw new ConfigurationException("Unknown broadcast_rpc_address '" + config.broadcast_rpc_address + "'", false);
|
||||
}
|
||||
|
||||
if (broadcastRpcAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("broadcast_rpc_address cannot be a wildcard address (" + config.broadcast_rpc_address + ")!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rpcAddress.isAnyLocalAddress())
|
||||
throw new ConfigurationException("If rpc_address is set to a wildcard address (" + config.rpc_address + "), then " +
|
||||
"you must set broadcast_rpc_address to a value other than " + config.rpc_address, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyThriftHSHA()
|
||||
{
|
||||
// fail early instead of OOMing (see CASSANDRA-8116)
|
||||
if (ThriftServerType.HSHA.equals(conf.rpc_server_type) && conf.rpc_max_threads == Integer.MAX_VALUE)
|
||||
throw new ConfigurationException("The hsha rpc_server_type is not compatible with an rpc_max_threads " +
|
||||
"setting of 'unlimited'. Please see the comments in cassandra.yaml " +
|
||||
"for rpc_server_type and rpc_max_threads.",
|
||||
false);
|
||||
if (ThriftServerType.HSHA.equals(conf.rpc_server_type) && conf.rpc_max_threads > (FBUtilities.getAvailableProcessors() * 2 + 1024))
|
||||
logger.warn("rpc_max_threads setting of {} may be too high for the hsha server and cause unnecessary thread contention, reducing performance", conf.rpc_max_threads);
|
||||
}
|
||||
|
||||
public static void applyEncryptionContext()
|
||||
{
|
||||
// always attempt to load the cipher factory, as we could be in the situation where the user has disabled encryption,
|
||||
// but has existing commitlogs and sstables on disk that are still encrypted (and still need to be read)
|
||||
encryptionContext = new EncryptionContext(conf.transparent_data_encryption_options);
|
||||
}
|
||||
|
||||
public static void applySeedProvider()
|
||||
{
|
||||
// load the seeds for node contact points
|
||||
if (conf.seed_provider == null)
|
||||
{
|
||||
|
|
@ -808,34 +776,107 @@ public class DatabaseDescriptor
|
|||
}
|
||||
if (seedProvider.getSeeds().size() == 0)
|
||||
throw new ConfigurationException("The seed provider lists no seeds.", false);
|
||||
}
|
||||
|
||||
if (conf.user_defined_function_fail_timeout < 0)
|
||||
throw new ConfigurationException("user_defined_function_fail_timeout must not be negative", false);
|
||||
if (conf.user_defined_function_warn_timeout < 0)
|
||||
throw new ConfigurationException("user_defined_function_warn_timeout must not be negative", false);
|
||||
|
||||
if (conf.user_defined_function_fail_timeout < conf.user_defined_function_warn_timeout)
|
||||
throw new ConfigurationException("user_defined_function_warn_timeout must less than user_defined_function_fail_timeout", false);
|
||||
|
||||
// always attempt to load the cipher factory, as we could be in the situation where the user has disabled encryption,
|
||||
// but has existing commitlogs and sstables on disk that are still encrypted (and still need to be read)
|
||||
encryptionContext = new EncryptionContext(config.transparent_data_encryption_options);
|
||||
|
||||
if (conf.max_mutation_size_in_kb == null)
|
||||
conf.max_mutation_size_in_kb = conf.commitlog_segment_size_in_mb * 1024 / 2;
|
||||
else if (conf.commitlog_segment_size_in_mb * 1024 < 2 * conf.max_mutation_size_in_kb)
|
||||
throw new ConfigurationException("commitlog_segment_size_in_mb must be at least twice the size of max_mutation_size_in_kb / 1024", false);
|
||||
|
||||
// native transport encryption options
|
||||
if (conf.native_transport_port_ssl != null
|
||||
&& conf.native_transport_port_ssl.intValue() != conf.native_transport_port.intValue()
|
||||
&& !conf.client_encryption_options.enabled)
|
||||
public static void applyInitialTokens()
|
||||
{
|
||||
if (conf.initial_token != null)
|
||||
{
|
||||
throw new ConfigurationException("Encryption must be enabled in client_encryption_options for native_transport_port_ssl", false);
|
||||
Collection<String> tokens = tokensFromString(conf.initial_token);
|
||||
if (tokens.size() != conf.num_tokens)
|
||||
throw new ConfigurationException("The number of initial tokens (by initial_token) specified is different from num_tokens value", false);
|
||||
|
||||
for (String token : tokens)
|
||||
partitioner.getTokenFactory().validate(token);
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe safe for clients + tools
|
||||
public static void applyRequestScheduler()
|
||||
{
|
||||
/* Request Scheduler setup */
|
||||
requestSchedulerOptions = conf.request_scheduler_options;
|
||||
if (conf.request_scheduler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (requestSchedulerOptions == null)
|
||||
{
|
||||
requestSchedulerOptions = new RequestSchedulerOptions();
|
||||
}
|
||||
Class<?> cls = Class.forName(conf.request_scheduler);
|
||||
requestScheduler = (IRequestScheduler) cls.getConstructor(RequestSchedulerOptions.class).newInstance(requestSchedulerOptions);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
throw new ConfigurationException("Invalid Request Scheduler class " + conf.request_scheduler, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ConfigurationException("Unable to instantiate request scheduler", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
requestScheduler = new NoScheduler();
|
||||
}
|
||||
|
||||
if (conf.max_value_size_in_mb == null || conf.max_value_size_in_mb <= 0)
|
||||
throw new ConfigurationException("max_value_size_in_mb must be positive", false);
|
||||
if (conf.request_scheduler_id == RequestSchedulerId.keyspace)
|
||||
{
|
||||
requestSchedulerId = conf.request_scheduler_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to Keyspace
|
||||
requestSchedulerId = RequestSchedulerId.keyspace;
|
||||
}
|
||||
}
|
||||
|
||||
// definitely not safe for tools + clients - implicitly instantiates StorageService
|
||||
public static void applySnitch()
|
||||
{
|
||||
/* end point snitch */
|
||||
if (conf.endpoint_snitch == null)
|
||||
{
|
||||
throw new ConfigurationException("Missing endpoint_snitch directive", false);
|
||||
}
|
||||
snitch = createEndpointSnitch(conf.dynamic_snitch, conf.endpoint_snitch);
|
||||
EndpointSnitchInfo.create();
|
||||
|
||||
localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress());
|
||||
localComparator = new Comparator<InetAddress>()
|
||||
{
|
||||
public int compare(InetAddress endpoint1, InetAddress endpoint2)
|
||||
{
|
||||
boolean local1 = localDC.equals(snitch.getDatacenter(endpoint1));
|
||||
boolean local2 = localDC.equals(snitch.getDatacenter(endpoint2));
|
||||
if (local1 && !local2)
|
||||
return -1;
|
||||
if (local2 && !local1)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// definitely not safe for tools + clients - implicitly instantiates schema
|
||||
public static void applyPartitioner()
|
||||
{
|
||||
/* Hashing strategy */
|
||||
if (conf.partitioner == null)
|
||||
{
|
||||
throw new ConfigurationException("Missing directive: partitioner", false);
|
||||
}
|
||||
try
|
||||
{
|
||||
partitioner = FBUtilities.newPartitioner(System.getProperty("cassandra.partitioner", conf.partitioner));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ConfigurationException("Invalid partitioner class " + conf.partitioner, false);
|
||||
}
|
||||
|
||||
paritionerName = partitioner.getClass().getCanonicalName();
|
||||
}
|
||||
|
||||
private static FileStore guessFileStore(String dir) throws IOException
|
||||
|
|
@ -870,16 +911,31 @@ public class DatabaseDescriptor
|
|||
return authenticator;
|
||||
}
|
||||
|
||||
public static void setAuthenticator(IAuthenticator authenticator)
|
||||
{
|
||||
DatabaseDescriptor.authenticator = authenticator;
|
||||
}
|
||||
|
||||
public static IAuthorizer getAuthorizer()
|
||||
{
|
||||
return authorizer;
|
||||
}
|
||||
|
||||
public static void setAuthorizer(IAuthorizer authorizer)
|
||||
{
|
||||
DatabaseDescriptor.authorizer = authorizer;
|
||||
}
|
||||
|
||||
public static IRoleManager getRoleManager()
|
||||
{
|
||||
return roleManager;
|
||||
}
|
||||
|
||||
public static void setRoleManager(IRoleManager roleManager)
|
||||
{
|
||||
DatabaseDescriptor.roleManager = roleManager;
|
||||
}
|
||||
|
||||
public static int getPermissionsValidity()
|
||||
{
|
||||
return conf.permissions_validity_in_ms;
|
||||
|
|
@ -1183,16 +1239,6 @@ public class DatabaseDescriptor
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isReplacing()
|
||||
{
|
||||
if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemKeyspace.bootstrapComplete())
|
||||
{
|
||||
logger.info("Replace address on first boot requested; this node is already bootstrapped");
|
||||
return false;
|
||||
}
|
||||
return getReplaceAddress() != null;
|
||||
}
|
||||
|
||||
public static String getClusterName()
|
||||
{
|
||||
return conf.cluster_name;
|
||||
|
|
@ -1293,34 +1339,6 @@ public class DatabaseDescriptor
|
|||
return conf.cross_node_timeout;
|
||||
}
|
||||
|
||||
// not part of the Verb enum so we can change timeouts easily via JMX
|
||||
public static long getTimeout(MessagingService.Verb verb)
|
||||
{
|
||||
switch (verb)
|
||||
{
|
||||
case READ:
|
||||
return getReadRpcTimeout();
|
||||
case RANGE_SLICE:
|
||||
case PAGED_RANGE:
|
||||
return getRangeRpcTimeout();
|
||||
case TRUNCATE:
|
||||
return getTruncateRpcTimeout();
|
||||
case READ_REPAIR:
|
||||
case MUTATION:
|
||||
case PAXOS_COMMIT:
|
||||
case PAXOS_PREPARE:
|
||||
case PAXOS_PROPOSE:
|
||||
case HINT:
|
||||
case BATCH_STORE:
|
||||
case BATCH_REMOVE:
|
||||
return getWriteRpcTimeout();
|
||||
case COUNTER_MUTATION:
|
||||
return getCounterWriteRpcTimeout();
|
||||
default:
|
||||
return getRpcTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
public static long getSlowQueryTimeout()
|
||||
{
|
||||
return conf.slow_query_log_timeout_in_ms;
|
||||
|
|
@ -1530,6 +1548,11 @@ public class DatabaseDescriptor
|
|||
return internodeAuthenticator;
|
||||
}
|
||||
|
||||
public static void setInternodeAuthenticator(IInternodeAuthenticator internodeAuthenticator)
|
||||
{
|
||||
DatabaseDescriptor.internodeAuthenticator = internodeAuthenticator;
|
||||
}
|
||||
|
||||
public static void setBroadcastAddress(InetAddress broadcastAdd)
|
||||
{
|
||||
broadcastAddress = broadcastAdd;
|
||||
|
|
@ -1793,7 +1816,7 @@ public class DatabaseDescriptor
|
|||
return new File(conf.hints_directory);
|
||||
}
|
||||
|
||||
public static File getSerializedCachePath(CacheService.CacheType cacheType, String version, String extension)
|
||||
public static File getSerializedCachePath(CacheType cacheType, String version, String extension)
|
||||
{
|
||||
String name = cacheType.toString()
|
||||
+ (version == null ? "" : "-" + version + "." + extension);
|
||||
|
|
@ -1828,12 +1851,12 @@ public class DatabaseDescriptor
|
|||
conf.dynamic_snitch_badness_threshold = dynamicBadnessThreshold;
|
||||
}
|
||||
|
||||
public static ServerEncryptionOptions getServerEncryptionOptions()
|
||||
public static EncryptionOptions.ServerEncryptionOptions getServerEncryptionOptions()
|
||||
{
|
||||
return conf.server_encryption_options;
|
||||
}
|
||||
|
||||
public static ClientEncryptionOptions getClientEncryptionOptions()
|
||||
public static EncryptionOptions.ClientEncryptionOptions getClientEncryptionOptions()
|
||||
{
|
||||
return conf.client_encryption_options;
|
||||
}
|
||||
|
|
@ -2060,33 +2083,24 @@ public class DatabaseDescriptor
|
|||
return conf.inter_dc_tcp_nodelay;
|
||||
}
|
||||
|
||||
|
||||
public static SSTableFormat.Type getSSTableFormat()
|
||||
public static long getMemtableHeapSpaceInMb()
|
||||
{
|
||||
return sstable_format;
|
||||
return conf.memtable_heap_space_in_mb;
|
||||
}
|
||||
|
||||
public static MemtablePool getMemtableAllocatorPool()
|
||||
public static long getMemtableOffheapSpaceInMb()
|
||||
{
|
||||
long heapLimit = ((long) conf.memtable_heap_space_in_mb) << 20;
|
||||
long offHeapLimit = ((long) conf.memtable_offheap_space_in_mb) << 20;
|
||||
switch (conf.memtable_allocation_type)
|
||||
{
|
||||
case unslabbed_heap_buffers:
|
||||
return new HeapPool(heapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case heap_buffers:
|
||||
return new SlabPool(heapLimit, 0, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case offheap_buffers:
|
||||
if (!FileUtils.isCleanerAvailable)
|
||||
{
|
||||
throw new IllegalStateException("Could not free direct byte buffer: offheap_buffers is not a safe memtable_allocation_type without this ability, please adjust your config. This feature is only guaranteed to work on an Oracle JVM. Refusing to start.");
|
||||
}
|
||||
return new SlabPool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case offheap_objects:
|
||||
return new NativePool(heapLimit, offHeapLimit, conf.memtable_cleanup_threshold, new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
return conf.memtable_offheap_space_in_mb;
|
||||
}
|
||||
|
||||
public static Config.MemtableAllocationType getMemtableAllocationType()
|
||||
{
|
||||
return conf.memtable_allocation_type;
|
||||
}
|
||||
|
||||
public static Float getMemtableCleanupThreshold()
|
||||
{
|
||||
return conf.memtable_cleanup_threshold;
|
||||
}
|
||||
|
||||
public static int getIndexSummaryResizeIntervalInMinutes()
|
||||
|
|
|
|||
|
|
@ -17,18 +17,14 @@
|
|||
*/
|
||||
package org.apache.cassandra.config;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.auth.AuthKeyspace;
|
||||
import org.apache.cassandra.cql3.functions.*;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
|
|
@ -40,10 +36,8 @@ import org.apache.cassandra.db.marshal.UserType;
|
|||
import org.apache.cassandra.index.Index;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.locator.LocalStrategy;
|
||||
import org.apache.cassandra.repair.SystemDistributedKeyspace;
|
||||
import org.apache.cassandra.schema.*;
|
||||
import org.apache.cassandra.service.MigrationManager;
|
||||
import org.apache.cassandra.tracing.TraceKeyspace;
|
||||
import org.apache.cassandra.utils.ConcurrentBiMap;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
import org.cliffc.high_scale_lib.NonBlockingHashMap;
|
||||
|
|
@ -54,22 +48,6 @@ public class Schema
|
|||
|
||||
public static final Schema instance = new Schema();
|
||||
|
||||
/* system keyspace names (the ones with LocalStrategy replication strategy) */
|
||||
public static final Set<String> SYSTEM_KEYSPACE_NAMES = ImmutableSet.of(SystemKeyspace.NAME, SchemaKeyspace.NAME);
|
||||
|
||||
/* replicate system keyspace names (the ones with a "true" replication strategy) */
|
||||
public static final Set<String> REPLICATED_SYSTEM_KEYSPACE_NAMES = ImmutableSet.of(TraceKeyspace.NAME,
|
||||
AuthKeyspace.NAME,
|
||||
SystemDistributedKeyspace.NAME);
|
||||
|
||||
/**
|
||||
* longest permissible KS or CF name. Our main concern is that filename not be more than 255 characters;
|
||||
* the filename will contain both the KS and CF names. Since non-schema-name components only take up
|
||||
* ~64 characters, we could allow longer names than this, but on Windows, the entire path should be not greater than
|
||||
* 255 characters, so a lower limit here helps avoid problems. See CASSANDRA-4110.
|
||||
*/
|
||||
public static final int NAME_LENGTH = 48;
|
||||
|
||||
/* metadata map for faster keyspace lookup */
|
||||
private final Map<String, KeyspaceMetadata> keyspaces = new NonBlockingHashMap<>();
|
||||
|
||||
|
|
@ -81,22 +59,6 @@ public class Schema
|
|||
|
||||
private volatile UUID version;
|
||||
|
||||
// 59adb24e-f3cd-3e02-97f0-5b395827453f
|
||||
public static final UUID emptyVersion;
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
emptyVersion = UUID.nameUUIDFromBytes(MessageDigest.getInstance("MD5").digest());
|
||||
}
|
||||
catch (NoSuchAlgorithmException e)
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize empty schema object and load the hardcoded system tables
|
||||
*/
|
||||
|
|
@ -109,14 +71,6 @@ public class Schema
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether or not the keyspace is a really system one (w/ LocalStrategy, unmodifiable, hardcoded)
|
||||
*/
|
||||
public static boolean isSystemKeyspace(String keyspaceName)
|
||||
{
|
||||
return SYSTEM_KEYSPACE_NAMES.contains(keyspaceName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* load keyspace (keyspace) definitions, but do not initialize the keyspace instances.
|
||||
* Schema version may be updated as the result.
|
||||
|
|
@ -341,7 +295,7 @@ public class Schema
|
|||
|
||||
private Set<String> getNonSystemKeyspacesSet()
|
||||
{
|
||||
return Sets.difference(keyspaces.keySet(), SYSTEM_KEYSPACE_NAMES);
|
||||
return Sets.difference(keyspaces.keySet(), SchemaConstants.SYSTEM_KEYSPACE_NAMES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -370,7 +324,7 @@ public class Schema
|
|||
*/
|
||||
public List<String> getUserKeyspaces()
|
||||
{
|
||||
return ImmutableList.copyOf(Sets.difference(getNonSystemKeyspacesSet(), REPLICATED_SYSTEM_KEYSPACE_NAMES));
|
||||
return ImmutableList.copyOf(Sets.difference(getNonSystemKeyspacesSet(), SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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 java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public final class SchemaConstants
|
||||
{
|
||||
public static final String SYSTEM_KEYSPACE_NAME = "system";
|
||||
public static final String SCHEMA_KEYSPACE_NAME = "system_schema";
|
||||
|
||||
public static final String TRACE_KEYSPACE_NAME = "system_traces";
|
||||
public static final String AUTH_KEYSPACE_NAME = "system_auth";
|
||||
public static final String DISTRIBUTED_KEYSPACE_NAME = "system_distributed";
|
||||
|
||||
/* system keyspace names (the ones with LocalStrategy replication strategy) */
|
||||
public static final Set<String> SYSTEM_KEYSPACE_NAMES = ImmutableSet.of(SYSTEM_KEYSPACE_NAME, SCHEMA_KEYSPACE_NAME);
|
||||
|
||||
/* replicate system keyspace names (the ones with a "true" replication strategy) */
|
||||
public static final Set<String> REPLICATED_SYSTEM_KEYSPACE_NAMES = ImmutableSet.of(TRACE_KEYSPACE_NAME,
|
||||
AUTH_KEYSPACE_NAME,
|
||||
DISTRIBUTED_KEYSPACE_NAME);
|
||||
/**
|
||||
* longest permissible KS or CF name. Our main concern is that filename not be more than 255 characters;
|
||||
* the filename will contain both the KS and CF names. Since non-schema-name components only take up
|
||||
* ~64 characters, we could allow longer names than this, but on Windows, the entire path should be not greater than
|
||||
* 255 characters, so a lower limit here helps avoid problems. See CASSANDRA-4110.
|
||||
*/
|
||||
public static final int NAME_LENGTH = 48;
|
||||
|
||||
// 59adb24e-f3cd-3e02-97f0-5b395827453f
|
||||
public static final UUID emptyVersion;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
emptyVersion = UUID.nameUUIDFromBytes(MessageDigest.getInstance("MD5").digest());
|
||||
}
|
||||
catch (NoSuchAlgorithmException e)
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether or not the keyspace is a really system one (w/ LocalStrategy, unmodifiable, hardcoded)
|
||||
*/
|
||||
public static boolean isSystemKeyspace(String keyspaceName)
|
||||
{
|
||||
return SYSTEM_KEYSPACE_NAMES.contains(keyspaceName.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
|
@ -91,11 +91,13 @@ public class YamlConfigurationLoader implements ConfigurationLoader
|
|||
return url;
|
||||
}
|
||||
|
||||
private static final URL storageConfigURL = getStorageConfigURL();
|
||||
private static URL storageConfigURL;
|
||||
|
||||
@Override
|
||||
public Config loadConfig() throws ConfigurationException
|
||||
{
|
||||
if (storageConfigURL == null)
|
||||
storageConfigURL = getStorageConfigURL();
|
||||
return loadConfig(storageConfigURL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ import org.slf4j.LoggerFactory;
|
|||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||
import org.antlr.runtime.*;
|
||||
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.functions.Function;
|
||||
import org.apache.cassandra.cql3.functions.FunctionName;
|
||||
import org.apache.cassandra.cql3.statements.*;
|
||||
|
|
@ -134,7 +136,7 @@ public class QueryProcessor implements QueryHandler
|
|||
InternalStateInstance()
|
||||
{
|
||||
ClientState state = ClientState.forInternalCalls();
|
||||
state.setKeyspace(SystemKeyspace.NAME);
|
||||
state.setKeyspace(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
this.queryState = new QueryState(state);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.cassandra.cql3.functions;
|
|||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
|
||||
public final class FunctionName
|
||||
{
|
||||
|
|
@ -28,7 +28,7 @@ public final class FunctionName
|
|||
|
||||
public static FunctionName nativeFunction(String name)
|
||||
{
|
||||
return new FunctionName(SystemKeyspace.NAME, name);
|
||||
return new FunctionName(SchemaConstants.SYSTEM_KEYSPACE_NAME, name);
|
||||
}
|
||||
|
||||
public FunctionName(String keyspace, String name)
|
||||
|
|
@ -67,8 +67,8 @@ public final class FunctionName
|
|||
|
||||
public final boolean equalsNativeFunction(FunctionName nativeFunction)
|
||||
{
|
||||
assert nativeFunction.keyspace.equals(SystemKeyspace.NAME);
|
||||
if (this.hasKeyspace() && !this.keyspace.equals(SystemKeyspace.NAME))
|
||||
assert nativeFunction.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
if (this.hasKeyspace() && !this.keyspace.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
return false;
|
||||
|
||||
return Objects.equal(this.name, nativeFunction.name);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.cassandra.cql3.statements;
|
|||
|
||||
import org.apache.cassandra.auth.Permission;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.exceptions.*;
|
||||
import org.apache.cassandra.locator.LocalStrategy;
|
||||
import org.apache.cassandra.schema.KeyspaceMetadata;
|
||||
|
|
@ -55,7 +56,7 @@ public class AlterKeyspaceStatement extends SchemaAlteringStatement
|
|||
KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name);
|
||||
if (ksm == null)
|
||||
throw new InvalidRequestException("Unknown keyspace " + name);
|
||||
if (Schema.isSystemKeyspace(ksm.name))
|
||||
if (SchemaConstants.isSystemKeyspace(ksm.name))
|
||||
throw new InvalidRequestException("Cannot alter system keyspace");
|
||||
|
||||
attrs.validate();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.exceptions.*;
|
||||
import org.apache.cassandra.locator.LocalStrategy;
|
||||
import org.apache.cassandra.schema.KeyspaceMetadata;
|
||||
|
|
@ -79,8 +79,8 @@ public class CreateKeyspaceStatement extends SchemaAlteringStatement
|
|||
// keyspace name
|
||||
if (!PATTERN_WORD_CHARS.matcher(name).matches())
|
||||
throw new InvalidRequestException(String.format("\"%s\" is not a valid keyspace name", name));
|
||||
if (name.length() > Schema.NAME_LENGTH)
|
||||
throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, name));
|
||||
if (name.length() > SchemaConstants.NAME_LENGTH)
|
||||
throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", SchemaConstants.NAME_LENGTH, name));
|
||||
|
||||
attrs.validate();
|
||||
|
||||
|
|
|
|||
|
|
@ -206,8 +206,8 @@ public class CreateTableStatement extends SchemaAlteringStatement
|
|||
// Column family name
|
||||
if (!PATTERN_WORD_CHARS.matcher(columnFamily()).matches())
|
||||
throw new InvalidRequestException(String.format("\"%s\" is not a valid table name (must be alphanumeric character or underscore only: [a-zA-Z_0-9]+)", columnFamily()));
|
||||
if (columnFamily().length() > Schema.NAME_LENGTH)
|
||||
throw new InvalidRequestException(String.format("Table names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, columnFamily()));
|
||||
if (columnFamily().length() > SchemaConstants.NAME_LENGTH)
|
||||
throw new InvalidRequestException(String.format("Table names shouldn't be more than %s characters long (got \"%s\")", SchemaConstants.NAME_LENGTH, columnFamily()));
|
||||
|
||||
for (Multiset.Entry<ColumnIdentifier> entry : definedNames.entrySet())
|
||||
if (entry.getCount() > 1)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.*;
|
|||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.*;
|
||||
import org.apache.cassandra.db.marshal.UTF8Type;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
|
|
@ -31,7 +32,7 @@ import org.apache.cassandra.transport.messages.ResultMessage;
|
|||
|
||||
public class ListPermissionsStatement extends AuthorizationStatement
|
||||
{
|
||||
private static final String KS = AuthKeyspace.NAME;
|
||||
private static final String KS = SchemaConstants.AUTH_KEYSPACE_NAME;
|
||||
private static final String CF = "permissions"; // virtual cf to use for now.
|
||||
|
||||
private static final List<ColumnSpecification> metadata;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
|
|||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.*;
|
||||
import org.apache.cassandra.db.marshal.BooleanType;
|
||||
import org.apache.cassandra.db.marshal.MapType;
|
||||
|
|
@ -37,7 +38,7 @@ import org.apache.cassandra.transport.messages.ResultMessage;
|
|||
public class ListRolesStatement extends AuthorizationStatement
|
||||
{
|
||||
// pseudo-virtual cf as the actual datasource is dependent on the IRoleManager impl
|
||||
private static final String KS = AuthKeyspace.NAME;
|
||||
private static final String KS = SchemaConstants.AUTH_KEYSPACE_NAME;
|
||||
private static final String CF = AuthKeyspace.ROLES;
|
||||
|
||||
private static final MapType optionsType = MapType.getInstance(UTF8Type.instance, UTF8Type.instance, false);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
|
|||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
import org.apache.cassandra.cql3.ColumnSpecification;
|
||||
import org.apache.cassandra.cql3.ResultSet;
|
||||
|
|
@ -33,7 +34,7 @@ import org.apache.cassandra.transport.messages.ResultMessage;
|
|||
public class ListUsersStatement extends ListRolesStatement
|
||||
{
|
||||
// pseudo-virtual cf as the actual datasource is dependent on the IRoleManager impl
|
||||
private static final String KS = AuthKeyspace.NAME;
|
||||
private static final String KS = SchemaConstants.AUTH_KEYSPACE_NAME;
|
||||
private static final String CF = "users";
|
||||
|
||||
private static final List<ColumnSpecification> metadata =
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import java.util.Set;
|
|||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.RoleName;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.exceptions.RequestValidationException;
|
||||
import org.apache.cassandra.exceptions.UnauthorizedException;
|
||||
|
|
@ -54,7 +54,7 @@ public abstract class PermissionsManagementStatement extends AuthorizationStatem
|
|||
|
||||
// altering permissions on builtin functions is not supported
|
||||
if (resource instanceof FunctionResource
|
||||
&& SystemKeyspace.NAME.equals(((FunctionResource)resource).getKeyspace()))
|
||||
&& SchemaConstants.SYSTEM_KEYSPACE_NAME.equals(((FunctionResource)resource).getKeyspace()))
|
||||
{
|
||||
throw new InvalidRequestException("Altering permissions on builtin functions is not supported");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -817,7 +817,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
|
||||
public String getSSTablePath(File directory)
|
||||
{
|
||||
return getSSTablePath(directory, DatabaseDescriptor.getSSTableFormat().info.getLatestVersion(), DatabaseDescriptor.getSSTableFormat());
|
||||
return getSSTablePath(directory, SSTableFormat.Type.current().info.getLatestVersion(), SSTableFormat.Type.current());
|
||||
}
|
||||
|
||||
public String getSSTablePath(File directory, SSTableFormat.Type format)
|
||||
|
|
@ -1775,7 +1775,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
}
|
||||
|
||||
writeSnapshotManifest(filesJSONArr, snapshotName);
|
||||
if (!Schema.SYSTEM_KEYSPACE_NAMES.contains(metadata.ksName) && !Schema.REPLICATED_SYSTEM_KEYSPACE_NAMES.contains(metadata.ksName))
|
||||
if (!SchemaConstants.SYSTEM_KEYSPACE_NAMES.contains(metadata.ksName) && !SchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES.contains(metadata.ksName))
|
||||
writeSnapshotSchema(snapshotName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class Keyspace
|
|||
|
||||
public static Keyspace open(String keyspaceName)
|
||||
{
|
||||
assert initialized || Schema.isSystemKeyspace(keyspaceName);
|
||||
assert initialized || SchemaConstants.isSystemKeyspace(keyspaceName);
|
||||
return open(keyspaceName, Schema.instance, true);
|
||||
}
|
||||
|
||||
|
|
@ -685,7 +685,7 @@ public class Keyspace
|
|||
|
||||
public static Iterable<Keyspace> system()
|
||||
{
|
||||
return Iterables.transform(Schema.SYSTEM_KEYSPACE_NAMES, keyspaceTransformer);
|
||||
return Iterables.transform(SchemaConstants.SYSTEM_KEYSPACE_NAMES, keyspaceTransformer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.utils.AbstractIterator;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
@ -1025,7 +1026,7 @@ public abstract class LegacyLayout
|
|||
// then simply ignore the cell is fine. But also not that we ignore if it's the
|
||||
// system keyspace because for those table we actually remove columns without registering
|
||||
// them in the dropped columns
|
||||
assert metadata.ksName.equals(SystemKeyspace.NAME) || metadata.getDroppedColumnDefinition(e.columnName) != null : e.getMessage();
|
||||
assert metadata.ksName.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME) || metadata.getDroppedColumnDefinition(e.columnName) != null : e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1105,7 +1106,7 @@ public abstract class LegacyLayout
|
|||
// then simply ignore the cell is fine. But also not that we ignore if it's the
|
||||
// system keyspace because for those table we actually remove columns without registering
|
||||
// them in the dropped columns
|
||||
if (metadata.ksName.equals(SystemKeyspace.NAME) || metadata.getDroppedColumnDefinition(e.columnName) != null)
|
||||
if (metadata.ksName.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME) || metadata.getDroppedColumnDefinition(e.columnName) != null)
|
||||
return computeNext();
|
||||
else
|
||||
throw new IOError(e);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.db.commitlog.CommitLogPosition;
|
||||
import org.apache.cassandra.db.commitlog.IntervalSet;
|
||||
|
|
@ -48,20 +49,48 @@ import org.apache.cassandra.index.transactions.UpdateTransaction;
|
|||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.io.sstable.SSTableMultiWriter;
|
||||
import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
|
||||
import org.apache.cassandra.io.util.FileUtils;
|
||||
import org.apache.cassandra.service.ActiveRepairService;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.ObjectSizes;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.utils.concurrent.OpOrder;
|
||||
import org.apache.cassandra.utils.memory.HeapPool;
|
||||
import org.apache.cassandra.utils.memory.MemtableAllocator;
|
||||
import org.apache.cassandra.utils.memory.MemtablePool;
|
||||
import org.apache.cassandra.utils.memory.NativePool;
|
||||
import org.apache.cassandra.utils.memory.SlabPool;
|
||||
|
||||
public class Memtable implements Comparable<Memtable>
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Memtable.class);
|
||||
|
||||
public static final MemtablePool MEMORY_POOL = DatabaseDescriptor.getMemtableAllocatorPool();
|
||||
public static final MemtablePool MEMORY_POOL = createMemtableAllocatorPool();
|
||||
|
||||
private static MemtablePool createMemtableAllocatorPool()
|
||||
{
|
||||
long heapLimit = DatabaseDescriptor.getMemtableHeapSpaceInMb() << 20;
|
||||
long offHeapLimit = DatabaseDescriptor.getMemtableOffheapSpaceInMb() << 20;
|
||||
switch (DatabaseDescriptor.getMemtableAllocationType())
|
||||
{
|
||||
case unslabbed_heap_buffers:
|
||||
return new HeapPool(heapLimit, DatabaseDescriptor.getMemtableCleanupThreshold(), new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case heap_buffers:
|
||||
return new SlabPool(heapLimit, 0, DatabaseDescriptor.getMemtableCleanupThreshold(), new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case offheap_buffers:
|
||||
if (!FileUtils.isCleanerAvailable)
|
||||
{
|
||||
throw new IllegalStateException("Could not free direct byte buffer: offheap_buffers is not a safe memtable_allocation_type without this ability, please adjust your config. This feature is only guaranteed to work on an Oracle JVM. Refusing to start.");
|
||||
}
|
||||
return new SlabPool(heapLimit, offHeapLimit, DatabaseDescriptor.getMemtableCleanupThreshold(), new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
case offheap_objects:
|
||||
return new NativePool(heapLimit, offHeapLimit, DatabaseDescriptor.getMemtableCleanupThreshold(), new ColumnFamilyStore.FlushLargestColumnFamily());
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int ROW_OVERHEAD_HEAP_SIZE = estimateRowOverhead(Integer.parseInt(System.getProperty("cassandra.memtable_row_overhead_computation_step", "100000")));
|
||||
|
||||
private final MemtableAllocator allocator;
|
||||
|
|
@ -416,7 +445,7 @@ public class Memtable implements Comparable<Memtable>
|
|||
+ liveDataSize.get()) // data
|
||||
* 1.2); // bloom filter and row index overhead
|
||||
|
||||
this.isBatchLogTable = cfs.name.equals(SystemKeyspace.BATCHES) && cfs.keyspace.getName().equals(SystemKeyspace.NAME);
|
||||
this.isBatchLogTable = cfs.name.equals(SystemKeyspace.BATCHES) && cfs.keyspace.getName().equals(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
|
||||
if (flushLocation == null)
|
||||
writer = createFlushWriter(txn, cfs.getSSTablePath(getDirectories().getWriteableLocationAsFile(estimatedSize)), columnsCollector.get(), statsCollector.get());
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ public abstract class ReadCommand extends MonitorableImpl implements ReadQuery
|
|||
private final int failureThreshold = DatabaseDescriptor.getTombstoneFailureThreshold();
|
||||
private final int warningThreshold = DatabaseDescriptor.getTombstoneWarnThreshold();
|
||||
|
||||
private final boolean respectTombstoneThresholds = !Schema.isSystemKeyspace(ReadCommand.this.metadata().ksName);
|
||||
private final boolean respectTombstoneThresholds = !SchemaConstants.isSystemKeyspace(ReadCommand.this.metadata().ksName);
|
||||
|
||||
private int liveRows = 0;
|
||||
private int tombstones = 0;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.cql3.functions.*;
|
||||
|
|
@ -84,8 +85,6 @@ public final class SystemKeyspace
|
|||
// Cassandra was not previously installed and we're in the process of starting a fresh node.
|
||||
public static final CassandraVersion NULL_VERSION = new CassandraVersion("0.0.0-absent");
|
||||
|
||||
public static final String NAME = "system";
|
||||
|
||||
public static final String BATCHES = "batches";
|
||||
public static final String PAXOS = "paxos";
|
||||
public static final String BUILT_INDEXES = "IndexInfo";
|
||||
|
|
@ -432,13 +431,13 @@ public final class SystemKeyspace
|
|||
|
||||
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.SYSTEM_KEYSPACE_NAME)
|
||||
.comment(description);
|
||||
}
|
||||
|
||||
public static KeyspaceMetadata metadata()
|
||||
{
|
||||
return KeyspaceMetadata.create(NAME, KeyspaceParams.local(), tables(), Views.none(), Types.none(), functions());
|
||||
return KeyspaceMetadata.create(SchemaConstants.SYSTEM_KEYSPACE_NAME, KeyspaceParams.local(), tables(), Views.none(), Types.none(), functions());
|
||||
}
|
||||
|
||||
private static Tables tables()
|
||||
|
|
@ -557,14 +556,14 @@ public final class SystemKeyspace
|
|||
public static boolean isViewBuilt(String keyspaceName, String viewName)
|
||||
{
|
||||
String req = "SELECT view_name FROM %s.\"%s\" WHERE keyspace_name=? AND view_name=?";
|
||||
UntypedResultSet result = executeInternal(String.format(req, NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
UntypedResultSet result = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
return !result.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isViewStatusReplicated(String keyspaceName, String viewName)
|
||||
{
|
||||
String req = "SELECT status_replicated FROM %s.\"%s\" WHERE keyspace_name=? AND view_name=?";
|
||||
UntypedResultSet result = executeInternal(String.format(req, NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
UntypedResultSet result = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
|
||||
if (result.isEmpty())
|
||||
return false;
|
||||
|
|
@ -575,18 +574,18 @@ public final class SystemKeyspace
|
|||
public static void setViewBuilt(String keyspaceName, String viewName, boolean replicated)
|
||||
{
|
||||
String req = "INSERT INTO %s.\"%s\" (keyspace_name, view_name, status_replicated) VALUES (?, ?, ?)";
|
||||
executeInternal(String.format(req, NAME, BUILT_VIEWS), keyspaceName, viewName, replicated);
|
||||
executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName, replicated);
|
||||
forceBlockingFlush(BUILT_VIEWS);
|
||||
}
|
||||
|
||||
public static void setViewRemoved(String keyspaceName, String viewName)
|
||||
{
|
||||
String buildReq = "DELETE FROM %S.%s WHERE keyspace_name = ? AND view_name = ?";
|
||||
executeInternal(String.format(buildReq, NAME, VIEWS_BUILDS_IN_PROGRESS), keyspaceName, viewName);
|
||||
executeInternal(String.format(buildReq, SchemaConstants.SYSTEM_KEYSPACE_NAME, VIEWS_BUILDS_IN_PROGRESS), keyspaceName, viewName);
|
||||
forceBlockingFlush(VIEWS_BUILDS_IN_PROGRESS);
|
||||
|
||||
String builtReq = "DELETE FROM %s.\"%s\" WHERE keyspace_name = ? AND view_name = ?";
|
||||
executeInternal(String.format(builtReq, NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
executeInternal(String.format(builtReq, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName);
|
||||
forceBlockingFlush(BUILT_VIEWS);
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +813,7 @@ public final class SystemKeyspace
|
|||
public static void forceBlockingFlush(String cfname)
|
||||
{
|
||||
if (!Boolean.getBoolean("cassandra.unsafesystem"))
|
||||
FBUtilities.waitOnFuture(Keyspace.open(NAME).getColumnFamilyStore(cfname).forceFlush());
|
||||
FBUtilities.waitOnFuture(Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(cfname).forceFlush());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -930,7 +929,7 @@ public final class SystemKeyspace
|
|||
Keyspace keyspace;
|
||||
try
|
||||
{
|
||||
keyspace = Keyspace.open(NAME);
|
||||
keyspace = Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
}
|
||||
catch (AssertionError err)
|
||||
{
|
||||
|
|
@ -1041,21 +1040,21 @@ public final class SystemKeyspace
|
|||
public static boolean isIndexBuilt(String keyspaceName, String indexName)
|
||||
{
|
||||
String req = "SELECT index_name FROM %s.\"%s\" WHERE table_name=? AND index_name=?";
|
||||
UntypedResultSet result = executeInternal(String.format(req, NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
UntypedResultSet result = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
return !result.isEmpty();
|
||||
}
|
||||
|
||||
public static void setIndexBuilt(String keyspaceName, String indexName)
|
||||
{
|
||||
String req = "INSERT INTO %s.\"%s\" (table_name, index_name) VALUES (?, ?)";
|
||||
executeInternal(String.format(req, NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
forceBlockingFlush(BUILT_INDEXES);
|
||||
}
|
||||
|
||||
public static void setIndexRemoved(String keyspaceName, String indexName)
|
||||
{
|
||||
String req = "DELETE FROM %s.\"%s\" WHERE table_name = ? AND index_name = ?";
|
||||
executeInternal(String.format(req, NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName);
|
||||
forceBlockingFlush(BUILT_INDEXES);
|
||||
}
|
||||
|
||||
|
|
@ -1063,7 +1062,7 @@ public final class SystemKeyspace
|
|||
{
|
||||
List<String> names = new ArrayList<>(indexNames);
|
||||
String req = "SELECT index_name from %s.\"%s\" WHERE table_name=? AND index_name IN ?";
|
||||
UntypedResultSet results = executeInternal(String.format(req, NAME, BUILT_INDEXES), keyspaceName, names);
|
||||
UntypedResultSet results = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, names);
|
||||
return StreamSupport.stream(results.spliterator(), false)
|
||||
.map(r -> r.getString("index_name"))
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -1273,7 +1272,7 @@ public final class SystemKeyspace
|
|||
*/
|
||||
public static void clearSizeEstimates(String keyspace, String table)
|
||||
{
|
||||
String cql = String.format("DELETE FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, SIZE_ESTIMATES);
|
||||
String cql = String.format("DELETE FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SYSTEM_KEYSPACE_NAME, SIZE_ESTIMATES);
|
||||
executeInternal(cql, keyspace, table);
|
||||
}
|
||||
|
||||
|
|
@ -1306,7 +1305,7 @@ public final class SystemKeyspace
|
|||
|
||||
public static void resetAvailableRanges()
|
||||
{
|
||||
ColumnFamilyStore availableRanges = Keyspace.open(NAME).getColumnFamilyStore(AVAILABLE_RANGES);
|
||||
ColumnFamilyStore availableRanges = Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(AVAILABLE_RANGES);
|
||||
availableRanges.truncateBlocking();
|
||||
}
|
||||
|
||||
|
|
@ -1363,7 +1362,7 @@ public final class SystemKeyspace
|
|||
String snapshotName = Keyspace.getTimestampedSnapshotName(String.format("upgrade-%s-%s",
|
||||
previous,
|
||||
next));
|
||||
Keyspace systemKs = Keyspace.open(SystemKeyspace.NAME);
|
||||
Keyspace systemKs = Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
systemKs.snapshot(snapshotName, null);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1392,7 +1391,7 @@ public final class SystemKeyspace
|
|||
// the current version is. If we couldn't read a previous version from system.local we check for
|
||||
// the existence of the legacy system.Versions table. We don't actually attempt to read a version
|
||||
// from there, but it informs us that this isn't a completely new node.
|
||||
for (File dataDirectory : Directories.getKSChildDirectories(SystemKeyspace.NAME))
|
||||
for (File dataDirectory : Directories.getKSChildDirectories(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
{
|
||||
if (dataDirectory.getName().equals("Versions") && dataDirectory.listFiles().length > 0)
|
||||
{
|
||||
|
|
@ -1474,7 +1473,7 @@ public final class SystemKeyspace
|
|||
{
|
||||
executeInternal(String.format("INSERT INTO %s.%s"
|
||||
+ " (logged_keyspace, prepared_id, query_string) VALUES (?, ?, ?)",
|
||||
NAME, PREPARED_STATEMENTS),
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME, PREPARED_STATEMENTS),
|
||||
loggedKeyspace, key.byteBuffer(), cql);
|
||||
logger.debug("stored prepared statement for logged keyspace '{}': '{}'", loggedKeyspace, cql);
|
||||
}
|
||||
|
|
@ -1483,13 +1482,13 @@ public final class SystemKeyspace
|
|||
{
|
||||
executeInternal(String.format("DELETE FROM %s.%s"
|
||||
+ " WHERE prepared_id = ?",
|
||||
NAME, PREPARED_STATEMENTS),
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME, PREPARED_STATEMENTS),
|
||||
key.byteBuffer());
|
||||
}
|
||||
|
||||
public static List<Pair<String, String>> loadPreparedStatements()
|
||||
{
|
||||
String query = String.format("SELECT logged_keyspace, query_string FROM %s.%s", NAME, PREPARED_STATEMENTS);
|
||||
String query = String.format("SELECT logged_keyspace, query_string FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, PREPARED_STATEMENTS);
|
||||
UntypedResultSet resultSet = executeOnceInternal(query);
|
||||
List<Pair<String, String>> r = new ArrayList<>();
|
||||
for (UntypedResultSet.Row row : resultSet)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,11 @@ import org.apache.cassandra.concurrent.Stage;
|
|||
import org.apache.cassandra.concurrent.StageManager;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.Mutation;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.db.partitions.PartitionUpdate;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
|
|
@ -155,7 +159,7 @@ public class CommitLogReplayer implements CommitLogReadHandler
|
|||
List<Future<?>> futures = new ArrayList<Future<?>>();
|
||||
for (Keyspace keyspace : keyspacesReplayed)
|
||||
{
|
||||
if (keyspace.getName().equals(SystemKeyspace.NAME))
|
||||
if (keyspace.getName().equals(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
flushingSystem = true;
|
||||
|
||||
futures.addAll(keyspace.flush());
|
||||
|
|
@ -163,7 +167,7 @@ public class CommitLogReplayer implements CommitLogReadHandler
|
|||
|
||||
// also flush batchlog incase of any MV updates
|
||||
if (!flushingSystem)
|
||||
futures.add(Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceFlush());
|
||||
futures.add(Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceFlush());
|
||||
|
||||
FBUtilities.waitOnFutures(futures);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.datastax.driver.core.Row;
|
|||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.TokenRange;
|
||||
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapred.InputSplit;
|
||||
import org.apache.hadoop.mapred.JobConf;
|
||||
|
|
@ -239,7 +240,7 @@ public class CqlInputFormat extends org.apache.hadoop.mapreduce.InputFormat<Long
|
|||
String query = String.format("SELECT mean_partition_size, partitions_count " +
|
||||
"FROM %s.%s " +
|
||||
"WHERE keyspace_name = ? AND table_name = ? AND range_start = ? AND range_end = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.SIZE_ESTIMATES);
|
||||
|
||||
ResultSet resultSet = session.execute(query, keyspace, table, tokenRange.getStart().toString(), tokenRange.getEnd().toString());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import java.util.function.Function;
|
|||
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.net.IAsyncCallbackWithFailure;
|
||||
import org.apache.cassandra.net.MessageIn;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
|
|
@ -178,7 +177,7 @@ final class HintsDispatcher implements AutoCloseable
|
|||
|
||||
Outcome await()
|
||||
{
|
||||
long timeout = TimeUnit.MILLISECONDS.toNanos(DatabaseDescriptor.getTimeout(MessagingService.Verb.HINT)) - (System.nanoTime() - start);
|
||||
long timeout = TimeUnit.MILLISECONDS.toNanos(MessagingService.Verb.HINT.getTimeout()) - (System.nanoTime() - start);
|
||||
boolean timedOut;
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -27,6 +27,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.*;
|
||||
|
|
@ -59,7 +60,7 @@ public final class LegacyHintsMigrator
|
|||
this.hintsDirectory = hintsDirectory;
|
||||
this.maxHintsFileSize = maxHintsFileSize;
|
||||
|
||||
legacyHintsTable = Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_HINTS);
|
||||
legacyHintsTable = Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_HINTS);
|
||||
pageSize = calculatePageSize(legacyHintsTable);
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ public final class LegacyHintsMigrator
|
|||
logger.info("Migrating legacy hints to new storage");
|
||||
|
||||
// major-compact all of the existing sstables to get rid of the tombstones + expired hints
|
||||
logger.info("Forcing a major compaction of {}.{} table", SystemKeyspace.NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
logger.info("Forcing a major compaction of {}.{} table", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
compactLegacyHints();
|
||||
|
||||
// paginate over legacy hints and write them to the new storage
|
||||
|
|
@ -96,7 +97,7 @@ public final class LegacyHintsMigrator
|
|||
migrateLegacyHints();
|
||||
|
||||
// truncate the legacy hints table
|
||||
logger.info("Truncating {}.{} table", SystemKeyspace.NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
logger.info("Truncating {}.{} table", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
legacyHintsTable.truncateBlocking();
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +124,7 @@ public final class LegacyHintsMigrator
|
|||
private void migrateLegacyHints()
|
||||
{
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(256 * 1024);
|
||||
String query = String.format("SELECT DISTINCT target_id FROM %s.%s", SystemKeyspace.NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
String query = String.format("SELECT DISTINCT target_id FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_HINTS);
|
||||
//noinspection ConstantConditions
|
||||
QueryProcessor.executeInternal(query).forEach(row -> migrateLegacyHints(row.getUUID("target_id"), buffer));
|
||||
FileUtils.clean(buffer);
|
||||
|
|
@ -134,7 +135,7 @@ public final class LegacyHintsMigrator
|
|||
String query = String.format("SELECT target_id, hint_id, message_version, mutation, ttl(mutation) AS ttl, writeTime(mutation) AS write_time " +
|
||||
"FROM %s.%s " +
|
||||
"WHERE target_id = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_HINTS);
|
||||
|
||||
// read all the old hints (paged iterator), write them in the new format
|
||||
|
|
@ -215,7 +216,7 @@ public final class LegacyHintsMigrator
|
|||
{
|
||||
logger.error("Failed to migrate a hint for {} from legacy {}.{} table",
|
||||
row.getUUID("target_id"),
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_HINTS,
|
||||
e);
|
||||
return null;
|
||||
|
|
@ -224,7 +225,7 @@ public final class LegacyHintsMigrator
|
|||
{
|
||||
logger.warn("Failed to validate a hint for {} from legacy {}.{} table - skipping",
|
||||
row.getUUID("target_id"),
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_HINTS,
|
||||
e);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
package org.apache.cassandra.io.compress;
|
||||
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.schema.CompressionParams;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -32,6 +32,20 @@ public class DeflateCompressor implements ICompressor
|
|||
{
|
||||
public static final DeflateCompressor instance = new DeflateCompressor();
|
||||
|
||||
private static final ThreadLocal<byte[]> threadLocalScratchBuffer = new ThreadLocal<byte[]>()
|
||||
{
|
||||
@Override
|
||||
protected byte[] initialValue()
|
||||
{
|
||||
return new byte[CompressionParams.DEFAULT_CHUNK_LENGTH];
|
||||
}
|
||||
};
|
||||
|
||||
public static byte[] getThreadLocalScratchBuffer()
|
||||
{
|
||||
return threadLocalScratchBuffer.get();
|
||||
}
|
||||
|
||||
private final ThreadLocal<Deflater> deflater;
|
||||
private final ThreadLocal<Inflater> inflater;
|
||||
|
||||
|
|
@ -104,7 +118,7 @@ public class DeflateCompressor implements ICompressor
|
|||
Deflater def = deflater.get();
|
||||
def.reset();
|
||||
|
||||
byte[] buffer = FBUtilities.getThreadLocalScratchBuffer();
|
||||
byte[] buffer = getThreadLocalScratchBuffer();
|
||||
// Use half the buffer for input, half for output.
|
||||
int chunkLen = buffer.length / 2;
|
||||
while (input.remaining() > chunkLen)
|
||||
|
|
@ -149,7 +163,7 @@ public class DeflateCompressor implements ICompressor
|
|||
Inflater inf = inflater.get();
|
||||
inf.reset();
|
||||
|
||||
byte[] buffer = FBUtilities.getThreadLocalScratchBuffer();
|
||||
byte[] buffer = getThreadLocalScratchBuffer();
|
||||
// Use half the buffer for input, half for output.
|
||||
int chunkLen = buffer.length / 2;
|
||||
while (input.remaining() > chunkLen)
|
||||
|
|
|
|||
|
|
@ -25,14 +25,10 @@ import java.nio.ByteBuffer;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.db.compaction.OperationType;
|
||||
import org.apache.cassandra.db.lifecycle.LifecycleTransaction;
|
||||
import org.apache.cassandra.db.rows.EncodingStats;
|
||||
import org.apache.cassandra.db.partitions.PartitionUpdate;
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.io.sstable.format.RangeAwareSSTableWriter;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableFormat;
|
||||
import org.apache.cassandra.service.ActiveRepairService;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
|
@ -45,7 +41,7 @@ abstract class AbstractSSTableSimpleWriter implements Closeable
|
|||
protected final ColumnFamilyStore cfs;
|
||||
protected final IPartitioner partitioner;
|
||||
protected final PartitionColumns columns;
|
||||
protected SSTableFormat.Type formatType = DatabaseDescriptor.getSSTableFormat();
|
||||
protected SSTableFormat.Type formatType = SSTableFormat.Type.current();
|
||||
protected static AtomicInteger generation = new AtomicInteger(0);
|
||||
protected boolean makeRangeAware = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ public class Descriptor
|
|||
public final Component digestComponent;
|
||||
private final int hashCode;
|
||||
|
||||
/**
|
||||
* A descriptor that assumes CURRENT_VERSION.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public Descriptor(File directory, String ksname, String cfname, int generation)
|
||||
{
|
||||
this(SSTableFormat.Type.current().info.getLatestVersion(), directory, ksname, cfname, generation, SSTableFormat.Type.current(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for sstable writers only.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public interface SSTableFormat
|
|||
public final SSTableFormat info;
|
||||
public final String name;
|
||||
|
||||
public static Type current()
|
||||
{
|
||||
return BIG;
|
||||
}
|
||||
|
||||
private Type(String name, SSTableFormat info)
|
||||
{
|
||||
//Since format comes right after generation
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import org.apache.cassandra.config.CFMetaData;
|
|||
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.db.*;
|
||||
import org.apache.cassandra.db.filter.ColumnFilter;
|
||||
import org.apache.cassandra.db.rows.EncodingStats;
|
||||
|
|
@ -136,11 +137,18 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
|
|||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(SSTableReader.class);
|
||||
|
||||
private static final ScheduledThreadPoolExecutor syncExecutor = new ScheduledThreadPoolExecutor(1);
|
||||
static
|
||||
private static final ScheduledThreadPoolExecutor syncExecutor = initSyncExecutor();
|
||||
private static ScheduledThreadPoolExecutor initSyncExecutor()
|
||||
{
|
||||
if (Config.isClientOrToolsMode())
|
||||
return null;
|
||||
|
||||
// Do NOT start this thread pool in client mode
|
||||
|
||||
ScheduledThreadPoolExecutor syncExecutor = new ScheduledThreadPoolExecutor(1);
|
||||
// Immediately remove readMeter sync task when cancelled.
|
||||
syncExecutor.setRemoveOnCancelPolicy(true);
|
||||
return syncExecutor;
|
||||
}
|
||||
private static final RateLimiter meterSyncThrottle = RateLimiter.create(100.0);
|
||||
|
||||
|
|
@ -2205,7 +2213,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
|
|||
|
||||
// Don't track read rates for tables in the system keyspace and don't bother trying to load or persist
|
||||
// the read meter when in client mode.
|
||||
if (Schema.isSystemKeyspace(desc.ksname))
|
||||
// Also, do not track read rates when running in client or tools mode (syncExecuter isn't available in these modes)
|
||||
if (SchemaConstants.isSystemKeyspace(desc.ksname) || Config.isClientOrToolsMode())
|
||||
{
|
||||
readMeter = null;
|
||||
readMeterSyncFuture = NULL;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import javax.management.MBeanServer;
|
|||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.cassandra.concurrent.ScheduledExecutors;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.gms.ApplicationState;
|
||||
import org.apache.cassandra.gms.EndpointState;
|
||||
|
|
@ -100,9 +101,13 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
|
|||
reset();
|
||||
}
|
||||
};
|
||||
updateSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(update, dynamicUpdateInterval, dynamicUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
resetSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(reset, dynamicResetInterval, dynamicResetInterval, TimeUnit.MILLISECONDS);
|
||||
registerMBean();
|
||||
|
||||
if (!Config.isClientOrToolsMode())
|
||||
{
|
||||
updateSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(update, dynamicUpdateInterval, dynamicUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
resetSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(reset, dynamicResetInterval, dynamicResetInterval, TimeUnit.MILLISECONDS);
|
||||
registerMBean();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,15 +119,21 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
|
|||
if (dynamicUpdateInterval != DatabaseDescriptor.getDynamicUpdateInterval())
|
||||
{
|
||||
dynamicUpdateInterval = DatabaseDescriptor.getDynamicUpdateInterval();
|
||||
updateSchedular.cancel(false);
|
||||
updateSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(update, dynamicUpdateInterval, dynamicUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
if (!Config.isClientOrToolsMode())
|
||||
{
|
||||
updateSchedular.cancel(false);
|
||||
updateSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(update, dynamicUpdateInterval, dynamicUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicResetInterval != DatabaseDescriptor.getDynamicResetInterval())
|
||||
{
|
||||
dynamicResetInterval = DatabaseDescriptor.getDynamicResetInterval();
|
||||
resetSchedular.cancel(false);
|
||||
resetSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(reset, dynamicResetInterval, dynamicResetInterval, TimeUnit.MILLISECONDS);
|
||||
if (!Config.isClientOrToolsMode())
|
||||
{
|
||||
resetSchedular.cancel(false);
|
||||
resetSchedular = ScheduledExecutors.scheduledTasks.scheduleWithFixedDelay(reset, dynamicResetInterval, dynamicResetInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
dynamicBadnessThreshold = DatabaseDescriptor.getDynamicBadnessThreshold();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.Memtable;
|
||||
|
|
@ -37,7 +38,6 @@ import org.apache.cassandra.index.SecondaryIndexManager;
|
|||
import org.apache.cassandra.io.compress.CompressionMetadata;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
|
||||
import org.apache.cassandra.repair.SystemDistributedKeyspace;
|
||||
import org.apache.cassandra.utils.EstimatedHistogram;
|
||||
import org.apache.cassandra.utils.TopKSampler;
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ public class TableMetrics
|
|||
for (String keyspace : Schema.instance.getNonSystemKeyspaces())
|
||||
{
|
||||
Keyspace k = Schema.instance.getKeyspaceInstance(keyspace);
|
||||
if (SystemDistributedKeyspace.NAME.equals(k.getName()))
|
||||
if (SchemaConstants.DISTRIBUTED_KEYSPACE_NAME.equals(k.getName()))
|
||||
continue;
|
||||
if (k.getReplicationStrategy().getReplicationFactor() < 2)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class MessageIn<T>
|
|||
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getTimeout(verb);
|
||||
return verb.getTimeout();
|
||||
}
|
||||
|
||||
public long getSlowQueryTimeout()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.apache.cassandra.concurrent.Stage;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.TypeSizes;
|
||||
import org.apache.cassandra.io.IVersionedSerializer;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
|
|
@ -91,7 +90,7 @@ public class MessageOut<T>
|
|||
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getTimeout(verb);
|
||||
return verb.getTimeout();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
|
|
|||
|
|
@ -107,16 +107,58 @@ public final class MessagingService implements MessagingServiceMBean
|
|||
/* All verb handler identifiers */
|
||||
public enum Verb
|
||||
{
|
||||
MUTATION,
|
||||
HINT,
|
||||
READ_REPAIR,
|
||||
READ,
|
||||
MUTATION
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
HINT
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
READ_REPAIR
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
READ
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getReadRpcTimeout();
|
||||
}
|
||||
},
|
||||
REQUEST_RESPONSE, // client-initiated reads and writes
|
||||
BATCH_STORE, // was @Deprecated STREAM_INITIATE,
|
||||
BATCH_REMOVE, // was @Deprecated STREAM_INITIATE_DONE,
|
||||
BATCH_STORE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
}, // was @Deprecated STREAM_INITIATE,
|
||||
BATCH_REMOVE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
}, // was @Deprecated STREAM_INITIATE_DONE,
|
||||
@Deprecated STREAM_REPLY,
|
||||
@Deprecated STREAM_REQUEST,
|
||||
RANGE_SLICE,
|
||||
RANGE_SLICE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getRangeRpcTimeout();
|
||||
}
|
||||
},
|
||||
@Deprecated BOOTSTRAP_TOKEN,
|
||||
@Deprecated TREE_REQUEST,
|
||||
@Deprecated TREE_RESPONSE,
|
||||
|
|
@ -126,12 +168,24 @@ public final class MessagingService implements MessagingServiceMBean
|
|||
GOSSIP_DIGEST_ACK2,
|
||||
@Deprecated DEFINITIONS_ANNOUNCE,
|
||||
DEFINITIONS_UPDATE,
|
||||
TRUNCATE,
|
||||
TRUNCATE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getTruncateRpcTimeout();
|
||||
}
|
||||
},
|
||||
SCHEMA_CHECK,
|
||||
@Deprecated INDEX_SCAN,
|
||||
REPLICATION_FINISHED,
|
||||
INTERNAL_RESPONSE, // responses to internal calls
|
||||
COUNTER_MUTATION,
|
||||
COUNTER_MUTATION
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getCounterWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
@Deprecated STREAMING_REPAIR_REQUEST,
|
||||
@Deprecated STREAMING_REPAIR_RESPONSE,
|
||||
SNAPSHOT, // Similar to nt snapshot
|
||||
|
|
@ -140,10 +194,34 @@ public final class MessagingService implements MessagingServiceMBean
|
|||
_TRACE, // dummy verb so we can use MS.droppedMessagesMap
|
||||
ECHO,
|
||||
REPAIR_MESSAGE,
|
||||
PAXOS_PREPARE,
|
||||
PAXOS_PROPOSE,
|
||||
PAXOS_COMMIT,
|
||||
@Deprecated PAGED_RANGE,
|
||||
PAXOS_PREPARE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
PAXOS_PROPOSE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
PAXOS_COMMIT
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getWriteRpcTimeout();
|
||||
}
|
||||
},
|
||||
@Deprecated PAGED_RANGE
|
||||
{
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getRangeRpcTimeout();
|
||||
}
|
||||
},
|
||||
// remember to add new verbs at the end, since we serialize by ordinal
|
||||
UNUSED_1,
|
||||
UNUSED_2,
|
||||
|
|
@ -161,6 +239,11 @@ public final class MessagingService implements MessagingServiceMBean
|
|||
|
||||
return verb;
|
||||
}
|
||||
|
||||
public long getTimeout()
|
||||
{
|
||||
return DatabaseDescriptor.getRpcTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
public static final Verb[] verbValues = Verb.values();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import org.apache.cassandra.concurrent.JMXConfigurableThreadPoolExecutor;
|
||||
import org.apache.cassandra.concurrent.NamedThreadFactory;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.QueryOptions;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
|
|
@ -375,7 +376,7 @@ public class RepairRunnable extends WrappedRunnable implements ProgressEventNoti
|
|||
throw new Exception("no tracestate");
|
||||
|
||||
String format = "select event_id, source, activity from %s.%s where session_id = ? and event_id > ? and event_id < ?;";
|
||||
String query = String.format(format, TraceKeyspace.NAME, TraceKeyspace.EVENTS);
|
||||
String query = String.format(format, SchemaConstants.TRACE_KEYSPACE_NAME, TraceKeyspace.EVENTS);
|
||||
SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
|
||||
|
||||
ByteBuffer sessionIdBytes = ByteBufferUtil.bytes(sessionId);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.db.ConsistencyLevel;
|
||||
|
|
@ -60,8 +61,6 @@ public final class SystemDistributedKeyspace
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SystemDistributedKeyspace.class);
|
||||
|
||||
public static final String NAME = "system_distributed";
|
||||
|
||||
public static final String REPAIR_HISTORY = "repair_history";
|
||||
|
||||
public static final String PARENT_REPAIR_HISTORY = "parent_repair_history";
|
||||
|
|
@ -115,13 +114,13 @@ public final class SystemDistributedKeyspace
|
|||
|
||||
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.DISTRIBUTED_KEYSPACE_NAME)
|
||||
.comment(description);
|
||||
}
|
||||
|
||||
public static KeyspaceMetadata metadata()
|
||||
{
|
||||
return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(3), Tables.of(RepairHistory, ParentRepairHistory, ViewBuildStatus));
|
||||
return KeyspaceMetadata.create(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, KeyspaceParams.simple(3), Tables.of(RepairHistory, ParentRepairHistory, ViewBuildStatus));
|
||||
}
|
||||
|
||||
public static void startParentRepair(UUID parent_id, String keyspaceName, String[] cfnames, RepairOption options)
|
||||
|
|
@ -130,7 +129,7 @@ public final class SystemDistributedKeyspace
|
|||
String query = "INSERT INTO %s.%s (parent_id, keyspace_name, columnfamily_names, requested_ranges, started_at, options)"+
|
||||
" VALUES (%s, '%s', { '%s' }, { '%s' }, toTimestamp(now()), { %s })";
|
||||
String fmtQry = String.format(query,
|
||||
NAME,
|
||||
SchemaConstants.DISTRIBUTED_KEYSPACE_NAME,
|
||||
PARENT_REPAIR_HISTORY,
|
||||
parent_id.toString(),
|
||||
keyspaceName,
|
||||
|
|
@ -165,14 +164,14 @@ public final class SystemDistributedKeyspace
|
|||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
String fmtQuery = String.format(query, NAME, PARENT_REPAIR_HISTORY, parent_id.toString());
|
||||
String fmtQuery = String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, PARENT_REPAIR_HISTORY, parent_id.toString());
|
||||
processSilent(fmtQuery, t.getMessage(), sw.toString());
|
||||
}
|
||||
|
||||
public static void successfulParentRepair(UUID parent_id, Collection<Range<Token>> successfulRanges)
|
||||
{
|
||||
String query = "UPDATE %s.%s SET finished_at = toTimestamp(now()), successful_ranges = {'%s'} WHERE parent_id=%s";
|
||||
String fmtQuery = String.format(query, NAME, PARENT_REPAIR_HISTORY, Joiner.on("','").join(successfulRanges), parent_id.toString());
|
||||
String fmtQuery = String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, PARENT_REPAIR_HISTORY, Joiner.on("','").join(successfulRanges), parent_id.toString());
|
||||
processSilent(fmtQuery);
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +191,7 @@ public final class SystemDistributedKeyspace
|
|||
{
|
||||
for (Range<Token> range : ranges)
|
||||
{
|
||||
String fmtQry = String.format(query, NAME, REPAIR_HISTORY,
|
||||
String fmtQry = String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, REPAIR_HISTORY,
|
||||
keyspaceName,
|
||||
cfname,
|
||||
id.toString(),
|
||||
|
|
@ -216,7 +215,7 @@ public final class SystemDistributedKeyspace
|
|||
public static void successfulRepairJob(UUID id, String keyspaceName, String cfname)
|
||||
{
|
||||
String query = "UPDATE %s.%s SET status = '%s', finished_at = toTimestamp(now()) WHERE keyspace_name = '%s' AND columnfamily_name = '%s' AND id = %s";
|
||||
String fmtQuery = String.format(query, NAME, REPAIR_HISTORY,
|
||||
String fmtQuery = String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, REPAIR_HISTORY,
|
||||
RepairState.SUCCESS.toString(),
|
||||
keyspaceName,
|
||||
cfname,
|
||||
|
|
@ -230,18 +229,18 @@ public final class SystemDistributedKeyspace
|
|||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
t.printStackTrace(pw);
|
||||
String fmtQry = String.format(query, NAME, REPAIR_HISTORY,
|
||||
RepairState.FAILED.toString(),
|
||||
keyspaceName,
|
||||
cfname,
|
||||
id.toString());
|
||||
String fmtQry = String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, REPAIR_HISTORY,
|
||||
RepairState.FAILED.toString(),
|
||||
keyspaceName,
|
||||
cfname,
|
||||
id.toString());
|
||||
processSilent(fmtQry, t.getMessage(), sw.toString());
|
||||
}
|
||||
|
||||
public static void startViewBuild(String keyspace, String view, UUID hostId)
|
||||
{
|
||||
String query = "INSERT INTO %s.%s (keyspace_name, view_name, host_id, status) VALUES (?, ?, ?, ?)";
|
||||
QueryProcessor.process(String.format(query, NAME, VIEW_BUILD_STATUS),
|
||||
QueryProcessor.process(String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, VIEW_BUILD_STATUS),
|
||||
ConsistencyLevel.ONE,
|
||||
Lists.newArrayList(bytes(keyspace),
|
||||
bytes(view),
|
||||
|
|
@ -252,7 +251,7 @@ public final class SystemDistributedKeyspace
|
|||
public static void successfulViewBuild(String keyspace, String view, UUID hostId)
|
||||
{
|
||||
String query = "UPDATE %s.%s SET status = ? WHERE keyspace_name = ? AND view_name = ? AND host_id = ?";
|
||||
QueryProcessor.process(String.format(query, NAME, VIEW_BUILD_STATUS),
|
||||
QueryProcessor.process(String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, VIEW_BUILD_STATUS),
|
||||
ConsistencyLevel.ONE,
|
||||
Lists.newArrayList(bytes(BuildStatus.SUCCESS.toString()),
|
||||
bytes(keyspace),
|
||||
|
|
@ -266,7 +265,7 @@ public final class SystemDistributedKeyspace
|
|||
UntypedResultSet results;
|
||||
try
|
||||
{
|
||||
results = QueryProcessor.execute(String.format(query, NAME, VIEW_BUILD_STATUS),
|
||||
results = QueryProcessor.execute(String.format(query, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, VIEW_BUILD_STATUS),
|
||||
ConsistencyLevel.ONE,
|
||||
keyspace,
|
||||
view);
|
||||
|
|
@ -286,7 +285,7 @@ public final class SystemDistributedKeyspace
|
|||
public static void setViewRemoved(String keyspaceName, String viewName)
|
||||
{
|
||||
String buildReq = "DELETE FROM %s.%s WHERE keyspace_name = ? AND view_name = ?";
|
||||
QueryProcessor.executeInternal(String.format(buildReq, NAME, VIEW_BUILD_STATUS), keyspaceName, viewName);
|
||||
QueryProcessor.executeInternal(String.format(buildReq, SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, VIEW_BUILD_STATUS), keyspaceName, viewName);
|
||||
forceBlockingFlush(VIEW_BUILD_STATUS);
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +309,7 @@ public final class SystemDistributedKeyspace
|
|||
public static void forceBlockingFlush(String table)
|
||||
{
|
||||
if (!Boolean.getBoolean("cassandra.unsafesystem"))
|
||||
FBUtilities.waitOnFuture(Keyspace.open(NAME).getColumnFamilyStore(table).forceFlush());
|
||||
FBUtilities.waitOnFuture(Keyspace.open(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME).getColumnFamilyStore(table).forceFlush());
|
||||
}
|
||||
|
||||
private enum RepairState
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import com.google.common.base.Objects;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.config.ViewDefinition;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ public final class KeyspaceMetadata
|
|||
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,
|
||||
SchemaConstants.NAME_LENGTH,
|
||||
name));
|
||||
params.validate(name);
|
||||
tablesAndViews().forEach(CFMetaData::validate);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public final class LegacySchemaMigrator
|
|||
// write metadata to the new schema tables
|
||||
logger.info("Moving {} keyspaces from legacy schema tables to the new schema keyspace ({})",
|
||||
keyspaces.size(),
|
||||
SchemaKeyspace.NAME);
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME);
|
||||
keyspaces.forEach(LegacySchemaMigrator::storeKeyspaceInNewSchemaTables);
|
||||
keyspaces.forEach(LegacySchemaMigrator::migrateBuiltIndexesForKeyspace);
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ public final class LegacySchemaMigrator
|
|||
|
||||
static void unloadLegacySchemaTables()
|
||||
{
|
||||
KeyspaceMetadata systemKeyspace = Schema.instance.getKSMetaData(SystemKeyspace.NAME);
|
||||
KeyspaceMetadata systemKeyspace = Schema.instance.getKSMetaData(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
|
||||
Tables systemTables = systemKeyspace.tables;
|
||||
for (CFMetaData table : LegacySchemaTables)
|
||||
|
|
@ -167,10 +167,10 @@ public final class LegacySchemaMigrator
|
|||
*/
|
||||
private static Collection<Keyspace> readSchema()
|
||||
{
|
||||
String query = format("SELECT keyspace_name FROM %s.%s", SystemKeyspace.NAME, SystemKeyspace.LEGACY_KEYSPACES);
|
||||
String query = format("SELECT keyspace_name FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_KEYSPACES);
|
||||
Collection<String> keyspaceNames = new ArrayList<>();
|
||||
query(query).forEach(row -> keyspaceNames.add(row.getString("keyspace_name")));
|
||||
keyspaceNames.removeAll(Schema.SYSTEM_KEYSPACE_NAMES);
|
||||
keyspaceNames.removeAll(SchemaConstants.SYSTEM_KEYSPACE_NAMES);
|
||||
|
||||
Collection<Keyspace> keyspaces = new ArrayList<>();
|
||||
keyspaceNames.forEach(name -> keyspaces.add(readKeyspace(name)));
|
||||
|
|
@ -199,7 +199,7 @@ public final class LegacySchemaMigrator
|
|||
private static long readKeyspaceTimestamp(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT writeTime(durable_writes) AS timestamp FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_KEYSPACES);
|
||||
return query(query, keyspaceName).one().getLong("timestamp");
|
||||
}
|
||||
|
|
@ -207,7 +207,7 @@ public final class LegacySchemaMigrator
|
|||
private static KeyspaceParams readKeyspaceParams(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_KEYSPACES);
|
||||
UntypedResultSet.Row row = query(query, keyspaceName).one();
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ public final class LegacySchemaMigrator
|
|||
private static Collection<Table> readTables(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT columnfamily_name FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_COLUMNFAMILIES);
|
||||
Collection<String> tableNames = new ArrayList<>();
|
||||
query(query, keyspaceName).forEach(row -> tableNames.add(row.getString("columnfamily_name")));
|
||||
|
|
@ -247,7 +247,7 @@ public final class LegacySchemaMigrator
|
|||
private static long readTableTimestamp(String keyspaceName, String tableName)
|
||||
{
|
||||
String query = format("SELECT writeTime(type) AS timestamp FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_COLUMNFAMILIES);
|
||||
return query(query, keyspaceName, tableName).one().getLong("timestamp");
|
||||
}
|
||||
|
|
@ -255,17 +255,17 @@ public final class LegacySchemaMigrator
|
|||
private static CFMetaData readTableMetadata(String keyspaceName, String tableName)
|
||||
{
|
||||
String tableQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_COLUMNFAMILIES);
|
||||
UntypedResultSet.Row tableRow = query(tableQuery, keyspaceName, tableName).one();
|
||||
|
||||
String columnsQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_COLUMNS);
|
||||
UntypedResultSet columnRows = query(columnsQuery, keyspaceName, tableName);
|
||||
|
||||
String triggersQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_TRIGGERS);
|
||||
UntypedResultSet triggerRows = query(triggersQuery, keyspaceName, tableName);
|
||||
|
||||
|
|
@ -811,7 +811,7 @@ public final class LegacySchemaMigrator
|
|||
private static Collection<Type> readTypes(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT type_name FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_USERTYPES);
|
||||
Collection<String> typeNames = new ArrayList<>();
|
||||
query(query, keyspaceName).forEach(row -> typeNames.add(row.getString("type_name")));
|
||||
|
|
@ -834,7 +834,7 @@ public final class LegacySchemaMigrator
|
|||
*/
|
||||
private static long readTypeTimestamp(String keyspaceName, String typeName)
|
||||
{
|
||||
ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SystemKeyspace.NAME)
|
||||
ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME)
|
||||
.getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES);
|
||||
|
||||
ClusteringComparator comparator = store.metadata.comparator;
|
||||
|
|
@ -853,7 +853,7 @@ public final class LegacySchemaMigrator
|
|||
private static UserType readTypeMetadata(String keyspaceName, String typeName)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND type_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_USERTYPES);
|
||||
UntypedResultSet.Row row = query(query, keyspaceName, typeName).one();
|
||||
|
||||
|
|
@ -879,7 +879,7 @@ public final class LegacySchemaMigrator
|
|||
private static Collection<Function> readFunctions(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT function_name, signature FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_FUNCTIONS);
|
||||
HashMultimap<String, List<String>> functionSignatures = HashMultimap.create();
|
||||
query(query, keyspaceName).forEach(row -> functionSignatures.put(row.getString("function_name"), row.getList("signature", UTF8Type.instance)));
|
||||
|
|
@ -901,7 +901,7 @@ public final class LegacySchemaMigrator
|
|||
String query = format("SELECT writeTime(return_type) AS timestamp " +
|
||||
"FROM %s.%s " +
|
||||
"WHERE keyspace_name = ? AND function_name = ? AND signature = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_FUNCTIONS);
|
||||
return query(query, keyspaceName, functionName, signature).one().getLong("timestamp");
|
||||
}
|
||||
|
|
@ -909,7 +909,7 @@ public final class LegacySchemaMigrator
|
|||
private static UDFunction readFunctionMetadata(String keyspaceName, String functionName, List<String> signature)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND function_name = ? AND signature = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_FUNCTIONS);
|
||||
UntypedResultSet.Row row = query(query, keyspaceName, functionName, signature).one();
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ public final class LegacySchemaMigrator
|
|||
private static Collection<Aggregate> readAggregates(Functions functions, String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT aggregate_name, signature FROM %s.%s WHERE keyspace_name = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_AGGREGATES);
|
||||
HashMultimap<String, List<String>> aggregateSignatures = HashMultimap.create();
|
||||
query(query, keyspaceName).forEach(row -> aggregateSignatures.put(row.getString("aggregate_name"), row.getList("signature", UTF8Type.instance)));
|
||||
|
|
@ -970,7 +970,7 @@ public final class LegacySchemaMigrator
|
|||
String query = format("SELECT writeTime(return_type) AS timestamp " +
|
||||
"FROM %s.%s " +
|
||||
"WHERE keyspace_name = ? AND aggregate_name = ? AND signature = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_AGGREGATES);
|
||||
return query(query, keyspaceName, aggregateName, signature).one().getLong("timestamp");
|
||||
}
|
||||
|
|
@ -978,7 +978,7 @@ public final class LegacySchemaMigrator
|
|||
private static UDAggregate readAggregateMetadata(Functions functions, String keyspaceName, String functionName, List<String> signature)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND aggregate_name = ? AND signature = ?",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.LEGACY_AGGREGATES);
|
||||
UntypedResultSet.Row row = query(query, keyspaceName, functionName, signature).one();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ public final class SchemaKeyspace
|
|||
|
||||
private static final boolean FLUSH_SCHEMA_TABLES = Boolean.parseBoolean(System.getProperty("cassandra.test.flush_local_schema_changes", "true"));
|
||||
|
||||
public static final String NAME = "system_schema";
|
||||
|
||||
public static final String KEYSPACES = "keyspaces";
|
||||
public static final String TABLES = "tables";
|
||||
public static final String COLUMNS = "columns";
|
||||
|
|
@ -237,14 +235,14 @@ public final class SchemaKeyspace
|
|||
|
||||
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.SCHEMA_KEYSPACE_NAME)
|
||||
.comment(description)
|
||||
.gcGraceSeconds((int) TimeUnit.DAYS.toSeconds(7));
|
||||
}
|
||||
|
||||
public static KeyspaceMetadata metadata()
|
||||
{
|
||||
return KeyspaceMetadata.create(NAME, KeyspaceParams.local(), org.apache.cassandra.schema.Tables.of(ALL_TABLE_METADATA));
|
||||
return KeyspaceMetadata.create(SchemaConstants.SCHEMA_KEYSPACE_NAME, KeyspaceParams.local(), org.apache.cassandra.schema.Tables.of(ALL_TABLE_METADATA));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -252,16 +250,16 @@ public final class SchemaKeyspace
|
|||
*/
|
||||
public static void saveSystemKeyspacesSchema()
|
||||
{
|
||||
KeyspaceMetadata system = Schema.instance.getKSMetaData(SystemKeyspace.NAME);
|
||||
KeyspaceMetadata schema = Schema.instance.getKSMetaData(NAME);
|
||||
KeyspaceMetadata system = Schema.instance.getKSMetaData(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
KeyspaceMetadata schema = Schema.instance.getKSMetaData(SchemaConstants.SCHEMA_KEYSPACE_NAME);
|
||||
|
||||
long timestamp = FBUtilities.timestampMicros();
|
||||
|
||||
// delete old, possibly obsolete entries in schema tables
|
||||
for (String schemaTable : ALL)
|
||||
{
|
||||
String query = String.format("DELETE FROM %s.%s USING TIMESTAMP ? WHERE keyspace_name = ?", NAME, schemaTable);
|
||||
for (String systemKeyspace : Schema.SYSTEM_KEYSPACE_NAMES)
|
||||
String query = String.format("DELETE FROM %s.%s USING TIMESTAMP ? WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, schemaTable);
|
||||
for (String systemKeyspace : SchemaConstants.SYSTEM_KEYSPACE_NAMES)
|
||||
executeOnceInternal(query, timestamp, systemKeyspace);
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +325,7 @@ public final class SchemaKeyspace
|
|||
*/
|
||||
private static ColumnFamilyStore getSchemaCFS(String schemaTableName)
|
||||
{
|
||||
return Keyspace.open(NAME).getColumnFamilyStore(schemaTableName);
|
||||
return Keyspace.open(SchemaConstants.SCHEMA_KEYSPACE_NAME).getColumnFamilyStore(schemaTableName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -367,7 +365,7 @@ public final class SchemaKeyspace
|
|||
Mutation mutation = mutationMap.get(key);
|
||||
if (mutation == null)
|
||||
{
|
||||
mutation = new Mutation(NAME, key);
|
||||
mutation = new Mutation(SchemaConstants.SCHEMA_KEYSPACE_NAME, key);
|
||||
mutationMap.put(key, mutation);
|
||||
}
|
||||
|
||||
|
|
@ -379,7 +377,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static boolean isSystemKeyspaceSchemaPartition(DecoratedKey partitionKey)
|
||||
{
|
||||
return Schema.isSystemKeyspace(UTF8Type.instance.compose(partitionKey.getKey()));
|
||||
return SchemaConstants.isSystemKeyspace(UTF8Type.instance.compose(partitionKey.getKey()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -419,7 +417,7 @@ public final class SchemaKeyspace
|
|||
|
||||
public static Mutation.SimpleBuilder makeDropKeyspaceMutation(KeyspaceMetadata keyspace, long timestamp)
|
||||
{
|
||||
Mutation.SimpleBuilder builder = Mutation.simpleBuilder(NAME, decorate(Keyspaces, keyspace.name))
|
||||
Mutation.SimpleBuilder builder = Mutation.simpleBuilder(SchemaConstants.SCHEMA_KEYSPACE_NAME, decorate(Keyspaces, keyspace.name))
|
||||
.timestamp(timestamp);
|
||||
|
||||
for (CFMetaData schemaTable : ALL_TABLE_METADATA)
|
||||
|
|
@ -850,12 +848,12 @@ public final class SchemaKeyspace
|
|||
|
||||
public static Keyspaces fetchNonSystemKeyspaces()
|
||||
{
|
||||
return fetchKeyspacesWithout(Schema.SYSTEM_KEYSPACE_NAMES);
|
||||
return fetchKeyspacesWithout(SchemaConstants.SYSTEM_KEYSPACE_NAMES);
|
||||
}
|
||||
|
||||
private static Keyspaces fetchKeyspacesWithout(Set<String> excludedKeyspaceNames)
|
||||
{
|
||||
String query = format("SELECT keyspace_name FROM %s.%s", NAME, KEYSPACES);
|
||||
String query = format("SELECT keyspace_name FROM %s.%s", SchemaConstants.SCHEMA_KEYSPACE_NAME, KEYSPACES);
|
||||
|
||||
Keyspaces.Builder keyspaces = org.apache.cassandra.schema.Keyspaces.builder();
|
||||
for (UntypedResultSet.Row row : query(query))
|
||||
|
|
@ -873,7 +871,7 @@ public final class SchemaKeyspace
|
|||
* We know the keyspace names we are going to query, but we still want to run the SELECT IN
|
||||
* query, to filter out the keyspaces that had been dropped by the applied mutation set.
|
||||
*/
|
||||
String query = format("SELECT keyspace_name FROM %s.%s WHERE keyspace_name IN ?", NAME, KEYSPACES);
|
||||
String query = format("SELECT keyspace_name FROM %s.%s WHERE keyspace_name IN ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, KEYSPACES);
|
||||
|
||||
Keyspaces.Builder keyspaces = org.apache.cassandra.schema.Keyspaces.builder();
|
||||
for (UntypedResultSet.Row row : query(query, new ArrayList<>(includedKeyspaceNames)))
|
||||
|
|
@ -893,7 +891,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static KeyspaceParams fetchKeyspaceParams(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", NAME, KEYSPACES);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, KEYSPACES);
|
||||
|
||||
UntypedResultSet.Row row = query(query, keyspaceName).one();
|
||||
boolean durableWrites = row.getBoolean(KeyspaceParams.Option.DURABLE_WRITES.toString());
|
||||
|
|
@ -903,7 +901,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Types fetchTypes(String keyspaceName)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", NAME, TYPES);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, TYPES);
|
||||
|
||||
Types.RawBuilder types = org.apache.cassandra.schema.Types.rawBuilder(keyspaceName);
|
||||
for (UntypedResultSet.Row row : query(query, keyspaceName))
|
||||
|
|
@ -918,7 +916,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Tables fetchTables(String keyspaceName, Types types)
|
||||
{
|
||||
String query = format("SELECT table_name FROM %s.%s WHERE keyspace_name = ?", NAME, TABLES);
|
||||
String query = format("SELECT table_name FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, TABLES);
|
||||
|
||||
Tables.Builder tables = org.apache.cassandra.schema.Tables.builder();
|
||||
for (UntypedResultSet.Row row : query(query, keyspaceName))
|
||||
|
|
@ -928,7 +926,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static CFMetaData fetchTable(String keyspaceName, String tableName, Types types)
|
||||
{
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, TABLES);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, TABLES);
|
||||
UntypedResultSet rows = query(query, keyspaceName, tableName);
|
||||
if (rows.isEmpty())
|
||||
throw new RuntimeException(String.format("%s:%s not found in the schema definitions keyspace.", keyspaceName, tableName));
|
||||
|
|
@ -994,7 +992,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static List<ColumnDefinition> fetchColumns(String keyspace, String table, Types types)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, COLUMNS);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, COLUMNS);
|
||||
List<ColumnDefinition> columns = new ArrayList<>();
|
||||
query(query, keyspace, table).forEach(row -> columns.add(createColumnFromRow(row, types)));
|
||||
return columns;
|
||||
|
|
@ -1021,7 +1019,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Map<ByteBuffer, CFMetaData.DroppedColumn> fetchDroppedColumns(String keyspace, String table)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, DROPPED_COLUMNS);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, DROPPED_COLUMNS);
|
||||
Map<ByteBuffer, CFMetaData.DroppedColumn> columns = new HashMap<>();
|
||||
for (UntypedResultSet.Row row : query(query, keyspace, table))
|
||||
{
|
||||
|
|
@ -1047,7 +1045,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Indexes fetchIndexes(String keyspace, String table)
|
||||
{
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, INDEXES);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, INDEXES);
|
||||
Indexes.Builder indexes = org.apache.cassandra.schema.Indexes.builder();
|
||||
query(query, keyspace, table).forEach(row -> indexes.add(createIndexMetadataFromRow(row)));
|
||||
return indexes.build();
|
||||
|
|
@ -1063,7 +1061,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Triggers fetchTriggers(String keyspace, String table)
|
||||
{
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", NAME, TRIGGERS);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, TRIGGERS);
|
||||
Triggers.Builder triggers = org.apache.cassandra.schema.Triggers.builder();
|
||||
query(query, keyspace, table).forEach(row -> triggers.add(createTriggerFromRow(row)));
|
||||
return triggers.build();
|
||||
|
|
@ -1078,7 +1076,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Views fetchViews(String keyspaceName, Types types)
|
||||
{
|
||||
String query = format("SELECT view_name FROM %s.%s WHERE keyspace_name = ?", NAME, VIEWS);
|
||||
String query = format("SELECT view_name FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, VIEWS);
|
||||
|
||||
Views.Builder views = org.apache.cassandra.schema.Views.builder();
|
||||
for (UntypedResultSet.Row row : query(query, keyspaceName))
|
||||
|
|
@ -1088,7 +1086,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static ViewDefinition fetchView(String keyspaceName, String viewName, Types types)
|
||||
{
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND view_name = ?", NAME, VIEWS);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND view_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, VIEWS);
|
||||
UntypedResultSet rows = query(query, keyspaceName, viewName);
|
||||
if (rows.isEmpty())
|
||||
throw new RuntimeException(String.format("%s:%s not found in the schema definitions keyspace.", keyspaceName, viewName));
|
||||
|
|
@ -1136,7 +1134,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Functions fetchUDFs(String keyspaceName, Types types)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", NAME, FUNCTIONS);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, FUNCTIONS);
|
||||
|
||||
Functions.Builder functions = org.apache.cassandra.schema.Functions.builder();
|
||||
for (UntypedResultSet.Row row : query(query, keyspaceName))
|
||||
|
|
@ -1197,7 +1195,7 @@ public final class SchemaKeyspace
|
|||
|
||||
private static Functions fetchUDAs(String keyspaceName, Functions udfs, Types types)
|
||||
{
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", NAME, AGGREGATES);
|
||||
String query = format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, AGGREGATES);
|
||||
|
||||
Functions.Builder aggregates = org.apache.cassandra.schema.Functions.builder();
|
||||
for (UntypedResultSet.Row row : query(query, keyspaceName))
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ import com.addthis.metrics3.reporter.config.ReporterConfig;
|
|||
import com.codahale.metrics.Meter;
|
||||
import com.codahale.metrics.MetricRegistryListener;
|
||||
import com.codahale.metrics.SharedMetricRegistries;
|
||||
import org.apache.cassandra.auth.AuthConfig;
|
||||
import org.apache.cassandra.batchlog.LegacyBatchlogMigrator;
|
||||
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.cql3.functions.ThreadAwareSecurityManager;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.db.*;
|
||||
|
|
@ -153,7 +155,7 @@ public class CassandraDaemon
|
|||
}
|
||||
}
|
||||
|
||||
private static final CassandraDaemon instance = new CassandraDaemon();
|
||||
static final CassandraDaemon instance = new CassandraDaemon();
|
||||
|
||||
public Server thriftServer;
|
||||
private NativeTransportService nativeTransportService;
|
||||
|
|
@ -264,7 +266,7 @@ public class CassandraDaemon
|
|||
for (String keyspaceName : Schema.instance.getKeyspaces())
|
||||
{
|
||||
// Skip system as we've already cleaned it
|
||||
if (keyspaceName.equals(SystemKeyspace.NAME))
|
||||
if (keyspaceName.equals(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
continue;
|
||||
|
||||
for (CFMetaData cfm : Schema.instance.getTablesAndViews(keyspaceName))
|
||||
|
|
@ -575,14 +577,7 @@ public class CassandraDaemon
|
|||
// Do not put any references to DatabaseDescriptor above the forceStaticInitialization call.
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
DatabaseDescriptor.forceStaticInitialization();
|
||||
}
|
||||
catch (ExceptionInInitializerError e)
|
||||
{
|
||||
throw e.getCause();
|
||||
}
|
||||
applyConfig();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -645,6 +640,12 @@ public class CassandraDaemon
|
|||
}
|
||||
}
|
||||
|
||||
public void applyConfig()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
AuthConfig.applyAuthz();
|
||||
}
|
||||
|
||||
public void startNativeTransport()
|
||||
{
|
||||
if (nativeTransportService == null)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.apache.cassandra.config.Config;
|
|||
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.cql3.QueryHandler;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.functions.Function;
|
||||
|
|
@ -41,7 +42,6 @@ import org.apache.cassandra.exceptions.InvalidRequestException;
|
|||
import org.apache.cassandra.exceptions.UnauthorizedException;
|
||||
import org.apache.cassandra.schema.SchemaKeyspace;
|
||||
import org.apache.cassandra.thrift.ThriftValidation;
|
||||
import org.apache.cassandra.tracing.TraceKeyspace;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.JVMStabilityInspector;
|
||||
import org.apache.cassandra.utils.CassandraVersion;
|
||||
|
|
@ -63,11 +63,12 @@ public class ClientState
|
|||
// We want these system cfs to be always readable to authenticated users since many tools rely on them
|
||||
// (nodetool, cqlsh, bulkloader, etc.)
|
||||
for (String cf : Arrays.asList(SystemKeyspace.LOCAL, SystemKeyspace.PEERS))
|
||||
READABLE_SYSTEM_RESOURCES.add(DataResource.table(SystemKeyspace.NAME, cf));
|
||||
READABLE_SYSTEM_RESOURCES.add(DataResource.table(SchemaConstants.SYSTEM_KEYSPACE_NAME, cf));
|
||||
|
||||
SchemaKeyspace.ALL.forEach(table -> READABLE_SYSTEM_RESOURCES.add(DataResource.table(SchemaKeyspace.NAME, table)));
|
||||
SchemaKeyspace.ALL.forEach(table -> READABLE_SYSTEM_RESOURCES.add(DataResource.table(SchemaConstants.SCHEMA_KEYSPACE_NAME, table)));
|
||||
|
||||
if (!Config.isClientMode())
|
||||
// neither clients nor tools need authentication/authorization
|
||||
if (!Config.isClientOrToolsMode())
|
||||
{
|
||||
PROTECTED_AUTH_RESOURCES.addAll(DatabaseDescriptor.getAuthenticator().protectedResources());
|
||||
PROTECTED_AUTH_RESOURCES.addAll(DatabaseDescriptor.getAuthorizer().protectedResources());
|
||||
|
|
@ -77,11 +78,11 @@ public class ClientState
|
|||
// allow users with sufficient privileges to alter KS level options on AUTH_KS and
|
||||
// TRACING_KS, and also to drop legacy tables (users, credentials, permissions) from
|
||||
// AUTH_KS
|
||||
ALTERABLE_SYSTEM_KEYSPACES.add(AuthKeyspace.NAME);
|
||||
ALTERABLE_SYSTEM_KEYSPACES.add(TraceKeyspace.NAME);
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(AuthKeyspace.NAME, PasswordAuthenticator.LEGACY_CREDENTIALS_TABLE));
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(AuthKeyspace.NAME, CassandraRoleManager.LEGACY_USERS_TABLE));
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(AuthKeyspace.NAME, CassandraAuthorizer.USER_PERMISSIONS));
|
||||
ALTERABLE_SYSTEM_KEYSPACES.add(SchemaConstants.AUTH_KEYSPACE_NAME);
|
||||
ALTERABLE_SYSTEM_KEYSPACES.add(SchemaConstants.TRACE_KEYSPACE_NAME);
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, PasswordAuthenticator.LEGACY_CREDENTIALS_TABLE));
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, CassandraRoleManager.LEGACY_USERS_TABLE));
|
||||
DROPPABLE_SYSTEM_TABLES.add(DataResource.table(SchemaConstants.AUTH_KEYSPACE_NAME, CassandraAuthorizer.USER_PERMISSIONS));
|
||||
}
|
||||
|
||||
// Current user for the session
|
||||
|
|
@ -323,7 +324,7 @@ public class ClientState
|
|||
|
||||
// Access to built in functions is unrestricted
|
||||
if(resource instanceof FunctionResource && resource.hasParent())
|
||||
if (((FunctionResource)resource).getKeyspace().equals(SystemKeyspace.NAME))
|
||||
if (((FunctionResource)resource).getKeyspace().equals(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
return;
|
||||
|
||||
checkPermissionOnResourceChain(perm, resource);
|
||||
|
|
@ -365,7 +366,7 @@ public class ClientState
|
|||
return;
|
||||
|
||||
// prevent system keyspace modification
|
||||
if (Schema.isSystemKeyspace(keyspace))
|
||||
if (SchemaConstants.isSystemKeyspace(keyspace))
|
||||
throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");
|
||||
|
||||
// allow users with sufficient privileges to alter KS level options on AUTH_KS and
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ package org.apache.cassandra.service;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.cassandra.service.CassandraDaemon;
|
||||
|
||||
/**
|
||||
* An embedded, in-memory cassandra storage service that listens
|
||||
* on the thrift interface as configured in cassandra.yaml
|
||||
|
|
@ -48,7 +46,8 @@ public class EmbeddedCassandraService
|
|||
|
||||
public void start() throws IOException
|
||||
{
|
||||
cassandraDaemon = new CassandraDaemon();
|
||||
cassandraDaemon = CassandraDaemon.instance;
|
||||
cassandraDaemon.applyConfig();
|
||||
cassandraDaemon.init(null);
|
||||
cassandraDaemon.start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.cassandra.concurrent.Stage;
|
|||
import org.apache.cassandra.concurrent.StageManager;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.config.ViewDefinition;
|
||||
import org.apache.cassandra.cql3.functions.UDAggregate;
|
||||
import org.apache.cassandra.cql3.functions.UDFunction;
|
||||
|
|
@ -95,7 +96,7 @@ public class MigrationManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (Schema.emptyVersion.equals(Schema.instance.getVersion()) || runtimeMXBean.getUptime() < MIGRATION_DELAY_IN_MS)
|
||||
if (SchemaConstants.emptyVersion.equals(Schema.instance.getVersion()) || runtimeMXBean.getUptime() < MIGRATION_DELAY_IN_MS)
|
||||
{
|
||||
// If we think we may be bootstrapping or have recently started, submit MigrationTask immediately
|
||||
logger.debug("Submitting migration task for {}", endpoint);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
|
|||
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.Directories;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
|
|
@ -317,7 +318,7 @@ public class StartupChecks
|
|||
// we do a one-off scrub of the system keyspace first; we can't load the list of the rest of the keyspaces,
|
||||
// until system keyspace is opened.
|
||||
|
||||
for (CFMetaData cfm : Schema.instance.getTablesAndViews(SystemKeyspace.NAME))
|
||||
for (CFMetaData cfm : Schema.instance.getTablesAndViews(SchemaConstants.SYSTEM_KEYSPACE_NAME))
|
||||
ColumnFamilyStore.scrubDataDirectories(cfm);
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import org.apache.cassandra.concurrent.StageManager;
|
|||
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.*;
|
||||
import org.apache.cassandra.db.filter.DataLimits;
|
||||
import org.apache.cassandra.db.filter.TombstoneOverwhelmingException;
|
||||
|
|
@ -964,7 +965,7 @@ public class StorageProxy implements StorageProxyMBean
|
|||
WriteResponseHandler<?> handler = new WriteResponseHandler<>(endpoints.all,
|
||||
Collections.<InetAddress>emptyList(),
|
||||
endpoints.all.size() == 1 ? ConsistencyLevel.ONE : ConsistencyLevel.TWO,
|
||||
Keyspace.open(SystemKeyspace.NAME),
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME),
|
||||
null,
|
||||
WriteType.BATCH_LOG,
|
||||
queryStartNanoTime);
|
||||
|
|
@ -1519,7 +1520,7 @@ public class StorageProxy implements StorageProxyMBean
|
|||
private static boolean systemKeyspaceQuery(List<? extends ReadCommand> cmds)
|
||||
{
|
||||
for (ReadCommand cmd : cmds)
|
||||
if (!Schema.isSystemKeyspace(cmd.metadata().ksName))
|
||||
if (!SchemaConstants.isSystemKeyspace(cmd.metadata().ksName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1841,7 +1842,7 @@ public class StorageProxy implements StorageProxyMBean
|
|||
{
|
||||
try
|
||||
{
|
||||
command.setMonitoringTime(new ConstructionTime(constructionTime), timeout, DatabaseDescriptor.getSlowQueryTimeout());
|
||||
command.setMonitoringTime(new ConstructionTime(constructionTime), verb.getTimeout(), DatabaseDescriptor.getSlowQueryTimeout());
|
||||
|
||||
ReadResponse response;
|
||||
try (ReadExecutionController executionController = command.executionController();
|
||||
|
|
@ -2522,19 +2523,17 @@ public class StorageProxy implements StorageProxyMBean
|
|||
{
|
||||
final long constructionTime;
|
||||
final MessagingService.Verb verb;
|
||||
final long timeout;
|
||||
|
||||
public DroppableRunnable(MessagingService.Verb verb)
|
||||
{
|
||||
this.constructionTime = System.currentTimeMillis();
|
||||
this.verb = verb;
|
||||
this.timeout = DatabaseDescriptor.getTimeout(verb);
|
||||
}
|
||||
|
||||
public final void run()
|
||||
{
|
||||
long timeTaken = System.currentTimeMillis() - constructionTime;
|
||||
if (timeTaken > timeout)
|
||||
if (timeTaken > verb.getTimeout())
|
||||
{
|
||||
MessagingService.instance().incrementDroppedMessages(verb, timeTaken);
|
||||
return;
|
||||
|
|
@ -2575,7 +2574,7 @@ public class StorageProxy implements StorageProxyMBean
|
|||
public final void run()
|
||||
{
|
||||
final MessagingService.Verb verb = verb();
|
||||
long mutationTimeout = DatabaseDescriptor.getTimeout(verb);
|
||||
long mutationTimeout = verb.getTimeout();
|
||||
long timeTaken = System.currentTimeMillis() - constructionTime;
|
||||
if (timeTaken > mutationTimeout)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import org.apache.cassandra.concurrent.StageManager;
|
|||
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.*;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
|
|
@ -634,7 +635,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
}, "StorageServiceShutdownHook");
|
||||
Runtime.getRuntime().addShutdownHook(drainOnShutdown);
|
||||
|
||||
replacing = DatabaseDescriptor.isReplacing();
|
||||
replacing = isReplacing();
|
||||
|
||||
if (!Boolean.parseBoolean(System.getProperty("cassandra.start_gossip", "true")))
|
||||
{
|
||||
|
|
@ -704,6 +705,16 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isReplacing()
|
||||
{
|
||||
if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemKeyspace.bootstrapComplete())
|
||||
{
|
||||
logger.info("Replace address on first boot requested; this node is already bootstrapped");
|
||||
return false;
|
||||
}
|
||||
return DatabaseDescriptor.getReplaceAddress() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* In the event of forceful termination we need to remove the shutdown hook to prevent hanging (OOM for instance)
|
||||
*/
|
||||
|
|
@ -846,7 +857,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
for (int i = 0; i < delay; i += 1000)
|
||||
{
|
||||
// if we see schema, we can proceed to the next check directly
|
||||
if (!Schema.instance.getVersion().equals(Schema.emptyVersion))
|
||||
if (!Schema.instance.getVersion().equals(SchemaConstants.emptyVersion))
|
||||
{
|
||||
logger.debug("got schema: {}", Schema.instance.getVersion());
|
||||
break;
|
||||
|
|
@ -2722,7 +2733,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
|
||||
public int forceKeyspaceCleanup(int jobs, String keyspaceName, String... tables) throws IOException, ExecutionException, InterruptedException
|
||||
{
|
||||
if (Schema.isSystemKeyspace(keyspaceName))
|
||||
if (SchemaConstants.isSystemKeyspace(keyspaceName))
|
||||
throw new RuntimeException("Cleanup of the system keyspace is neither necessary nor wise");
|
||||
|
||||
CompactionManager.AllSSTableOpStatus status = CompactionManager.AllSSTableOpStatus.SUCCESSFUL;
|
||||
|
|
@ -3045,7 +3056,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
Map<String, TabularData> snapshotMap = new HashMap<>();
|
||||
for (Keyspace keyspace : Keyspace.all())
|
||||
{
|
||||
if (Schema.isSystemKeyspace(keyspace.getName()))
|
||||
if (SchemaConstants.isSystemKeyspace(keyspace.getName()))
|
||||
continue;
|
||||
|
||||
for (ColumnFamilyStore cfStore : keyspace.getColumnFamilyStores())
|
||||
|
|
@ -3071,7 +3082,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
|
|||
long total = 0;
|
||||
for (Keyspace keyspace : Keyspace.all())
|
||||
{
|
||||
if (Schema.isSystemKeyspace(keyspace.getName()))
|
||||
if (SchemaConstants.isSystemKeyspace(keyspace.getName()))
|
||||
continue;
|
||||
|
||||
for (ColumnFamilyStore cfStore : keyspace.getColumnFamilyStores())
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.SerializationHeader;
|
||||
import org.apache.cassandra.db.TypeSizes;
|
||||
import org.apache.cassandra.io.compress.CompressionMetadata;
|
||||
|
|
@ -222,7 +221,7 @@ public class FileMessageHeader
|
|||
{
|
||||
UUID cfId = UUIDSerializer.serializer.deserialize(in, MessagingService.current_version);
|
||||
int sequenceNumber = in.readInt();
|
||||
Version sstableVersion = DatabaseDescriptor.getSSTableFormat().info.getVersion(in.readUTF());
|
||||
Version sstableVersion = SSTableFormat.Type.current().info.getVersion(in.readUTF());
|
||||
|
||||
SSTableFormat.Type format = SSTableFormat.Type.LEGACY;
|
||||
if (version >= StreamMessage.VERSION_22)
|
||||
|
|
|
|||
|
|
@ -41,16 +41,16 @@ public class TServerCustomFactory implements TServerFactory
|
|||
public TServer buildTServer(TServerFactory.Args args)
|
||||
{
|
||||
TServer server;
|
||||
if (ThriftServer.SYNC.equalsIgnoreCase(serverType))
|
||||
if (ThriftServer.ThriftServerType.SYNC.equalsIgnoreCase(serverType))
|
||||
{
|
||||
server = new CustomTThreadPoolServer.Factory().buildTServer(args);
|
||||
}
|
||||
else if(ThriftServer.ASYNC.equalsIgnoreCase(serverType))
|
||||
else if(ThriftServer.ThriftServerType.ASYNC.equalsIgnoreCase(serverType))
|
||||
{
|
||||
server = new CustomTNonBlockingServer.Factory().buildTServer(args);
|
||||
logger.info(String.format("Using non-blocking/asynchronous thrift server on %s : %s", args.addr.getHostName(), args.addr.getPort()));
|
||||
}
|
||||
else if(ThriftServer.HSHA.equalsIgnoreCase(serverType))
|
||||
else if(ThriftServer.ThriftServerType.HSHA.equalsIgnoreCase(serverType))
|
||||
{
|
||||
server = new THsHaDisruptorServer.Factory().buildTServer(args);
|
||||
logger.info(String.format("Using custom half-sync/half-async thrift server on %s : %s", args.addr.getHostName(), args.addr.getPort()));
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ import org.apache.thrift.transport.TTransportFactory;
|
|||
|
||||
public class ThriftServer implements CassandraDaemon.Server
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(ThriftServer.class);
|
||||
public final static String SYNC = "sync";
|
||||
public final static String ASYNC = "async";
|
||||
public final static String HSHA = "hsha";
|
||||
private static final Logger logger = LoggerFactory.getLogger(ThriftServer.class);
|
||||
|
||||
protected final InetAddress address;
|
||||
protected final int port;
|
||||
|
|
@ -143,4 +140,11 @@ public class ThriftServer implements CassandraDaemon.Server
|
|||
serverEngine.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ThriftServerType
|
||||
{
|
||||
public final static String SYNC = "sync";
|
||||
public final static String ASYNC = "async";
|
||||
public final static String HSHA = "hsha";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.Attributes;
|
||||
import org.apache.cassandra.cql3.Operator;
|
||||
import org.apache.cassandra.db.*;
|
||||
|
|
@ -636,7 +637,7 @@ public class ThriftValidation
|
|||
|
||||
public static void validateKeyspaceNotSystem(String modifiedKeyspace) throws org.apache.cassandra.exceptions.InvalidRequestException
|
||||
{
|
||||
if (Schema.isSystemKeyspace(modifiedKeyspace))
|
||||
if (SchemaConstants.isSystemKeyspace(modifiedKeyspace))
|
||||
throw new org.apache.cassandra.exceptions.InvalidRequestException(String.format("%s keyspace is not user-modifiable", modifiedKeyspace));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.google.common.collect.Multimap;
|
|||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.EncryptionOptions;
|
||||
import org.apache.cassandra.io.sstable.SSTableLoader;
|
||||
|
|
@ -51,7 +50,7 @@ public class BulkLoader
|
|||
|
||||
public static void load(LoaderOptions options) throws BulkLoadException
|
||||
{
|
||||
Config.setClientMode(true);
|
||||
DatabaseDescriptor.toolInitialization();
|
||||
OutputHandler handler = new OutputHandler.SystemOutput(options.verbose, options.debug);
|
||||
SSTableLoader loader = new SSTableLoader(
|
||||
options.directory,
|
||||
|
|
|
|||
|
|
@ -267,8 +267,10 @@ public class NodeProbe implements AutoCloseable
|
|||
|
||||
private void checkJobs(PrintStream out, int jobs)
|
||||
{
|
||||
// TODO this should get the configured number of concurrent_compactors via JMX and not using DatabaseDescriptor
|
||||
DatabaseDescriptor.toolInitialization();
|
||||
if (jobs > DatabaseDescriptor.getConcurrentCompactors())
|
||||
out.println(String.format("jobs (%d) is bigger than configured concurrent_compactors (%d), using at most %d threads", jobs, DatabaseDescriptor.getConcurrentCompactors(), DatabaseDescriptor.getConcurrentCompactors()));
|
||||
out.println(String.format("jobs (%d) is bigger than configured concurrent_compactors (%d) on this host, using at most %d threads", jobs, DatabaseDescriptor.getConcurrentCompactors(), DatabaseDescriptor.getConcurrentCompactors()));
|
||||
}
|
||||
|
||||
public void forceKeyspaceCleanup(PrintStream out, int jobs, String keyspaceName, String... tableNames) throws IOException, ExecutionException, InterruptedException
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.stream.StreamSupport;
|
|||
import org.apache.commons.cli.*;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
import org.apache.cassandra.db.DecoratedKey;
|
||||
import org.apache.cassandra.db.PartitionPosition;
|
||||
|
|
@ -62,7 +62,7 @@ public class SSTableExport
|
|||
|
||||
static
|
||||
{
|
||||
Config.setClientMode(true);
|
||||
DatabaseDescriptor.toolInitialization();
|
||||
|
||||
Option optKey = new Option(KEY_OPTION, true, "Partition key");
|
||||
// Number of times -k <key> can be passed on the command line.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.io.sstable.Component;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.service.ActiveRepairService;
|
||||
|
|
@ -48,9 +49,6 @@ public class SSTableRepairedAtSetter
|
|||
*/
|
||||
public static void main(final String[] args) throws IOException
|
||||
{
|
||||
// Necessary since BufferPool used in RandomAccessReader needs to access DatabaseDescriptor
|
||||
Config.setClientMode(true);
|
||||
|
||||
PrintStream out = System.out;
|
||||
if (args.length == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Directories;
|
||||
|
|
@ -48,6 +49,7 @@ public class StandaloneSSTableUtil
|
|||
try
|
||||
{
|
||||
// load keyspace descriptions.
|
||||
Util.initDatabaseDescriptor();
|
||||
Schema.instance.loadFromDisk(false);
|
||||
|
||||
CFMetaData metadata = Schema.instance.getCFMetaData(options.keyspaceName, options.cfName);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.cassandra.tools;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.cassandra.io.sstable.format.SSTableFormat;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ public class StandaloneUpgrader
|
|||
try
|
||||
{
|
||||
SSTableReader sstable = SSTableReader.openNoValidation(entry.getKey(), components, cfs);
|
||||
if (sstable.descriptor.version.equals(DatabaseDescriptor.getSSTableFormat().info.getLatestVersion()))
|
||||
if (sstable.descriptor.version.equals(SSTableFormat.Type.current().info.getLatestVersion()))
|
||||
continue;
|
||||
readers.add(sstable);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -35,22 +35,21 @@ public final class Util
|
|||
{
|
||||
try
|
||||
{
|
||||
DatabaseDescriptor.forceStaticInitialization();
|
||||
DatabaseDescriptor.toolInitialization();
|
||||
}
|
||||
catch (ExceptionInInitializerError e)
|
||||
catch (Throwable e)
|
||||
{
|
||||
Throwable cause = e.getCause();
|
||||
boolean logStackTrace = !(cause instanceof ConfigurationException) || ((ConfigurationException) cause).logStackTrace;
|
||||
System.out.println("Exception (" + cause.getClass().getName() + ") encountered during startup: " + cause.getMessage());
|
||||
boolean logStackTrace = !(e instanceof ConfigurationException) || ((ConfigurationException) e).logStackTrace;
|
||||
System.out.println("Exception (" + e.getClass().getName() + ") encountered during startup: " + e.getMessage());
|
||||
|
||||
if (logStackTrace)
|
||||
{
|
||||
cause.printStackTrace();
|
||||
e.printStackTrace();
|
||||
System.exit(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.err.println(cause.getMessage());
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import io.airlift.command.Command;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import io.airlift.command.Option;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.tools.NodeProbe;
|
||||
import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ public class Cleanup extends NodeToolCmd
|
|||
|
||||
for (String keyspace : keyspaces)
|
||||
{
|
||||
if (Schema.isSystemKeyspace(keyspace))
|
||||
if (SchemaConstants.isSystemKeyspace(keyspace))
|
||||
continue;
|
||||
|
||||
try
|
||||
|
|
@ -60,4 +60,4 @@ public class Cleanup extends NodeToolCmd
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.repair.RepairParallelism;
|
||||
import org.apache.cassandra.repair.SystemDistributedKeyspace;
|
||||
import org.apache.cassandra.repair.messages.RepairOption;
|
||||
import org.apache.cassandra.tools.NodeProbe;
|
||||
import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
|
||||
|
|
@ -41,7 +41,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
@Command(name = "repair", description = "Repair one or more tables")
|
||||
public class Repair extends NodeToolCmd
|
||||
{
|
||||
public final static Set<String> ONLY_EXPLICITLY_REPAIRED = Sets.newHashSet(SystemDistributedKeyspace.NAME);
|
||||
public final static Set<String> ONLY_EXPLICITLY_REPAIRED = Sets.newHashSet(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME);
|
||||
|
||||
@Arguments(usage = "[<keyspace> <tables>...]", description = "The keyspace followed by one or many tables")
|
||||
private List<String> args = new ArrayList<>();
|
||||
|
|
@ -134,4 +134,4 @@ public class Repair extends NodeToolCmd
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.*;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.db.Mutation;
|
||||
import org.apache.cassandra.db.rows.Row;
|
||||
import org.apache.cassandra.db.partitions.PartitionUpdate;
|
||||
|
|
@ -37,8 +38,6 @@ public final class TraceKeyspace
|
|||
{
|
||||
}
|
||||
|
||||
public static final String NAME = "system_traces";
|
||||
|
||||
public static final String SESSIONS = "sessions";
|
||||
public static final String EVENTS = "events";
|
||||
|
||||
|
|
@ -70,13 +69,13 @@ public final class TraceKeyspace
|
|||
|
||||
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.TRACE_KEYSPACE_NAME)
|
||||
.comment(description);
|
||||
}
|
||||
|
||||
public static KeyspaceMetadata metadata()
|
||||
{
|
||||
return KeyspaceMetadata.create(NAME, KeyspaceParams.simple(2), Tables.of(Sessions, Events));
|
||||
return KeyspaceMetadata.create(SchemaConstants.TRACE_KEYSPACE_NAME, KeyspaceParams.simple(2), Tables.of(Sessions, Events));
|
||||
}
|
||||
|
||||
static Mutation makeStartSessionMutation(ByteBuffer sessionId,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.util.*;
|
|||
import com.google.common.base.Splitter;
|
||||
|
||||
import org.apache.cassandra.auth.PasswordAuthenticator;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.QueryOptions;
|
||||
import org.apache.cassandra.db.ConsistencyLevel;
|
||||
import org.apache.cassandra.db.marshal.Int32Type;
|
||||
|
|
@ -238,7 +238,7 @@ public class Client extends SimpleClient
|
|||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Config.setClientMode(true);
|
||||
DatabaseDescriptor.clientInitialization();
|
||||
|
||||
// Print usage if no argument is specified.
|
||||
if (args.length < 2 || args.length > 3)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ import org.apache.cassandra.io.sstable.Descriptor;
|
|||
import org.apache.cassandra.io.sstable.metadata.MetadataComponent;
|
||||
import org.apache.cassandra.io.sstable.metadata.MetadataType;
|
||||
import org.apache.cassandra.io.sstable.metadata.ValidationMetadata;
|
||||
import org.apache.cassandra.schema.CompressionParams;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.io.util.DataOutputBufferFixed;
|
||||
import org.apache.cassandra.io.util.FileUtils;
|
||||
|
|
@ -735,20 +734,6 @@ public class FBUtilities
|
|||
buffer.position(position);
|
||||
}
|
||||
|
||||
private static final ThreadLocal<byte[]> threadLocalScratchBuffer = new ThreadLocal<byte[]>()
|
||||
{
|
||||
@Override
|
||||
protected byte[] initialValue()
|
||||
{
|
||||
return new byte[CompressionParams.DEFAULT_CHUNK_LENGTH];
|
||||
}
|
||||
};
|
||||
|
||||
public static byte[] getThreadLocalScratchBuffer()
|
||||
{
|
||||
return threadLocalScratchBuffer.get();
|
||||
}
|
||||
|
||||
public static long abs(long index)
|
||||
{
|
||||
long negbit = index >> 63;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.datastax.driver.core.*;
|
|||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.ColumnDefinition.ClusteringOrder;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
import org.apache.cassandra.db.marshal.*;
|
||||
import org.apache.cassandra.dht.*;
|
||||
|
|
@ -107,7 +108,7 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
|
|||
|
||||
private static Types fetchTypes(String keyspace, Session session)
|
||||
{
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaKeyspace.NAME, SchemaKeyspace.TYPES);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TYPES);
|
||||
|
||||
Types.RawBuilder types = Types.rawBuilder(keyspace);
|
||||
for (Row row : session.execute(query, keyspace))
|
||||
|
|
@ -132,7 +133,7 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
|
|||
private static Map<String, CFMetaData> fetchTables(String keyspace, Session session, IPartitioner partitioner, Types types)
|
||||
{
|
||||
Map<String, CFMetaData> tables = new HashMap<>();
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaKeyspace.NAME, SchemaKeyspace.TABLES);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES);
|
||||
|
||||
for (Row row : session.execute(query, keyspace))
|
||||
{
|
||||
|
|
@ -149,7 +150,7 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
|
|||
private static Map<String, CFMetaData> fetchViews(String keyspace, Session session, IPartitioner partitioner, Types types)
|
||||
{
|
||||
Map<String, CFMetaData> tables = new HashMap<>();
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaKeyspace.NAME, SchemaKeyspace.VIEWS);
|
||||
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.VIEWS);
|
||||
|
||||
for (Row row : session.execute(query, keyspace))
|
||||
{
|
||||
|
|
@ -177,7 +178,7 @@ public class NativeSSTableLoaderClient extends SSTableLoader.Client
|
|||
boolean isCompound = isView || flags.contains(CFMetaData.Flag.COMPOUND);
|
||||
|
||||
String columnsQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND table_name = ?",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.COLUMNS);
|
||||
|
||||
List<ColumnDefinition> defs = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ import org.apache.cassandra.security.EncryptionContextGenerator;
|
|||
|
||||
public class CommitLogStressTest
|
||||
{
|
||||
static
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
public static ByteBuffer dataSource;
|
||||
|
||||
public static int NUM_THREADS = 4 * Runtime.getRuntime().availableProcessors() - 1;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
public class DynamicEndpointSnitchLongTest
|
||||
{
|
||||
static
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcurrency() throws InterruptedException, IOException, ConfigurationException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.junit.Test;
|
|||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
|
|
@ -51,6 +52,8 @@ public class LongStreamingTest
|
|||
@BeforeClass
|
||||
public static void setup() throws Exception
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
|
||||
SchemaLoader.cleanupAndLeaveDirs();
|
||||
Keyspace.setInitialized();
|
||||
StorageService.instance.initServer();
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ import javax.security.auth.Subject;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.auth.*;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
|
@ -40,6 +42,12 @@ import static org.junit.Assert.fail;
|
|||
|
||||
public class AuthorizationProxyTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
JMXResource osBean = JMXResource.mbean("java.lang:type=OperatingSystem");
|
||||
JMXResource runtimeBean = JMXResource.mbean("java.lang:type=Runtime");
|
||||
JMXResource threadingBean = JMXResource.mbean("java.lang:type=Threading");
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import org.apache.cassandra.Util.PartitionerSwitcher;
|
|||
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.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.DecoratedKey;
|
||||
|
|
@ -72,6 +73,7 @@ public class BatchlogManagerTest
|
|||
@BeforeClass
|
||||
public static void defineSchema() throws ConfigurationException
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
sw = Util.switchPartitioner(Murmur3Partitioner.instance);
|
||||
SchemaLoader.prepareServer();
|
||||
SchemaLoader.createKeyspace(KEYSPACE1,
|
||||
|
|
@ -97,8 +99,8 @@ public class BatchlogManagerTest
|
|||
InetAddress localhost = InetAddress.getByName("127.0.0.1");
|
||||
metadata.updateNormalToken(Util.token("A"), localhost);
|
||||
metadata.updateHostId(UUIDGen.getTimeUUID(), localhost);
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).truncateBlocking();
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG).truncateBlocking();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).truncateBlocking();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG).truncateBlocking();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -171,12 +173,12 @@ public class BatchlogManagerTest
|
|||
|
||||
if (legacy)
|
||||
{
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG).forceBlockingFlush();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.LEGACY_BATCHLOG).forceBlockingFlush();
|
||||
LegacyBatchlogMigrator.migrate();
|
||||
}
|
||||
|
||||
// Flush the batchlog to disk (see CASSANDRA-6822).
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
|
||||
assertEquals(100, BatchlogManager.instance.countAllBatches() - initialAllBatches);
|
||||
assertEquals(0, BatchlogManager.instance.getTotalBatchesReplayed() - initialReplayedBatches);
|
||||
|
|
@ -260,7 +262,7 @@ public class BatchlogManagerTest
|
|||
}
|
||||
|
||||
// Flush the batchlog to disk (see CASSANDRA-6822).
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
|
||||
// Force batchlog replay and wait for it to complete.
|
||||
BatchlogManager.instance.startBatchlogReplay().get();
|
||||
|
|
@ -341,15 +343,15 @@ public class BatchlogManagerTest
|
|||
}
|
||||
|
||||
// Flush the batchlog to disk (see CASSANDRA-6822).
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
|
||||
assertEquals(1500, BatchlogManager.instance.countAllBatches() - initialAllBatches);
|
||||
assertEquals(0, BatchlogManager.instance.getTotalBatchesReplayed() - initialReplayedBatches);
|
||||
|
||||
UntypedResultSet result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SystemKeyspace.NAME, SystemKeyspace.LEGACY_BATCHLOG));
|
||||
UntypedResultSet result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_BATCHLOG));
|
||||
assertNotNull(result);
|
||||
assertEquals("Count in blog legacy", 0, result.one().getLong("count"));
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SystemKeyspace.NAME, SystemKeyspace.BATCHES));
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.BATCHES));
|
||||
assertNotNull(result);
|
||||
assertEquals("Count in blog", 1500, result.one().getLong("count"));
|
||||
|
||||
|
|
@ -382,10 +384,10 @@ public class BatchlogManagerTest
|
|||
assertEquals(750, result.one().getLong("count"));
|
||||
|
||||
// Ensure batchlog is left as expected.
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SystemKeyspace.NAME, SystemKeyspace.BATCHES));
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.BATCHES));
|
||||
assertNotNull(result);
|
||||
assertEquals("Count in blog after initial replay", 750, result.one().getLong("count"));
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SystemKeyspace.NAME, SystemKeyspace.LEGACY_BATCHLOG));
|
||||
result = executeInternal(String.format("SELECT count(*) FROM \"%s\".\"%s\"", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.LEGACY_BATCHLOG));
|
||||
assertNotNull(result);
|
||||
assertEquals("Count in blog legacy after initial replay ", 0, result.one().getLong("count"));
|
||||
}
|
||||
|
|
@ -414,7 +416,7 @@ public class BatchlogManagerTest
|
|||
Assert.assertEquals(initialAllBatches + 1, BatchlogManager.instance.countAllBatches());
|
||||
|
||||
String query = String.format("SELECT count(*) FROM %s.%s where id = %s",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.BATCHES,
|
||||
uuid);
|
||||
UntypedResultSet result = executeInternal(query);
|
||||
|
|
@ -451,7 +453,7 @@ public class BatchlogManagerTest
|
|||
assertEquals(initialAllBatches, BatchlogManager.instance.countAllBatches());
|
||||
|
||||
String query = String.format("SELECT count(*) FROM %s.%s where id = %s",
|
||||
SystemKeyspace.NAME,
|
||||
SchemaConstants.SYSTEM_KEYSPACE_NAME,
|
||||
SystemKeyspace.BATCHES,
|
||||
uuid);
|
||||
UntypedResultSet result = executeInternal(query);
|
||||
|
|
@ -486,7 +488,7 @@ public class BatchlogManagerTest
|
|||
assertEquals(1, BatchlogManager.instance.countAllBatches() - initialAllBatches);
|
||||
|
||||
// Flush the batchlog to disk (see CASSANDRA-6822).
|
||||
Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
Keyspace.open(SchemaConstants.SYSTEM_KEYSPACE_NAME).getColumnFamilyStore(SystemKeyspace.BATCHES).forceBlockingFlush();
|
||||
|
||||
assertEquals(1, BatchlogManager.instance.countAllBatches() - initialAllBatches);
|
||||
assertEquals(0, BatchlogManager.instance.getTotalBatchesReplayed() - initialReplayedBatches);
|
||||
|
|
|
|||
|
|
@ -24,12 +24,20 @@ package org.apache.cassandra.concurrent;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.utils.WrappedRunnable;
|
||||
|
||||
public class DebuggableThreadPoolExecutorTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupDD()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,15 +151,15 @@ public class CFMetaDataTest
|
|||
|
||||
// Test schema conversion
|
||||
Mutation rm = SchemaKeyspace.makeCreateTableMutation(keyspace, cfm, FBUtilities.timestampMicros()).build();
|
||||
PartitionUpdate cfU = rm.getPartitionUpdate(Schema.instance.getId(SchemaKeyspace.NAME, SchemaKeyspace.TABLES));
|
||||
PartitionUpdate cdU = rm.getPartitionUpdate(Schema.instance.getId(SchemaKeyspace.NAME, SchemaKeyspace.COLUMNS));
|
||||
PartitionUpdate cfU = rm.getPartitionUpdate(Schema.instance.getId(SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES));
|
||||
PartitionUpdate cdU = rm.getPartitionUpdate(Schema.instance.getId(SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.COLUMNS));
|
||||
|
||||
UntypedResultSet.Row tableRow = QueryProcessor.resultify(String.format("SELECT * FROM %s.%s", SchemaKeyspace.NAME, SchemaKeyspace.TABLES),
|
||||
UntypedResultSet.Row tableRow = QueryProcessor.resultify(String.format("SELECT * FROM %s.%s", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES),
|
||||
UnfilteredRowIterators.filter(cfU.unfilteredIterator(), FBUtilities.nowInSeconds()))
|
||||
.one();
|
||||
TableParams params = SchemaKeyspace.createTableParamsFromRow(tableRow);
|
||||
|
||||
UntypedResultSet columnsRows = QueryProcessor.resultify(String.format("SELECT * FROM %s.%s", SchemaKeyspace.NAME, SchemaKeyspace.COLUMNS),
|
||||
UntypedResultSet columnsRows = QueryProcessor.resultify(String.format("SELECT * FROM %s.%s", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.COLUMNS),
|
||||
UnfilteredRowIterators.filter(cdU.unfilteredIterator(), FBUtilities.nowInSeconds()));
|
||||
Set<ColumnDefinition> columns = new HashSet<>();
|
||||
for (UntypedResultSet.Row row : columnsRows)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.cassandra.config;
|
|||
*/
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.db.marshal.*;
|
||||
|
|
@ -29,6 +30,12 @@ import org.apache.cassandra.utils.ByteBufferUtil;
|
|||
|
||||
public class ColumnDefinitionTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupDD()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerializeDeserialize() throws Exception
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* 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 java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Verifies that {@link DatabaseDescriptor#clientInitialization()} } and a couple of <i>apply</i> methods
|
||||
* do not somehow lazily initialize any unwanted part of Cassandra like schema, commit log or start
|
||||
* unexpected threads.
|
||||
*
|
||||
* {@link DatabaseDescriptor#toolInitialization()} is tested via unit tests extending
|
||||
* {@link org.apache.cassandra.tools.ToolsTester}.
|
||||
*/
|
||||
public class DatabaseDescriptorRefTest
|
||||
{
|
||||
static final String[] validClasses = {
|
||||
"org.apache.cassandra.auth.IInternodeAuthenticator",
|
||||
"org.apache.cassandra.auth.IAuthenticator",
|
||||
"org.apache.cassandra.auth.IAuthorizer",
|
||||
"org.apache.cassandra.auth.IRoleManager",
|
||||
"org.apache.cassandra.config.DatabaseDescriptor",
|
||||
"org.apache.cassandra.config.ConfigurationLoader",
|
||||
"org.apache.cassandra.config.Config",
|
||||
"org.apache.cassandra.config.Config$1",
|
||||
"org.apache.cassandra.config.Config$RequestSchedulerId",
|
||||
"org.apache.cassandra.config.Config$CommitLogSync",
|
||||
"org.apache.cassandra.config.Config$DiskAccessMode",
|
||||
"org.apache.cassandra.config.Config$DiskFailurePolicy",
|
||||
"org.apache.cassandra.config.Config$CommitFailurePolicy",
|
||||
"org.apache.cassandra.config.Config$DiskOptimizationStrategy",
|
||||
"org.apache.cassandra.config.Config$InternodeCompression",
|
||||
"org.apache.cassandra.config.Config$MemtableAllocationType",
|
||||
"org.apache.cassandra.config.Config$UserFunctionTimeoutPolicy",
|
||||
"org.apache.cassandra.config.RequestSchedulerOptions",
|
||||
"org.apache.cassandra.config.ParameterizedClass",
|
||||
"org.apache.cassandra.config.EncryptionOptions",
|
||||
"org.apache.cassandra.config.EncryptionOptions$ClientEncryptionOptions",
|
||||
"org.apache.cassandra.config.EncryptionOptions$ServerEncryptionOptions",
|
||||
"org.apache.cassandra.config.EncryptionOptions$ServerEncryptionOptions$InternodeEncryption",
|
||||
"org.apache.cassandra.config.YamlConfigurationLoader",
|
||||
"org.apache.cassandra.config.YamlConfigurationLoader$PropertiesChecker",
|
||||
"org.apache.cassandra.config.YamlConfigurationLoader$PropertiesChecker$1",
|
||||
"org.apache.cassandra.config.YamlConfigurationLoader$CustomConstructor",
|
||||
"org.apache.cassandra.config.TransparentDataEncryptionOptions",
|
||||
"org.apache.cassandra.dht.IPartitioner",
|
||||
"org.apache.cassandra.exceptions.ConfigurationException",
|
||||
"org.apache.cassandra.exceptions.RequestValidationException",
|
||||
"org.apache.cassandra.exceptions.CassandraException",
|
||||
"org.apache.cassandra.exceptions.TransportException",
|
||||
"org.apache.cassandra.locator.IEndpointSnitch",
|
||||
"org.apache.cassandra.io.FSWriteError",
|
||||
"org.apache.cassandra.io.FSError",
|
||||
"org.apache.cassandra.io.compress.ICompressor",
|
||||
"org.apache.cassandra.io.compress.LZ4Compressor",
|
||||
"org.apache.cassandra.io.sstable.metadata.MetadataType",
|
||||
"org.apache.cassandra.io.util.BufferedDataOutputStreamPlus",
|
||||
"org.apache.cassandra.io.util.DataOutputBuffer",
|
||||
"org.apache.cassandra.io.util.DataOutputBufferFixed",
|
||||
"org.apache.cassandra.io.util.DataOutputStreamPlus",
|
||||
"org.apache.cassandra.io.util.DataOutputPlus",
|
||||
"org.apache.cassandra.io.util.DiskOptimizationStrategy",
|
||||
"org.apache.cassandra.locator.SimpleSeedProvider",
|
||||
"org.apache.cassandra.locator.SeedProvider",
|
||||
"org.apache.cassandra.scheduler.IRequestScheduler",
|
||||
"org.apache.cassandra.security.EncryptionContext",
|
||||
"org.apache.cassandra.service.CacheService$CacheType",
|
||||
"org.apache.cassandra.utils.FBUtilities",
|
||||
"org.apache.cassandra.utils.FBUtilities$1",
|
||||
"org.apache.cassandra.utils.CloseableIterator",
|
||||
"org.apache.cassandra.utils.Pair",
|
||||
"org.apache.cassandra.OffsetAwareConfigurationLoader",
|
||||
"org.apache.cassandra.ConsoleAppender",
|
||||
"org.apache.cassandra.ConsoleAppender$1",
|
||||
"org.apache.cassandra.LogbackStatusListener",
|
||||
"org.apache.cassandra.LogbackStatusListener$1",
|
||||
"org.apache.cassandra.LogbackStatusListener$2",
|
||||
"org.apache.cassandra.TeeingAppender",
|
||||
// generated classes
|
||||
"org.apache.cassandra.config.ConfigBeanInfo",
|
||||
"org.apache.cassandra.config.ConfigCustomizer",
|
||||
"org.apache.cassandra.config.EncryptionOptionsBeanInfo",
|
||||
"org.apache.cassandra.config.EncryptionOptionsCustomizer",
|
||||
"org.apache.cassandra.config.EncryptionOptions$ServerEncryptionOptionsBeanInfo",
|
||||
"org.apache.cassandra.config.EncryptionOptions$ServerEncryptionOptionsCustomizer",
|
||||
"org.apache.cassandra.ConsoleAppenderBeanInfo",
|
||||
"org.apache.cassandra.ConsoleAppenderCustomizer",
|
||||
};
|
||||
|
||||
static final Set<String> checkedClasses = new HashSet<>(Arrays.asList(validClasses));
|
||||
|
||||
@Test
|
||||
public void testDatabaseDescriptorRef() throws Throwable
|
||||
{
|
||||
PrintStream out = System.out;
|
||||
PrintStream err = System.err;
|
||||
|
||||
ThreadMXBean threads = ManagementFactory.getThreadMXBean();
|
||||
int threadCount = threads.getThreadCount();
|
||||
|
||||
ClassLoader delegate = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
List<Pair<String, Exception>> violations = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
ClassLoader cl = new ClassLoader(null)
|
||||
{
|
||||
final Map<String, Class<?>> classMap = new HashMap<>();
|
||||
|
||||
public URL getResource(String name)
|
||||
{
|
||||
return delegate.getResource(name);
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String name)
|
||||
{
|
||||
return delegate.getResourceAsStream(name);
|
||||
}
|
||||
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException
|
||||
{
|
||||
Class<?> cls = classMap.get(name);
|
||||
if (cls != null)
|
||||
return cls;
|
||||
|
||||
if (name.startsWith("org.apache.cassandra."))
|
||||
{
|
||||
// out.println(name);
|
||||
|
||||
if (!checkedClasses.contains(name))
|
||||
violations.add(Pair.create(name, new Exception()));
|
||||
}
|
||||
|
||||
URL url = delegate.getResource(name.replace('.', '/') + ".class");
|
||||
if (url == null)
|
||||
throw new ClassNotFoundException(name);
|
||||
try (InputStream in = url.openConnection().getInputStream())
|
||||
{
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
int c;
|
||||
while ((c = in.read()) != -1)
|
||||
os.write(c);
|
||||
byte[] data = os.toByteArray();
|
||||
cls = defineClass(name, data, 0, data.length);
|
||||
classMap.put(name, cls);
|
||||
return cls;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new ClassNotFoundException(name, e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
|
||||
assertEquals("thread started", threadCount, threads.getThreadCount());
|
||||
|
||||
Class cDatabaseDescriptor = Class.forName("org.apache.cassandra.config.DatabaseDescriptor", true, cl);
|
||||
|
||||
for (String methodName : new String[]{
|
||||
"clientInitialization",
|
||||
"applyAddressConfig",
|
||||
"applyThriftHSHA",
|
||||
"applyInitialTokens",
|
||||
// no seed provider in default configuration for clients
|
||||
// "applySeedProvider",
|
||||
// definitely not safe for clients - implicitly instantiates schema
|
||||
// "applyPartitioner",
|
||||
// definitely not safe for clients - implicitly instantiates StorageService
|
||||
// "applySnitch",
|
||||
"applyEncryptionContext",
|
||||
// starts "REQUEST-SCHEDULER" thread via RoundRobinScheduler
|
||||
// "applyRequestScheduler",
|
||||
})
|
||||
{
|
||||
Method method = cDatabaseDescriptor.getDeclaredMethod(methodName);
|
||||
method.invoke(null);
|
||||
|
||||
if ("clientInitialization".equals(methodName) &&
|
||||
threadCount + 1 == threads.getThreadCount())
|
||||
{
|
||||
// ignore the "AsyncAppender-Worker-ASYNC" thread
|
||||
threadCount++;
|
||||
}
|
||||
|
||||
if (threadCount != threads.getThreadCount())
|
||||
{
|
||||
for (ThreadInfo threadInfo : threads.getThreadInfo(threads.getAllThreadIds()))
|
||||
out.println("Thread #" + threadInfo.getThreadId() + ": " + threadInfo.getThreadName());
|
||||
assertEquals("thread started in " + methodName, threadCount, ManagementFactory.getThreadMXBean().getThreadCount());
|
||||
}
|
||||
|
||||
checkViolations(err, violations);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkViolations(PrintStream err, List<Pair<String, Exception>> violations)
|
||||
{
|
||||
if (!violations.isEmpty())
|
||||
{
|
||||
for (Pair<String, Exception> violation : new ArrayList<>(violations))
|
||||
{
|
||||
err.println();
|
||||
err.println();
|
||||
err.println("VIOLATION: " + violation.left);
|
||||
violation.right.printStackTrace(err);
|
||||
}
|
||||
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +50,12 @@ import static org.junit.Assert.assertTrue;
|
|||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class DatabaseDescriptorTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupDatabaseDescriptor()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCFMetaDataSerialization() throws ConfigurationException, InvalidRequestException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ 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.cql3.functions.FunctionName;
|
||||
import org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager;
|
||||
import org.apache.cassandra.cql3.statements.ParsedStatement;
|
||||
|
|
@ -94,6 +95,8 @@ public abstract class CQLTester
|
|||
public static final List<Integer> PROTOCOL_VERSIONS;
|
||||
static
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
|
||||
// The latest versions might not be supported yet by the java driver
|
||||
ImmutableList.Builder<Integer> builder = ImmutableList.builder();
|
||||
for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++)
|
||||
|
|
@ -149,6 +152,8 @@ public abstract class CQLTester
|
|||
if (isServerPrepared)
|
||||
return;
|
||||
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
|
||||
// Cleanup first
|
||||
try
|
||||
{
|
||||
|
|
@ -673,7 +678,7 @@ public abstract class CQLTester
|
|||
try
|
||||
{
|
||||
ClientState state = ClientState.forInternalCalls();
|
||||
state.setKeyspace(SystemKeyspace.NAME);
|
||||
state.setKeyspace(SchemaConstants.SYSTEM_KEYSPACE_NAME);
|
||||
QueryState queryState = new QueryState(state);
|
||||
|
||||
ParsedStatement.Prepared prepared = QueryProcessor.parseStatement(query, queryState);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ package org.apache.cassandra.cql3;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.rows.BufferCell;
|
||||
import org.apache.cassandra.db.rows.Cell;
|
||||
import org.apache.cassandra.db.rows.CellPath;
|
||||
|
|
@ -46,6 +48,12 @@ public class ColumnConditionTest
|
|||
public static final ByteBuffer A = AsciiType.instance.fromString("a");
|
||||
public static final ByteBuffer B = AsciiType.instance.fromString("b");
|
||||
|
||||
@BeforeClass
|
||||
public static void setupDD()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
private static boolean isSatisfiedBy(ColumnCondition.Bound bound, ByteBuffer conditionValue, ByteBuffer columnValue) throws InvalidRequestException
|
||||
{
|
||||
Cell cell = null;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.statements.ParsedStatement;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.db.marshal.Int32Type;
|
||||
|
|
@ -43,7 +44,7 @@ public class PstmtPersistenceTest extends CQLTester
|
|||
// need this for pstmt execution/validation tests
|
||||
requireNetwork();
|
||||
|
||||
int rows = QueryProcessor.executeOnceInternal("SELECT * FROM " + SystemKeyspace.NAME + '.' + SystemKeyspace.PREPARED_STATEMENTS).size();
|
||||
int rows = QueryProcessor.executeOnceInternal("SELECT * FROM " + SchemaConstants.SYSTEM_KEYSPACE_NAME + '.' + SystemKeyspace.PREPARED_STATEMENTS).size();
|
||||
Assert.assertEquals(0, rows);
|
||||
|
||||
execute("CREATE KEYSPACE IF NOT EXISTS foo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}");
|
||||
|
|
@ -55,7 +56,7 @@ public class PstmtPersistenceTest extends CQLTester
|
|||
|
||||
List<MD5Digest> stmtIds = new ArrayList<>();
|
||||
// #0
|
||||
stmtIds.add(QueryProcessor.prepare("SELECT * FROM " + SchemaKeyspace.NAME + '.' + SchemaKeyspace.TABLES + " WHERE keyspace_name = ?", clientState, false).statementId);
|
||||
stmtIds.add(QueryProcessor.prepare("SELECT * FROM " + SchemaConstants.SCHEMA_KEYSPACE_NAME + '.' + SchemaKeyspace.TABLES + " WHERE keyspace_name = ?", clientState, false).statementId);
|
||||
// #1
|
||||
stmtIds.add(QueryProcessor.prepare("SELECT * FROM " + KEYSPACE + '.' + currentTable() + " WHERE pk = ?", clientState, false).statementId);
|
||||
// #2
|
||||
|
|
@ -69,7 +70,7 @@ public class PstmtPersistenceTest extends CQLTester
|
|||
Assert.assertEquals(5, stmtIds.size());
|
||||
Assert.assertEquals(5, QueryProcessor.preparedStatementsCount());
|
||||
|
||||
String queryAll = "SELECT * FROM " + SystemKeyspace.NAME + '.' + SystemKeyspace.PREPARED_STATEMENTS;
|
||||
String queryAll = "SELECT * FROM " + SchemaConstants.SYSTEM_KEYSPACE_NAME + '.' + SystemKeyspace.PREPARED_STATEMENTS;
|
||||
|
||||
rows = QueryProcessor.executeOnceInternal(queryAll).size();
|
||||
Assert.assertEquals(5, rows);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,12 @@ import java.nio.ByteBuffer;
|
|||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.*;
|
||||
import org.apache.cassandra.cql3.Term.MultiItemTerminal;
|
||||
import org.apache.cassandra.cql3.statements.Bound;
|
||||
|
|
@ -41,6 +43,12 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class ClusteringColumnRestrictionsTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupDD()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoundsAsClusteringWithNoRestrictions()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class TombstonesTest extends CQLTester
|
|||
@BeforeClass
|
||||
public static void setUp() throws Throwable
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
DatabaseDescriptor.setTombstoneFailureThreshold(THRESHOLD);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ import ch.qos.logback.classic.turbo.TurboFilter;
|
|||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.TupleValue;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet.Row;
|
||||
import org.apache.cassandra.cql3.functions.UDAggregate;
|
||||
import org.apache.cassandra.db.SystemKeyspace;
|
||||
import org.apache.cassandra.db.marshal.AbstractType;
|
||||
import org.apache.cassandra.db.marshal.TypeParser;
|
||||
import org.apache.cassandra.exceptions.FunctionExecutionException;
|
||||
|
|
@ -1392,7 +1392,7 @@ public class AggregationTest extends CQLTester
|
|||
"CREATE AGGREGATE " + KEYSPACE_PER_TEST + ".test_wrong_ks(int) " +
|
||||
"SFUNC " + shortFunctionName(fState) + ' ' +
|
||||
"STYPE " + type + ' ' +
|
||||
"FINALFUNC " + SystemKeyspace.NAME + ".min " +
|
||||
"FINALFUNC " + SchemaConstants.SYSTEM_KEYSPACE_NAME + ".min " +
|
||||
"INITCOND 1");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package org.apache.cassandra.cql3.validation.operations;
|
||||
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
|
|
@ -283,7 +284,7 @@ public class AlterTest extends CQLTester
|
|||
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -292,7 +293,7 @@ public class AlterTest extends CQLTester
|
|||
execute("ALTER TABLE %s WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_in_kb' : 32 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -301,7 +302,7 @@ public class AlterTest extends CQLTester
|
|||
execute("ALTER TABLE %s WITH compression = { 'sstable_compression' : 'LZ4Compressor', 'chunk_length_kb' : 64 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -310,7 +311,7 @@ public class AlterTest extends CQLTester
|
|||
execute("ALTER TABLE %s WITH compression = { 'sstable_compression' : '', 'chunk_length_kb' : 32 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -320,7 +321,7 @@ public class AlterTest extends CQLTester
|
|||
execute("ALTER TABLE %s WITH compression = { 'enabled' : 'false'};");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.junit.Test;
|
|||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.Schema;
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.db.Mutation;
|
||||
import org.apache.cassandra.db.partitions.Partition;
|
||||
|
|
@ -510,7 +511,7 @@ public class CreateTest extends CQLTester
|
|||
createTable("CREATE TABLE %s (a text, b int, c int, primary key (a, b))");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -520,7 +521,7 @@ public class CreateTest extends CQLTester
|
|||
+ " WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_in_kb' : 32 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -530,7 +531,7 @@ public class CreateTest extends CQLTester
|
|||
+ " WITH compression = { 'class' : 'SnappyCompressor', 'chunk_length_in_kb' : 32, 'enabled' : true };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -540,7 +541,7 @@ public class CreateTest extends CQLTester
|
|||
+ " WITH compression = { 'sstable_compression' : 'SnappyCompressor', 'chunk_length_kb' : 32 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -550,7 +551,7 @@ public class CreateTest extends CQLTester
|
|||
+ " WITH compression = { 'sstable_compression' : '', 'chunk_length_kb' : 32 };");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
@ -560,7 +561,7 @@ public class CreateTest extends CQLTester
|
|||
+ " WITH compression = { 'enabled' : 'false'};");
|
||||
|
||||
assertRows(execute(format("SELECT compression FROM %s.%s WHERE keyspace_name = ? and table_name = ?;",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TABLES),
|
||||
KEYSPACE,
|
||||
currentTable()),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.cassandra.cql3.validation.operations;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.SchemaConstants;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
|
|
@ -1283,7 +1284,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
|
|||
// create and confirm
|
||||
schemaChange("CREATE KEYSPACE IF NOT EXISTS " + keyspace + " WITH replication = { 'class':'SimpleStrategy', 'replication_factor':1} and durable_writes = true ");
|
||||
assertRows(execute(format("select durable_writes from %s.%s where keyspace_name = ?",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.KEYSPACES),
|
||||
keyspace),
|
||||
row(true));
|
||||
|
|
@ -1292,7 +1293,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
|
|||
schemaChange("CREATE KEYSPACE IF NOT EXISTS " + keyspace + " WITH replication = {'class':'SimpleStrategy', 'replication_factor':1} and durable_writes = false ");
|
||||
|
||||
assertRows(execute(format("select durable_writes from %s.%s where keyspace_name = ?",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.KEYSPACES),
|
||||
keyspace),
|
||||
row(true));
|
||||
|
|
@ -1300,7 +1301,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
|
|||
// drop and confirm
|
||||
schemaChange("DROP KEYSPACE IF EXISTS " + keyspace);
|
||||
|
||||
assertEmpty(execute(format("select * from %s.%s where keyspace_name = ?", SchemaKeyspace.NAME, SchemaKeyspace.KEYSPACES),
|
||||
assertEmpty(execute(format("select * from %s.%s where keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.KEYSPACES),
|
||||
keyspace));
|
||||
}
|
||||
|
||||
|
|
@ -1377,7 +1378,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
|
|||
// create and confirm
|
||||
execute("CREATE TYPE IF NOT EXISTS mytype (somefield int)");
|
||||
assertRows(execute(format("SELECT type_name from %s.%s where keyspace_name = ? and type_name = ?",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TYPES),
|
||||
KEYSPACE,
|
||||
"mytype"),
|
||||
|
|
@ -1390,7 +1391,7 @@ public class InsertUpdateIfConditionTest extends CQLTester
|
|||
// drop and confirm
|
||||
execute("DROP TYPE IF EXISTS mytype");
|
||||
assertEmpty(execute(format("SELECT type_name from %s.%s where keyspace_name = ? and type_name = ?",
|
||||
SchemaKeyspace.NAME,
|
||||
SchemaConstants.SCHEMA_KEYSPACE_NAME,
|
||||
SchemaKeyspace.TYPES),
|
||||
KEYSPACE,
|
||||
"mytype"));
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.junit.Test;
|
|||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
import org.apache.cassandra.db.marshal.*;
|
||||
import org.apache.cassandra.db.rows.*;
|
||||
|
|
@ -41,6 +42,11 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
public class CellTest
|
||||
{
|
||||
static
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
private static final String KEYSPACE1 = "CellTest";
|
||||
private static final String CF_STANDARD1 = "Standard1";
|
||||
private static final String CF_COLLECTION = "Collection1";
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import junit.framework.Assert;
|
|||
import org.apache.cassandra.MockSchema;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.ColumnDefinition;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.marshal.SetType;
|
||||
import org.apache.cassandra.db.marshal.UTF8Type;
|
||||
import org.apache.cassandra.io.util.DataInputBuffer;
|
||||
|
|
@ -43,6 +44,10 @@ import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
|||
|
||||
public class ColumnsTest
|
||||
{
|
||||
static
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
private static final CFMetaData cfMetaData = MockSchema.newCFS().metadata;
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,10 @@ public class DirectoriesTest
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws IOException
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
|
||||
FileUtils.setFSErrorHandler(new DefaultFSErrorHandler());
|
||||
|
||||
for (String table : TABLES)
|
||||
{
|
||||
UUID tableID = CFMetaData.generateLegacyCfId(KS, table);
|
||||
|
|
|
|||
|
|
@ -17,14 +17,22 @@
|
|||
*/
|
||||
package org.apache.cassandra.db;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
public class LegacyCellNameTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setupDD()
|
||||
{
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColumnSameNameAsPartitionKeyCompactStorage() throws Exception
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue