public class FileManager extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FileManager.DefaultRandomAccessFile
The RandomAccessFile for production use.
|
static interface |
FileManager.FileFactory
The factory interface for creating RandomAccessFiles.
|
static class |
FileManager.FileMode |
| Modifier and Type | Field and Description |
|---|---|
static String |
BAD_SUFFIX |
static String |
BUP_SUFFIX |
static String |
DEL_SUFFIX |
static FileManager.FileFactory |
fileFactory
The factory instance used to create RandomAccessFiles.
|
static String |
JE_SUFFIX |
static boolean |
LOGWRITE_EXCEPTION_TESTING |
static long |
N_BAD_WRITES |
static long |
STOP_ON_WRITE_COUNT |
static boolean |
THROW_ON_WRITE |
static String |
TMP_SUFFIX |
boolean |
VERIFY_CHECKSUMS |
static long |
WRITE_COUNT |
| Constructor and Description |
|---|
FileManager(EnvironmentImpl envImpl,
File dbEnvHome,
boolean readOnly)
Set up the file cache and initialize the file manager to point to the
beginning of the log.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkEnvHomePermissions(boolean rdOnly)
Ensure that if the environment home dir is on readonly media or in a
readonly directory that the environment has been opened for readonly
access.
|
void |
clear()
Close all file handles and empty the cache.
|
void |
close()
Clear the file lock.
|
boolean |
deleteFile(long fileNum)
Delete log file NNNNNNNN.
|
boolean |
filesExist() |
static int |
firstLogEntryOffset()
Return the offset of the first log entry after the file header.
|
void |
force(Set<Long> fileNums)
Fsync this set of log files.
|
void |
forceNewLogFile()
Set the flag that causes a new file to be written before the next write.
|
File[] |
gatherDataDirs() |
Long[] |
getAllFileNumbers()
Get all JE file numbers.
|
FileManager.FileMode |
getAppropriateReadWriteMode() |
long |
getCurrentFileNum()
Returns the highest (current) file number.
|
FileHandle |
getFileHandle(long fileNum)
Return a read only file handle that corresponds to this file number.
|
long |
getFileHeaderPrevOffset(long fileNum) |
Timestamp |
getFileHeaderTimestamp(long fileNum) |
int |
getFileLogVersion(long fileNum)
Returns the log version for the given file.
|
static String |
getFileName(long fileNum) |
static String |
getFileName(long fileNum,
String suffix) |
Long |
getFirstFileNum()
public for cleaner.
|
Long |
getFollowingFileNum(long curFile,
boolean forward)
Get the next file number before/after currentFileNum.
|
String |
getFullFileName(long fileNum) |
String |
getFullFileName(long fileNum,
String suffix) |
String |
getFullFileName(String fileName) |
Long |
getLastFileNum() |
long |
getLastUsedLsn()
Return the last allocated LSN in the log.
|
long |
getNextLsn()
Return the next available LSN in the log.
|
Long |
getNumFromName(String fileName)
Get the file number from a file name.
|
String |
getPartialFileName(long fileNum) |
boolean |
getReadOnly() |
boolean |
hasQueuedWrites()
Returns whether anything is in the write queue.
|
boolean |
isFileValid(long fileNum)
For assertions that check whether a file is valid or has been deleted
via log cleaning.
|
String[] |
listFileNames(long minFileNumber,
long maxFileNumber)
Find .jdb files which are >= the minimimum file number and
<= the maximum file number.
|
static String[] |
listFiles(File envDirFile,
String[] suffixes,
boolean envMultiSubDir)
Find JE files, flavor for unit test support.
|
File[] |
listJDBFiles() |
File[] |
listJDBFilesInternalMultiDir(com.sleepycat.je.log.JEFileFilter fileFilter) |
File[] |
listJDBFilesInternalSingleDir(com.sleepycat.je.log.JEFileFilter fileFilter) |
boolean |
lockEnvironment(boolean rdOnly,
boolean exclusive)
Lock the environment.
|
void |
makeInvisible(long fileNum,
List<Long> lsns)
Mark the specified log entries as invisible and obsolete.
|
boolean |
noteFsyncTime(long fSyncMs)
Update fsync statistics given that an fsync was performed which took the
specified amount of time in milliseconds.
|
RandomAccessFile |
openFileReadWrite(String fullPath)
Opens an existing file for read-write access.
|
void |
releaseExclusiveLock() |
boolean |
renameFile(long fileNum,
String newSuffix) |
File |
renameFile(long fileNum,
String newSuffix,
String subDir)
Rename this file to NNNNNNNN.suffix.
|
void |
setIncludeDeletedFiles(boolean includeDeletedFiles) |
void |
setLastPosition(long nextAvailableLsn,
long lastUsedLsn,
long prevOffset)
Set the file manager's "end of log".
|
void |
setSyncAtFileEnd(boolean sync)
May be used to disable sync at file end to speed unit tests.
|
void |
startFileCacheWarmer(long recoveryStartLsn) |
void |
testWriteQueueLock()
For unit testing only.
|
void |
testWriteQueueUnlock()
For unit testing only.
|
void |
truncateLog(long fileNum,
long offset) |
void |
truncateSingleFile(long fileNum,
long offset)
Truncate a log at this position.
|
public static long WRITE_COUNT
public static long STOP_ON_WRITE_COUNT
public static long N_BAD_WRITES
public static boolean THROW_ON_WRITE
public static final String JE_SUFFIX
public static final String DEL_SUFFIX
public static final String BAD_SUFFIX
public static final String TMP_SUFFIX
public static final String BUP_SUFFIX
public boolean VERIFY_CHECKSUMS
public static final boolean LOGWRITE_EXCEPTION_TESTING
public static FileManager.FileFactory fileFactory
public FileManager(EnvironmentImpl envImpl, File dbEnvHome, boolean readOnly) throws EnvironmentLockedException
dbEnvHome - environment home directoryIllegalArgumentException - via Environment ctorEnvironmentLockedException - via Environment ctorpublic void setLastPosition(long nextAvailableLsn,
long lastUsedLsn,
long prevOffset)
nextAvailableLsn - LSN to be used for the next log entrylastUsedLsn - last LSN to have a valid entry, may be nullprevOffset - value to use for the prevOffset of the next entry.
If the beginning of the file, this is 0.public void setSyncAtFileEnd(boolean sync)
public Long getFirstFileNum()
public boolean getReadOnly()
public Long getLastFileNum()
public long getCurrentFileNum()
public boolean isFileValid(long fileNum)
public void setIncludeDeletedFiles(boolean includeDeletedFiles)
public Long[] getAllFileNumbers()
public Long getFollowingFileNum(long curFile, boolean forward)
curFile - the file we're at right now. Note that
it may not exist, if it's been cleaned and renamed.forward - if true, we want the next larger file, if false
we want the previous filepublic boolean filesExist()
public Long getNumFromName(String fileName)
fileName - the file namepublic String[] listFileNames(long minFileNumber, long maxFileNumber)
public static String[] listFiles(File envDirFile, String[] suffixes, boolean envMultiSubDir)
suffixes - which type of file we're looking forpublic File[] listJDBFiles()
public File[] listJDBFilesInternalSingleDir(com.sleepycat.je.log.JEFileFilter fileFilter)
public File[] listJDBFilesInternalMultiDir(com.sleepycat.je.log.JEFileFilter fileFilter)
public File[] gatherDataDirs()
public String getFullFileName(long fileNum)
public String getFullFileName(long fileNum, String suffix)
public String getPartialFileName(long fileNum)
public static String getFileName(long fileNum, String suffix)
public static String getFileName(long fileNum)
public boolean renameFile(long fileNum,
String newSuffix)
throws IOException,
DatabaseException
IOExceptionDatabaseExceptionpublic File renameFile(long fileNum, String newSuffix, String subDir) throws IOException
fileNum - the file we want to movenewSuffix - the new file suffixsubDir - the data directory sub-directory to rename the file into.
The subDir must already exist. May be null to leave the file in its
current data directory.IOExceptionpublic boolean deleteFile(long fileNum)
throws IOException,
DatabaseException
fileNum - the file we want to moveIOExceptionDatabaseExceptionpublic RandomAccessFile openFileReadWrite(String fullPath) throws FileNotFoundException
protected.FileNotFoundExceptionfileUpdateMutexpublic int getFileLogVersion(long fileNum)
throws DatabaseException
DatabaseExceptionpublic FileHandle getFileHandle(long fileNum) throws FileNotFoundException, ChecksumException, DatabaseException
fileNum - which fileFileNotFoundExceptionChecksumExceptionDatabaseExceptionpublic FileManager.FileMode getAppropriateReadWriteMode()
public long getFileHeaderPrevOffset(long fileNum)
throws FileNotFoundException,
ChecksumException
FileNotFoundExceptionChecksumExceptionpublic Timestamp getFileHeaderTimestamp(long fileNum) throws FileNotFoundException, ChecksumException
FileNotFoundExceptionChecksumExceptionpublic boolean hasQueuedWrites()
public void testWriteQueueLock()
public void testWriteQueueUnlock()
public void startFileCacheWarmer(long recoveryStartLsn)
public void clear()
throws IOException,
DatabaseException
IOExceptionDatabaseExceptionpublic void close()
throws IOException
IOExceptionpublic boolean lockEnvironment(boolean rdOnly,
boolean exclusive)
public void releaseExclusiveLock()
throws DatabaseException
DatabaseExceptionpublic boolean checkEnvHomePermissions(boolean rdOnly)
throws DatabaseException
IllegalArgumentException - via Environment ctorDatabaseExceptionpublic void truncateSingleFile(long fileNum,
long offset)
throws IOException,
DatabaseException
This method forces a new log file to be written next, if the last file (the file truncated to) has an old version in its header. This ensures that when the log is opened by an old version of JE, a version incompatibility will be detected. [#11243]
IOExceptionDatabaseExceptionpublic void truncateLog(long fileNum,
long offset)
throws IOException,
DatabaseException
IOExceptionDatabaseExceptionpublic void makeInvisible(long fileNum,
List<Long> lsns)
fileNum - target file.lsns - The list of LSNs to make invisible, must be sorted in
ascending order.public void force(Set<Long> fileNums)
public void forceNewLogFile()
public static int firstLogEntryOffset()
public long getNextLsn()
public long getLastUsedLsn()
public boolean noteFsyncTime(long fSyncMs)
Copyright © 2024. All rights reserved.