Package com.attivio.util.ft
Class TransactionLog
- java.lang.Object
-
- com.attivio.util.ft.TransactionLog
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class TransactionLog extends java.lang.Object implements java.io.Closeable
-
-
Field Summary
Fields Modifier and Type Field Description protected static byteADD_DOCUMENT_FRAMEprotected static byteADD_MESSAGE_FRAMEstatic intDEFAULT_MAX_RETRIESstatic longDEFAULT_RETRY_WAITprotected static byteDEL_DOCUMENT_FRAMEprotected static byteDEL_QUERY_FRAMEprotected AttivioLoggerlog
-
Constructor Summary
Constructors Constructor Description TransactionLog(TransactionStorage store, java.lang.String baseName)TransactionLog(TransactionStorage store, java.lang.String baseName, int maxRetries, long retryWait)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocument(byte[] id, IngestDocument doc)Add a document update to the transaction log.voidaddDocument(IngestDocument doc)Add a document update to the transaction log.voidaddMessage(PlatformMessage msg)Add aPlatformMessageto the transaction log.voidcancelRecovery()voidcheckpoint(long flushId)Delete all transaction logs older than (but not including)flushIdlongcheckpointId()voidcheckpointSpecific(long checkpoint)Deletes a set of checkpoint files given a set of checkpoint ids.voidclose()voiddeleteByQuery(Query query)Add a query deletion to the transaction log.voiddeleteDocument(byte[] id)Add a document deletion to the transaction log.voiddeleteDocument(java.lang.String id)Add a document deletion to the transaction log.TransactionStoragegetStorage()longinitialize()Initialize any saved checkpoints.<T extends TransactionReceiver>
Tinitialize(T receiver)Initialize and replay transaction log.longprepareCheckpoint()Close current traction log.longprepareCheckpoint(long maxSize)Flush the transaction log to stable storage, optionally closing the current checkpoint if the log exceedsmaxSize.<T extends TransactionReceiver>
Trecover(T receiver)Replay the transaction log, passing events toreceiver.intrecoverableCheckpoints()voidtruncate()protected voidwriteFrame(TransactionStorage.FrameOutputStream frame)
-
-
-
Field Detail
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIES
- See Also:
- Constant Field Values
-
DEFAULT_RETRY_WAIT
public static final long DEFAULT_RETRY_WAIT
- See Also:
- Constant Field Values
-
log
protected final AttivioLogger log
-
ADD_DOCUMENT_FRAME
protected static final byte ADD_DOCUMENT_FRAME
- See Also:
- Constant Field Values
-
DEL_DOCUMENT_FRAME
protected static final byte DEL_DOCUMENT_FRAME
- See Also:
- Constant Field Values
-
DEL_QUERY_FRAME
protected static final byte DEL_QUERY_FRAME
- See Also:
- Constant Field Values
-
ADD_MESSAGE_FRAME
protected static final byte ADD_MESSAGE_FRAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TransactionLog
public TransactionLog(TransactionStorage store, java.lang.String baseName)
-
TransactionLog
public TransactionLog(TransactionStorage store, java.lang.String baseName, int maxRetries, long retryWait)
-
-
Method Detail
-
checkpointId
public long checkpointId()
-
getStorage
public TransactionStorage getStorage()
-
writeFrame
protected void writeFrame(TransactionStorage.FrameOutputStream frame) throws java.io.IOException
- Throws:
java.io.IOException
-
addDocument
public void addDocument(IngestDocument doc) throws java.io.IOException
Add a document update to the transaction log.- Throws:
java.io.IOException
-
addDocument
public void addDocument(byte[] id, IngestDocument doc) throws java.io.IOExceptionAdd a document update to the transaction log.- Throws:
java.io.IOException
-
deleteDocument
public void deleteDocument(java.lang.String id) throws java.io.IOExceptionAdd a document deletion to the transaction log.- Throws:
java.io.IOException
-
deleteDocument
public void deleteDocument(byte[] id) throws java.io.IOExceptionAdd a document deletion to the transaction log.- Throws:
java.io.IOException
-
deleteByQuery
public void deleteByQuery(Query query) throws java.io.IOException
Add a query deletion to the transaction log.- Throws:
java.io.IOException
-
addMessage
public void addMessage(PlatformMessage msg) throws java.io.IOException
Add aPlatformMessageto the transaction log.- Throws:
java.io.IOException
-
prepareCheckpoint
public long prepareCheckpoint(long maxSize)
Flush the transaction log to stable storage, optionally closing the current checkpoint if the log exceedsmaxSize.
-
prepareCheckpoint
public long prepareCheckpoint()
Close current traction log.
-
checkpointSpecific
public void checkpointSpecific(long checkpoint)
Deletes a set of checkpoint files given a set of checkpoint ids.Note that this traverses backwards through the checkpoint list and thus is optimized for recent checkpoints
-
recoverableCheckpoints
public int recoverableCheckpoints()
-
truncate
public void truncate() throws java.io.IOException- Throws:
java.io.IOException
-
checkpoint
public void checkpoint(long flushId) throws java.io.IOExceptionDelete all transaction logs older than (but not including)flushId- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
initialize
public long initialize() throws java.io.IOExceptionInitialize any saved checkpoints.- Throws:
java.io.IOException
-
initialize
public <T extends TransactionReceiver> T initialize(T receiver) throws java.io.IOException
Initialize and replay transaction log.- Throws:
java.io.IOException
-
cancelRecovery
public void cancelRecovery()
-
recover
public <T extends TransactionReceiver> T recover(T receiver) throws java.io.IOException
Replay the transaction log, passing events toreceiver.- Throws:
java.io.IOException
-
-