Java Doc for FileManager.java in  » JMX » je » com » sleepycat » je » log » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.je.log 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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

Field Summary
final public static  StringBAD_SUFFIX
    
final public static  StringDEL_SUFFIX
    
final static  String[]DEL_SUFFIXES
    
static  booleanIO_EXCEPTION_TESTING_ON_READ
    
static  booleanIO_EXCEPTION_TESTING_ON_WRITE
    
final public static  StringJE_SUFFIX
    
final static  String[]JE_SUFFIXES
    
public static  longN_BAD_WRITES
    
static  booleanRUNRECOVERY_EXCEPTION_TESTING
    
public static  longSTOP_ON_WRITE_COUNT
    
public static  booleanTHROW_ON_WRITE
    
static  booleanTHROW_RRE_FOR_UNIT_TESTS
    
public static  longWRITE_COUNT
    

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
 booleanbumpLsn(long size)
     Increase the current log position by "size" bytes.
public  booleancheckEnvHomePermissions(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  voidclear()
     Close all file handles and empty the cache.
public  voidclose()
     Clear the file lock.
public  voiddeleteFile(long fileNum)
     Delete log file NNNNNNNN.
public  booleanfilesExist()
    
public static  intfirstLogEntryOffset()
    
 voidforceNewLogFile()
     Set the flag that causes a new file to be written before the next write.
public  Long[]getAllFileNumbers()
     Get all JE file numbers.
 SetgetCacheKeys()
    
public  longgetCurrentFileNum()
    
 FileHandlegetFileHandle(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.
 longgetFileHeaderPrevOffset(long fileNum)
    
public static  StringgetFileName(long fileNum, String suffix)
    
public  LonggetFirstFileNum()
     public for cleaner.
public  LonggetFollowingFileNum(long currentFileNum, boolean forward)
     Get the next file number before/after currentFileNum.
Parameters:
  currentFileNum - the file we're at right now.
public  StringgetFullFileName(long fileNum, String suffix)
    
 String[]getFullFileNames(long fileNum)
    
public  LonggetLastFileNum()
    
public  longgetLastUsedLsn()
     Return the last allocated LSN in the log.
public  longgetNFSyncRequests()
    
public  longgetNFSyncTimeouts()
    
public  longgetNFSyncs()
    
public  longgetNextLsn()
     Return the next available LSN in the log.
public  LonggetNumFromName(String fileName)
     Get the file number from a file name.
 longgetPrevEntryOffset()
     the file offset of the last LSN that was used.
public  booleangetReadOnly()
    
 voidgroupSync()
     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.
 voidloadStats(StatsConfig config, EnvironmentStats stats)
    
public  booleanlockEnvironment(boolean readOnly, boolean exclusive)
     Lock the environment.
 voidreadFromFile(RandomAccessFile file, ByteBuffer readBuffer, long offset)
     Read a buffer from a file at a given offset, using NIO if so configured.
public  voidreleaseExclusiveLock()
    
public  voidrenameFile(long fileNum, String newSuffix)
     Rename this file to NNNNNNNN.suffix.
 voidrestoreLastPosition()
    
 voidsaveLastPosition()
    
public  voidsetIncludeDeletedFiles(boolean includeDeletedFiles)
    
public  voidsetLastPosition(long nextAvailableLsn, long lastUsedLsn, long prevOffset)
     Set the file manager's "end of log".
public  voidsetSyncAtFileEnd(boolean sync)
     May be used to disable sync at file end to speed unit tests.
 voidsyncLogEnd()
     FSync the end of the log.
 voidsyncLogEndAndFinishFile()
     Sync the end of the log, close off this log file.
public  voidtruncateLog(long fileNum, long offset)
     Truncate a log at this position.
 voidwriteLogBuffer(LogBuffer fullBuffer)
     Write out a log buffer to the file.

Field Detail
BAD_SUFFIX
final public static String BAD_SUFFIX(Code)



DEL_SUFFIX
final public static String DEL_SUFFIX(Code)



DEL_SUFFIXES
final static String[] DEL_SUFFIXES(Code)



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)



JE_SUFFIX
final public static String JE_SUFFIX(Code)



JE_SUFFIXES
final static String[] JE_SUFFIXES(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)




Constructor Detail
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




Method Detail
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.



clear
public void clear() throws IOException, DatabaseException(Code)
Close all file handles and empty the cache.



close
public void close() throws IOException, DatabaseException(Code)
Clear the file lock.



deleteFile
public void deleteFile(long fileNum) throws DatabaseException, IOException(Code)
Delete log file NNNNNNNN.
Parameters:
  fileNum - the file we want to move



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.



getCacheKeys
Set getCacheKeys()(Code)



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



getFileHeaderPrevOffset
long getFileHeaderPrevOffset(long fileNum) throws IOException, DatabaseException(Code)
the prevOffset field stored in the file header.



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



loadStats
void loadStats(StatsConfig config, EnvironmentStats stats) throws DatabaseException(Code)



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.



releaseExclusiveLock
public void releaseExclusiveLock() throws DatabaseException(Code)



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.



syncLogEnd
void syncLogEnd() throws DatabaseException(Code)
FSync the end of the log.



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



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.