Class ODirectMemoryOnlyDiskCache
java.lang.Object
com.orientechnologies.orient.core.storage.cache.OAbstractWriteCache
com.orientechnologies.orient.core.storage.memory.ODirectMemoryOnlyDiskCache
- All Implemented Interfaces:
OReadCache,OWriteCache
public final class ODirectMemoryOnlyDiskCache
extends OAbstractWriteCache
implements OReadCache, OWriteCache
- Since:
- 6/24/14
- Author:
- Andrey Lomakin (a.lomakin-at-orientdb.com)
-
Field Summary
Fields inherited from interface com.orientechnologies.orient.core.storage.cache.OReadCache
MIN_CACHE_SIZE -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdds listener which is triggered if exception is cast inside background flush data thread.final longfinal longfinal longaddFile(String fileName, long fileId, OWriteCache writeCache) final longaddFile(String fileName, OWriteCache writeCache) final voidaddPageIsBrokenListener(OPageIsBrokenListener listener) Not implemented because has no senseintallocateNewPage(long fileId) final OCacheEntryallocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN) final longbookFileId(String fileName) voidchangeMaximumAmountOfMemory(long calculateReadCacheMaxMemory) final voidfinal booleanfinal OPageDataVerificationError[]checkStoredPages(OCommandOutputListener commandOutputListener) final voidclear()final long[]close()final voidclose(long fileId, boolean flush) final voidcloseFile(long fileId, boolean flush, OWriteCache writeCache) final voidcloseStorage(OWriteCache writeCache) Closes all files inside of write cache and flushes all associated data.voidcreate()final long[]delete()final voiddeleteFile(long fileId) final voiddeleteFile(long fileId, OWriteCache writeCache) final voiddeleteStorage(OWriteCache writeCache) final booleanexists(long fileId) final booleanfinal longexternalFileId(int fileId) Converts unique internal file id to external one.final longfileIdByName(String fileName) Returns id associated with given file or value < 0 if such file does not exist.final booleanfileIdsAreEqual(long firsId, long secondId) DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGEfinal StringfileNameById(long fileId) files()final voidflush()final voidflush(long fileId) final voidflushTillSegment(long segmentId) final longfinal longgetFilledUpTo(long fileId) final intgetId()final Longfinal PathDirectory which contains all files managed by write cache.final longfinal 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.final OCachePointerload(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) final longRegisters new file in write cache and returns file id assigned to this file.final OCacheEntryloadForRead(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums) final OCacheEntryloadForWrite(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums, OLogSequenceNumber startLSN) final StringnativeFileNameById(long fileId) Obtains native file name by the given file id.voidopen()final intpageSize()DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGEfinal voidreleaseFromRead(OCacheEntry cacheEntry) final voidreleaseFromWrite(OCacheEntry cacheEntry, OWriteCache writeCache, boolean changed) final voidRemoves listener which is triggered if exception is cast inside background flush data thread.final voidNot implemented because has no sensefinal voidrenameFile(long fileId, String newFileName) voidreplaceFileId(long fileId, long newFileId) final StringrestoreFileById(long fileId) Finds if there was file in write cache with given id which is deleted right now.voidvoidsilentLoadForRead(long extFileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums) final voidstore(long fileId, long pageIndex, OCachePointer dataPointer) final voidsyncDataFiles(long segmentId, byte[] lastMetadata) final voidtruncateFile(long fileId) final voidtruncateFile(long fileId, OWriteCache writeCache) final voidupdateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN) Methods inherited from class com.orientechnologies.orient.core.storage.cache.OAbstractWriteCache
checkFileIdCompatibility, composeFileId, extractFileId, extractStorageId
-
Method Details
-
getRootDirectory
Directory which contains all files managed by write cache.- Specified by:
getRootDirectoryin interfaceOWriteCache- Returns:
- Directory which contains all files managed by write cache or
nullin case of in memory database.
-
addFile
- Specified by:
addFilein interfaceOReadCache
-
fileIdByName
Description copied from interface:OWriteCacheReturns id associated with given file or value < 0 if such file does not exist.- Specified by:
fileIdByNamein interfaceOWriteCache- 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.
-
internalFileId
public final int internalFileId(long fileId) Description copied from interface:OWriteCacheReturns 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.- Specified by:
internalFileIdin interfaceOWriteCache- Parameters:
fileId- External file id.- Returns:
- Internal file id.
-
externalFileId
public final long externalFileId(int fileId) Description copied from interface:OWriteCacheConverts 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.- Specified by:
externalFileIdin interfaceOWriteCache- Parameters:
fileId- Internal file id.- Returns:
- External file id.
- See Also:
-
bookFileId
- Specified by:
bookFileIdin interfaceOWriteCache
-
addBackgroundExceptionListener
Description copied from interface:OWriteCacheAdds listener which is triggered if exception is cast inside background flush data thread.- Specified by:
addBackgroundExceptionListenerin interfaceOWriteCache- Parameters:
listener- Listener to trigger
-
removeBackgroundExceptionListener
Description copied from interface:OWriteCacheRemoves listener which is triggered if exception is cast inside background flush data thread.- Specified by:
removeBackgroundExceptionListenerin interfaceOWriteCache- Parameters:
listener- Listener to remove
-
checkCacheOverflow
public final void checkCacheOverflow()- Specified by:
checkCacheOverflowin interfaceOWriteCache
-
addFile
- Specified by:
addFilein interfaceOReadCache
-
loadForWrite
public final OCacheEntry loadForWrite(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums, OLogSequenceNumber startLSN) - Specified by:
loadForWritein interfaceOReadCache
-
loadForRead
public final OCacheEntry loadForRead(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums) - Specified by:
loadForReadin interfaceOReadCache
-
silentLoadForRead
public OCacheEntry silentLoadForRead(long extFileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums) - Specified by:
silentLoadForReadin interfaceOReadCache
-
allocateNewPage
public final OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN) - Specified by:
allocateNewPagein interfaceOReadCache
-
allocateNewPage
public int allocateNewPage(long fileId) - Specified by:
allocateNewPagein interfaceOWriteCache
-
releaseFromWrite
- Specified by:
releaseFromWritein interfaceOReadCache
-
releaseFromRead
- Specified by:
releaseFromReadin interfaceOReadCache
-
getFilledUpTo
public final long getFilledUpTo(long fileId) - Specified by:
getFilledUpToin interfaceOWriteCache
-
flush
public final void flush(long fileId) - Specified by:
flushin interfaceOWriteCache
-
close
public final void close(long fileId, boolean flush) - Specified by:
closein interfaceOWriteCache
-
deleteFile
public final void deleteFile(long fileId) - Specified by:
deleteFilein interfaceOWriteCache
-
renameFile
- Specified by:
renameFilein interfaceOWriteCache
-
truncateFile
public final void truncateFile(long fileId) - Specified by:
truncateFilein interfaceOWriteCache
-
flush
public final void flush()- Specified by:
flushin interfaceOWriteCache
-
close
public final long[] close()- Specified by:
closein interfaceOWriteCache
-
clear
public final void clear()- Specified by:
clearin interfaceOReadCache
-
delete
public final long[] delete()- Specified by:
deletein interfaceOWriteCache
-
replaceFileId
- Specified by:
replaceFileIdin interfaceOWriteCache- Throws:
IOException
-
deleteStorage
- Specified by:
deleteStoragein interfaceOReadCache
-
closeStorage
Closes all files inside of write cache and flushes all associated data.- Specified by:
closeStoragein interfaceOReadCache- Parameters:
writeCache- Write cache to close.
-
changeMaximumAmountOfMemory
public void changeMaximumAmountOfMemory(long calculateReadCacheMaxMemory) - Specified by:
changeMaximumAmountOfMemoryin interfaceOReadCache
-
checkStoredPages
public final OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener) - Specified by:
checkStoredPagesin interfaceOWriteCache
-
exists
- Specified by:
existsin interfaceOWriteCache
-
exists
public final boolean exists(long fileId) - Specified by:
existsin interfaceOWriteCache
-
restoreModeOn
public void restoreModeOn()- Specified by:
restoreModeOnin interfaceOWriteCache
-
restoreModeOff
public void restoreModeOff()- Specified by:
restoreModeOffin interfaceOWriteCache
-
fileNameById
- Specified by:
fileNameByIdin interfaceOWriteCache
-
nativeFileNameById
Description copied from interface:OWriteCacheObtains 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.
- Specified by:
nativeFileNameByIdin interfaceOWriteCache- 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.
-
getUsedMemory
public final long getUsedMemory()- Specified by:
getUsedMemoryin interfaceOReadCache
-
checkLowDiskSpace
public final boolean checkLowDiskSpace()- Specified by:
checkLowDiskSpacein interfaceOWriteCache
-
addPageIsBrokenListener
Not implemented because has no sense- Specified by:
addPageIsBrokenListenerin interfaceOWriteCache
-
removePageIsBrokenListener
Not implemented because has no sense- Specified by:
removePageIsBrokenListenerin interfaceOWriteCache
-
loadFile
Description copied from interface:OWriteCacheRegisters 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
OWriteCache.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.
- Specified by:
loadFilein interfaceOWriteCache- Parameters:
fileName- Name of file to register inside storage.- Returns:
- Id of registered file
- Internal id is permanent and can not be changed during life of storage
-
addFile
- Specified by:
addFilein interfaceOWriteCache
-
addFile
- Specified by:
addFilein interfaceOWriteCache
-
store
- Specified by:
storein interfaceOWriteCache
-
syncDataFiles
public final void syncDataFiles(long segmentId, byte[] lastMetadata) - Specified by:
syncDataFilesin interfaceOWriteCache
-
flushTillSegment
public final void flushTillSegment(long segmentId) - Specified by:
flushTillSegmentin interfaceOWriteCache
-
getMinimalNotFlushedSegment
- Specified by:
getMinimalNotFlushedSegmentin interfaceOWriteCache
-
updateDirtyPagesTable
- Specified by:
updateDirtyPagesTablein interfaceOWriteCache
-
create
public void create()- Specified by:
createin interfaceOWriteCache
-
open
public void open()- Specified by:
openin interfaceOWriteCache
-
load
public final OCachePointer load(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) - Specified by:
loadin interfaceOWriteCache
-
getExclusiveWriteCachePagesSize
public final long getExclusiveWriteCachePagesSize()- Specified by:
getExclusiveWriteCachePagesSizein interfaceOWriteCache
-
truncateFile
- Specified by:
truncateFilein interfaceOReadCache
-
getId
public final int getId()- Specified by:
getIdin interfaceOWriteCache
-
files
- Specified by:
filesin interfaceOWriteCache
-
pageSize
public final int pageSize()Description copied from interface:OWriteCacheDO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE- Specified by:
pageSizein interfaceOWriteCache- Returns:
- Size of page inside of cache.
-
fileIdsAreEqual
public final boolean fileIdsAreEqual(long firsId, long secondId) Description copied from interface:OWriteCacheDO 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.
- Specified by:
fileIdsAreEqualin interfaceOWriteCache
-
restoreFileById
Description copied from interface:OWriteCacheFinds 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.- Specified by:
restoreFileByIdin interfaceOWriteCache- Parameters:
fileId- If of file which should be restored- Returns:
- Name of restored file or
nullif such name does not exist
-
closeFile
- Specified by:
closeFilein interfaceOReadCache
-
deleteFile
- Specified by:
deleteFilein interfaceOReadCache
-