public class Directories
extends java.lang.Object
/<path_to_data_dir>/ks/<cf dir>/ks-cf1-jb-1-Data.db
/<cf dir>/la-2-Data.db
/<cf dir>/.<index name>/ks-cf1.idx-jb-1-Data.db
/<cf dir>/.<index name>/la-1-Data.db
...
Until v2.0, <cf dir>
is just column family name.
Since v2.1, <cf dir>
has column family ID(tableId) added to its end.
SSTables from secondary indexes were put in the same directory as their parent.
Since v2.2, they have their own directory under the parent directory whose name is index name.
Upon startup, those secondary index files are moved to new directory when upgrading.
For backward compatibility, Directories can use directory without tableId 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 there are
snapshotted (resp. backuped) but inside a subdirectory named 'snapshots'
(resp. backups) (and snapshots are further inside a subdirectory of the name
of the snapshot). For secondary indexes, snapshots (backups) are not created in
their own directory, but are in their parent's snapshot (backup) directory.
This class abstracts all those details from the rest of the code.Modifier and Type | Class and Description |
---|---|
static class |
Directories.DataDirectories
Data directories used to store keyspace data.
|
static class |
Directories.DataDirectory |
static class |
Directories.FileAction |
static class |
Directories.FileType
The type of files that can be listed by SSTableLister, we never return txn logs,
use LifecycleTransaction.getFiles() if you need txn logs.
|
static class |
Directories.OnTxnErr
How to handle a failure to read a txn log file.
|
static class |
Directories.SnapshotSizeDetails |
static class |
Directories.SSTableLister |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BACKUPS_SUBDIR |
static Directories.DataDirectories |
dataDirectories
The directories used to store keyspaces data.
|
static java.lang.String |
SECONDARY_INDEX_NAME_SEPARATOR |
static java.lang.String |
SNAPSHOT_SUBDIR |
static java.lang.String |
TMP_SUBDIR |
Constructor and Description |
---|
Directories(TableMetadata metadata) |
Directories(TableMetadata metadata,
java.util.Collection<Directories.DataDirectory> paths) |
Directories(TableMetadata metadata,
Directories.DataDirectory[] paths)
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,
com.google.common.util.concurrent.RateLimiter snapshotRateLimiter) |
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() |
Directories.DataDirectory |
getDataDirectoryForFile(Descriptor descriptor) |
java.io.File |
getDirectoryForNewSSTables()
Basically the same as calling
getWriteableLocationAsFile(long) with an unknown size (-1L ),
which may return any allowed 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.io.File |
getNewEphemeralSnapshotMarkerFile(java.lang.String snapshotName) |
long |
getRawDiretoriesSize() |
java.util.Map<java.lang.String,Directories.SnapshotSizeDetails> |
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)
Returns directory to write snapshot.
|
java.io.File |
getSnapshotManifestFile(java.lang.String snapshotName) |
java.io.File |
getSnapshotSchemaFile(java.lang.String snapshotName) |
java.io.File |
getTemporaryWriteableDirectoryAsFile(long writeSize)
Returns a temporary subdirectory on allowed data directory
that _currently_ has
writeSize bytes as usable space. |
long |
getTrueAllocatedSizeIn(java.io.File input) |
Directories.DataDirectory |
getWriteableLocation(long writeSize)
Returns an allowed data directory that _currently_ has
writeSize bytes as usable space. |
java.io.File |
getWriteableLocationAsFile(long writeSize)
Returns an allowed directory that _currently_ has
writeSize bytes as usable space. |
Directories.DataDirectory[] |
getWriteableLocations() |
java.io.File |
getWriteableLocationToLoadFile(java.io.File sourceFile)
Returns a data directory to load the file
sourceFile . |
boolean |
hasAvailableDiskSpace(long estimatedSSTables,
long expectedTotalWriteSize) |
static boolean |
isSecondaryIndexFolder(java.io.File dir) |
static boolean |
isStoredInLocalSystemKeyspacesDataLocation(java.lang.String keyspace,
java.lang.String table)
Checks if the specified table should be stored with local system data.
|
java.util.List<java.lang.String> |
listEphemeralSnapshots() |
void |
removeTemporaryDirectories() |
long |
snapshotCreationTime(java.lang.String snapshotName) |
boolean |
snapshotExists(java.lang.String snapshotName) |
Directories.SSTableLister |
sstableLister(Directories.OnTxnErr onTxnErr) |
Directories.SSTableLister |
sstableLister(java.io.File directory,
Directories.OnTxnErr onTxnErr) |
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 TMP_SUBDIR
public static final java.lang.String SECONDARY_INDEX_NAME_SEPARATOR
public static final Directories.DataDirectories dataDirectories
public Directories(TableMetadata metadata)
public Directories(TableMetadata metadata, java.util.Collection<Directories.DataDirectory> paths)
public Directories(TableMetadata metadata, Directories.DataDirectory[] paths)
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 Directories.DataDirectory getDataDirectoryForFile(Descriptor descriptor)
public Descriptor find(java.lang.String filename)
public java.io.File getDirectoryForNewSSTables()
getWriteableLocationAsFile(long)
with an unknown size (-1L
),
which may return any allowed directory - even a data directory that has no usable space.
Do not use this method in production code.FSWriteError
- if all directories are disallowed.public java.io.File getWriteableLocationAsFile(long writeSize)
writeSize
bytes as usable space.FSWriteError
- if all directories are disallowed.public java.io.File getWriteableLocationToLoadFile(java.io.File sourceFile)
sourceFile
. If the sourceFile is on same disk partition as any
data directory then use that one as data directory otherwise use getWriteableLocationAsFile(long)
to
find suitable data directory.
Also makes sure returned directory is not disallowed.FSWriteError
- if all directories are disallowed.public java.io.File getTemporaryWriteableDirectoryAsFile(long writeSize)
writeSize
bytes as usable space.
This method does not create the temporary directory.java.io.IOError
- if all directories are disallowed.public void removeTemporaryDirectories()
public Directories.DataDirectory getWriteableLocation(long writeSize)
writeSize
bytes as usable space.FSWriteError
- if all directories are disallowed.public boolean hasAvailableDiskSpace(long estimatedSSTables, long expectedTotalWriteSize)
public Directories.DataDirectory[] getWriteableLocations()
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)
location
indicates secondary index, this will return
<cf dir>/snapshots/<snapshot name>/.<index name>
.
Otherwise, this will return <cf dir>/snapshots/<snapshot name>
.location
- base directorysnapshotName
- snapshot namepublic java.io.File getSnapshotManifestFile(java.lang.String snapshotName)
public java.io.File getSnapshotSchemaFile(java.lang.String snapshotName)
public java.io.File getNewEphemeralSnapshotMarkerFile(java.lang.String snapshotName)
public static java.io.File getBackupsDirectory(Descriptor desc)
public static java.io.File getBackupsDirectory(java.io.File location)
public static boolean isStoredInLocalSystemKeyspacesDataLocation(java.lang.String keyspace, java.lang.String table)
To minimize the risk of failures, SSTables for local system keyspaces must be stored in a single data directory. The only exception to this are some of the system table as the server can continue operating even if those tables loose some data.
keyspace
- the keyspace nametable
- the table nametrue
if the specified table should be stored with local system data, false
otherwise.public Directories.SSTableLister sstableLister(Directories.OnTxnErr onTxnErr)
public Directories.SSTableLister sstableLister(java.io.File directory, Directories.OnTxnErr onTxnErr)
public java.util.Map<java.lang.String,Directories.SnapshotSizeDetails> getSnapshotDetails()
public java.util.List<java.lang.String> listEphemeralSnapshots()
public boolean snapshotExists(java.lang.String snapshotName)
public static void clearSnapshot(java.lang.String snapshotName, java.util.List<java.io.File> snapshotDirectories, com.google.common.util.concurrent.RateLimiter snapshotRateLimiter)
public long snapshotCreationTime(java.lang.String snapshotName)
public long trueSnapshotsSize()
public long getRawDiretoriesSize()
public long getTrueAllocatedSizeIn(java.io.File input)
public static java.util.List<java.io.File> getKSChildDirectories(java.lang.String ksName)
public static boolean isSecondaryIndexFolder(java.io.File dir)
public java.util.List<java.io.File> getCFDirectories()
Copyright © 2009- The Apache Software Foundation