public final class ODirectMemoryOnlyDiskCache extends OAbstractWriteCache implements OReadCache, OWriteCache
Modifier and Type | Method and Description |
---|---|
void |
addBackgroundExceptionListener(OBackgroundExceptionListener listener)
Adds listener which is triggered if exception is cast inside background flush data thread.
|
long |
addFile(String fileName) |
long |
addFile(String fileName,
long fileId) |
long |
addFile(String fileName,
long fileId,
OWriteCache writeCache) |
long |
addFile(String fileName,
OWriteCache writeCache) |
void |
addLowDiskSpaceListener(OLowDiskSpaceListener listener) |
void |
addPageIsBrokenListener(OPageIsBrokenListener listener)
Not implemented because has no sense
|
int |
allocateNewPage(long fileId) |
OCacheEntry |
allocateNewPage(long fileId,
OWriteCache writeCache,
OLogSequenceNumber startLSN) |
long |
bookFileId(String fileName) |
void |
changeMaximumAmountOfMemory(long calculateReadCacheMaxMemory) |
void |
checkCacheOverflow() |
boolean |
checkLowDiskSpace() |
OPageDataVerificationError[] |
checkStoredPages(OCommandOutputListener commandOutputListener) |
void |
clear() |
long[] |
close() |
void |
close(long fileId,
boolean flush) |
void |
closeFile(long fileId,
boolean flush,
OWriteCache writeCache) |
void |
closeStorage(OWriteCache writeCache)
Closes all files inside of write cache and flushes all associated data.
|
long[] |
delete() |
void |
deleteFile(long fileId) |
void |
deleteFile(long fileId,
OWriteCache writeCache) |
void |
deleteStorage(OWriteCache writeCache) |
boolean |
exists(long fileId) |
boolean |
exists(String name) |
long |
externalFileId(int fileId)
Converts unique internal file id to external one.
|
long |
fileIdByName(String fileName)
Returns id associated with given file or value < 0 if such file does not exist.
|
boolean |
fileIdsAreEqual(long firsId,
long secondId)
DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE
Takes two ids and checks whether they are equal from point of view of write cache.
|
String |
fileNameById(long fileId) |
Map<String,Long> |
files() |
void |
flush() |
void |
flush(long fileId) |
void |
flushTillSegment(long segmentId) |
long |
getExclusiveWriteCachePagesSize() |
long |
getFilledUpTo(long fileId) |
int |
getId() |
Long |
getMinimalNotFlushedSegment() |
Path |
getRootDirectory()
Directory which contains all files managed by write cache.
|
long |
getUsedMemory() |
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.
|
OCachePointer[] |
load(long fileId,
long startPageIndex,
int pageCount,
OModifiableBoolean cacheHit,
boolean verifyChecksums) |
void |
loadCacheState(OWriteCache writeCache)
Load state of cache from file system if possible.
|
long |
loadFile(String fileName)
Registers new file in write cache and returns file id assigned to this file.
|
OCacheEntry |
loadForRead(long fileId,
long pageIndex,
boolean checkPinnedPages,
OWriteCache writeCache,
int pageCount,
boolean verifyChecksums) |
OCacheEntry |
loadForWrite(long fileId,
long pageIndex,
boolean checkPinnedPages,
OWriteCache writeCache,
int pageCount,
boolean verifyChecksums,
OLogSequenceNumber startLSN) |
void |
makeFuzzyCheckpoint(long segmentId) |
String |
nativeFileNameById(long fileId)
Obtains native file name by the given file id.
|
int |
pageSize()
DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE
|
void |
pinPage(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
releaseFromRead(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
releaseFromWrite(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
Removes listener which is triggered if exception is cast inside background flush data thread.
|
void |
removeLowDiskSpaceListener(OLowDiskSpaceListener listener) |
void |
removePageIsBrokenListener(OPageIsBrokenListener listener)
Not implemented because has no sense
|
void |
renameFile(long fileId,
String newFileName) |
void |
replaceFileContentWith(long fileId,
Path newContentFile)
Replaces the file content with the content of the provided file.
|
String |
restoreFileById(long fileId)
Finds if there was file in write cache with given id which is deleted right now.
|
OCacheEntry |
silentLoadForRead(long fileId,
int pageIndex,
OWriteCache writeCache,
boolean verifyChecksums)
Loads page from the disk cache if it is already loaded otherwise loads it from disk but does
not put it the disk cache.
|
void |
store(long fileId,
long pageIndex,
OCachePointer dataPointer) |
void |
storeCacheState(OWriteCache writeCache)
Stores state of cache inside file if possible.
|
void |
truncateFile(long fileId) |
void |
truncateFile(long fileId,
OWriteCache writeCache) |
void |
updateDirtyPagesTable(OCachePointer pointer,
OLogSequenceNumber startLSN) |
checkFileIdCompatibility, composeFileId, extractFileId, extractStorageId
public final Path getRootDirectory()
getRootDirectory
in interface OWriteCache
null
in case of in memory database.public final long addFile(String fileName, OWriteCache writeCache)
addFile
in interface OReadCache
public final long fileIdByName(String fileName)
OWriteCache
fileIdByName
in interface OWriteCache
fileName
- File name id of which has to be returned.public final int internalFileId(long fileId)
OWriteCache
internalFileId
in interface OWriteCache
fileId
- External file id.public final long externalFileId(int fileId)
OWriteCache
externalFileId
in interface OWriteCache
fileId
- Internal file id.OWriteCache.internalFileId(long)
,
OWriteCache.getId()
public final long bookFileId(String fileName)
bookFileId
in interface OWriteCache
public final void addBackgroundExceptionListener(OBackgroundExceptionListener listener)
OWriteCache
addBackgroundExceptionListener
in interface OWriteCache
listener
- Listener to triggerpublic final void removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
OWriteCache
removeBackgroundExceptionListener
in interface OWriteCache
listener
- Listener to removepublic final void checkCacheOverflow()
checkCacheOverflow
in interface OWriteCache
public final long addFile(String fileName, long fileId, OWriteCache writeCache)
addFile
in interface OReadCache
public final OCacheEntry loadForWrite(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums, OLogSequenceNumber startLSN)
loadForWrite
in interface OReadCache
public OCacheEntry silentLoadForRead(long fileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums)
OReadCache
silentLoadForRead
in interface OReadCache
public final OCacheEntry loadForRead(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums)
loadForRead
in interface OReadCache
public final void pinPage(OCacheEntry cacheEntry, OWriteCache writeCache)
pinPage
in interface OReadCache
public final OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN)
allocateNewPage
in interface OReadCache
public int allocateNewPage(long fileId)
allocateNewPage
in interface OWriteCache
public final void releaseFromWrite(OCacheEntry cacheEntry, OWriteCache writeCache)
releaseFromWrite
in interface OReadCache
public final void releaseFromRead(OCacheEntry cacheEntry, OWriteCache writeCache)
releaseFromRead
in interface OReadCache
public final long getFilledUpTo(long fileId)
getFilledUpTo
in interface OWriteCache
public final void flush(long fileId)
flush
in interface OWriteCache
public final void close(long fileId, boolean flush)
close
in interface OWriteCache
public final void deleteFile(long fileId)
deleteFile
in interface OWriteCache
public final void renameFile(long fileId, String newFileName)
renameFile
in interface OWriteCache
public final void replaceFileContentWith(long fileId, Path newContentFile)
OWriteCache
replaceFileContentWith
in interface OWriteCache
fileId
- the file id of the file to replace the content of.newContentFile
- the new content file to replace the current content with.public final void truncateFile(long fileId)
truncateFile
in interface OWriteCache
public final void flush()
flush
in interface OWriteCache
public final long[] close()
close
in interface OWriteCache
public final void clear()
clear
in interface OReadCache
public final long[] delete()
delete
in interface OWriteCache
public final void deleteStorage(OWriteCache writeCache)
deleteStorage
in interface OReadCache
public final void closeStorage(OWriteCache writeCache)
closeStorage
in interface OReadCache
writeCache
- Write cache to close.public final void loadCacheState(OWriteCache writeCache)
loadCacheState
in interface OReadCache
writeCache
- Write cache is used to load pages back into cache if possible.public final void storeCacheState(OWriteCache writeCache)
storeCacheState
in interface OReadCache
writeCache
- Write cache which manages files cache state of which is going to be stored.public void changeMaximumAmountOfMemory(long calculateReadCacheMaxMemory)
changeMaximumAmountOfMemory
in interface OReadCache
public final OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener)
checkStoredPages
in interface OWriteCache
public final boolean exists(String name)
exists
in interface OWriteCache
public final boolean exists(long fileId)
exists
in interface OWriteCache
public final String fileNameById(long fileId)
fileNameById
in interface OWriteCache
public final String nativeFileNameById(long fileId)
OWriteCache
Native file name is a file name of a "physical" on-disk file, it may differ from the "virtual" logical file name.
nativeFileNameById
in interface OWriteCache
fileId
- the file id to obtain the native file name of.null
if the passed file id doesn't correspond to any file.public final long getUsedMemory()
getUsedMemory
in interface OReadCache
public final boolean checkLowDiskSpace()
checkLowDiskSpace
in interface OWriteCache
public final void addPageIsBrokenListener(OPageIsBrokenListener listener)
addPageIsBrokenListener
in interface OWriteCache
public final void removePageIsBrokenListener(OPageIsBrokenListener listener)
removePageIsBrokenListener
in interface OWriteCache
public final void addLowDiskSpaceListener(OLowDiskSpaceListener listener)
addLowDiskSpaceListener
in interface OWriteCache
public final void removeLowDiskSpaceListener(OLowDiskSpaceListener listener)
removeLowDiskSpaceListener
in interface OWriteCache
public final long loadFile(String fileName)
OWriteCache
File id consist of two parts:
OWriteCache.internalFileId(long)
If file with the same name is deleted and then new file is created this file with have the same internal id.
loadFile
in interface OWriteCache
fileName
- Name of file to register inside storage.public final long addFile(String fileName)
addFile
in interface OWriteCache
public final long addFile(String fileName, long fileId)
addFile
in interface OWriteCache
public final void store(long fileId, long pageIndex, OCachePointer dataPointer)
store
in interface OWriteCache
public final void makeFuzzyCheckpoint(long segmentId)
makeFuzzyCheckpoint
in interface OWriteCache
public final void flushTillSegment(long segmentId)
flushTillSegment
in interface OWriteCache
public final Long getMinimalNotFlushedSegment()
getMinimalNotFlushedSegment
in interface OWriteCache
public final void updateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN)
updateDirtyPagesTable
in interface OWriteCache
public final OCachePointer[] load(long fileId, long startPageIndex, int pageCount, OModifiableBoolean cacheHit, boolean verifyChecksums)
load
in interface OWriteCache
public final long getExclusiveWriteCachePagesSize()
getExclusiveWriteCachePagesSize
in interface OWriteCache
public final void truncateFile(long fileId, OWriteCache writeCache)
truncateFile
in interface OReadCache
public final int getId()
getId
in interface OWriteCache
public final Map<String,Long> files()
files
in interface OWriteCache
public final int pageSize()
OWriteCache
pageSize
in interface OWriteCache
public final boolean fileIdsAreEqual(long firsId, long secondId)
OWriteCache
Takes 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.
fileIdsAreEqual
in interface OWriteCache
public final String restoreFileById(long fileId)
OWriteCache
restoreFileById
in interface OWriteCache
fileId
- If of file which should be restorednull
if such name does not existpublic final void closeFile(long fileId, boolean flush, OWriteCache writeCache)
closeFile
in interface OReadCache
public final void deleteFile(long fileId, OWriteCache writeCache)
deleteFile
in interface OReadCache
Copyright © 2009–2020 OrientDB. All rights reserved.