You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2013/09/13 09:35:08 UTC
git commit: Remove old json leveled manifest migration code.
Updated Branches:
refs/heads/trunk cabf0fa32 -> e546e3387
Remove old json leveled manifest migration code.
Patch by marcuse, reviewed by jbellis for CASSANDRA-5996
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e546e338
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e546e338
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e546e338
Branch: refs/heads/trunk
Commit: e546e33872426be0db084b2eee1f9ffac0994772
Parents: cabf0fa
Author: Marcus Eriksson <ma...@spotify.com>
Authored: Fri Sep 13 09:27:44 2013 +0200
Committer: Marcus Eriksson <ma...@spotify.com>
Committed: Fri Sep 13 09:33:19 2013 +0200
----------------------------------------------------------------------
CHANGES.txt | 2 +-
NEWS.txt | 10 ++
.../apache/cassandra/db/ColumnFamilyStore.java | 3 -
.../org/apache/cassandra/db/Directories.java | 28 ----
.../db/compaction/LegacyLeveledManifest.java | 141 -------------------
.../db/compaction/LeveledManifest.java | 2 -
.../cassandra/service/CassandraDaemon.java | 16 ---
.../cassandra/tools/StandaloneScrubber.java | 7 -
.../apache/cassandra/db/DirectoriesTest.java | 13 --
.../compaction/LegacyLeveledManifestTest.java | 117 ---------------
.../LegacyLeveledManifestTestHelper.java | 78 ----------
11 files changed, 11 insertions(+), 406 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 27cc64d..71cfc28 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,7 +3,7 @@
* switch to LZ4 compression for internode communication (CASSANDRA-5887)
* Stop using Thrift-generated Index* classes internally (CASSANDRA-5971)
* Remove 1.2 network compatibility code (CASSANDRA-5960)
-
+ * Remove leveled json manifest migration code (CASSANDRA-5996)
2.0.1
* Improve error message when yaml contains invalid properties (CASSANDRA-5958)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 4e11bf2..580e149 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -13,6 +13,16 @@ restore snapshots created with the previous major version using the
'sstableloader' tool. You can upgrade the file format of your snapshots
using the provided 'sstableupgrade' tool.
+2.1
+===
+Upgrading
+---------
+ - Rolling upgrades from anything pre-2.0 is not supported.
+ - 2.0 must be atleast started before upgrading to 2.1 due to
+ the fact that the old JSON leveled manifest is migrated into
+ the sstable metadata files on startup in 2.0 and this code is
+ gone from 2.1.
+
2.0.0
=====
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index a77f449..cd68e96 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1734,9 +1734,6 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
if (logger.isDebugEnabled())
logger.debug("Snapshot for {} keyspace data file {} created in {}", keyspace, ssTable.getFilename(), snapshotDirectory);
}
-
- if (cfs.compactionStrategy instanceof LeveledCompactionStrategy)
- cfs.directories.snapshotLeveledManifest(snapshotName);
}
finally
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/src/java/org/apache/cassandra/db/Directories.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java
index 5dda2ec..a199fa8 100644
--- a/src/java/org/apache/cassandra/db/Directories.java
+++ b/src/java/org/apache/cassandra/db/Directories.java
@@ -393,34 +393,6 @@ public class Directories
}
}
- @Deprecated
- public File tryGetLeveledManifest()
- {
- for (File dir : sstableDirectories)
- {
- File manifestFile = new File(dir, cfname + LeveledManifest.EXTENSION);
- if (manifestFile.exists())
- {
- logger.debug("Found manifest at {}", manifestFile);
- return manifestFile;
- }
- }
- logger.debug("No level manifest found");
- return null;
- }
-
- @Deprecated
- public void snapshotLeveledManifest(String snapshotName)
- {
- File manifest = tryGetLeveledManifest();
- if (manifest != null)
- {
- File snapshotDirectory = getOrCreate(manifest.getParentFile(), SNAPSHOT_SUBDIR, snapshotName);
- File target = new File(snapshotDirectory, manifest.getName());
- FileUtils.createHardLink(manifest, target);
- }
- }
-
public boolean snapshotExists(String snapshotName)
{
for (File dir : sstableDirectories)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/src/java/org/apache/cassandra/db/compaction/LegacyLeveledManifest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LegacyLeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LegacyLeveledManifest.java
deleted file mode 100644
index 645c2be..0000000
--- a/src/java/org/apache/cassandra/db/compaction/LegacyLeveledManifest.java
+++ /dev/null
@@ -1,141 +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.db.compaction;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.cassandra.db.Directories;
-import org.apache.cassandra.io.sstable.Component;
-import org.apache.cassandra.io.sstable.Descriptor;
-import org.apache.cassandra.io.sstable.SSTableMetadata;
-import org.apache.cassandra.io.util.FileUtils;
-import org.apache.cassandra.utils.Pair;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
-
-/**
- * This class was added to be able to migrate pre-CASSANDRA-4782 leveled manifests into the sstable metadata
- *
- * @deprecated since it can be removed in a future revision.
- */
-@Deprecated
-public class LegacyLeveledManifest
-{
- private static final Logger logger = LoggerFactory.getLogger(LegacyLeveledManifest.class);
-
- private Map<Integer, Integer> sstableLevels;
-
- private LegacyLeveledManifest(File path) throws IOException
- {
- sstableLevels = new HashMap<Integer, Integer>();
- ObjectMapper m = new ObjectMapper();
- JsonNode rootNode = m.readValue(path, JsonNode.class);
- JsonNode generations = rootNode.get("generations");
- assert generations.isArray();
- for (JsonNode generation : generations)
- {
- int level = generation.get("generation").getIntValue();
- JsonNode generationValues = generation.get("members");
- for (JsonNode generationValue : generationValues)
- {
- sstableLevels.put(generationValue.getIntValue(), level);
- }
- }
- }
-
- private int levelOf(int sstableGeneration)
- {
- return sstableLevels.containsKey(sstableGeneration) ? sstableLevels.get(sstableGeneration) : 0;
- }
-
- /**
- * We need to migrate if there is a legacy leveledmanifest json-file
- * <p/>
- * If there is no jsonfile, we can just start as normally, sstable level will be at 0 for all sstables.
- *
- * @param keyspace
- * @param columnFamily
- * @return
- */
- public static boolean manifestNeedsMigration(String keyspace, String columnFamily)
- {
- return Directories.create(keyspace, columnFamily).tryGetLeveledManifest() != null;
- }
-
- public static void migrateManifests(String keyspace, String columnFamily) throws IOException
- {
- logger.info("Migrating manifest for {}/{}", keyspace, columnFamily);
-
- snapshotWithoutCFS(keyspace, columnFamily);
- Directories directories = Directories.create(keyspace, columnFamily);
- File manifestFile = directories.tryGetLeveledManifest();
- if (manifestFile == null)
- return;
-
- LegacyLeveledManifest legacyManifest = new LegacyLeveledManifest(manifestFile);
- for (Map.Entry<Descriptor, Set<Component>> entry : directories.sstableLister().includeBackups(false).skipTemporary(true).list().entrySet())
- {
- Descriptor d = entry.getKey();
- Pair<SSTableMetadata, Set<Integer>> oldMetadata = SSTableMetadata.serializer.deserialize(d, false);
- String metadataFilename = d.filenameFor(Component.STATS);
- LeveledManifest.mutateLevel(oldMetadata, d, metadataFilename, legacyManifest.levelOf(d.generation));
- }
- FileUtils.deleteWithConfirm(manifestFile);
- }
-
- /**
- * Snapshot a CF without having to load the sstables in that directory
- *
- * @param keyspace
- * @param columnFamily
- * @throws IOException
- */
- public static void snapshotWithoutCFS(String keyspace, String columnFamily) throws IOException
- {
- Directories directories = Directories.create(keyspace, columnFamily);
- String snapshotName = "pre-sstablemetamigration";
- logger.info("Snapshotting {}, {} to {}", keyspace, columnFamily, snapshotName);
-
- for (Map.Entry<Descriptor, Set<Component>> entry : directories.sstableLister().includeBackups(false).skipTemporary(true).list().entrySet())
- {
- Descriptor descriptor = entry.getKey();
- File snapshotDirectoryPath = Directories.getSnapshotDirectory(descriptor, snapshotName);
- for (Component component : entry.getValue())
- {
- File sourceFile = new File(descriptor.filenameFor(component));
- File targetLink = new File(snapshotDirectoryPath, sourceFile.getName());
- FileUtils.createHardLink(sourceFile, targetLink);
- }
- }
-
- File manifestFile = directories.tryGetLeveledManifest();
- if (manifestFile != null)
- {
- File snapshotDirectory = new File(new File(manifestFile.getParentFile(), Directories.SNAPSHOT_SUBDIR), snapshotName);
- File target = new File(snapshotDirectory, manifestFile.getName());
- FileUtils.createHardLink(manifestFile, target);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
index 23e5af3..2d5aa27 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -45,8 +45,6 @@ public class LeveledManifest
{
private static final Logger logger = LoggerFactory.getLogger(LeveledManifest.class);
- public static final String EXTENSION = ".json";
-
/**
* limit the number of L0 sstables we do at once, because compaction bloom filter creation
* uses a pessimistic estimate of how many keys overlap (none), so we risk wasting memory
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index a127dca..f66a898 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -41,7 +41,6 @@ import org.apache.cassandra.config.Schema;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.commitlog.CommitLog;
import org.apache.cassandra.db.compaction.CompactionManager;
-import org.apache.cassandra.db.compaction.LegacyLeveledManifest;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.io.FSError;
import org.apache.cassandra.io.util.FileUtils;
@@ -187,22 +186,7 @@ public class CassandraDaemon
for (String keyspaceName : Schema.instance.getKeyspaces())
{
for (CFMetaData cfm : Schema.instance.getKeyspaceMetaData(keyspaceName).values())
- {
- if (LegacyLeveledManifest.manifestNeedsMigration(keyspaceName,cfm.cfName))
- {
- try
- {
- LegacyLeveledManifest.migrateManifests(keyspaceName, cfm.cfName);
- }
- catch (IOException e)
- {
- logger.error("Could not migrate old leveled manifest. Move away the .json file in the data directory", e);
- System.exit(100);
- }
- }
-
ColumnFamilyStore.scrubDataDirectories(keyspaceName, cfm.cfName);
- }
}
// clean up compaction leftovers
SetMultimap<Pair<String, String>, Integer> unfinishedCompactions = SystemKeyspace.getUnfinishedCompactions();
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/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 5c8ce14..8d1a0a1 100644
--- a/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
+++ b/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
@@ -92,13 +92,6 @@ public class StandaloneScrubber
}
System.out.println(String.format("Pre-scrub sstables snapshotted into snapshot %s", snapshotName));
- // if old-style json manifest, snapshot it
- if (cfs.directories.tryGetLeveledManifest() != null)
- {
- cfs.directories.snapshotLeveledManifest(snapshotName);
- System.out.println(String.format("Leveled manifest snapshotted into snapshot %s", snapshotName));
- }
-
LeveledManifest manifest = null;
// If leveled, load the manifest
if (cfs.getCompactionStrategy() instanceof LeveledCompactionStrategy)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
index 89530e1..75a0b00 100644
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -29,7 +29,6 @@ import org.junit.Test;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.Config.DiskFailurePolicy;
import org.apache.cassandra.db.Directories.DataDirectory;
-import org.apache.cassandra.db.compaction.LeveledManifest;
import org.apache.cassandra.io.sstable.Component;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.util.FileUtils;
@@ -72,8 +71,6 @@ public class DirectoriesTest
createFakeSSTable(dir, cf, 1, false, fs);
createFakeSSTable(dir, cf, 2, true, fs);
- // leveled manifest
- new File(dir, cf + LeveledManifest.EXTENSION).createNewFile();
File backupDir = new File(dir, Directories.BACKUPS_SUBDIR);
backupDir.mkdir();
@@ -164,16 +161,6 @@ public class DirectoriesTest
}
}
- @Test
- public void testLeveledManifestPath()
- {
- for (String cf : CFS)
- {
- Directories directories = Directories.create(KS, cf);
- File manifest = new File(cfDir(cf), cf + LeveledManifest.EXTENSION);
- Assert.assertEquals(manifest, directories.tryGetLeveledManifest());
- }
- }
@Test
public void testDiskFailurePolicy_best_effort() throws IOException
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTest.java b/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTest.java
deleted file mode 100644
index d8e8af0..0000000
--- a/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.apache.cassandra.db.compaction;
-/*
- *
- * 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.
- *
- */
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.cassandra.db.Directories;
-import org.apache.cassandra.io.sstable.Descriptor;
-import org.apache.cassandra.io.sstable.SSTableMetadata;
-import org.apache.cassandra.io.util.FileUtils;
-import org.apache.cassandra.utils.Pair;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.apache.cassandra.db.compaction.LegacyLeveledManifestTestHelper.*;
-
-public class LegacyLeveledManifestTest
-{
- private final static String LEGACY_VERSION = "ic";
-
- private File destDir;
- @Before
- public void setup()
- {
- destDir = Directories.create(KS, CF).getDirectoryForNewSSTables(0);
- FileUtils.createDirectory(destDir);
- for (File srcFile : getLegacySSTableDir(LEGACY_VERSION).listFiles())
- {
- File destFile = new File(destDir, srcFile.getName());
- FileUtils.createHardLink(srcFile,destFile);
- assert destFile.exists() : destFile.getAbsoluteFile();
- }
- }
- @After
- public void tearDown()
- {
- FileUtils.deleteRecursive(destDir);
- }
-
- @Test
- public void migrateTest() throws IOException
- {
- assertTrue(LegacyLeveledManifest.manifestNeedsMigration(KS, CF));
- }
-
- @Test
- public void doMigrationTest() throws IOException, InterruptedException
- {
- LegacyLeveledManifest.migrateManifests(KS, CF);
-
- for (int i = 0; i <= 2; i++)
- {
- Descriptor descriptor = Descriptor.fromFilename(destDir+File.separator+KS+"-"+CF+"-"+LEGACY_VERSION+"-"+i+"-Statistics.db");
- SSTableMetadata metadata = SSTableMetadata.serializer.deserialize(descriptor).left;
- assertEquals(metadata.sstableLevel, i);
- }
- }
-
- /**
- * Validate that the rewritten stats file is the same as the original one.
- * @throws IOException
- */
- @Test
- public void validateSSTableMetadataTest() throws IOException
- {
- Map<Descriptor, Pair<SSTableMetadata, Set<Integer>>> beforeMigration = new HashMap<>();
- for (int i = 0; i <= 2; i++)
- {
- Descriptor descriptor = Descriptor.fromFilename(destDir+File.separator+KS+"-"+CF+"-"+LEGACY_VERSION+"-"+i+"-Statistics.db");
- beforeMigration.put(descriptor, SSTableMetadata.serializer.deserialize(descriptor, false));
- }
-
- LegacyLeveledManifest.migrateManifests(KS, CF);
-
- for (Map.Entry<Descriptor, Pair<SSTableMetadata, Set<Integer>>> entry : beforeMigration.entrySet())
- {
- Pair<SSTableMetadata, Set<Integer>> newMetaPair = SSTableMetadata.serializer.deserialize(entry.getKey());
- SSTableMetadata newMetadata = newMetaPair.left;
- SSTableMetadata oldMetadata = entry.getValue().left;
- assertEquals(newMetadata.estimatedRowSize, oldMetadata.estimatedRowSize);
- assertEquals(newMetadata.estimatedColumnCount, oldMetadata.estimatedColumnCount);
- assertEquals(newMetadata.replayPosition, oldMetadata.replayPosition);
- assertEquals(newMetadata.minTimestamp, oldMetadata.minTimestamp);
- assertEquals(newMetadata.maxTimestamp, oldMetadata.maxTimestamp);
- assertEquals(newMetadata.compressionRatio, oldMetadata.compressionRatio, 0.01);
- assertEquals(newMetadata.partitioner, oldMetadata.partitioner);
- assertEquals(newMetadata.estimatedTombstoneDropTime, oldMetadata.estimatedTombstoneDropTime);
- assertEquals(entry.getValue().right, newMetaPair.right);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e546e338/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java b/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
deleted file mode 100644
index 4ee92fe..0000000
--- a/test/unit/org/apache/cassandra/db/compaction/LegacyLeveledManifestTestHelper.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.apache.cassandra.db.compaction;
-/*
- *
- * 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.
- *
- */
-
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.apache.cassandra.SchemaLoader;
-import org.apache.cassandra.io.sstable.Descriptor;
-import org.apache.cassandra.io.sstable.SSTableReader;
-import org.apache.cassandra.io.sstable.SSTableUtils;
-import org.apache.cassandra.io.util.FileUtils;
-
-@Ignore
-public class LegacyLeveledManifestTestHelper extends SchemaLoader
-{
- public final static String PROP = "migration-sstable-root";
- public final static String KS = "Keyspace1";
- public final static String CF = "legacyleveled";
- /**
- * Generates two sstables to be used to test migrating from a .json manifest to keeping the level in the sstable
- * metadata.
- *
- * Do this:
- * 1. remove @Ignore
- * 2. comment out the @Before and @After methods above
- * 3. run this method
- * 4. checkout trunk
- * 5. copy the .json file from the previous version to the current one
- * (ie; test/data/migration-sstables/ic/Keyspace1/legacyleveled/legacyleveled.json)
- * 6. update LegacyLeveledManifestTest to use the new version.
- */
- @Test
- public void generateSSTable() throws IOException
- {
- File legacySSTableDir = getLegacySSTableDir(Descriptor.Version.current_version);
- FileUtils.createDirectory(legacySSTableDir);
- Set<String> keys = new HashSet<String>();
- for(int i = 0; i < 10; i++)
- {
- keys.add("key"+i);
- }
- for(int i = 0; i < 3; i++)
- {
- SSTableReader ssTable = SSTableUtils.prepare().ks(KS).cf(CF).dest(new Descriptor(legacySSTableDir, KS, CF, i, false)).write(keys);
- System.out.println(ssTable);
- }
- }
- public static File getLegacySSTableDir(String version)
- {
- return new File(System.getProperty(PROP) + File.separator + version + File.separator + KS + File.separator + CF);
- }
-
-}