Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC2E2F80E for ; Fri, 14 Nov 2014 17:59:05 +0000 (UTC) Received: (qmail 26475 invoked by uid 500); 14 Nov 2014 17:59:05 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 26441 invoked by uid 500); 14 Nov 2014 17:59:05 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 26427 invoked by uid 99); 14 Nov 2014 17:59:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Nov 2014 17:59:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 21F2B94166F; Fri, 14 Nov 2014 17:59:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aleksey@apache.org To: commits@cassandra.apache.org Message-Id: <9a80a5ab02674d269690bce18905085f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cassandra git commit: Remove post-2.1 dead schema migrations and columns Date: Fri, 14 Nov 2014 17:59:04 +0000 (UTC) Repository: cassandra Updated Branches: refs/heads/trunk 58fdc6b5c -> cbbc1191c Remove post-2.1 dead schema migrations and columns Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/cbbc1191 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/cbbc1191 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/cbbc1191 Branch: refs/heads/trunk Commit: cbbc1191ce1656a92354a4fa3859626cb10083e5 Parents: 58fdc6b Author: Aleksey Yeschenko Authored: Fri Nov 14 20:58:33 2014 +0300 Committer: Aleksey Yeschenko Committed: Fri Nov 14 20:58:33 2014 +0300 ---------------------------------------------------------------------- .../apache/cassandra/cache/CachingOptions.java | 9 +-- .../org/apache/cassandra/config/CFMetaData.java | 45 +------------- .../org/apache/cassandra/db/SystemKeyspace.java | 62 +------------------- 3 files changed, 5 insertions(+), 111 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/cbbc1191/src/java/org/apache/cassandra/cache/CachingOptions.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cache/CachingOptions.java b/src/java/org/apache/cassandra/cache/CachingOptions.java index 6eeaa37..f9c7e64 100644 --- a/src/java/org/apache/cassandra/cache/CachingOptions.java +++ b/src/java/org/apache/cassandra/cache/CachingOptions.java @@ -130,11 +130,7 @@ public class CachingOptions return result; } - public static boolean isLegacy(String CachingOptions) - { - return legacyOptions.contains(CachingOptions.toUpperCase()); - } - + // FIXME: move to ThriftConversion public static CachingOptions fromThrift(String caching, String cellsPerRow) throws ConfigurationException { @@ -153,6 +149,7 @@ public class CachingOptions return new CachingOptions(kc, rc); } + // FIXME: move to ThriftConversion public String toThriftCaching() { if (rowCache.isEnabled() && keyCache.isEnabled()) @@ -164,6 +161,7 @@ public class CachingOptions return "NONE"; } + // FIXME: move to ThriftConversion public String toThriftCellsPerRow() { if (rowCache.cacheFullPartitions()) @@ -171,7 +169,6 @@ public class CachingOptions return String.valueOf(rowCache.rowsToCache); } - public static class KeyCache { public final Type type; http://git-wip-us.apache.org/repos/asf/cassandra/blob/cbbc1191/src/java/org/apache/cassandra/config/CFMetaData.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java index 14271c0..2ed4a95 100644 --- a/src/java/org/apache/cassandra/config/CFMetaData.java +++ b/src/java/org/apache/cassandra/config/CFMetaData.java @@ -54,7 +54,6 @@ import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.UUIDGen; -import static org.apache.cassandra.utils.FBUtilities.fromJsonList; import static org.apache.cassandra.utils.FBUtilities.fromJsonMap; import static org.apache.cassandra.utils.FBUtilities.json; @@ -1251,7 +1250,6 @@ public final class CFMetaData adder.add("min_compaction_threshold", minCompactionThreshold); adder.add("max_compaction_threshold", maxCompactionThreshold); adder.add("bloom_filter_fp_chance", getBloomFilterFpChance()); - adder.add("memtable_flush_period_in_ms", memtableFlushPeriod); adder.add("caching", caching.toString()); adder.add("default_time_to_live", defaultTimeToLive); @@ -1260,18 +1258,12 @@ public final class CFMetaData adder.add("compaction_strategy_options", json(compactionStrategyOptions)); adder.add("min_index_interval", minIndexInterval); adder.add("max_index_interval", maxIndexInterval); - adder.add("index_interval", null); adder.add("speculative_retry", speculativeRetry.toString()); for (Map.Entry entry : droppedColumns.entrySet()) adder.addMapEntry("dropped_columns", entry.getKey().toString(), entry.getValue()); adder.add("is_dense", isDense); - - // Save the CQL3 metadata "the old way" for compatibility sake - adder.add("key_aliases", aliasesToJson(partitionKeyColumns)); - adder.add("column_aliases", aliasesToJson(clusteringColumns)); - adder.add("value_alias", compactValueColumn == null ? null : compactValueColumn.name.toString()); } @VisibleForTesting @@ -1328,11 +1320,9 @@ public final class CFMetaData cfm.compressionParameters(CompressionParameters.create(fromJsonMap(result.getString("compression_parameters")))); cfm.compactionStrategyOptions(fromJsonMap(result.getString("compaction_strategy_options"))); - // migrate old index_interval values to min_index_interval, if present if (result.has("min_index_interval")) cfm.minIndexInterval(result.getInt("min_index_interval")); - else if (result.has("index_interval")) - cfm.minIndexInterval(result.getInt("index_interval")); + if (result.has("max_index_interval")) cfm.maxIndexInterval(result.getInt("max_index_interval")); @@ -1341,20 +1331,6 @@ public final class CFMetaData else cfm.bloomFilterFpChance(cfm.getBloomFilterFpChance()); - /* - * The info previously hold by key_aliases, column_aliases and value_alias is now stored in columnMetadata (because 1) this - * make more sense and 2) this allow to store indexing information). - * However, for upgrade sake we need to still be able to read those old values. Moreover, we cannot easily - * remove those old columns once "converted" to columnMetadata because that would screw up nodes that may - * not have upgraded. So for now we keep the both info and in sync, even though its redundant. - */ - if (result.has("key_aliases")) - cfm.addColumnMetadataFromAliases(aliasesFromStrings(fromJsonList(result.getString("key_aliases"))), cfm.keyValidator, ColumnDefinition.Kind.PARTITION_KEY); - if (result.has("column_aliases")) - cfm.addColumnMetadataFromAliases(aliasesFromStrings(fromJsonList(result.getString("column_aliases"))), cfm.comparator.asAbstractType(), ColumnDefinition.Kind.CLUSTERING_COLUMN); - if (result.has("value_alias")) - cfm.addColumnMetadataFromAliases(Collections.singletonList(result.getBytes("value_alias")), cfm.defaultValidator, ColumnDefinition.Kind.COMPACT_VALUE); - if (result.has("dropped_columns")) cfm.droppedColumns(convertDroppedColumns(result.getMap("dropped_columns", UTF8Type.instance, LongType.instance))); @@ -1415,25 +1391,6 @@ public final class CFMetaData return fromSchema(result); } - private String aliasesToJson(List rawAliases) - { - if (rawAliases == null) - return null; - - List aliases = new ArrayList<>(rawAliases.size()); - for (ColumnDefinition rawAlias : rawAliases) - aliases.add(rawAlias.name.toString()); - return json(aliases); - } - - private static List aliasesFromStrings(List aliases) - { - List rawAliases = new ArrayList<>(aliases.size()); - for (String alias : aliases) - rawAliases.add(UTF8Type.instance.decompose(alias)); - return rawAliases; - } - private static Map convertDroppedColumns(Map raw) { Map converted = Maps.newHashMap(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/cbbc1191/src/java/org/apache/cassandra/db/SystemKeyspace.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java index 7806d5f..ddf6fa0 100644 --- a/src/java/org/apache/cassandra/db/SystemKeyspace.java +++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java @@ -33,7 +33,6 @@ import com.google.common.collect.Sets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.cassandra.cache.CachingOptions; import org.apache.cassandra.config.CFMetaData; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.KSMetaData; @@ -119,7 +118,6 @@ public final class SystemKeyspace + "bloom_filter_fp_chance double," + "caching text," + "cf_id uuid," // post-2.1 UUID cfid - + "column_aliases text," + "comment text," + "compaction_strategy_class text," + "compaction_strategy_options text," @@ -129,9 +127,7 @@ public final class SystemKeyspace + "default_validator text," + "dropped_columns map," + "gc_grace_seconds int," - + "index_interval int," + "is_dense boolean," - + "key_aliases text," + "key_validator text," + "local_read_repair_chance double," + "max_compaction_threshold int," @@ -143,7 +139,6 @@ public final class SystemKeyspace + "speculative_retry text," + "subcomparator text," + "type text," - + "value_alias text," + "PRIMARY KEY ((keyspace_name), columnfamily_name))") .gcGraceSeconds(WEEK); @@ -370,16 +365,11 @@ public final class SystemKeyspace { setupVersion(); - migrateIndexInterval(); - migrateCachingOption(); // add entries to system schema columnfamilies for the hardcoded system definitions KSMetaData ksmd = Schema.instance.getKSMetaData(NAME); // delete old, possibly obsolete entries in schema tables - // FIXME: once schema_functions moves from 'namespace' to 'keyspace_name', fix this - List schemaTables = new ArrayList<>(ALL_SCHEMA_TABLES); - schemaTables.remove(SCHEMA_FUNCTIONS_TABLE); - for (String table : schemaTables) + for (String table : ALL_SCHEMA_TABLES) executeOnceInternal(String.format("DELETE FROM system.%s WHERE keyspace_name = ?", table), ksmd.name); // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just added) @@ -401,56 +391,6 @@ public final class SystemKeyspace 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_TABLE))) - { - 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 = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_TABLE); - long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)"); - try - { - table.toSchema(timestamp).apply(); - } - catch (ConfigurationException e) - { - // shouldn't happen - } - } - } - - private static void migrateCachingOption() - { - for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_TABLE))) - { - if (!row.has("caching")) - continue; - - if (!CachingOptions.isLegacy(row.getString("caching"))) - continue; - try - { - CachingOptions caching = CachingOptions.fromString(row.getString("caching")); - CFMetaData table = CFMetaData.fromSchema(row); - logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"), caching.toString(), table.ksName, table.cfName); - String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_TABLE); - long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)"); - table.toSchema(timestamp).apply(); - } - catch (ConfigurationException e) - { - // shouldn't happen - } - } - } - /** * Write compaction log, except columfamilies under system keyspace. *