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,
boolean useNativeOsAPI) |
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 |
addLowDiskSpaceListener(OLowDiskSpaceListener listener) |
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 |
getCacheOverflowCount() |
long |
getExclusiveWriteCachePagesSize() |
long |
getExclusiveWriteCacheSize() |
long |
getFilledUpTo(long fileId) |
int |
getId() |
Long |
getMinimalNotFlushedSegment() |
Path |
getRootDirectory()
Directory which contains all files managed by write cache.
|
long |
getWriteCacheSize() |
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.
|
void |
makeFuzzyCheckpoint(long segmentId,
byte[] lastMetadata) |
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 |
removeLowDiskSpaceListener(OLowDiskSpaceListener listener) |
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 |
truncateFile(long fileId) |
void |
updateDirtyPagesTable(OCachePointer pointer,
OLogSequenceNumber startLSN) |
checkFileIdCompatibility, composeFileId, extractFileId, extractStorageId
public 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, boolean useNativeOsAPI)
public void loadRegisteredFiles() throws IOException, InterruptedException
IOException
InterruptedException
public void addBackgroundExceptionListener(OBackgroundExceptionListener listener)
addBackgroundExceptionListener
in interface OWriteCache
listener
- Listener to triggerpublic void removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
removeBackgroundExceptionListener
in interface OWriteCache
listener
- Listener to removepublic Path getRootDirectory()
getRootDirectory
in interface OWriteCache
null
in case
of in memory database.public void addLowDiskSpaceListener(OLowDiskSpaceListener listener)
addLowDiskSpaceListener
in interface OWriteCache
public void addPageIsBrokenListener(OPageIsBrokenListener listener)
OWriteCache
addPageIsBrokenListener
in interface OWriteCache
public void removePageIsBrokenListener(OPageIsBrokenListener listener)
OWriteCache
removePageIsBrokenListener
in interface OWriteCache
public void removeLowDiskSpaceListener(OLowDiskSpaceListener listener)
removeLowDiskSpaceListener
in interface OWriteCache
public long bookFileId(String fileName)
bookFileId
in interface OWriteCache
public int pageSize()
OWriteCache
pageSize
in interface OWriteCache
public 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 long loadFile(String fileName) throws IOException
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.IOException
public long addFile(String fileName) throws IOException
addFile
in interface OWriteCache
IOException
public long fileIdByName(String fileName)
OWriteCache
fileIdByName
in interface OWriteCache
fileName
- File name id of which has to be returned.public int internalFileId(long fileId)
OWriteCache
internalFileId
in interface OWriteCache
fileId
- External file id.public long externalFileId(int fileId)
OWriteCache
externalFileId
in interface OWriteCache
fileId
- Internal file id.OWriteCache.internalFileId(long)
,
OWriteCache.getId()
public Long getMinimalNotFlushedSegment()
getMinimalNotFlushedSegment
in interface OWriteCache
public void updateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN)
updateDirtyPagesTable
in interface OWriteCache
public void create()
create
in interface OWriteCache
public void open()
open
in interface OWriteCache
public long addFile(String fileName, long fileId) throws IOException
addFile
in interface OWriteCache
IOException
public boolean checkLowDiskSpace() throws IOException
checkLowDiskSpace
in interface OWriteCache
IOException
public void makeFuzzyCheckpoint(long segmentId, byte[] lastMetadata) throws IOException
makeFuzzyCheckpoint
in interface OWriteCache
IOException
public void flushTillSegment(long segmentId)
flushTillSegment
in interface OWriteCache
public boolean exists(String fileName)
exists
in interface OWriteCache
public boolean exists(long fileId)
exists
in interface OWriteCache
public void restoreModeOn() throws IOException
restoreModeOn
in interface OWriteCache
IOException
public void restoreModeOff()
restoreModeOff
in interface OWriteCache
public void checkCacheOverflow() throws InterruptedException
checkCacheOverflow
in interface OWriteCache
InterruptedException
public void store(long fileId, long pageIndex, OCachePointer dataPointer)
store
in interface OWriteCache
public Map<String,Long> files()
files
in interface OWriteCache
public OCachePointer load(long fileId, long startPageIndex, OModifiableBoolean cacheHit, boolean verifyChecksums) throws IOException
load
in interface OWriteCache
IOException
public int allocateNewPage(long fileId) throws IOException
allocateNewPage
in interface OWriteCache
IOException
public void addOnlyWriters(long fileId, long pageIndex)
addOnlyWriters
in interface OCachePointer.WritersListener
public void removeOnlyWriters(long fileId, long pageIndex)
removeOnlyWriters
in interface OCachePointer.WritersListener
public void flush(long fileId)
flush
in interface OWriteCache
public void flush()
flush
in interface OWriteCache
public long getFilledUpTo(long fileId)
getFilledUpTo
in interface OWriteCache
public long getExclusiveWriteCachePagesSize()
getExclusiveWriteCachePagesSize
in interface OWriteCache
public void deleteFile(long fileId) throws IOException
deleteFile
in interface OWriteCache
IOException
public void truncateFile(long fileId) throws IOException
truncateFile
in interface OWriteCache
IOException
public void renameFile(long fileId, String newFileName) throws IOException
renameFile
in interface OWriteCache
IOException
public long[] close() throws IOException
close
in interface OWriteCache
IOException
public void close(long fileId, boolean flush)
close
in interface OWriteCache
public String restoreFileById(long fileId) throws IOException
OWriteCache
restoreFileById
in interface OWriteCache
fileId
- If of file which should be restorednull
if such name does not existIOException
public OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener)
checkStoredPages
in interface OWriteCache
public long[] delete() throws IOException
delete
in interface OWriteCache
IOException
public String fileNameById(long fileId)
fileNameById
in interface OWriteCache
public 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 int getId()
getId
in interface OWriteCache
public long getCacheOverflowCount()
public long getWriteCacheSize()
public long getExclusiveWriteCacheSize()
public void setChecksumMode(OChecksumMode checksumMode)
Copyright © 2009–2020 OrientDB. All rights reserved.