public class Directories
extends java.lang.Object
/<path_to_data_dir>/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
<path_to_data_dir>
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.Modifier and Type | Class and Description |
---|---|
static class |
Directories.DataDirectory |
static class |
Directories.FileAction |
class |
Directories.SSTableLister |
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 and Description |
---|
Directories(CFMetaData metadata)
Create Directories of given ColumnFamily.
|
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) |
static java.io.File |
getBackupsDirectory(java.io.File location) |
java.util.List<java.io.File> |
getCFDirectories() |
java.io.File |
getDirectoryForNewSSTables()
Basically the same as calling
getWriteableLocationAsFile(long) with an unknown size (-1L ),
which may return any non-blacklisted directory - even a data directory that has no usable space. |
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) |
static java.io.File |
getSnapshotDirectory(java.io.File location,
java.lang.String snapshotName) |
java.io.File |
getSnapshotManifestFile(java.lang.String snapshotName) |
long |
getTrueAllocatedSizeIn(java.io.File input) |
Directories.DataDirectory |
getWriteableLocation(long writeSize)
Returns a non-blacklisted data directory that _currently_ has
writeSize bytes as usable space. |
java.io.File |
getWriteableLocationAsFile(long writeSize)
Returns a non-blacklisted data directory that _currently_ has
writeSize bytes as usable space. |
boolean |
hasAvailableDiskSpace(long estimatedSSTables,
long expectedTotalWriteSize) |
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.
|
public static final java.lang.String BACKUPS_SUBDIR
public static final java.lang.String SNAPSHOT_SUBDIR
public static final java.lang.String SECONDARY_INDEX_NAME_SEPARATOR
public static final Directories.DataDirectory[] dataDirectories
public Directories(CFMetaData metadata)
metadata
- metadata of ColumnFamilypublic static boolean verifyFullPermissions(java.io.File dir, java.lang.String dataDir)
dir
- File object of the directory.dataDir
- String representation of the directory's locationpublic java.io.File getLocationForDisk(Directories.DataDirectory dataDirectory)
dataDirectory
- public Descriptor find(java.lang.String filename)
public java.io.File getDirectoryForNewSSTables()
getWriteableLocationAsFile(long)
with an unknown size (-1L
),
which may return any non-blacklisted directory - even a data directory that has no usable space.
Do not use this method in production code.java.io.IOError
- if all directories are blacklisted.public java.io.File getWriteableLocationAsFile(long writeSize)
writeSize
bytes as usable space.java.io.IOError
- if all directories are blacklisted.public Directories.DataDirectory getWriteableLocation(long writeSize)
writeSize
bytes as usable space.java.io.IOError
- if all directories are blacklisted.public boolean hasAvailableDiskSpace(long estimatedSSTables, long expectedTotalWriteSize)
public static java.io.File getSnapshotDirectory(Descriptor desc, java.lang.String snapshotName)
public static java.io.File getSnapshotDirectory(java.io.File location, java.lang.String snapshotName)
public java.io.File getSnapshotManifestFile(java.lang.String snapshotName)
public static java.io.File getBackupsDirectory(Descriptor desc)
public static java.io.File getBackupsDirectory(java.io.File location)
public Directories.SSTableLister sstableLister()
public java.util.Map<java.lang.String,Pair<java.lang.Long,java.lang.Long>> getSnapshotDetails()
public boolean snapshotExists(java.lang.String snapshotName)
public static void clearSnapshot(java.lang.String snapshotName, java.util.List<java.io.File> snapshotDirectories)
public long snapshotCreationTime(java.lang.String snapshotName)
public long trueSnapshotsSize()
public long getTrueAllocatedSizeIn(java.io.File input)
public static java.util.List<java.io.File> getKSChildDirectories(java.lang.String ksName)
public java.util.List<java.io.File> getCFDirectories()
Copyright © 2015 The Apache Software Foundation