| java.lang.Object com.sleepycat.je.log.FileManager
FileManager | public class FileManager (Code) | | The FileManager presents the abstraction of one contiguous file. It doles
out LSNs.
|
Inner Class :public static class FileMode | |
Inner Class :class LogEndFileDescriptor | |
Constructor Summary | |
public | 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. |
Method Summary | |
boolean | bumpLsn(long size) Increase the current log position by "size" bytes. | public 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. | public void | clear() Close all file handles and empty the cache. | public void | close() Clear the file lock. | public void | deleteFile(long fileNum) Delete log file NNNNNNNN. | public boolean | filesExist() | public static int | firstLogEntryOffset() | void | forceNewLogFile() Set the flag that causes a new file to be written before the next write. | public Long[] | getAllFileNumbers() Get all JE file numbers. | Set | getCacheKeys() | public long | getCurrentFileNum() | FileHandle | getFileHandle(long fileNum) Return a read only file handle that corresponds the this file number.
Retrieve it from the cache or open it anew and validate the file header.
This method takes a latch on this file, so that the file descriptor will
be held in the cache as long as it's in use. | long | getFileHeaderPrevOffset(long fileNum) | public static String | getFileName(long fileNum, String suffix) | public Long | getFirstFileNum() public for cleaner. | public Long | getFollowingFileNum(long currentFileNum, boolean forward) Get the next file number before/after currentFileNum.
Parameters: currentFileNum - the file we're at right now. | public String | getFullFileName(long fileNum, String suffix) | String[] | getFullFileNames(long fileNum) | public Long | getLastFileNum() | public long | getLastUsedLsn() Return the last allocated LSN in the log. | public long | getNFSyncRequests() | public long | getNFSyncTimeouts() | public long | getNFSyncs() | public long | getNextLsn() Return the next available LSN in the log. | public Long | getNumFromName(String fileName) Get the file number from a file name. | long | getPrevEntryOffset() the file offset of the last LSN that was used. | public boolean | getReadOnly() | void | groupSync() Flush a file using the group sync mechanism, trying to amortize off
other syncs. | public String[] | listFiles(String[] suffixes) Find je files. | public String[] | listFiles(long minFileNumber, long maxFileNumber) Find .jdb files which are >= the minimimum file number and
<= the maximum file number. | public static String[] | listFiles(File envDirFile, String[] suffixes) Find je files, flavor for unit test support. | void | loadStats(StatsConfig config, EnvironmentStats stats) | public boolean | lockEnvironment(boolean readOnly, boolean exclusive) Lock the environment. | void | readFromFile(RandomAccessFile file, ByteBuffer readBuffer, long offset) Read a buffer from a file at a given offset, using NIO if so configured. | public void | releaseExclusiveLock() | public void | renameFile(long fileNum, String newSuffix) Rename this file to NNNNNNNN.suffix. | void | restoreLastPosition() | void | saveLastPosition() | public void | setIncludeDeletedFiles(boolean includeDeletedFiles) | public void | setLastPosition(long nextAvailableLsn, long lastUsedLsn, long prevOffset) Set the file manager's "end of log". | public void | setSyncAtFileEnd(boolean sync) May be used to disable sync at file end to speed unit tests. | void | syncLogEnd() FSync the end of the log. | void | syncLogEndAndFinishFile() Sync the end of the log, close off this log file. | public void | truncateLog(long fileNum, long offset) Truncate a log at this position. | void | writeLogBuffer(LogBuffer fullBuffer) Write out a log buffer to the file. |
IO_EXCEPTION_TESTING_ON_READ | static boolean IO_EXCEPTION_TESTING_ON_READ(Code) | | |
IO_EXCEPTION_TESTING_ON_WRITE | static boolean IO_EXCEPTION_TESTING_ON_WRITE(Code) | | |
N_BAD_WRITES | public static long N_BAD_WRITES(Code) | | |
RUNRECOVERY_EXCEPTION_TESTING | static boolean RUNRECOVERY_EXCEPTION_TESTING(Code) | | |
STOP_ON_WRITE_COUNT | public static long STOP_ON_WRITE_COUNT(Code) | | |
THROW_ON_WRITE | public static boolean THROW_ON_WRITE(Code) | | |
THROW_RRE_FOR_UNIT_TESTS | static boolean THROW_RRE_FOR_UNIT_TESTS(Code) | | |
WRITE_COUNT | public static long WRITE_COUNT(Code) | | |
FileManager | public FileManager(EnvironmentImpl envImpl, File dbEnvHome, boolean readOnly) throws DatabaseException(Code) | | Set up the file cache and initialize the file manager to point to the
beginning of the log.
Parameters: configManager - Parameters: dbEnvHome - environment home directory |
bumpLsn | boolean bumpLsn(long size)(Code) | | Increase the current log position by "size" bytes. Move the prevOffset
pointer along.
Parameters: size - is an unsigned int true if we flipped to the next log file. |
checkEnvHomePermissions | public boolean checkEnvHomePermissions(boolean readOnly) throws DatabaseException(Code) | | 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.
true if the environment home dir is readonly. |
filesExist | public boolean filesExist()(Code) | | true if there are any files at all. |
firstLogEntryOffset | public static int firstLogEntryOffset()(Code) | | the size in bytes of the file header log entry. |
forceNewLogFile | void forceNewLogFile()(Code) | | Set the flag that causes a new file to be written before the next write.
|
getAllFileNumbers | public Long[] getAllFileNumbers()(Code) | | Get all JE file numbers.
an array of all JE file numbers. |
getCurrentFileNum | public long getCurrentFileNum()(Code) | | |
getFileHandle | FileHandle getFileHandle(long fileNum) throws LogException, DatabaseException(Code) | | Return a read only file handle that corresponds the this file number.
Retrieve it from the cache or open it anew and validate the file header.
This method takes a latch on this file, so that the file descriptor will
be held in the cache as long as it's in use. When the user is done with
the file, the latch must be released.
Parameters: fileNum - which file the file handle for the existing or newly created file |
getFileName | public static String getFileName(long fileNum, String suffix)(Code) | | the file name for the nth file. |
getFirstFileNum | public Long getFirstFileNum()(Code) | | public for cleaner.
the number of the first file in this environment. |
getFollowingFileNum | public Long getFollowingFileNum(long currentFileNum, boolean forward)(Code) | | Get the next file number before/after currentFileNum.
Parameters: currentFileNum - the file we're at right now. Note thatit may not exist, if it's been cleaned and renamed. Parameters: forward - if true, we want the next larger file, if falsewe want the previous file null if there is no following file, or if filenum doesn't exist |
getFullFileName | public String getFullFileName(long fileNum, String suffix)(Code) | | the full file name and path for the given file number andsuffix. |
getFullFileNames | String[] getFullFileNames(long fileNum)(Code) | | the full file name and path for the nth je file. |
getLastFileNum | public Long getLastFileNum()(Code) | | the number of the last file in this environment. |
getLastUsedLsn | public long getLastUsedLsn()(Code) | | Return the last allocated LSN in the log. Note that this is
unsynchronized, so if it is called outside the log write latch it is
only valid as an approximation of log size.
|
getNFSyncRequests | public long getNFSyncRequests()(Code) | | |
getNFSyncTimeouts | public long getNFSyncTimeouts()(Code) | | |
getNFSyncs | public long getNFSyncs()(Code) | | |
getNextLsn | public long getNextLsn()(Code) | | Return the next available LSN in the log. Note that this is
unsynchronized, so is only valid as an approximation of log size.
|
getNumFromName | public Long getNumFromName(String fileName)(Code) | | Get the file number from a file name.
Parameters: the - file name the file number |
getPrevEntryOffset | long getPrevEntryOffset()(Code) | | the file offset of the last LSN that was used. For constructingthe headers of log entries. If the last LSN that was used was in aprevious file, or this is the very first LSN of the whole system, return0. |
getReadOnly | public boolean getReadOnly()(Code) | | |
groupSync | void groupSync() throws DatabaseException(Code) | | Flush a file using the group sync mechanism, trying to amortize off
other syncs.
|
listFiles | public String[] listFiles(String[] suffixes)(Code) | | Find je files. Return names sorted in ascending fashion.
Parameters: suffix - which type of file we're looking for array of file names |
listFiles | public String[] listFiles(long minFileNumber, long maxFileNumber)(Code) | | Find .jdb files which are >= the minimimum file number and
<= the maximum file number.
Return names sorted in ascending fashion.
array of file names |
listFiles | public static String[] listFiles(File envDirFile, String[] suffixes)(Code) | | Find je files, flavor for unit test support.
Parameters: suffix - which type of file we're looking for array of file names |
lockEnvironment | public boolean lockEnvironment(boolean readOnly, boolean exclusive) throws DatabaseException(Code) | | Lock the environment. Return true if the lock was acquired. If
exclusive is false, then this implements a single writer, multiple
reader lock. If exclusive is true, then implement an exclusive lock.
There is a lock file and there are two regions of the lock file: byte 0,
and byte 1. Byte 0 is the exclusive writer process area of the lock
file. If an environment is opened for write, then it attempts to take
an exclusive write lock on byte 0. Byte 1 is the shared reader process
area of the lock file. If an environment is opened for read-only, then
it attempts to take a shared lock on byte 1. This is how we implement
single writer, multi reader semantics.
The cleaner, each time it is invoked, attempts to take an exclusive lock
on byte 1. The owning process already either has an exclusive lock on
byte 0, or a shared lock on byte 1. This will necessarily conflict with
any shared locks on byte 1, even if it's in the same process and there
are no other holders of that shared lock. So if there is only one
read-only process, it will have byte 1 for shared access, and the
cleaner can not run in it because it will attempt to get an exclusive
lock on byte 1 (which is already locked for shared access by itself).
If a write process comes along and tries to run the cleaner, it will
attempt to get an exclusive lock on byte 1. If there are no other
reader processes (with shared locks on byte 1), and no other writers
(which are running cleaners on with exclusive locks on byte 1), then the
cleaner will run.
|
readFromFile | void readFromFile(RandomAccessFile file, ByteBuffer readBuffer, long offset) throws IOException(Code) | | Read a buffer from a file at a given offset, using NIO if so configured.
|
renameFile | public void renameFile(long fileNum, String newSuffix) throws DatabaseException, IOException(Code) | | Rename this file to NNNNNNNN.suffix. If that file already exists, try
NNNNNNNN.suffix.1, etc. Used for deleting files or moving corrupt files
aside.
Parameters: fileNum - the file we want to move Parameters: newSuffix - the new file suffix |
restoreLastPosition | void restoreLastPosition()(Code) | | |
saveLastPosition | void saveLastPosition()(Code) | | |
setIncludeDeletedFiles | public void setIncludeDeletedFiles(boolean includeDeletedFiles)(Code) | | |
setLastPosition | public void setLastPosition(long nextAvailableLsn, long lastUsedLsn, long prevOffset)(Code) | | Set the file manager's "end of log".
Parameters: nextAvailableLsn - LSN to be used for the next log entry Parameters: lastUsedLsn - last LSN to have a valid entry, may be null Parameters: prevOffset - value to use for the prevOffset of the next entry.If the beginning of the file, this is 0. |
setSyncAtFileEnd | public void setSyncAtFileEnd(boolean sync)(Code) | | May be used to disable sync at file end to speed unit tests.
Must only be used for unit testing, since log corruption may result.
|
syncLogEndAndFinishFile | void syncLogEndAndFinishFile() throws DatabaseException, IOException(Code) | | Sync the end of the log, close off this log file. Should only be called
under the log write latch.
|
truncateLog | public void truncateLog(long fileNum, long offset) throws IOException, DatabaseException(Code) | | Truncate a log at this position. Used by recovery to a timestamp
utilities and by recovery to set the end-of-log position.
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]
|
writeLogBuffer | void writeLogBuffer(LogBuffer fullBuffer) throws DatabaseException(Code) | | Write out a log buffer to the file.
Parameters: fullBuffer - buffer to write |
|
|