public class FileManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FileManager.FileMode |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BAD_SUFFIX |
static java.lang.String |
DEL_SUFFIX |
static java.lang.String |
JE_SUFFIX |
static long |
N_BAD_WRITES |
static long |
STOP_ON_WRITE_COUNT |
static boolean |
THROW_ON_WRITE |
static long |
WRITE_COUNT |
Constructor and Description |
---|
FileManager(EnvironmentImpl envImpl,
java.io.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 readOnly)
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.
|
void |
deleteFile(long fileNum)
Delete log file NNNNNNNN.
|
boolean |
filesExist() |
static int |
firstLogEntryOffset() |
java.lang.Long[] |
getAllFileNumbers()
Get all JE file numbers.
|
long |
getCurrentFileNum() |
static java.lang.String |
getFileName(long fileNum,
java.lang.String suffix) |
java.lang.Long |
getFirstFileNum()
public for cleaner.
|
java.lang.Long |
getFollowingFileNum(long currentFileNum,
boolean forward)
Get the next file number before/after currentFileNum.
|
java.lang.String |
getFullFileName(long fileNum,
java.lang.String suffix) |
java.lang.Long |
getLastFileNum() |
long |
getLastUsedLsn()
Return the last allocated LSN in the log.
|
long |
getNextLsn()
Return the next available LSN in the log.
|
long |
getNFSyncRequests() |
long |
getNFSyncs() |
long |
getNFSyncTimeouts() |
java.lang.Long |
getNumFromName(java.lang.String fileName)
Get the file number from a file name.
|
boolean |
getReadOnly() |
static java.lang.String[] |
listFiles(java.io.File envDirFile,
java.lang.String[] suffixes)
Find je files, flavor for unit test support.
|
java.lang.String[] |
listFiles(long minFileNumber,
long maxFileNumber)
Find .jdb files which are >= the minimimum file number and
<= the maximum file number.
|
java.lang.String[] |
listFiles(java.lang.String[] suffixes)
Find je files.
|
boolean |
lockEnvironment(boolean readOnly,
boolean exclusive)
Lock the environment.
|
void |
releaseExclusiveLock() |
void |
renameFile(long fileNum,
java.lang.String newSuffix)
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 |
truncateLog(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 java.lang.String JE_SUFFIX
public static final java.lang.String DEL_SUFFIX
public static final java.lang.String BAD_SUFFIX
public FileManager(EnvironmentImpl envImpl, java.io.File dbEnvHome, boolean readOnly) throws DatabaseException
configManager
- dbEnvHome
- environment home directoryDatabaseException
public 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 java.lang.Long getFirstFileNum()
public boolean getReadOnly()
public java.lang.Long getLastFileNum()
public long getCurrentFileNum()
public void setIncludeDeletedFiles(boolean includeDeletedFiles)
public java.lang.Long[] getAllFileNumbers()
public java.lang.Long getFollowingFileNum(long currentFileNum, boolean forward)
currentFileNum
- 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 java.lang.Long getNumFromName(java.lang.String fileName)
the
- file namepublic java.lang.String[] listFiles(java.lang.String[] suffixes)
suffix
- which type of file we're looking forpublic java.lang.String[] listFiles(long minFileNumber, long maxFileNumber)
public static java.lang.String[] listFiles(java.io.File envDirFile, java.lang.String[] suffixes)
suffix
- which type of file we're looking forpublic java.lang.String getFullFileName(long fileNum, java.lang.String suffix)
public static java.lang.String getFileName(long fileNum, java.lang.String suffix)
public void renameFile(long fileNum, java.lang.String newSuffix) throws DatabaseException, java.io.IOException
fileNum
- the file we want to movenewSuffix
- the new file suffixDatabaseException
java.io.IOException
public void deleteFile(long fileNum) throws DatabaseException, java.io.IOException
fileNum
- the file we want to moveDatabaseException
java.io.IOException
public void clear() throws java.io.IOException, DatabaseException
java.io.IOException
DatabaseException
public void close() throws java.io.IOException, DatabaseException
java.io.IOException
DatabaseException
public boolean lockEnvironment(boolean readOnly, boolean exclusive) throws DatabaseException
DatabaseException
public void releaseExclusiveLock() throws DatabaseException
DatabaseException
public boolean checkEnvHomePermissions(boolean readOnly) throws DatabaseException
DatabaseException
public void truncateLog(long fileNum, long offset) throws java.io.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]
java.io.IOException
DatabaseException
public static int firstLogEntryOffset()
public long getNextLsn()
public long getLastUsedLsn()
public long getNFSyncs()
public long getNFSyncRequests()
public long getNFSyncTimeouts()