Directories (apache-cassandra API)
Date: 2014-10-21

org.apache.cassandra.db

## Class Directories

- java.lang.Object
- - org.apache.cassandra.db.Directories

-     public class Directories
      extends java.lang.Object

  Encapsulate handling of paths to the data files. Since v2.1, the directory layout is the following: //ks/cf1-cfId/ks-cf1-ka-1-Data.db /cf2-cfId/ks-cf2-ka-1-Data.db ... cfId is an hex encoded CFID. For backward compatibility, Directories uses older directory layout if exists. In addition, more that one 'root' data directory can be specified so that potentially represents multiple locations. Note that in the case of multiple locations, the manifest for the leveled compaction is only in one of the location. Snapshots (resp. backups) are always created along the sstables thare are snapshoted (resp. backuped) but inside a subdirectory named 'snapshots' (resp. backups) (and snapshots are furter inside a subdirectory of the name of the snapshot). This class abstracts all those details from the rest of the code.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Directories.DataDirectory`
    `static class` | `Directories.FileAction`
    `class` | `Directories.SSTableLister`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `BACKUPS_SUBDIR`
    `static Directories.DataDirectory[]` | `dataDirectories`
    `static java.lang.String` | `SECONDARY_INDEX_NAME_SEPARATOR`
    `static java.lang.String` | `SNAPSHOT_SUBDIR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Directories(CFMetaData metadata)` Create Directories of given ColumnFamily.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearSnapshot(java.lang.String snapshotName, java.util.List<java.io.File> snapshotDirectories)`
    `Descriptor` | `find(java.lang.String filename)`
    `static java.io.File` | `getBackupsDirectory(Descriptor desc)`
    `java.util.List<java.io.File>` | `getCFDirectories()`
    `java.io.File` | `getDirectoryForNewSSTables()`
    `static java.util.List<java.io.File>` | `getKSChildDirectories(java.lang.String ksName)`
    `java.io.File` | `getLocationForDisk(Directories.DataDirectory dataDirectory)` Returns SSTable location which is inside given data directory.
    `java.util.Map<java.lang.String,Pair<java.lang.Long,java.lang.Long>>` | `getSnapshotDetails()`
    `static java.io.File` | `getSnapshotDirectory(Descriptor desc, java.lang.String snapshotName)`
    `java.io.File` | `getSnapshotManifestFile(java.lang.String snapshotName)`
    `long` | `getTrueAllocatedSizeIn(java.io.File input)`
    `Directories.DataDirectory` | `getWriteableLocation()`
    `java.io.File` | `getWriteableLocationAsFile()`
    `long` | `snapshotCreationTime(java.lang.String snapshotName)`
    `boolean` | `snapshotExists(java.lang.String snapshotName)`
    `Directories.SSTableLister` | `sstableLister()`
    `long` | `trueSnapshotsSize()`
    `static boolean` | `verifyFullPermissions(java.io.File dir, java.lang.String dataDir)` Checks whether Cassandra has RWX permissions to the specified directory.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BACKUPS_SUBDIR

          public static final java.lang.String BACKUPS_SUBDIR

      See Also:
        Constant Field Values

    - #### SNAPSHOT_SUBDIR

          public static final java.lang.String SNAPSHOT_SUBDIR

      See Also:
        Constant Field Values

    - #### SECONDARY_INDEX_NAME_SEPARATOR

          public static final java.lang.String SECONDARY_INDEX_NAME_SEPARATOR

      See Also:
        Constant Field Values

    - #### dataDirectories

          public static final Directories.DataDirectory[] dataDirectories

  - ### Constructor Detail

    - #### Directories

          public Directories(CFMetaData metadata)

      Create Directories of given ColumnFamily. SSTable directories are created under data_directories defined in cassandra.yaml if not exist at this time.
      Parameters:
        `metadata` - metadata of ColumnFamily

  - ### Method Detail

    - #### verifyFullPermissions

          public static boolean verifyFullPermissions(java.io.File dir,
                                      java.lang.String dataDir)

      Checks whether Cassandra has RWX permissions to the specified directory. Logs an error with the details if it does not.
      Parameters:
        `dir` - File object of the directory.
        `dataDir` - String representation of the directory's location
      Returns:
        status representing Cassandra's RWX permissions to the supplied folder location.

    - #### getLocationForDisk

          public java.io.File getLocationForDisk(Directories.DataDirectory dataDirectory)

      Returns SSTable location which is inside given data directory.
      Parameters:
        `dataDirectory` -
      Returns:
        SSTable location

    - #### find

          public Descriptor find(java.lang.String filename)

    - #### getDirectoryForNewSSTables

          public java.io.File getDirectoryForNewSSTables()

    - #### getWriteableLocationAsFile

          public java.io.File getWriteableLocationAsFile()

    - #### getWriteableLocation

          public Directories.DataDirectory getWriteableLocation()

      Returns:
        a non-blacklisted directory with the most free space and least current tasks.
      Throws:
        `java.io.IOError` - if all directories are blacklisted.

    - #### getSnapshotDirectory

          public static java.io.File getSnapshotDirectory(Descriptor desc,
                                          java.lang.String snapshotName)

    - #### getSnapshotManifestFile

          public java.io.File getSnapshotManifestFile(java.lang.String snapshotName)

    - #### getBackupsDirectory

          public static java.io.File getBackupsDirectory(Descriptor desc)

    - #### sstableLister

          public Directories.SSTableLister sstableLister()

    - #### getSnapshotDetails

          public java.util.Map<java.lang.String,Pair<java.lang.Long,java.lang.Long>> getSnapshotDetails()

      Returns:
        Return a map of all snapshots to space being used The pair for a snapshot has size on disk and true size.

    - #### snapshotExists

          public boolean snapshotExists(java.lang.String snapshotName)

    - #### clearSnapshot

          public static void clearSnapshot(java.lang.String snapshotName,
                           java.util.List<java.io.File> snapshotDirectories)

    - #### snapshotCreationTime

          public long snapshotCreationTime(java.lang.String snapshotName)

    - #### trueSnapshotsSize

          public long trueSnapshotsSize()

    - #### getTrueAllocatedSizeIn

          public long getTrueAllocatedSizeIn(java.io.File input)

    - #### getKSChildDirectories

          public static java.util.List<java.io.File> getKSChildDirectories(java.lang.String ksName)

    - #### getCFDirectories

          public java.util.List<java.io.File> getCFDirectories()

Copyright © 2014 The Apache Software Foundation