Package com.semedy.reasoner.core
Class TransactionLogHandler
java.lang.Object
com.semedy.reasoner.core.TransactionLogHandler
Handles all for transaction logs
- Author:
- angele
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Close transaction logstatic File
createChangeLog
(Set<String> predicates, String logdir) open write phase in a transaction.static void
close write phase in a transaction Predicate file is deleted fstatic void
deleteChangeLogs
(String logdir) delete all change log files in logging dirstatic void
deleteCorruptedIndices
(List<String> corrupted) Try to repair predicates from changeLog.static void
deleteTransactionLogs
(String logDir) delete the transaction log filesgetCorruptedEntries
(String logdir) return all possible corrupted predicatesgetCorruptedIndices
(List<String> corrupted) return file paths with corrupted indicesgetCorruptedPredicates
(List<String> corrupted) returns corrupted predicatesstatic PrintWriter
openTransactionLog
(String predicate, boolean delete, String logdir) Open transaction log for predicatereadLockFile
(String logdir) read the lock file and log an error message if it is found.static void
removeLockFile
(String logdir) remove lock file during shut downstatic void
replayTransactionLogs
(String logdir, ExtensionalDB edb, SymbolTable symbols, ExternalDataTypeProvider datatypes) Search for corrupted predicates in logdir and
Replay corresponding transaction log into edb relations.static void
replayTransactionLogs
(List<String> predicates, String logdir, ExtensionalDB edb, SymbolTable symbols, ExternalDataTypeProvider externalDataTypes) Replay transaction files of predicates.static void
setWriteRead
(boolean b) static void
writeLockFile
(String logdir) write a shut down file into edb directory.static void
writeToTransactionLog
(PrintWriter print, Object[] terms, int mode) Write a tuple to transaction log
-
Constructor Details
-
TransactionLogHandler
public TransactionLogHandler()
-
-
Method Details
-
setWriteRead
public static void setWriteRead(boolean b) -
writeLockFile
write a shut down file into edb directory.
This indicates whether sem.reasoner has been shutted down correctly.- Parameters:
logdir
-- Throws:
IOException
-
getCorruptedEntries
return all possible corrupted predicates- Parameters:
logdir
-- Returns:
- Throws:
IOException
-
deleteChangeLogs
delete all change log files in logging dir- Parameters:
logdir
-
-
deleteCorruptedIndices
Try to repair predicates from changeLog.
Currently the indices are deleted only- Parameters:
corrupted
-
-
getCorruptedIndices
return file paths with corrupted indices- Parameters:
corrupted
- , entries from readShutdownFile- Returns:
-
getCorruptedPredicates
returns corrupted predicates- Parameters:
corrupted
- , entries from readShutdownFile- Returns:
-
readLockFile
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
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
open write phase in a transaction.
All to be modified predicate names are written to a file- Parameters:
predicates
-logdir
-- Returns:
- Throws:
IOException
-
deleteTransactionLogs
delete the transaction log files- Parameters:
logDir
-
-
deleteChangeLog
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
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 areedb
- , extensional databasesymbols
- , symbol tabledatatypes
- , 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
-