diff --git a/CHANGES.txt b/CHANGES.txt index ee48fcfa4b..10b4ac7016 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.1-beta2 + * Move Schema.FORCE_LOAD_KEYSPACES and Schema.FORCE_LOAD_KEYSPACES_PROP to CassandraRelevantProps (CASSANDRA-17783) * Add --resolve-ip option to nodetool gossipinfo (CASSANDRA-17934) * Allow pre-V5 global limit on bytes in flight to revert to zero asynchronously in RateLimitingTest (CASSANDRA-17927) Merged from 4.0: diff --git a/src/java/org/apache/cassandra/config/CassandraRelevantProperties.java b/src/java/org/apache/cassandra/config/CassandraRelevantProperties.java index 188a8aa68d..2a62aa5759 100644 --- a/src/java/org/apache/cassandra/config/CassandraRelevantProperties.java +++ b/src/java/org/apache/cassandra/config/CassandraRelevantProperties.java @@ -295,9 +295,12 @@ public enum CassandraRelevantProperties ORG_APACHE_CASSANDRA_CONF_CASSANDRA_RELEVANT_PROPERTIES_TEST("org.apache.cassandra.conf.CassandraRelevantPropertiesTest"), ORG_APACHE_CASSANDRA_DB_VIRTUAL_SYSTEM_PROPERTIES_TABLE_TEST("org.apache.cassandra.db.virtual.SystemPropertiesTableTest"), + /** Used when running in Client mode and the system and schema keyspaces need to be initialized outside of their normal initialization path **/ + FORCE_LOAD_LOCAL_KEYSPACES("cassandra.schema.force_load_local_keyspaces"), ; + CassandraRelevantProperties(String key, String defaultVal) { this.key = key; diff --git a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java index 40abe2c36d..6d5456124f 100644 --- a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java +++ b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; +import org.apache.cassandra.config.CassandraRelevantProperties; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.cql3.statements.schema.CreateTableStatement; import org.apache.cassandra.cql3.statements.schema.CreateTypeStatement; @@ -104,7 +105,7 @@ public class CQLSSTableWriter implements Closeable static { - System.setProperty("cassandra.schema.force_load_local_keyspaces", "true"); + CassandraRelevantProperties.FORCE_LOAD_LOCAL_KEYSPACES.setBoolean(true); DatabaseDescriptor.clientInitialization(false); // Partitioner is not set in client mode. if (DatabaseDescriptor.getPartitioner() == null) @@ -554,7 +555,8 @@ public class CQLSSTableWriter implements Closeable throw new IllegalStateException("No modification (INSERT/UPDATE/DELETE) statement specified, you should provide a modification statement through using()"); Preconditions.checkState(Sets.difference(SchemaConstants.LOCAL_SYSTEM_KEYSPACE_NAMES, Schema.instance.getKeyspaces()).isEmpty(), - "Local keyspaces were not loaded. If this is running as a client, please make sure to add %s=true system property.", Schema.FORCE_LOAD_LOCAL_KEYSPACES_PROP); + "Local keyspaces were not loaded. If this is running as a client, please make sure to add %s=true system property.", + CassandraRelevantProperties.FORCE_LOAD_LOCAL_KEYSPACES.getKey()); synchronized (CQLSSTableWriter.class) { diff --git a/src/java/org/apache/cassandra/schema/Schema.java b/src/java/org/apache/cassandra/schema/Schema.java index 9869be4abf..dee24c18cf 100644 --- a/src/java/org/apache/cassandra/schema/Schema.java +++ b/src/java/org/apache/cassandra/schema/Schema.java @@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.MapDifference; import org.apache.commons.lang3.ObjectUtils; +import org.apache.cassandra.config.CassandraRelevantProperties; import org.apache.cassandra.cql3.functions.*; import org.apache.cassandra.db.*; import org.apache.cassandra.db.marshal.AbstractType; @@ -74,9 +75,6 @@ public class Schema implements SchemaProvider { private static final Logger logger = LoggerFactory.getLogger(Schema.class); - public static final String FORCE_LOAD_LOCAL_KEYSPACES_PROP = "cassandra.schema.force_load_local_keyspaces"; - private static final boolean FORCE_LOAD_LOCAL_KEYSPACES = Boolean.getBoolean(FORCE_LOAD_LOCAL_KEYSPACES_PROP); - public static final Schema instance = new Schema(); private volatile Keyspaces distributedKeyspaces = Keyspaces.none(); @@ -108,7 +106,7 @@ public class Schema implements SchemaProvider private Schema() { this.online = isDaemonInitialized(); - this.localKeyspaces = (FORCE_LOAD_LOCAL_KEYSPACES || isDaemonInitialized() || isToolInitialized()) + this.localKeyspaces = (CassandraRelevantProperties.FORCE_LOAD_LOCAL_KEYSPACES.getBoolean() || isDaemonInitialized() || isToolInitialized()) ? Keyspaces.of(SchemaKeyspace.metadata(), SystemKeyspace.metadata()) : Keyspaces.none();