Interface OWriteCache

All Known Implementing Classes:
ODirectMemoryOnlyDiskCache, OWOWCache

public interface OWriteCache
  • Method Details

    • addPageIsBrokenListener

      void addPageIsBrokenListener(OPageIsBrokenListener listener)
      Adds listener which is called by cache if corruption of file page is detected.
    • removePageIsBrokenListener

      void removePageIsBrokenListener(OPageIsBrokenListener listener)
      Removes listener which is called by cache if corruption of file page is detected.
    • bookFileId

      long bookFileId(String fileName)
    • loadFile

      long loadFile(String fileName) throws IOException
      Registers new file in write cache and returns file id assigned to this file.

      File id consist of two parts:

      1. Internal id is permanent and can not be changed during life of storage internalFileId(long)
      2. 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
    • addFile

      long addFile(String fileName) throws IOException
      Throws:
      IOException
    • addFile

      long addFile(String fileName, long fileId) throws IOException
      Throws:
      IOException
    • fileIdByName

      long fileIdByName(String fileName)
      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

      boolean checkLowDiskSpace() throws IOException
      Throws:
      IOException
    • syncDataFiles

      void syncDataFiles(long segmentId, byte[] lastMetadata) throws IOException
      Throws:
      IOException
    • flushTillSegment

      void flushTillSegment(long segmentId)
    • exists

      boolean exists(String fileName)
    • exists

      boolean exists(long fileId)
    • restoreModeOn

      void restoreModeOn() throws IOException
      Throws:
      IOException
    • restoreModeOff

      void restoreModeOff()
    • store

      void store(long fileId, long pageIndex, OCachePointer dataPointer)
    • checkCacheOverflow

      void checkCacheOverflow() throws InterruptedException
      Throws:
      InterruptedException
    • allocateNewPage

      int allocateNewPage(long fileId) throws IOException
      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

      void deleteFile(long fileId) throws IOException
      Throws:
      IOException
    • truncateFile

      void truncateFile(long fileId) throws IOException
      Throws:
      IOException
    • renameFile

      void renameFile(long fileId, String newFileName) throws IOException
      Throws:
      IOException
    • close

      long[] close() throws IOException
      Throws:
      IOException
    • close

      void close(long fileId, boolean flush)
    • checkStoredPages

      OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener)
    • delete

      long[] delete() throws IOException
      Throws:
      IOException
    • fileNameById

      String fileNameById(long fileId)
    • nativeFileNameById

      String nativeFileNameById(long fileId)
      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 null if the passed file id doesn't correspond to any file.
    • getId

      int getId()
    • files

      Map<String,Long> files()
    • pageSize

      int pageSize()
      DO NOT DELETE THIS METHOD IT IS USED IN ENTERPRISE STORAGE
      Returns:
      Size of page inside of cache.
    • restoreFileById

      String restoreFileById(long fileId) throws IOException
      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 null if such name does not exist
      Throws:
      IOException
    • addBackgroundExceptionListener

      void addBackgroundExceptionListener(OBackgroundExceptionListener listener)
      Adds listener which is triggered if exception is cast inside background flush data thread.
      Parameters:
      listener - Listener to trigger
    • removeBackgroundExceptionListener

      void removeBackgroundExceptionListener(OBackgroundExceptionListener listener)
      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 null in 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 STORAGE

      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.

    • getMinimalNotFlushedSegment

      Long getMinimalNotFlushedSegment()
    • updateDirtyPagesTable

      void updateDirtyPagesTable(OCachePointer pointer, OLogSequenceNumber startLSN)
    • create

      void create() throws IOException
      Throws:
      IOException
    • open

      void open() throws IOException
      Throws:
      IOException
    • replaceFileId

      void replaceFileId(long fileId, long newFileId) throws IOException
      Throws:
      IOException