Class TransactionLogHandler

java.lang.Object
com.semedy.reasoner.core.TransactionLogHandler

public class TransactionLogHandler extends Object
Handles all for transaction logs
Author:
angele
  • Constructor Details

    • TransactionLogHandler

      public TransactionLogHandler()
  • Method Details

    • setWriteRead

      public static void setWriteRead(boolean b)
    • writeLockFile

      public static void writeLockFile(String logdir) throws IOException
      write a shut down file into edb directory.
      This indicates whether sem.reasoner has been shutted down correctly.
      Parameters:
      logdir -
      Throws:
      IOException
    • getCorruptedEntries

      public static List<String> getCorruptedEntries(String logdir) throws IOException
      return all possible corrupted predicates
      Parameters:
      logdir -
      Returns:
      Throws:
      IOException
    • deleteChangeLogs

      public static void deleteChangeLogs(String logdir)
      delete all change log files in logging dir
      Parameters:
      logdir -
    • deleteCorruptedIndices

      public static void deleteCorruptedIndices(List<String> corrupted)
      Try to repair predicates from changeLog.
      Currently the indices are deleted only
      Parameters:
      corrupted -
    • getCorruptedIndices

      public static List<String> getCorruptedIndices(List<String> corrupted)
      return file paths with corrupted indices
      Parameters:
      corrupted - , entries from readShutdownFile
      Returns:
    • getCorruptedPredicates

      public static List<String> getCorruptedPredicates(List<String> corrupted)
      returns corrupted predicates
      Parameters:
      corrupted - , entries from readShutdownFile
      Returns:
    • readLockFile

      public static List<String> readLockFile(String logdir) throws IOException
      read the lock file and log an error message if it is found.
      In addition all possibly corrupted predicates are logged
      Parameters:
      logdir -
      Throws:
      IOException
    • removeLockFile

      public static void removeLockFile(String logdir)
      remove lock file during shut down
      Parameters:
      logdir -
    • openTransactionLog

      public static PrintWriter openTransactionLog(String predicate, boolean delete, String logdir) throws IOException
      Open transaction log for predicate
      Parameters:
      predicate -
      delete -
      logdir -
      Returns:
      Throws:
      IOException
    • createChangeLog

      public static File createChangeLog(Set<String> predicates, String logdir) throws IOException
      open write phase in a transaction.
      All to be modified predicate names are written to a file
      Parameters:
      predicates -
      logdir -
      Returns:
      Throws:
      IOException
    • deleteTransactionLogs

      public static void deleteTransactionLogs(String logDir)
      delete the transaction log files
      Parameters:
      logDir -
    • deleteChangeLog

      public static void deleteChangeLog(File f)
      close write phase in a transaction Predicate file is deleted f
      Parameters:
      f -
    • writeToTransactionLog

      public static void writeToTransactionLog(PrintWriter print, Object[] terms, int mode) throws IOException
      Write a tuple to transaction log
      Parameters:
      out -
      buf -
      mode -
      Throws:
      IOException
    • closeTransactionLog

      public static void closeTransactionLog(TupleFile out) throws IOException
      Close transaction log
      Parameters:
      out -
      Throws:
      IOException
    • replayTransactionLogs

      public static void replayTransactionLogs(String logdir, ExtensionalDB edb, SymbolTable symbols, ExternalDataTypeProvider datatypes) throws IOException, SemReasonerException
      Search for corrupted predicates in logdir and
      Replay corresponding transaction log into edb relations.
      edb must be in a consistent state, either empty, restored, etc.
      Parameters:
      logdir - , the directory where the log files are
      edb - , extensional database
      symbols - , symbol table
      datatypes - , external data types
      Throws:
      IOException
      SemReasonerException
    • replayTransactionLogs

      public static void replayTransactionLogs(List<String> predicates, String logdir, ExtensionalDB edb, SymbolTable symbols, ExternalDataTypeProvider externalDataTypes) throws IOException, SemReasonerException
      Replay transaction files of predicates.
      edb must be in a consistent state, either empty, restored, etc.
      Parameters:
      predicates -
      logdir -
      edb -
      symbols -
      externalDataTypes -
      Throws:
      IOException
      SemReasonerException