|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.log.FileManager
public class FileManager
The FileManager presents the abstraction of one contiguous file. It doles out LSNs.
Nested Class Summary | |
---|---|
static class |
FileManager.FileMode
|
(package private) class |
FileManager.LogEndFileDescriptor
The LogEndFileDescriptor is used to write and fsync the end of the log. |
Field Summary | |
---|---|
static String |
BAD_SUFFIX
|
static String |
CIF_SUFFIX
|
static String |
DEL_SUFFIX
|
(package private) static String[] |
DEL_SUFFIXES
|
(package private) static boolean |
IO_EXCEPTION_TESTING
|
static String |
JE_SUFFIX
|
(package private) static String[] |
JE_SUFFIXES
|
static String |
LOCK_SUFFIX
|
(package private) static boolean |
RUNRECOVERY_EXCEPTION_TESTING
|
Constructor Summary | |
---|---|
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 | |
---|---|
(package private) boolean |
bumpLsn(long size)
Increase the current log position by "size" bytes. |
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()
|
(package private) void |
forceNewLogFile()
Set the flag that causes a new file to be written before the next write. |
Long[] |
getAllFileNumbers()
Get all JE file numbers. |
(package private) Set |
getCacheKeys()
|
long |
getCurrentFileNum()
|
(package private) FileHandle |
getFileHandle(long fileNum)
Return a read only file handle that corresponds the this file number. |
(package private) long |
getFileHeaderPrevOffset(long fileNum)
|
static String |
getFileName(long fileNum,
String suffix)
|
Long |
getFirstFileNum()
public for cleaner. |
Long |
getFollowingFileNum(long currentFileNum,
boolean forward)
Get the next file number before/after currentFileNum. |
String |
getFullFileName(long fileNum,
String suffix)
|
(package private) String[] |
getFullFileNames(long fileNum)
|
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()
|
(package private) long |
getPrevEntryOffset()
|
boolean |
getReadOnly()
|
(package private) void |
groupSync()
Flush a file using the group sync mechanism, trying to amortize off other syncs. |
static String[] |
listFiles(File envDirFile,
String[] suffixes)
Find je files, flavor for unit test support. |
(package private) String[] |
listFiles(String[] suffixes)
Find je files. |
(package private) void |
loadStats(StatsConfig config,
EnvironmentStats stats)
|
boolean |
lockEnvironment(boolean readOnly,
boolean exclusive)
Lock the environment. |
(package private) void |
readFromFile(RandomAccessFile file,
ByteBuffer readBuffer,
long offset)
Read a buffer from a file at a given offset, using NIO if so configured. |
void |
releaseExclusiveLock()
|
void |
renameFile(long fileNum,
String newSuffix)
Rename this file to NNNNNNNN.suffix. |
(package private) void |
restoreLastPosition()
|
(package private) void |
saveLastPosition()
|
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. |
(package private) void |
syncLogEnd()
FSync the end of the log. |
(package private) void |
syncLogEndAndFinishFile()
Sync the end of the log, close off this log file. |
void |
truncateLog(long fileNum,
long offset)
Truncate a log at this position. |
(package private) void |
writeLogBuffer(LogBuffer fullBuffer)
Write out a log buffer to the file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static boolean IO_EXCEPTION_TESTING
public static final String JE_SUFFIX
public static final String CIF_SUFFIX
public static final String DEL_SUFFIX
public static final String BAD_SUFFIX
public static final String LOCK_SUFFIX
static final String[] DEL_SUFFIXES
static final String[] JE_SUFFIXES
static boolean RUNRECOVERY_EXCEPTION_TESTING
Constructor Detail |
---|
public FileManager(EnvironmentImpl envImpl, File dbEnvHome, boolean readOnly) throws DatabaseException
configManager
- dbEnvHome
- environment home directory
DatabaseException
Method Detail |
---|
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.void saveLastPosition()
void restoreLastPosition()
public void setSyncAtFileEnd(boolean sync)
public Long getFirstFileNum()
public boolean getReadOnly()
public Long getLastFileNum()
public long getCurrentFileNum()
public void setIncludeDeletedFiles(boolean includeDeletedFiles)
public Long[] getAllFileNumbers()
public 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 file
public boolean filesExist()
String[] listFiles(String[] suffixes)
suffix
- which type of file we're looking for
public static String[] listFiles(File envDirFile, String[] suffixes)
suffix
- which type of file we're looking for
String[] getFullFileNames(long fileNum)
public String getFullFileName(long fileNum, String suffix)
public static String getFileName(long fileNum, String suffix)
public void renameFile(long fileNum, String newSuffix) throws DatabaseException, IOException
fileNum
- the file we want to movenewSuffix
- the new file suffix
DatabaseException
IOException
public void deleteFile(long fileNum) throws DatabaseException, IOException
fileNum
- the file we want to move
DatabaseException
IOException
FileHandle getFileHandle(long fileNum) throws LogException, DatabaseException
fileNum
- which file
LogException
DatabaseException
long getFileHeaderPrevOffset(long fileNum) throws IOException, DatabaseException
IOException
DatabaseException
long getPrevEntryOffset()
boolean bumpLsn(long size)
size
- is an unsigned int
void writeLogBuffer(LogBuffer fullBuffer) throws DatabaseException
fullBuffer
- buffer to write
DatabaseException
void readFromFile(RandomAccessFile file, ByteBuffer readBuffer, long offset) throws IOException
IOException
void syncLogEnd() throws DatabaseException
DatabaseException
void syncLogEndAndFinishFile() throws DatabaseException, IOException
DatabaseException
IOException
void groupSync() throws DatabaseException
DatabaseException
public void clear() throws IOException, DatabaseException
IOException
DatabaseException
public void close() throws IOException, DatabaseException
IOException
DatabaseException
public boolean lockEnvironment(boolean readOnly, boolean exclusive) throws DatabaseException
DatabaseException
public void releaseExclusiveLock() throws DatabaseException
DatabaseException
public void truncateLog(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]
IOException
DatabaseException
void forceNewLogFile()
public static int firstLogEntryOffset()
public long getNextLsn()
public long getLastUsedLsn()
public long getNFSyncs()
public long getNFSyncRequests()
public long getNFSyncTimeouts()
void loadStats(StatsConfig config, EnvironmentStats stats) throws DatabaseException
DatabaseException
Set getCacheKeys()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |