Class FallbackPersistenceBackend

java.lang.Object
org.gcube.documentstore.persistence.PersistenceBackend
org.gcube.documentstore.persistence.FallbackPersistenceBackend

public class FallbackPersistenceBackend extends PersistenceBackend
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Details

    • FallbackPersistenceBackend

      protected FallbackPersistenceBackend(File fallbackFile)
  • Method Details

    • getFallbackFile

      protected File getFallbackFile()
      Returns:
      the fallbackFile
    • getOldFallbackFile

      @Deprecated protected File getOldFallbackFile()
      Deprecated.
    • moveFallbackFile

      protected File moveFallbackFile(String suffix)
      Move the fallbackFile to a new file with the same name by appending a suffix
      Parameters:
      suffix -
      Returns:
      the moved file if any, null otherwise
    • flushToFallback

      protected void flushToFallback() throws Exception
      This backend is the fallback file itself: its buffered records are written to it.
      Overrides:
      flushToFallback in class PersistenceBackend
      Throws:
      Exception - if the records cannot be written
    • prepareConnection

      public void prepareConnection(PersistenceBackendConfiguration configuration)
      Prepare the connection to persistence. This method must be used by implementation class to prepare the connection with the persistence storage, DB, file etc.
      Specified by:
      prepareConnection in class PersistenceBackend
      Parameters:
      configuration - The configuration to create the connection
    • openConnection

      protected void openConnection() throws Exception
      Description copied from class: PersistenceBackend
      This method is used to open db connection
      Specified by:
      openConnection in class PersistenceBackend
      Throws:
      Exception
    • close

      public void close() throws Exception
      This method is used to close
      Overrides:
      close in class PersistenceBackend
      Throws:
      Exception
    • accountWithFallback

      protected void accountWithFallback(Record... records) throws Exception
      Overrides:
      accountWithFallback in class PersistenceBackend
      Throws:
      Exception
    • reallyAccount

      protected void reallyAccount(Record record)
      This method contains the code to save the Record
      Specified by:
      reallyAccount in class PersistenceBackend
    • printLine

      protected void printLine(String line) throws Exception
      This method is synchronized on the lock of the fallback file path. Any action which modifies, renames or deletes the file must be synchronized on the same lock. This is intended for internal library usage only so that is protected.
      Throws:
      Exception
    • closeConnection

      protected void closeConnection() throws Exception
      Description copied from class: PersistenceBackend
      This method is used to close db connection
      Specified by:
      closeConnection in class PersistenceBackend
      Throws:
      Exception
    • isConnectionActive

      public boolean isConnectionActive() throws Exception
      Description copied from class: PersistenceBackend
      Check the Connection state
      Specified by:
      isConnectionActive in class PersistenceBackend
      Returns:
      true if the connection is active, false otherwise
      Throws:
      Exception
    • clean

      protected void clean() throws Exception
      Description copied from class: PersistenceBackend
      This method is used to allow PersistenceBackend implementations to clean a global status if any (or to renew it) when to much exceptions occurs trying to persist Records.
      Specified by:
      clean in class PersistenceBackend
      Throws:
      Exception