Search in sources :

Example 6 with SnapshotManifest

use of org.apache.cassandra.service.snapshot.SnapshotManifest in project cassandra by apache.

the class DirectoriesTest method testMaybeManifestLoading.

@Test
public void testMaybeManifestLoading() throws Exception {
    for (TableMetadata cfm : CFM) {
        String tag = "test";
        Directories directories = new Directories(cfm, toDataDirectories(tempDataDir));
        Descriptor parentDesc = new Descriptor(directories.getDirectoryForNewSSTables(), KS, cfm.name, 0, SSTableFormat.Type.BIG);
        File parentSnapshotDirectory = Directories.getSnapshotDirectory(parentDesc, tag);
        List<String> files = new LinkedList<>();
        files.add(parentSnapshotDirectory.toAbsolute().absolutePath());
        File manifestFile = directories.getSnapshotManifestFile(tag);
        SnapshotManifest manifest = new SnapshotManifest(files, new DurationSpec("1m"), Instant.now());
        manifest.serializeToJsonFile(manifestFile);
        Set<File> dirs = new HashSet<>();
        dirs.add(manifestFile.parent());
        dirs.add(new File("buzz"));
        SnapshotManifest loadedManifest = Directories.maybeLoadManifest(KS, cfm.name, tag, dirs);
        assertEquals(manifest, loadedManifest);
    }
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) DataDirectories(org.apache.cassandra.db.Directories.DataDirectories) SnapshotManifest(org.apache.cassandra.service.snapshot.SnapshotManifest) DurationSpec(org.apache.cassandra.config.DurationSpec) Descriptor(org.apache.cassandra.io.sstable.Descriptor) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) File(org.apache.cassandra.io.util.File) Test(org.junit.Test)

Aggregations

File (org.apache.cassandra.io.util.File)6 SnapshotManifest (org.apache.cassandra.service.snapshot.SnapshotManifest)6 Descriptor (org.apache.cassandra.io.sstable.Descriptor)4 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)3 DurationSpec (org.apache.cassandra.config.DurationSpec)2 TableSnapshot (org.apache.cassandra.service.snapshot.TableSnapshot)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 com.google.common.base (com.google.common.base)1 Throwables (com.google.common.base.Throwables)1 Throwables.propagate (com.google.common.base.Throwables.propagate)1 com.google.common.collect (com.google.common.collect)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 com.google.common.util.concurrent (com.google.common.util.concurrent)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ByteBuffer (java.nio.ByteBuffer)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1