Repository: cassandra Updated Branches: refs/heads/trunk 32ac6af2b -> 3e9d345f0
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/service/StorageService.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 999d6b6..a349e64 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -3259,7 +3259,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE private Future<StreamState> streamHints() { // StreamPlan will not fail if there are zero files to transfer, so flush anyway (need to get any in-memory hints, as well) - ColumnFamilyStore hintsCF = Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.HINTS_TABLE); + ColumnFamilyStore hintsCF = Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.HINTS); FBUtilities.waitOnFuture(hintsCF.forceFlush()); // gather all live nodes in the cluster that aren't also leaving @@ -3292,7 +3292,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE preferred, SystemKeyspace.NAME, ranges, - SystemKeyspace.HINTS_TABLE) + SystemKeyspace.HINTS) .execute(); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/thrift/ThriftConversion.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/thrift/ThriftConversion.java b/src/java/org/apache/cassandra/thrift/ThriftConversion.java index b04a091..d408767 100644 --- a/src/java/org/apache/cassandra/thrift/ThriftConversion.java +++ b/src/java/org/apache/cassandra/thrift/ThriftConversion.java @@ -30,6 +30,7 @@ import org.apache.cassandra.cql3.ColumnIdentifier; import org.apache.cassandra.cql3.Operator; import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.db.ColumnFamilyType; +import org.apache.cassandra.schema.LegacySchemaTables; import org.apache.cassandra.db.WriteType; import org.apache.cassandra.db.composites.CellNameType; import org.apache.cassandra.db.composites.CellNames; @@ -330,9 +331,9 @@ public class ThriftConversion List<Map<String, ByteBuffer>> cols = new ArrayList<>(columnsRes.rows.size()); for (CqlRow row : columnsRes.rows) cols.add(convertThriftCqlRow(row)); - UntypedResultSet colsRow = UntypedResultSet.create(cols); + UntypedResultSet colsRows = UntypedResultSet.create(cols); - return CFMetaData.fromSchemaNoTriggers(cfRow, colsRow); + return LegacySchemaTables.createTableFromTableRowAndColumnRows(cfRow, colsRows); } private static Map<String, ByteBuffer> convertThriftCqlRow(CqlRow row) http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/BulkLoader.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/BulkLoader.java b/src/java/org/apache/cassandra/tools/BulkLoader.java index 8e7e0e9..a720e12 100644 --- a/src/java/org/apache/cassandra/tools/BulkLoader.java +++ b/src/java/org/apache/cassandra/tools/BulkLoader.java @@ -26,12 +26,14 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import org.apache.commons.cli.*; + import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TTransport; import org.apache.cassandra.auth.IAuthenticator; import org.apache.cassandra.config.*; +import org.apache.cassandra.schema.LegacySchemaTables; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.db.marshal.UTF8Type; import org.apache.cassandra.dht.Range; @@ -309,7 +311,7 @@ public class BulkLoader String cfQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name = '%s'", SystemKeyspace.NAME, - SystemKeyspace.SCHEMA_COLUMNFAMILIES_TABLE, + LegacySchemaTables.COLUMNFAMILIES, keyspace); CqlResult cfRes = client.execute_cql3_query(ByteBufferUtil.bytes(cfQuery), Compression.NONE, ConsistencyLevel.ONE); @@ -319,7 +321,7 @@ public class BulkLoader String columnFamily = UTF8Type.instance.getString(row.columns.get(1).bufferForName()); String columnsQuery = String.format("SELECT * FROM %s.%s WHERE keyspace_name = '%s' AND columnfamily_name = '%s'", SystemKeyspace.NAME, - SystemKeyspace.SCHEMA_COLUMNS_TABLE, + LegacySchemaTables.COLUMNS, keyspace, columnFamily); CqlResult columnsRes = client.execute_cql3_query(ByteBufferUtil.bytes(columnsQuery), Compression.NONE, ConsistencyLevel.ONE); http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/SSTableExport.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/SSTableExport.java b/src/java/org/apache/cassandra/tools/SSTableExport.java index fa6b973..64dc2d8 100644 --- a/src/java/org/apache/cassandra/tools/SSTableExport.java +++ b/src/java/org/apache/cassandra/tools/SSTableExport.java @@ -26,7 +26,6 @@ import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.commons.cli.*; import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.*; import org.apache.cassandra.db.composites.CellNameType; @@ -420,7 +419,7 @@ public class SSTableExport String[] excludes = cmd.getOptionValues(EXCLUDEKEY_OPTION); String ssTableFileName = new File(cmd.getArgs()[0]).getAbsolutePath(); - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); Descriptor descriptor = Descriptor.fromFilename(ssTableFileName); // Start by validating keyspace name http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/SSTableImport.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/SSTableImport.java b/src/java/org/apache/cassandra/tools/SSTableImport.java index 6f5dc9d..f51610b 100644 --- a/src/java/org/apache/cassandra/tools/SSTableImport.java +++ b/src/java/org/apache/cassandra/tools/SSTableImport.java @@ -502,7 +502,7 @@ public class SSTableImport isSorted = true; } - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); if (Schema.instance.getNonSystemKeyspaces().size() < 1) { String msg = "no non-system keyspaces are defined"; http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/SSTableLevelResetter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/SSTableLevelResetter.java b/src/java/org/apache/cassandra/tools/SSTableLevelResetter.java index 3954b91..815620e 100644 --- a/src/java/org/apache/cassandra/tools/SSTableLevelResetter.java +++ b/src/java/org/apache/cassandra/tools/SSTableLevelResetter.java @@ -21,7 +21,6 @@ import java.io.PrintStream; import java.util.Map; import java.util.Set; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Keyspace; @@ -62,7 +61,7 @@ public class SSTableLevelResetter try { // load keyspace descriptions. - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); String keyspaceName = args[1]; String columnfamily = args[2]; http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/StandaloneScrubber.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/StandaloneScrubber.java b/src/java/org/apache/cassandra/tools/StandaloneScrubber.java index 94bf6e2..b6e2bf8 100644 --- a/src/java/org/apache/cassandra/tools/StandaloneScrubber.java +++ b/src/java/org/apache/cassandra/tools/StandaloneScrubber.java @@ -24,7 +24,6 @@ import java.util.*; import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.commons.cli.*; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Directories; @@ -53,7 +52,7 @@ public class StandaloneScrubber try { // load keyspace descriptions. - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); if (Schema.instance.getCFMetaData(options.keyspaceName, options.cfName) == null) throw new IllegalArgumentException(String.format("Unknown keyspace/table %s.%s", http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/StandaloneSplitter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/StandaloneSplitter.java b/src/java/org/apache/cassandra/tools/StandaloneSplitter.java index 66cb361..90ab48e 100644 --- a/src/java/org/apache/cassandra/tools/StandaloneSplitter.java +++ b/src/java/org/apache/cassandra/tools/StandaloneSplitter.java @@ -21,10 +21,10 @@ package org.apache.cassandra.tools; import java.io.File; import java.util.*; +import org.apache.cassandra.config.Schema; import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.commons.cli.*; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Directories; import org.apache.cassandra.db.Keyspace; @@ -52,7 +52,7 @@ public class StandaloneSplitter try { // load keyspace descriptions. - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); String ksName = null; String cfName = null; http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/src/java/org/apache/cassandra/tools/StandaloneUpgrader.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/StandaloneUpgrader.java b/src/java/org/apache/cassandra/tools/StandaloneUpgrader.java index 90eca5d..6617b96 100644 --- a/src/java/org/apache/cassandra/tools/StandaloneUpgrader.java +++ b/src/java/org/apache/cassandra/tools/StandaloneUpgrader.java @@ -46,7 +46,7 @@ public class StandaloneUpgrader try { // load keyspace descriptions. - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); if (Schema.instance.getCFMetaData(options.keyspace, options.cf) == null) throw new IllegalArgumentException(String.format("Unknown keyspace/table %s.%s", http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/config/CFMetaDataTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java index 79373ea..5fed5be 100644 --- a/test/unit/org/apache/cassandra/config/CFMetaDataTest.java +++ b/test/unit/org/apache/cassandra/config/CFMetaDataTest.java @@ -24,20 +24,21 @@ import java.util.HashMap; import java.util.HashSet; import org.apache.cassandra.SchemaLoader; -import org.apache.cassandra.cql3.QueryProcessor; -import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.db.*; import org.apache.cassandra.db.marshal.AsciiType; import org.apache.cassandra.db.marshal.UTF8Type; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.cassandra.io.compress.*; import org.apache.cassandra.locator.SimpleStrategy; +import org.apache.cassandra.schema.LegacySchemaTables; import org.apache.cassandra.service.StorageService; import org.apache.cassandra.thrift.CfDef; import org.apache.cassandra.thrift.ColumnDef; import org.apache.cassandra.thrift.IndexType; import org.apache.cassandra.thrift.ThriftConversion; import org.apache.cassandra.utils.ByteBufferUtil; +import org.apache.cassandra.utils.FBUtilities; + import org.junit.BeforeClass; import org.junit.Test; @@ -132,6 +133,7 @@ public class CFMetaDataTest private void checkInverses(CFMetaData cfm) throws Exception { DecoratedKey k = StorageService.getPartitioner().decorateKey(ByteBufferUtil.bytes(cfm.ksName)); + KSMetaData keyspace = Schema.instance.getKSMetaData(cfm.ksName); // Test thrift conversion CFMetaData before = cfm; @@ -139,11 +141,10 @@ public class CFMetaDataTest assert before.equals(after) : String.format("%n%s%n!=%n%s", before, after); // Test schema conversion - Mutation rm = cfm.toSchema(System.currentTimeMillis()); - ColumnFamily serializedCf = rm.getColumnFamily(Schema.instance.getId(SystemKeyspace.NAME, SystemKeyspace.SCHEMA_COLUMNFAMILIES_TABLE)); - ColumnFamily serializedCD = rm.getColumnFamily(Schema.instance.getId(SystemKeyspace.NAME, SystemKeyspace.SCHEMA_COLUMNS_TABLE)); - UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_columnfamilies", new Row(k, serializedCf)).one(); - CFMetaData newCfm = CFMetaData.fromSchemaNoTriggers(result, ColumnDefinition.resultify(new Row(k, serializedCD))); + Mutation rm = LegacySchemaTables.makeCreateTableMutation(keyspace, cfm, FBUtilities.timestampMicros()); + ColumnFamily serializedCf = rm.getColumnFamily(Schema.instance.getId(SystemKeyspace.NAME, LegacySchemaTables.COLUMNFAMILIES)); + ColumnFamily serializedCD = rm.getColumnFamily(Schema.instance.getId(SystemKeyspace.NAME, LegacySchemaTables.COLUMNS)); + CFMetaData newCfm = LegacySchemaTables.createTableFromTablePartitionAndColumnsPartition(new Row(k, serializedCf), new Row(k, serializedCD)); assert cfm.equals(newCfm) : String.format("%n%s%n!=%n%s", cfm, newCfm); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java index edfd7b6..8ca7a79 100644 --- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java +++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java @@ -56,9 +56,10 @@ public class DatabaseDescriptorTest @Test public void testKSMetaDataSerialization() throws ConfigurationException { - for (KSMetaData ksm : Schema.instance.getKeyspaceDefinitions()) + for (String ks : Schema.instance.getNonSystemKeyspaces()) { // Not testing round-trip on the KsDef via serDe() because maps + KSMetaData ksm = Schema.instance.getKSMetaData(ks); KSMetaData ksmDupe = ThriftConversion.fromThrift(ThriftConversion.toThrift(ksm)); assertNotNull(ksmDupe); assertEquals(ksm, ksmDupe); @@ -70,7 +71,7 @@ public class DatabaseDescriptorTest public void testTransKsMigration() throws ConfigurationException { SchemaLoader.cleanupAndLeaveDirs(); - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); assertEquals(0, Schema.instance.getNonSystemKeyspaces().size()); Gossiper.instance.start((int)(System.currentTimeMillis() / 1000)); @@ -91,7 +92,7 @@ public class DatabaseDescriptorTest assertNull(Schema.instance.getKSMetaData("ks0")); assertNull(Schema.instance.getKSMetaData("ks1")); - DatabaseDescriptor.loadSchemas(); + Schema.instance.loadFromDisk(); assertNotNull(Schema.instance.getKSMetaData("ks0")); assertNotNull(Schema.instance.getKSMetaData("ks1")); http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/config/DefsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/config/DefsTest.java b/test/unit/org/apache/cassandra/config/DefsTest.java deleted file mode 100644 index 6df67bc..0000000 --- a/test/unit/org/apache/cassandra/config/DefsTest.java +++ /dev/null @@ -1,564 +0,0 @@ -/** - * 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.File; -import java.nio.ByteBuffer; - -import org.apache.cassandra.OrderedJUnit4ClassRunner; -import org.apache.cassandra.SchemaLoader; -import org.apache.cassandra.Util; -import org.apache.cassandra.db.*; -import org.apache.cassandra.db.composites.*; -import org.apache.cassandra.db.marshal.BytesType; -import org.apache.cassandra.db.marshal.UTF8Type; -import org.apache.cassandra.db.marshal.TimeUUIDType; -import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.io.sstable.Component; -import org.apache.cassandra.io.sstable.Descriptor; -import org.apache.cassandra.io.sstable.SSTableDeletingTask; -import org.apache.cassandra.locator.OldNetworkTopologyStrategy; -import org.apache.cassandra.locator.SimpleStrategy; -import org.apache.cassandra.service.MigrationManager; -import org.apache.cassandra.utils.ByteBufferUtil; -import static org.apache.cassandra.Util.cellname; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(OrderedJUnit4ClassRunner.class) -public class DefsTest -{ - private static final String KEYSPACE1 = "Keyspace1"; - private static final String KEYSPACE3 = "Keyspace3"; - private static final String KEYSPACE6 = "Keyspace6"; - private static final String EMPTYKEYSPACE = "DefsTestEmptyKeyspace"; - private static final String CF_STANDARD1 = "Standard1"; - private static final String CF_STANDARD2 = "Standard2"; - private static final String CF_INDEXED = "Indexed1"; - - @BeforeClass - public static void defineSchema() throws ConfigurationException - { - SchemaLoader.prepareServer(); - SchemaLoader.startGossiper(); - SchemaLoader.createKeyspace(KEYSPACE1, - SimpleStrategy.class, - KSMetaData.optsWithRF(1), - SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1), - SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2)); - SchemaLoader.createKeyspace(KEYSPACE3, true, false, - SimpleStrategy.class, - KSMetaData.optsWithRF(5), - SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1), - SchemaLoader.indexCFMD(KEYSPACE3, CF_INDEXED, true)); - SchemaLoader.createKeyspace(KEYSPACE6, - SimpleStrategy.class, - KSMetaData.optsWithRF(1), - SchemaLoader.indexCFMD(KEYSPACE6, CF_INDEXED, true)); - } - - @Test - public void testCFMetaDataApply() throws ConfigurationException - { - CFMetaData cfm = new CFMetaData(KEYSPACE1, - "TestApplyCFM_CF", - ColumnFamilyType.Standard, - new SimpleDenseCellNameType(BytesType.instance)); - - for (int i = 0; i < 5; i++) - { - ByteBuffer name = ByteBuffer.wrap(new byte[] { (byte)i }); - cfm.addColumnDefinition(ColumnDefinition.regularDef(cfm, name, BytesType.instance, null).setIndex(Integer.toString(i), IndexType.KEYS, null)); - } - - cfm.comment("No comment") - .readRepairChance(0.5) - .gcGraceSeconds(100000) - .minCompactionThreshold(500) - .maxCompactionThreshold(500); - - // we'll be adding this one later. make sure it's not already there. - Assert.assertNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 5 }))); - - CFMetaData cfNew = cfm.copy(); - - // add one. - ColumnDefinition addIndexDef = ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(new byte[] { 5 }), BytesType.instance, null) - .setIndex("5", IndexType.KEYS, null); - cfNew.addColumnDefinition(addIndexDef); - - // remove one. - ColumnDefinition removeIndexDef = ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(new byte[] { 0 }), BytesType.instance, null) - .setIndex("0", IndexType.KEYS, null); - Assert.assertTrue(cfNew.removeColumnDefinition(removeIndexDef)); - - cfm.apply(cfNew); - - for (int i = 1; i < cfm.allColumns().size(); i++) - Assert.assertNotNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 1 }))); - Assert.assertNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 0 }))); - Assert.assertNotNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 5 }))); - } - - @Test - public void testInvalidNames() - { - String[] valid = {"1", "a", "_1", "b_", "__", "1_a"}; - for (String s : valid) - Assert.assertTrue(CFMetaData.isNameValid(s)); - - String[] invalid = {"b@t", "dash-y", "", " ", "dot.s", ".hidden"}; - for (String s : invalid) - Assert.assertFalse(CFMetaData.isNameValid(s)); - } - - @Ignore - @Test - public void saveAndRestore() - { - /* - // verify dump and reload. - UUID first = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress()); - DefsTables.dumpToStorage(first); - List<KSMetaData> defs = new ArrayList<KSMetaData>(DefsTables.loadFromStorage(first)); - - Assert.assertTrue(defs.size() > 0); - Assert.assertEquals(defs.size(), Schema.instance.getNonSystemKeyspaces().size()); - for (KSMetaData loaded : defs) - { - KSMetaData defined = Schema.instance.getKeyspaceDefinition(loaded.name); - Assert.assertTrue(String.format("%s != %s", loaded, defined), defined.equals(loaded)); - } - */ - } - - @Test - public void addNewCfToBogusKeyspace() - { - CFMetaData newCf = addTestCF("MadeUpKeyspace", "NewCF", "new cf"); - try - { - MigrationManager.announceNewColumnFamily(newCf); - throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist."); - } - catch (ConfigurationException expected) - { - } - } - - @Test - public void addNewCfWithNullComment() throws ConfigurationException - { - final String ks = KEYSPACE1; - final String cf = "BrandNewCfWithNull"; - KSMetaData original = Schema.instance.getKSMetaData(ks); - - CFMetaData newCf = addTestCF(original.name, cf, null); - - Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); - MigrationManager.announceNewColumnFamily(newCf); - - Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); - Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName)); - } - - @Test - public void addNewCF() throws ConfigurationException - { - final String ks = KEYSPACE1; - final String cf = "BrandNewCf"; - KSMetaData original = Schema.instance.getKSMetaData(ks); - - CFMetaData newCf = addTestCF(original.name, cf, "A New Table"); - - Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); - MigrationManager.announceNewColumnFamily(newCf); - - Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); - Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName)); - - // now read and write to it. - CellName col0 = cellname("col0"); - DecoratedKey dk = Util.dk("key0"); - Mutation rm = new Mutation(ks, dk.getKey()); - rm.add(cf, col0, ByteBufferUtil.bytes("value0"), 1L); - rm.applyUnsafe(); - ColumnFamilyStore store = Keyspace.open(ks).getColumnFamilyStore(cf); - Assert.assertNotNull(store); - store.forceBlockingFlush(); - - ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); - Assert.assertNotNull(cfam.getColumn(col0)); - Cell col = cfam.getColumn(col0); - Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); - } - - @Test - public void dropCf() throws ConfigurationException - { - DecoratedKey dk = Util.dk("dropCf"); - // sanity - final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE1); - Assert.assertNotNull(ks); - final CFMetaData cfm = ks.cfMetaData().get("Standard1"); - Assert.assertNotNull(cfm); - - // write some data, force a flush, then verify that files exist on disk. - Mutation rm = new Mutation(ks.name, dk.getKey()); - for (int i = 0; i < 100; i++) - rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); - rm.applyUnsafe(); - ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName); - Assert.assertNotNull(store); - store.forceBlockingFlush(); - Assert.assertTrue(store.directories.sstableLister().list().size() > 0); - - MigrationManager.announceColumnFamilyDrop(ks.name, cfm.cfName); - - Assert.assertFalse(Schema.instance.getKSMetaData(ks.name).cfMetaData().containsKey(cfm.cfName)); - - // any write should fail. - rm = new Mutation(ks.name, dk.getKey()); - boolean success = true; - try - { - rm.add("Standard1", cellname("col0"), ByteBufferUtil.bytes("value0"), 1L); - rm.applyUnsafe(); - } - catch (Throwable th) - { - success = false; - } - Assert.assertFalse("This mutation should have failed since the CF no longer exists.", success); - - // verify that the files are gone. - for (File file : store.directories.sstableLister().listFiles()) - { - if (file.getPath().endsWith("Data.db") && !new File(file.getPath().replace("Data.db", "Compacted")).exists()) - throw new AssertionError("undeleted file " + file); - } - } - - @Test - public void addNewKS() throws ConfigurationException - { - DecoratedKey dk = Util.dk("key0"); - CFMetaData newCf = addTestCF("NewKeyspace1", "AddedStandard1", "A new cf for a new ks"); - - KSMetaData newKs = KSMetaData.testMetadata(newCf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), newCf); - - MigrationManager.announceNewKeyspace(newKs); - - Assert.assertNotNull(Schema.instance.getKSMetaData(newCf.ksName)); - Assert.assertEquals(Schema.instance.getKSMetaData(newCf.ksName), newKs); - - // test reads and writes. - CellName col0 = cellname("col0"); - Mutation rm = new Mutation(newCf.ksName, dk.getKey()); - rm.add(newCf.cfName, col0, ByteBufferUtil.bytes("value0"), 1L); - rm.applyUnsafe(); - ColumnFamilyStore store = Keyspace.open(newCf.ksName).getColumnFamilyStore(newCf.cfName); - Assert.assertNotNull(store); - store.forceBlockingFlush(); - - ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); - Assert.assertNotNull(cfam.getColumn(col0)); - Cell col = cfam.getColumn(col0); - Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); - } - - @Test - public void dropKS() throws ConfigurationException - { - DecoratedKey dk = Util.dk("dropKs"); - // sanity - final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE1); - Assert.assertNotNull(ks); - final CFMetaData cfm = ks.cfMetaData().get("Standard2"); - Assert.assertNotNull(cfm); - - // write some data, force a flush, then verify that files exist on disk. - Mutation rm = new Mutation(ks.name, dk.getKey()); - for (int i = 0; i < 100; i++) - rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); - rm.applyUnsafe(); - ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName); - Assert.assertNotNull(store); - store.forceBlockingFlush(); - Assert.assertTrue(store.directories.sstableLister().list().size() > 0); - - MigrationManager.announceKeyspaceDrop(ks.name); - - Assert.assertNull(Schema.instance.getKSMetaData(ks.name)); - - // write should fail. - rm = new Mutation(ks.name, dk.getKey()); - boolean success = true; - try - { - rm.add("Standard1", cellname("col0"), ByteBufferUtil.bytes("value0"), 1L); - rm.applyUnsafe(); - } - catch (Throwable th) - { - success = false; - } - Assert.assertFalse("This mutation should have failed since the CF no longer exists.", success); - - // reads should fail too. - boolean threw = false; - try - { - Keyspace.open(ks.name); - } - catch (Throwable th) - { - threw = true; - } - Assert.assertTrue(threw); - } - - @Test - public void dropKSUnflushed() throws ConfigurationException - { - DecoratedKey dk = Util.dk("dropKs"); - // sanity - final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE3); - Assert.assertNotNull(ks); - final CFMetaData cfm = ks.cfMetaData().get("Standard1"); - Assert.assertNotNull(cfm); - - // write some data - Mutation rm = new Mutation(ks.name, dk.getKey()); - for (int i = 0; i < 100; i++) - rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); - rm.applyUnsafe(); - - MigrationManager.announceKeyspaceDrop(ks.name); - - Assert.assertNull(Schema.instance.getKSMetaData(ks.name)); - } - - @Test - public void createEmptyKsAddNewCf() throws ConfigurationException - { - Assert.assertNull(Schema.instance.getKSMetaData(EMPTYKEYSPACE)); - - KSMetaData newKs = KSMetaData.testMetadata(EMPTYKEYSPACE, SimpleStrategy.class, KSMetaData.optsWithRF(5)); - - MigrationManager.announceNewKeyspace(newKs); - Assert.assertNotNull(Schema.instance.getKSMetaData(EMPTYKEYSPACE)); - - CFMetaData newCf = addTestCF(EMPTYKEYSPACE, "AddedLater", "A new CF to add to an empty KS"); - - //should not exist until apply - Assert.assertFalse(Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName)); - - //add the new CF to the empty space - MigrationManager.announceNewColumnFamily(newCf); - - Assert.assertTrue(Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName)); - Assert.assertEquals(Schema.instance.getKSMetaData(newKs.name).cfMetaData().get(newCf.cfName), newCf); - - // now read and write to it. - CellName col0 = cellname("col0"); - DecoratedKey dk = Util.dk("key0"); - Mutation rm = new Mutation(newKs.name, dk.getKey()); - rm.add(newCf.cfName, col0, ByteBufferUtil.bytes("value0"), 1L); - rm.applyUnsafe(); - ColumnFamilyStore store = Keyspace.open(newKs.name).getColumnFamilyStore(newCf.cfName); - Assert.assertNotNull(store); - store.forceBlockingFlush(); - - ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); - Assert.assertNotNull(cfam.getColumn(col0)); - Cell col = cfam.getColumn(col0); - Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); - } - - @Test - public void testUpdateKeyspace() throws ConfigurationException - { - // create a keyspace to serve as existing. - CFMetaData cf = addTestCF("UpdatedKeyspace", "AddedStandard1", "A new cf for a new ks"); - KSMetaData oldKs = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), cf); - - MigrationManager.announceNewKeyspace(oldKs); - - Assert.assertNotNull(Schema.instance.getKSMetaData(cf.ksName)); - Assert.assertEquals(Schema.instance.getKSMetaData(cf.ksName), oldKs); - - // names should match. - KSMetaData newBadKs2 = KSMetaData.testMetadata(cf.ksName + "trash", SimpleStrategy.class, KSMetaData.optsWithRF(4)); - try - { - MigrationManager.announceKeyspaceUpdate(newBadKs2); - throw new AssertionError("Should not have been able to update a KS with an invalid KS name."); - } - catch (ConfigurationException ex) - { - // expected. - } - - KSMetaData newKs = KSMetaData.testMetadata(cf.ksName, OldNetworkTopologyStrategy.class, KSMetaData.optsWithRF(1)); - MigrationManager.announceKeyspaceUpdate(newKs); - - KSMetaData newFetchedKs = Schema.instance.getKSMetaData(newKs.name); - Assert.assertEquals(newFetchedKs.strategyClass, newKs.strategyClass); - Assert.assertFalse(newFetchedKs.strategyClass.equals(oldKs.strategyClass)); - } - - @Test - public void testUpdateColumnFamilyNoIndexes() throws ConfigurationException - { - // create a keyspace with a cf to update. - CFMetaData cf = addTestCF("UpdatedCfKs", "Standard1added", "A new cf that will be updated"); - KSMetaData ksm = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(1), cf); - MigrationManager.announceNewKeyspace(ksm); - - Assert.assertNotNull(Schema.instance.getKSMetaData(cf.ksName)); - Assert.assertEquals(Schema.instance.getKSMetaData(cf.ksName), ksm); - Assert.assertNotNull(Schema.instance.getCFMetaData(cf.ksName, cf.cfName)); - - // updating certain fields should fail. - CFMetaData newCfm = cf.copy(); - newCfm.defaultValidator(BytesType.instance); - newCfm.minCompactionThreshold(5); - newCfm.maxCompactionThreshold(31); - - // test valid operations. - newCfm.comment("Modified comment"); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); // doesn't get set back here. - - newCfm.readRepairChance(0.23); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); - - newCfm.gcGraceSeconds(12); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); - - newCfm.defaultValidator(UTF8Type.instance); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); - - newCfm.minCompactionThreshold(3); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); - - newCfm.maxCompactionThreshold(33); - MigrationManager.announceColumnFamilyUpdate(newCfm, false); - - // can't test changing the reconciler because there is only one impl. - - // check the cumulative affect. - Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getComment(), newCfm.getComment()); - Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getReadRepairChance(), newCfm.getReadRepairChance(), 0.0001); - Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getGcGraceSeconds(), newCfm.getGcGraceSeconds()); - Assert.assertEquals(UTF8Type.instance, Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getDefaultValidator()); - - // Change cfId - newCfm = new CFMetaData(cf.ksName, cf.cfName, cf.cfType, cf.comparator); - CFMetaData.copyOpts(newCfm, cf); - try - { - cf.apply(newCfm); - throw new AssertionError("Should have blown up when you used a different id."); - } - catch (ConfigurationException expected) {} - - // Change cfName - newCfm = new CFMetaData(cf.ksName, cf.cfName + "_renamed", cf.cfType, cf.comparator); - CFMetaData.copyOpts(newCfm, cf); - try - { - cf.apply(newCfm); - throw new AssertionError("Should have blown up when you used a different name."); - } - catch (ConfigurationException expected) {} - - // Change ksName - newCfm = new CFMetaData(cf.ksName + "_renamed", cf.cfName, cf.cfType, cf.comparator); - CFMetaData.copyOpts(newCfm, cf); - try - { - cf.apply(newCfm); - throw new AssertionError("Should have blown up when you used a different keyspace."); - } - catch (ConfigurationException expected) {} - - // Change cf type - newCfm = new CFMetaData(cf.ksName, cf.cfName, ColumnFamilyType.Super, cf.comparator); - CFMetaData.copyOpts(newCfm, cf); - try - { - cf.apply(newCfm); - throw new AssertionError("Should have blwon up when you used a different cf type."); - } - catch (ConfigurationException expected) {} - - // Change comparator - newCfm = new CFMetaData(cf.ksName, cf.cfName, cf.cfType, new SimpleDenseCellNameType(TimeUUIDType.instance)); - CFMetaData.copyOpts(newCfm, cf); - try - { - cf.apply(newCfm); - throw new AssertionError("Should have blown up when you used a different comparator."); - } - catch (ConfigurationException expected) {} - } - - @Test - public void testDropIndex() throws ConfigurationException - { - // persist keyspace definition in the system keyspace - Schema.instance.getKSMetaData(KEYSPACE6).toSchema(System.currentTimeMillis()).applyUnsafe(); - ColumnFamilyStore cfs = Keyspace.open(KEYSPACE6).getColumnFamilyStore("Indexed1"); - - // insert some data. save the sstable descriptor so we can make sure it's marked for delete after the drop - Mutation rm = new Mutation(KEYSPACE6, ByteBufferUtil.bytes("k1")); - rm.add("Indexed1", cellname("notbirthdate"), ByteBufferUtil.bytes(1L), 0); - rm.add("Indexed1", cellname("birthdate"), ByteBufferUtil.bytes(1L), 0); - rm.applyUnsafe(); - cfs.forceBlockingFlush(); - ColumnFamilyStore indexedCfs = cfs.indexManager.getIndexForColumn(ByteBufferUtil.bytes("birthdate")).getIndexCfs(); - Descriptor desc = indexedCfs.getSSTables().iterator().next().descriptor; - - // drop the index - CFMetaData meta = cfs.metadata.copy(); - ColumnDefinition cdOld = meta.regularColumns().iterator().next(); - ColumnDefinition cdNew = ColumnDefinition.regularDef(meta, cdOld.name.bytes, cdOld.type, null); - meta.addOrReplaceColumnDefinition(cdNew); - MigrationManager.announceColumnFamilyUpdate(meta, false); - - // check - Assert.assertTrue(cfs.indexManager.getIndexes().isEmpty()); - SSTableDeletingTask.waitForDeletions(); - Assert.assertFalse(new File(desc.filenameFor(Component.DATA)).exists()); - } - - private CFMetaData addTestCF(String ks, String cf, String comment) - { - CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, new SimpleDenseCellNameType(UTF8Type.instance)); - newCFMD.comment(comment) - .readRepairChance(0.0); - - return newCFMD; - } -} http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/config/KSMetaDataTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/config/KSMetaDataTest.java b/test/unit/org/apache/cassandra/config/KSMetaDataTest.java index 9093086..3d90bef 100644 --- a/test/unit/org/apache/cassandra/config/KSMetaDataTest.java +++ b/test/unit/org/apache/cassandra/config/KSMetaDataTest.java @@ -39,11 +39,7 @@ public class KSMetaDataTest options.put("key2", "value2"); options.put("key3", "value3"); - KSMetaData ksMeta = new KSMetaData("test", - SimpleStrategy.class, - options, - true, - Collections.<CFMetaData>emptyList()); + KSMetaData ksMeta = new KSMetaData("test", SimpleStrategy.class, options, true); assertTrue(ksMeta.toString().contains(options.toString())); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/cql3/CQLTester.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/CQLTester.java b/test/unit/org/apache/cassandra/cql3/CQLTester.java index 883da3a..4e536fe 100644 --- a/test/unit/org/apache/cassandra/cql3/CQLTester.java +++ b/test/unit/org/apache/cassandra/cql3/CQLTester.java @@ -159,10 +159,10 @@ public abstract class CQLTester schemaChange(String.format("DROP TABLE IF EXISTS %s.%s", KEYSPACE, tableToDrop)); for (String aggregateName : aggregatesToDrop) - schemaChange(String.format("DROP AGGREGATE IF EXISTS %s", aggregateName)); + schemaChange(String.format("DROP AGGREGATE IF EXISTS %s.%s", KEYSPACE, aggregateName)); for (String functionName : functionsToDrop) - schemaChange(String.format("DROP FUNCTION IF EXISTS %s", functionName)); + schemaChange(String.format("DROP FUNCTION IF EXISTS %s.%s", KEYSPACE, functionName)); for (String typeName : typesToDrop) schemaChange(String.format("DROP TYPE IF EXISTS %s.%s", KEYSPACE, typeName)); http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/db/BatchlogManagerTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/BatchlogManagerTest.java b/test/unit/org/apache/cassandra/db/BatchlogManagerTest.java index 608aee8..70d1d0c 100644 --- a/test/unit/org/apache/cassandra/db/BatchlogManagerTest.java +++ b/test/unit/org/apache/cassandra/db/BatchlogManagerTest.java @@ -101,7 +101,7 @@ public class BatchlogManagerTest } // Flush the batchlog to disk (see CASSANDRA-6822). - Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHLOG_TABLE).forceBlockingFlush(); + Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHLOG).forceBlockingFlush(); assertEquals(1000, BatchlogManager.instance.countAllBatches() - initialAllBatches); assertEquals(0, BatchlogManager.instance.getTotalBatchesReplayed() - initialReplayedBatches); @@ -171,7 +171,7 @@ public class BatchlogManagerTest } // Flush the batchlog to disk (see CASSANDRA-6822). - Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHLOG_TABLE).forceFlush(); + Keyspace.open(SystemKeyspace.NAME).getColumnFamilyStore(SystemKeyspace.BATCHLOG).forceFlush(); // Force batchlog replay and wait for it to complete. BatchlogManager.instance.startBatchlogReplay().get(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/db/HintedHandOffTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/HintedHandOffTest.java b/test/unit/org/apache/cassandra/db/HintedHandOffTest.java index 8b6834c..ce14c37 100644 --- a/test/unit/org/apache/cassandra/db/HintedHandOffTest.java +++ b/test/unit/org/apache/cassandra/db/HintedHandOffTest.java @@ -66,7 +66,7 @@ public class HintedHandOffTest { // prepare hints column family Keyspace systemKeyspace = Keyspace.open("system"); - ColumnFamilyStore hintStore = systemKeyspace.getColumnFamilyStore(SystemKeyspace.HINTS_TABLE); + ColumnFamilyStore hintStore = systemKeyspace.getColumnFamilyStore(SystemKeyspace.HINTS); hintStore.clearUnsafe(); hintStore.metadata.gcGraceSeconds(36000); // 10 hours hintStore.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName()); @@ -101,7 +101,7 @@ public class HintedHandOffTest HintedHandOffManager.instance.metrics.incrPastWindow(InetAddress.getLocalHost()); HintedHandOffManager.instance.metrics.log(); - UntypedResultSet rows = executeInternal("SELECT hints_dropped FROM system." + SystemKeyspace.PEER_EVENTS_TABLE); + UntypedResultSet rows = executeInternal("SELECT hints_dropped FROM system." + SystemKeyspace.PEER_EVENTS); Map<UUID, Integer> returned = rows.one().getMap("hints_dropped", UUIDType.instance, Int32Type.instance); assertEquals(Iterators.getLast(returned.values().iterator()).intValue(), 99); } @@ -110,7 +110,7 @@ public class HintedHandOffTest public void testTruncateHints() throws Exception { Keyspace systemKeyspace = Keyspace.open("system"); - ColumnFamilyStore hintStore = systemKeyspace.getColumnFamilyStore(SystemKeyspace.HINTS_TABLE); + ColumnFamilyStore hintStore = systemKeyspace.getColumnFamilyStore(SystemKeyspace.HINTS); hintStore.clearUnsafe(); // insert 1 hint @@ -138,7 +138,7 @@ public class HintedHandOffTest private int getNoOfHints() { String req = "SELECT * FROM system.%s"; - UntypedResultSet resultSet = executeInternal(String.format(req, SystemKeyspace.HINTS_TABLE)); + UntypedResultSet resultSet = executeInternal(String.format(req, SystemKeyspace.HINTS)); return resultSet.size(); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/schema/LegacySchemaTablesTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/schema/LegacySchemaTablesTest.java b/test/unit/org/apache/cassandra/schema/LegacySchemaTablesTest.java new file mode 100644 index 0000000..8190617 --- /dev/null +++ b/test/unit/org/apache/cassandra/schema/LegacySchemaTablesTest.java @@ -0,0 +1,568 @@ +/** + * 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.schema; + +import java.io.File; +import java.nio.ByteBuffer; + +import org.apache.cassandra.OrderedJUnit4ClassRunner; +import org.apache.cassandra.SchemaLoader; +import org.apache.cassandra.Util; +import org.apache.cassandra.config.*; +import org.apache.cassandra.db.*; +import org.apache.cassandra.db.composites.*; +import org.apache.cassandra.db.marshal.BytesType; +import org.apache.cassandra.db.marshal.UTF8Type; +import org.apache.cassandra.db.marshal.TimeUUIDType; +import org.apache.cassandra.exceptions.ConfigurationException; +import org.apache.cassandra.io.sstable.Component; +import org.apache.cassandra.io.sstable.Descriptor; +import org.apache.cassandra.io.sstable.SSTableDeletingTask; +import org.apache.cassandra.locator.OldNetworkTopologyStrategy; +import org.apache.cassandra.locator.SimpleStrategy; +import org.apache.cassandra.schema.LegacySchemaTables; +import org.apache.cassandra.service.MigrationManager; +import org.apache.cassandra.utils.ByteBufferUtil; +import org.apache.cassandra.utils.FBUtilities; + +import static org.apache.cassandra.Util.cellname; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(OrderedJUnit4ClassRunner.class) +public class LegacySchemaTablesTest +{ + private static final String KEYSPACE1 = "Keyspace1"; + private static final String KEYSPACE3 = "Keyspace3"; + private static final String KEYSPACE6 = "Keyspace6"; + private static final String EMPTYKEYSPACE = "DefsTestEmptyKeyspace"; + private static final String CF_STANDARD1 = "Standard1"; + private static final String CF_STANDARD2 = "Standard2"; + private static final String CF_INDEXED = "Indexed1"; + + @BeforeClass + public static void defineSchema() throws ConfigurationException + { + SchemaLoader.prepareServer(); + SchemaLoader.startGossiper(); + SchemaLoader.createKeyspace(KEYSPACE1, + SimpleStrategy.class, + KSMetaData.optsWithRF(1), + SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1), + SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2)); + SchemaLoader.createKeyspace(KEYSPACE3, true, false, + SimpleStrategy.class, + KSMetaData.optsWithRF(5), + SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1), + SchemaLoader.indexCFMD(KEYSPACE3, CF_INDEXED, true)); + SchemaLoader.createKeyspace(KEYSPACE6, + SimpleStrategy.class, + KSMetaData.optsWithRF(1), + SchemaLoader.indexCFMD(KEYSPACE6, CF_INDEXED, true)); + } + + @Test + public void testCFMetaDataApply() throws ConfigurationException + { + CFMetaData cfm = new CFMetaData(KEYSPACE1, + "TestApplyCFM_CF", + ColumnFamilyType.Standard, + new SimpleDenseCellNameType(BytesType.instance)); + + for (int i = 0; i < 5; i++) + { + ByteBuffer name = ByteBuffer.wrap(new byte[] { (byte)i }); + cfm.addColumnDefinition(ColumnDefinition.regularDef(cfm, name, BytesType.instance, null).setIndex(Integer.toString(i), IndexType.KEYS, null)); + } + + cfm.comment("No comment") + .readRepairChance(0.5) + .gcGraceSeconds(100000) + .minCompactionThreshold(500) + .maxCompactionThreshold(500); + + // we'll be adding this one later. make sure it's not already there. + Assert.assertNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 5 }))); + + CFMetaData cfNew = cfm.copy(); + + // add one. + ColumnDefinition addIndexDef = ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(new byte[] { 5 }), BytesType.instance, null) + .setIndex("5", IndexType.KEYS, null); + cfNew.addColumnDefinition(addIndexDef); + + // remove one. + ColumnDefinition removeIndexDef = ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(new byte[] { 0 }), BytesType.instance, null) + .setIndex("0", IndexType.KEYS, null); + Assert.assertTrue(cfNew.removeColumnDefinition(removeIndexDef)); + + cfm.apply(cfNew); + + for (int i = 1; i < cfm.allColumns().size(); i++) + Assert.assertNotNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 1 }))); + Assert.assertNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 0 }))); + Assert.assertNotNull(cfm.getColumnDefinition(ByteBuffer.wrap(new byte[] { 5 }))); + } + + @Test + public void testInvalidNames() + { + String[] valid = {"1", "a", "_1", "b_", "__", "1_a"}; + for (String s : valid) + Assert.assertTrue(CFMetaData.isNameValid(s)); + + String[] invalid = {"b@t", "dash-y", "", " ", "dot.s", ".hidden"}; + for (String s : invalid) + Assert.assertFalse(CFMetaData.isNameValid(s)); + } + + @Ignore + @Test + public void saveAndRestore() + { + /* + // verify dump and reload. + UUID first = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress()); + DefsTables.dumpToStorage(first); + List<KSMetaData> defs = new ArrayList<KSMetaData>(DefsTables.loadFromStorage(first)); + + Assert.assertTrue(defs.size() > 0); + Assert.assertEquals(defs.size(), Schema.instance.getNonSystemKeyspaces().size()); + for (KSMetaData loaded : defs) + { + KSMetaData defined = Schema.instance.getKeyspaceDefinition(loaded.name); + Assert.assertTrue(String.format("%s != %s", loaded, defined), defined.equals(loaded)); + } + */ + } + + @Test + public void addNewCfToBogusKeyspace() + { + CFMetaData newCf = addTestCF("MadeUpKeyspace", "NewCF", "new cf"); + try + { + MigrationManager.announceNewColumnFamily(newCf); + throw new AssertionError("You shouldn't be able to do anything to a keyspace that doesn't exist."); + } + catch (ConfigurationException expected) + { + } + } + + @Test + public void addNewCfWithNullComment() throws ConfigurationException + { + final String ks = KEYSPACE1; + final String cf = "BrandNewCfWithNull"; + KSMetaData original = Schema.instance.getKSMetaData(ks); + + CFMetaData newCf = addTestCF(original.name, cf, null); + + Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); + MigrationManager.announceNewColumnFamily(newCf); + + Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); + Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName)); + } + + @Test + public void addNewCF() throws ConfigurationException + { + final String ks = KEYSPACE1; + final String cf = "BrandNewCf"; + KSMetaData original = Schema.instance.getKSMetaData(ks); + + CFMetaData newCf = addTestCF(original.name, cf, "A New Table"); + + Assert.assertFalse(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); + MigrationManager.announceNewColumnFamily(newCf); + + Assert.assertTrue(Schema.instance.getKSMetaData(ks).cfMetaData().containsKey(newCf.cfName)); + Assert.assertEquals(newCf, Schema.instance.getKSMetaData(ks).cfMetaData().get(newCf.cfName)); + + // now read and write to it. + CellName col0 = cellname("col0"); + DecoratedKey dk = Util.dk("key0"); + Mutation rm = new Mutation(ks, dk.getKey()); + rm.add(cf, col0, ByteBufferUtil.bytes("value0"), 1L); + rm.applyUnsafe(); + ColumnFamilyStore store = Keyspace.open(ks).getColumnFamilyStore(cf); + Assert.assertNotNull(store); + store.forceBlockingFlush(); + + ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); + Assert.assertNotNull(cfam.getColumn(col0)); + Cell col = cfam.getColumn(col0); + Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); + } + + @Test + public void dropCf() throws ConfigurationException + { + DecoratedKey dk = Util.dk("dropCf"); + // sanity + final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE1); + Assert.assertNotNull(ks); + final CFMetaData cfm = ks.cfMetaData().get("Standard1"); + Assert.assertNotNull(cfm); + + // write some data, force a flush, then verify that files exist on disk. + Mutation rm = new Mutation(ks.name, dk.getKey()); + for (int i = 0; i < 100; i++) + rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); + rm.applyUnsafe(); + ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName); + Assert.assertNotNull(store); + store.forceBlockingFlush(); + Assert.assertTrue(store.directories.sstableLister().list().size() > 0); + + MigrationManager.announceColumnFamilyDrop(ks.name, cfm.cfName); + + Assert.assertFalse(Schema.instance.getKSMetaData(ks.name).cfMetaData().containsKey(cfm.cfName)); + + // any write should fail. + rm = new Mutation(ks.name, dk.getKey()); + boolean success = true; + try + { + rm.add("Standard1", cellname("col0"), ByteBufferUtil.bytes("value0"), 1L); + rm.applyUnsafe(); + } + catch (Throwable th) + { + success = false; + } + Assert.assertFalse("This mutation should have failed since the CF no longer exists.", success); + + // verify that the files are gone. + for (File file : store.directories.sstableLister().listFiles()) + { + if (file.getPath().endsWith("Data.db") && !new File(file.getPath().replace("Data.db", "Compacted")).exists()) + throw new AssertionError("undeleted file " + file); + } + } + + @Test + public void addNewKS() throws ConfigurationException + { + DecoratedKey dk = Util.dk("key0"); + CFMetaData newCf = addTestCF("NewKeyspace1", "AddedStandard1", "A new cf for a new ks"); + + KSMetaData newKs = KSMetaData.testMetadata(newCf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), newCf); + + MigrationManager.announceNewKeyspace(newKs); + + Assert.assertNotNull(Schema.instance.getKSMetaData(newCf.ksName)); + Assert.assertEquals(Schema.instance.getKSMetaData(newCf.ksName), newKs); + + // test reads and writes. + CellName col0 = cellname("col0"); + Mutation rm = new Mutation(newCf.ksName, dk.getKey()); + rm.add(newCf.cfName, col0, ByteBufferUtil.bytes("value0"), 1L); + rm.applyUnsafe(); + ColumnFamilyStore store = Keyspace.open(newCf.ksName).getColumnFamilyStore(newCf.cfName); + Assert.assertNotNull(store); + store.forceBlockingFlush(); + + ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); + Assert.assertNotNull(cfam.getColumn(col0)); + Cell col = cfam.getColumn(col0); + Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); + } + + @Test + public void dropKS() throws ConfigurationException + { + DecoratedKey dk = Util.dk("dropKs"); + // sanity + final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE1); + Assert.assertNotNull(ks); + final CFMetaData cfm = ks.cfMetaData().get("Standard2"); + Assert.assertNotNull(cfm); + + // write some data, force a flush, then verify that files exist on disk. + Mutation rm = new Mutation(ks.name, dk.getKey()); + for (int i = 0; i < 100; i++) + rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); + rm.applyUnsafe(); + ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName); + Assert.assertNotNull(store); + store.forceBlockingFlush(); + Assert.assertTrue(store.directories.sstableLister().list().size() > 0); + + MigrationManager.announceKeyspaceDrop(ks.name); + + Assert.assertNull(Schema.instance.getKSMetaData(ks.name)); + + // write should fail. + rm = new Mutation(ks.name, dk.getKey()); + boolean success = true; + try + { + rm.add("Standard1", cellname("col0"), ByteBufferUtil.bytes("value0"), 1L); + rm.applyUnsafe(); + } + catch (Throwable th) + { + success = false; + } + Assert.assertFalse("This mutation should have failed since the CF no longer exists.", success); + + // reads should fail too. + boolean threw = false; + try + { + Keyspace.open(ks.name); + } + catch (Throwable th) + { + threw = true; + } + Assert.assertTrue(threw); + } + + @Test + public void dropKSUnflushed() throws ConfigurationException + { + DecoratedKey dk = Util.dk("dropKs"); + // sanity + final KSMetaData ks = Schema.instance.getKSMetaData(KEYSPACE3); + Assert.assertNotNull(ks); + final CFMetaData cfm = ks.cfMetaData().get("Standard1"); + Assert.assertNotNull(cfm); + + // write some data + Mutation rm = new Mutation(ks.name, dk.getKey()); + for (int i = 0; i < 100; i++) + rm.add(cfm.cfName, cellname("col" + i), ByteBufferUtil.bytes("anyvalue"), 1L); + rm.applyUnsafe(); + + MigrationManager.announceKeyspaceDrop(ks.name); + + Assert.assertNull(Schema.instance.getKSMetaData(ks.name)); + } + + @Test + public void createEmptyKsAddNewCf() throws ConfigurationException + { + Assert.assertNull(Schema.instance.getKSMetaData(EMPTYKEYSPACE)); + + KSMetaData newKs = KSMetaData.testMetadata(EMPTYKEYSPACE, SimpleStrategy.class, KSMetaData.optsWithRF(5)); + + MigrationManager.announceNewKeyspace(newKs); + Assert.assertNotNull(Schema.instance.getKSMetaData(EMPTYKEYSPACE)); + + CFMetaData newCf = addTestCF(EMPTYKEYSPACE, "AddedLater", "A new CF to add to an empty KS"); + + //should not exist until apply + Assert.assertFalse(Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName)); + + //add the new CF to the empty space + MigrationManager.announceNewColumnFamily(newCf); + + Assert.assertTrue(Schema.instance.getKSMetaData(newKs.name).cfMetaData().containsKey(newCf.cfName)); + Assert.assertEquals(Schema.instance.getKSMetaData(newKs.name).cfMetaData().get(newCf.cfName), newCf); + + // now read and write to it. + CellName col0 = cellname("col0"); + DecoratedKey dk = Util.dk("key0"); + Mutation rm = new Mutation(newKs.name, dk.getKey()); + rm.add(newCf.cfName, col0, ByteBufferUtil.bytes("value0"), 1L); + rm.applyUnsafe(); + ColumnFamilyStore store = Keyspace.open(newKs.name).getColumnFamilyStore(newCf.cfName); + Assert.assertNotNull(store); + store.forceBlockingFlush(); + + ColumnFamily cfam = store.getColumnFamily(Util.namesQueryFilter(store, dk, col0)); + Assert.assertNotNull(cfam.getColumn(col0)); + Cell col = cfam.getColumn(col0); + Assert.assertEquals(ByteBufferUtil.bytes("value0"), col.value()); + } + + @Test + public void testUpdateKeyspace() throws ConfigurationException + { + // create a keyspace to serve as existing. + CFMetaData cf = addTestCF("UpdatedKeyspace", "AddedStandard1", "A new cf for a new ks"); + KSMetaData oldKs = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), cf); + + MigrationManager.announceNewKeyspace(oldKs); + + Assert.assertNotNull(Schema.instance.getKSMetaData(cf.ksName)); + Assert.assertEquals(Schema.instance.getKSMetaData(cf.ksName), oldKs); + + // names should match. + KSMetaData newBadKs2 = KSMetaData.testMetadata(cf.ksName + "trash", SimpleStrategy.class, KSMetaData.optsWithRF(4)); + try + { + MigrationManager.announceKeyspaceUpdate(newBadKs2); + throw new AssertionError("Should not have been able to update a KS with an invalid KS name."); + } + catch (ConfigurationException ex) + { + // expected. + } + + KSMetaData newKs = KSMetaData.testMetadata(cf.ksName, OldNetworkTopologyStrategy.class, KSMetaData.optsWithRF(1)); + MigrationManager.announceKeyspaceUpdate(newKs); + + KSMetaData newFetchedKs = Schema.instance.getKSMetaData(newKs.name); + Assert.assertEquals(newFetchedKs.strategyClass, newKs.strategyClass); + Assert.assertFalse(newFetchedKs.strategyClass.equals(oldKs.strategyClass)); + } + + @Test + public void testUpdateColumnFamilyNoIndexes() throws ConfigurationException + { + // create a keyspace with a cf to update. + CFMetaData cf = addTestCF("UpdatedCfKs", "Standard1added", "A new cf that will be updated"); + KSMetaData ksm = KSMetaData.testMetadata(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(1), cf); + MigrationManager.announceNewKeyspace(ksm); + + Assert.assertNotNull(Schema.instance.getKSMetaData(cf.ksName)); + Assert.assertEquals(Schema.instance.getKSMetaData(cf.ksName), ksm); + Assert.assertNotNull(Schema.instance.getCFMetaData(cf.ksName, cf.cfName)); + + // updating certain fields should fail. + CFMetaData newCfm = cf.copy(); + newCfm.defaultValidator(BytesType.instance); + newCfm.minCompactionThreshold(5); + newCfm.maxCompactionThreshold(31); + + // test valid operations. + newCfm.comment("Modified comment"); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); // doesn't get set back here. + + newCfm.readRepairChance(0.23); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); + + newCfm.gcGraceSeconds(12); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); + + newCfm.defaultValidator(UTF8Type.instance); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); + + newCfm.minCompactionThreshold(3); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); + + newCfm.maxCompactionThreshold(33); + MigrationManager.announceColumnFamilyUpdate(newCfm, false); + + // can't test changing the reconciler because there is only one impl. + + // check the cumulative affect. + Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getComment(), newCfm.getComment()); + Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getReadRepairChance(), newCfm.getReadRepairChance(), 0.0001); + Assert.assertEquals(Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getGcGraceSeconds(), newCfm.getGcGraceSeconds()); + Assert.assertEquals(UTF8Type.instance, Schema.instance.getCFMetaData(cf.ksName, cf.cfName).getDefaultValidator()); + + // Change cfId + newCfm = new CFMetaData(cf.ksName, cf.cfName, cf.cfType, cf.comparator); + CFMetaData.copyOpts(newCfm, cf); + try + { + cf.apply(newCfm); + throw new AssertionError("Should have blown up when you used a different id."); + } + catch (ConfigurationException expected) {} + + // Change cfName + newCfm = new CFMetaData(cf.ksName, cf.cfName + "_renamed", cf.cfType, cf.comparator); + CFMetaData.copyOpts(newCfm, cf); + try + { + cf.apply(newCfm); + throw new AssertionError("Should have blown up when you used a different name."); + } + catch (ConfigurationException expected) {} + + // Change ksName + newCfm = new CFMetaData(cf.ksName + "_renamed", cf.cfName, cf.cfType, cf.comparator); + CFMetaData.copyOpts(newCfm, cf); + try + { + cf.apply(newCfm); + throw new AssertionError("Should have blown up when you used a different keyspace."); + } + catch (ConfigurationException expected) {} + + // Change cf type + newCfm = new CFMetaData(cf.ksName, cf.cfName, ColumnFamilyType.Super, cf.comparator); + CFMetaData.copyOpts(newCfm, cf); + try + { + cf.apply(newCfm); + throw new AssertionError("Should have blwon up when you used a different cf type."); + } + catch (ConfigurationException expected) {} + + // Change comparator + newCfm = new CFMetaData(cf.ksName, cf.cfName, cf.cfType, new SimpleDenseCellNameType(TimeUUIDType.instance)); + CFMetaData.copyOpts(newCfm, cf); + try + { + cf.apply(newCfm); + throw new AssertionError("Should have blown up when you used a different comparator."); + } + catch (ConfigurationException expected) {} + } + + @Test + public void testDropIndex() throws ConfigurationException + { + // persist keyspace definition in the system keyspace + LegacySchemaTables.makeCreateKeyspaceMutation(Schema.instance.getKSMetaData(KEYSPACE6), FBUtilities.timestampMicros()).applyUnsafe(); + ColumnFamilyStore cfs = Keyspace.open(KEYSPACE6).getColumnFamilyStore("Indexed1"); + + // insert some data. save the sstable descriptor so we can make sure it's marked for delete after the drop + Mutation rm = new Mutation(KEYSPACE6, ByteBufferUtil.bytes("k1")); + rm.add("Indexed1", cellname("notbirthdate"), ByteBufferUtil.bytes(1L), 0); + rm.add("Indexed1", cellname("birthdate"), ByteBufferUtil.bytes(1L), 0); + rm.applyUnsafe(); + cfs.forceBlockingFlush(); + ColumnFamilyStore indexedCfs = cfs.indexManager.getIndexForColumn(ByteBufferUtil.bytes("birthdate")).getIndexCfs(); + Descriptor desc = indexedCfs.getSSTables().iterator().next().descriptor; + + // drop the index + CFMetaData meta = cfs.metadata.copy(); + ColumnDefinition cdOld = meta.regularColumns().iterator().next(); + ColumnDefinition cdNew = ColumnDefinition.regularDef(meta, cdOld.name.bytes, cdOld.type, null); + meta.addOrReplaceColumnDefinition(cdNew); + MigrationManager.announceColumnFamilyUpdate(meta, false); + + // check + Assert.assertTrue(cfs.indexManager.getIndexes().isEmpty()); + SSTableDeletingTask.waitForDeletions(); + Assert.assertFalse(new File(desc.filenameFor(Component.DATA)).exists()); + } + + private CFMetaData addTestCF(String ks, String cf, String comment) + { + CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, new SimpleDenseCellNameType(UTF8Type.instance)); + newCFMD.comment(comment) + .readRepairChance(0.0); + + return newCFMD; + } +} http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java b/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java index 1437886..ed0efee 100644 --- a/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java +++ b/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java @@ -59,11 +59,11 @@ public class EmbeddedCassandraServiceTest public static void defineSchema() throws Exception { SchemaLoader.prepareServer(); + setup(); SchemaLoader.createKeyspace(KEYSPACE1, SimpleStrategy.class, KSMetaData.optsWithRF(1), SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD)); - setup(); } /** http://git-wip-us.apache.org/repos/asf/cassandra/blob/3e9d345f/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java b/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java index f98751a..d1a4d85 100644 --- a/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java +++ b/test/unit/org/apache/cassandra/service/StorageServiceServerTest.java @@ -37,6 +37,7 @@ import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.Keyspace; +import org.apache.cassandra.schema.LegacySchemaTables; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.dht.Range; import org.apache.cassandra.dht.Token; @@ -98,7 +99,7 @@ public class StorageServiceServerTest public void testColumnFamilySnapshot() throws IOException { // no need to insert extra data, even an "empty" database will have a little information in the system keyspace - StorageService.instance.takeColumnFamilySnapshot(SystemKeyspace.NAME, SystemKeyspace.SCHEMA_KEYSPACES_TABLE, "cf_snapshot"); + StorageService.instance.takeColumnFamilySnapshot(SystemKeyspace.NAME, LegacySchemaTables.KEYSPACES, "cf_snapshot"); } @Test
