Interface OWriteCache
- All Known Implementing Classes:
ODirectMemoryOnlyDiskCache,OWOWCache
public interface OWriteCache
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds listener which is triggered if exception is cast inside background flush data thread.longlongvoidaddPageIsBrokenListener(OPageIsBrokenListener listener) Adds listener which is called by cache if corruption of file page is detected.intallocateNewPage(long fileId) longbookFileId(String fileName) voidbooleancheckStoredPages(OCommandOutputListener commandOutputListener) long[]close()voidclose(long fileId, boolean flush) voidcreate()long[]delete()voiddeleteFile(long fileId) booleanexists(long fileId) booleanlongexternalFileId(int fileId) Converts unique internal file id to external one.longfileIdByName(String fileName) Returns id associated with given file or value < 0 if such file does not exist.booleanfileIdsAreEqual(long firsId, long secondId) DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGEfileNameById(long fileId) files()voidflush()voidflush(long fileId) voidflushTillSegment(long segmentId) longlonggetFilledUpTo(long fileId) intgetId()Directory which contains all files managed by write cache.intinternalFileId(long fileId) Returns internal file id which is unique and always the same for given file in contrary to external id which changes over close/open cycle of cache.load(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) longRegisters new file in write cache and returns file id assigned to this file.nativeFileNameById(long fileId) Obtains native file name by the given file id.voidopen()intpageSize()DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGEvoidRemoves listener which is triggered if exception is cast inside background flush data thread.voidRemoves listener which is called by cache if corruption of file page is detected.voidrenameFile(long fileId, String newFileName) voidreplaceFileId(long fileId, long newFileId) restoreFileById(long fileId) Finds if there was file in write cache with given id which is deleted right now.voidvoidvoidstore(long fileId, long pageIndex, OCachePointer dataPointer) voidsyncDataFiles(long segmentId, byte[] lastMetadata) voidtruncateFile(long fileId) voidupdateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN)
-
Method Details
-
addPageIsBrokenListener
Adds listener which is called by cache if corruption of file page is detected. -
removePageIsBrokenListener
Removes listener which is called by cache if corruption of file page is detected. -
bookFileId
-
loadFile
Registers new file in write cache and returns file id assigned to this file.File id consist of two parts:
- Internal id is permanent and can not be changed during life of storage
internalFileId(long) - Write cache id which is changed between storage open/close cycles
If file with the same name is deleted and then new file is created this file with have the same internal id.
- Parameters:
fileName- Name of file to register inside storage.- Returns:
- Id of registered file
- Throws:
IOException
- Internal id is permanent and can not be changed during life of storage
-
addFile
- Throws:
IOException
-
addFile
- Throws:
IOException
-
fileIdByName
Returns id associated with given file or value < 0 if such file does not exist.- Parameters:
fileName- File name id of which has to be returned.- Returns:
- id associated with given file or value < 0 if such file does not exist.
-
checkLowDiskSpace
- Throws:
IOException
-
syncDataFiles
- Throws:
IOException
-
flushTillSegment
void flushTillSegment(long segmentId) -
exists
-
exists
boolean exists(long fileId) -
restoreModeOn
- Throws:
IOException
-
restoreModeOff
void restoreModeOff() -
store
-
checkCacheOverflow
- Throws:
InterruptedException
-
allocateNewPage
- Throws:
IOException
-
load
OCachePointer load(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) throws IOException - Throws:
IOException
-
flush
void flush(long fileId) -
flush
void flush() -
getFilledUpTo
long getFilledUpTo(long fileId) -
getExclusiveWriteCachePagesSize
long getExclusiveWriteCachePagesSize() -
deleteFile
- Throws:
IOException
-
truncateFile
- Throws:
IOException
-
renameFile
- Throws:
IOException
-
close
- Throws:
IOException
-
close
void close(long fileId, boolean flush) -
checkStoredPages
-
delete
- Throws:
IOException
-
fileNameById
-
nativeFileNameById
Obtains native file name by the given file id.Native file name is a file name of a "physical" on-disk file, it may differ from the "virtual" logical file name.
- Parameters:
fileId- the file id to obtain the native file name of.- Returns:
- the obtained native file name or
nullif the passed file id doesn't correspond to any file.
-
getId
int getId() -
files
-
pageSize
int pageSize()DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE- Returns:
- Size of page inside of cache.
-
restoreFileById
Finds if there was file in write cache with given id which is deleted right now. If such file exists it creates new file with the same name at it was in deleted file.- Parameters:
fileId- If of file which should be restored- Returns:
- Name of restored file or
nullif such name does not exist - Throws:
IOException
-
addBackgroundExceptionListener
Adds listener which is triggered if exception is cast inside background flush data thread.- Parameters:
listener- Listener to trigger
-
removeBackgroundExceptionListener
Removes listener which is triggered if exception is cast inside background flush data thread.- Parameters:
listener- Listener to remove
-
getRootDirectory
Path getRootDirectory()Directory which contains all files managed by write cache.- Returns:
- Directory which contains all files managed by write cache or
nullin case of in memory database.
-
internalFileId
int internalFileId(long fileId) Returns internal file id which is unique and always the same for given file in contrary to external id which changes over close/open cycle of cache.- Parameters:
fileId- External file id.- Returns:
- Internal file id.
-
externalFileId
long externalFileId(int fileId) Converts unique internal file id to external one. External id is combination of internal id and write cache id, which changes every time when cache is closed and opened again.- Parameters:
fileId- Internal file id.- Returns:
- External file id.
- See Also:
-
fileIdsAreEqual
boolean fileIdsAreEqual(long firsId, long secondId) DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGETakes two ids and checks whether they are equal from point of view of write cache. In other words methods checks whether two ids in reality contain the same internal ids.
-
getMinimalNotFlushedSegment
Long getMinimalNotFlushedSegment() -
updateDirtyPagesTable
-
create
- Throws:
IOException
-
open
- Throws:
IOException
-
replaceFileId
- Throws:
IOException
-