Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts:
src/java/org/apache/cassandra/db/SystemKeyspace.java
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6d2d60aa
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6d2d60aa
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6d2d60aa
Branch: refs/heads/trunk
Commit: 6d2d60aa6de3de9edb0a540dddcae3aaca41ea68
Parents: cb9d388 c3a8095
Author: Aleksey Yeschenko <[email protected]>
Authored: Fri Nov 7 21:33:38 2014 +0300
Committer: Aleksey Yeschenko <[email protected]>
Committed: Fri Nov 7 21:33:38 2014 +0300
----------------------------------------------------------------------
.../org/apache/cassandra/db/SystemKeyspace.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d2d60aa/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/SystemKeyspace.java
index 8b16564,64a487c..02a9530
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@@ -111,51 -109,36 +111,51 @@@ public class SystemKeyspac
{
setupVersion();
- copyAllAliasesToColumnsProper();
-
+ migrateIndexInterval();
+ migrateCachingOption();
// add entries to system schema columnfamilies for the hardcoded
system definitions
- for (String ksname : Schema.systemKeyspaceNames)
- {
- KSMetaData ksmd = Schema.instance.getKSMetaData(ksname);
+ KSMetaData ksmd = Schema.instance.getKSMetaData(Keyspace.SYSTEM_KS);
- // delete old, possibly obsolete entries in schema columnfamilies
- for (String cfname :
Arrays.asList(SystemKeyspace.SCHEMA_KEYSPACES_CF,
SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, SystemKeyspace.SCHEMA_COLUMNS_CF))
- executeOnceInternal(String.format("DELETE FROM system.%s
WHERE keyspace_name = ?", cfname), ksmd.name);
+ // delete old, possibly obsolete entries in schema columnfamilies
+ for (String cfname : Arrays.asList(SystemKeyspace.SCHEMA_KEYSPACES_CF,
+
SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF,
+ SystemKeyspace.SCHEMA_COLUMNS_CF,
+ SystemKeyspace.SCHEMA_TRIGGERS_CF))
- processInternal(String.format("DELETE FROM system.%s WHERE
keyspace_name = '%s'", cfname, ksmd.name));
++ executeOnceInternal(String.format("DELETE FROM system.%s WHERE
keyspace_name = ?", cfname), ksmd.name);
- // (+1 to timestamp to make sure we don't get shadowed by the
tombstones we just added)
- ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply();
- }
+ // (+1 to timestamp to make sure we don't get shadowed by the
tombstones we just added)
+ ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply();
}
- // Starting with 2.0 (CASSANDRA-5125) we keep all the 'aliases' in
system.schema_columns together with the regular columns,
- // but only for the newly-created tables. This migration is for the
pre-2.0 created tables.
- private static void copyAllAliasesToColumnsProper()
+ private static void setupVersion()
{
- for (UntypedResultSet.Row row : processInternal(String.format("SELECT
* FROM system.%s", SCHEMA_COLUMNFAMILIES_CF)))
+ String req = "INSERT INTO system.%s (key, release_version,
cql_version, thrift_version, native_protocol_version, data_center, rack,
partitioner) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
+ executeOnceInternal(String.format(req, LOCAL_CF),
+ LOCAL_KEY,
+ FBUtilities.getReleaseVersionString(),
+ QueryProcessor.CQL_VERSION.toString(),
+ cassandraConstants.VERSION,
+ String.valueOf(Server.CURRENT_VERSION),
+
snitch.getDatacenter(FBUtilities.getBroadcastAddress()),
+ snitch.getRack(FBUtilities.getBroadcastAddress()),
+
DatabaseDescriptor.getPartitioner().getClass().getName());
+ }
+
+ // TODO: In 3.0, remove this and the index_interval column from
system.schema_columnfamilies
+ /** Migrates index_interval values to min_index_interval and sets
index_interval to null */
+ private static void migrateIndexInterval()
+ {
+ for (UntypedResultSet.Row row :
executeOnceInternal(String.format("SELECT * FROM system.%s",
SCHEMA_COLUMNFAMILIES_CF)))
{
+ if (!row.has("index_interval"))
+ continue;
+
+ logger.debug("Migrating index_interval to min_index_interval");
+
CFMetaData table = CFMetaData.fromSchema(row);
- String query = String.format("SELECT writetime(type) "
- + "FROM system.%s "
- + "WHERE keyspace_name = '%s' AND
columnfamily_name = '%s'",
- SCHEMA_COLUMNFAMILIES_CF,
- table.ksName,
- table.cfName);
- long timestamp =
processInternal(query).one().getLong("writetime(type)");
+ String query = String.format("SELECT writetime(type) FROM
system.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
SCHEMA_COLUMNFAMILIES_CF);
+ long timestamp = executeOnceInternal(query, table.ksName,
table.cfName).one().getLong("writetime(type)");
try
{
table.toSchema(timestamp).apply();