
public final class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCachePointer.WritersListener
| Modifier and Type | Field and Description |
|---|---|
static int |
CHECKSUM_OFFSET |
static long |
MAGIC_NUMBER_WITH_CHECKSUM
Marks pages which have a checksum stored.
|
static long |
MAGIC_NUMBER_WITH_CHECKSUM_ENCRYPTED
Marks pages which have a checksum stored and data encrypted
|
| Constructor and Description |
|---|
OWOWCache(int pageSize,
OByteBufferPool bufferPool,
OWriteAheadLog writeAheadLog,
DoubleWriteLog doubleWriteLog,
long pagesFlushInterval,
int shutdownTimeout,
long exclusiveWriteCacheMaxSize,
Path storagePath,
String storageName,
OBinarySerializer<String> stringSerializer,
OClosableLinkedContainer<Long,OFile> files,
int id,
OChecksumMode checksumMode,
byte[] iv,
byte[] aesKey,
boolean callFsync) |
| 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) |
void |
addOnlyWriters(long fileId,
long pageIndex) |
void |
addPageIsBrokenListener(OPageIsBrokenListener listener)
Adds listener which is called by cache if corruption of file page is detected.
|
int |
allocateNewPage(long fileId) |
long |
bookFileId(String fileName) |
void |
checkCacheOverflow() |
boolean |
checkLowDiskSpace() |
OPageDataVerificationError[] |
checkStoredPages(OCommandOutputListener commandOutputListener) |
long[] |
close() |
void |
close(long fileId,
boolean flush) |
void |
create() |
long[] |
delete() |
void |
deleteFile(long fileId) |
boolean |
exists(long fileId) |
boolean |
exists(String fileName) |
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
|
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.
|
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,
OModifiableBoolean cacheHit,
boolean verifyChecksums) |
long |
loadFile(String fileName)
Registers new file in write cache and returns file id assigned to this file.
|
void |
loadRegisteredFiles()
Loads files already registered in storage.
|
String |
nativeFileNameById(long fileId)
Obtains native file name by the given file id.
|
void |
open() |
int |
pageSize()
DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE
|
void |
removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
Removes listener which is triggered if exception is cast inside background flush data thread.
|
void |
removeOnlyWriters(long fileId,
long pageIndex) |
void |
removePageIsBrokenListener(OPageIsBrokenListener listener)
Removes listener which is called by cache if corruption of file page is detected.
|
void |
renameFile(long fileId,
String newFileName) |
String |
restoreFileById(long fileId)
Finds if there was file in write cache with given id which is deleted right now.
|
void |
restoreModeOff() |
void |
restoreModeOn() |
void |
setChecksumMode(OChecksumMode checksumMode) |
void |
store(long fileId,
long pageIndex,
OCachePointer dataPointer) |
void |
syncDataFiles(long segmentId,
byte[] lastMetadata) |
void |
truncateFile(long fileId) |
void |
updateDirtyPagesTable(OCachePointer pointer,
OLogSequenceNumber startLSN) |
checkFileIdCompatibility, composeFileId, extractFileId, extractStorageIdpublic static final long MAGIC_NUMBER_WITH_CHECKSUM
public static final long MAGIC_NUMBER_WITH_CHECKSUM_ENCRYPTED
public static final int CHECKSUM_OFFSET
public OWOWCache(int pageSize,
OByteBufferPool bufferPool,
OWriteAheadLog writeAheadLog,
DoubleWriteLog doubleWriteLog,
long pagesFlushInterval,
int shutdownTimeout,
long exclusiveWriteCacheMaxSize,
Path storagePath,
String storageName,
OBinarySerializer<String> stringSerializer,
OClosableLinkedContainer<Long,OFile> files,
int id,
OChecksumMode checksumMode,
byte[] iv,
byte[] aesKey,
boolean callFsync)
public void loadRegisteredFiles()
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic void addBackgroundExceptionListener(OBackgroundExceptionListener listener)
addBackgroundExceptionListener in interface OWriteCachelistener - Listener to triggerpublic void removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
removeBackgroundExceptionListener in interface OWriteCachelistener - Listener to removepublic Path getRootDirectory()
getRootDirectory in interface OWriteCachenull in case
of in memory database.public void addPageIsBrokenListener(OPageIsBrokenListener listener)
OWriteCacheaddPageIsBrokenListener in interface OWriteCachepublic void removePageIsBrokenListener(OPageIsBrokenListener listener)
OWriteCacheremovePageIsBrokenListener in interface OWriteCachepublic long bookFileId(String fileName)
bookFileId in interface OWriteCachepublic int pageSize()
OWriteCachepageSize in interface OWriteCachepublic long loadFile(String fileName) throws IOException
OWriteCacheFile 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 OWriteCachefileName - Name of file to register inside storage.IOExceptionpublic long addFile(String fileName) throws IOException
addFile in interface OWriteCacheIOExceptionpublic long fileIdByName(String fileName)
OWriteCachefileIdByName in interface OWriteCachefileName - File name id of which has to be returned.public int internalFileId(long fileId)
OWriteCacheinternalFileId in interface OWriteCachefileId - External file id.public long externalFileId(int fileId)
OWriteCacheexternalFileId in interface OWriteCachefileId - Internal file id.OWriteCache.internalFileId(long),
OWriteCache.getId()public Long getMinimalNotFlushedSegment()
getMinimalNotFlushedSegment in interface OWriteCachepublic void updateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN)
updateDirtyPagesTable in interface OWriteCachepublic void create()
create in interface OWriteCachepublic void open()
open in interface OWriteCachepublic long addFile(String fileName, long fileId) throws IOException
addFile in interface OWriteCacheIOExceptionpublic boolean checkLowDiskSpace()
throws IOException
checkLowDiskSpace in interface OWriteCacheIOExceptionpublic void syncDataFiles(long segmentId,
byte[] lastMetadata)
throws IOException
syncDataFiles in interface OWriteCacheIOExceptionpublic void flushTillSegment(long segmentId)
flushTillSegment in interface OWriteCachepublic boolean exists(String fileName)
exists in interface OWriteCachepublic boolean exists(long fileId)
exists in interface OWriteCachepublic void restoreModeOn()
throws IOException
restoreModeOn in interface OWriteCacheIOExceptionpublic void restoreModeOff()
restoreModeOff in interface OWriteCachepublic void checkCacheOverflow()
throws InterruptedException
checkCacheOverflow in interface OWriteCacheInterruptedExceptionpublic void store(long fileId,
long pageIndex,
OCachePointer dataPointer)
store in interface OWriteCachepublic Map<String,Long> files()
files in interface OWriteCachepublic OCachePointer load(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) throws IOException
load in interface OWriteCacheIOExceptionpublic int allocateNewPage(long fileId)
throws IOException
allocateNewPage in interface OWriteCacheIOExceptionpublic void addOnlyWriters(long fileId,
long pageIndex)
addOnlyWriters in interface OCachePointer.WritersListenerpublic void removeOnlyWriters(long fileId,
long pageIndex)
removeOnlyWriters in interface OCachePointer.WritersListenerpublic void flush(long fileId)
flush in interface OWriteCachepublic void flush()
flush in interface OWriteCachepublic long getFilledUpTo(long fileId)
getFilledUpTo in interface OWriteCachepublic long getExclusiveWriteCachePagesSize()
getExclusiveWriteCachePagesSize in interface OWriteCachepublic void deleteFile(long fileId)
throws IOException
deleteFile in interface OWriteCacheIOExceptionpublic void truncateFile(long fileId)
throws IOException
truncateFile in interface OWriteCacheIOExceptionpublic boolean fileIdsAreEqual(long firsId,
long secondId)
OWriteCacheTakes 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 OWriteCachepublic void renameFile(long fileId,
String newFileName)
throws IOException
renameFile in interface OWriteCacheIOExceptionpublic long[] close()
throws IOException
close in interface OWriteCacheIOExceptionpublic void close(long fileId,
boolean flush)
close in interface OWriteCachepublic String restoreFileById(long fileId) throws IOException
OWriteCacherestoreFileById in interface OWriteCachefileId - If of file which should be restorednull if such name does not existIOExceptionpublic OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener)
checkStoredPages in interface OWriteCachepublic long[] delete()
throws IOException
delete in interface OWriteCacheIOExceptionpublic String fileNameById(long fileId)
fileNameById in interface OWriteCachepublic String nativeFileNameById(long fileId)
OWriteCacheNative file name is a file name of a "physical" on-disk file, it may differ from the "virtual" logical file name.
nativeFileNameById in interface OWriteCachefileId - the file id to obtain the native file name of.null if the passed file id doesn't correspond
to any file.public int getId()
getId in interface OWriteCachepublic void setChecksumMode(OChecksumMode checksumMode)
Copyright © 2009–2025 OrientDB. All rights reserved.