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 byte
ADD_DOCUMENT_FRAME
protected static byte
ADD_MESSAGE_FRAME
static int
DEFAULT_MAX_RETRIES
static long
DEFAULT_RETRY_WAIT
protected static byte
DEL_DOCUMENT_FRAME
protected static byte
DEL_QUERY_FRAME
protected AttivioLogger
log
-
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 void
addDocument(byte[] id, IngestDocument doc)
Add a document update to the transaction log.void
addDocument(IngestDocument doc)
Add a document update to the transaction log.void
addMessage(PlatformMessage msg)
Add aPlatformMessage
to the transaction log.void
cancelRecovery()
void
checkpoint(long flushId)
Delete all transaction logs older than (but not including)flushId
long
checkpointId()
void
checkpointSpecific(long checkpoint)
Deletes a set of checkpoint files given a set of checkpoint ids.void
close()
void
deleteByQuery(Query query)
Add a query deletion to the transaction log.void
deleteDocument(byte[] id)
Add a document deletion to the transaction log.void
deleteDocument(java.lang.String id)
Add a document deletion to the transaction log.TransactionStorage
getStorage()
long
initialize()
Initialize any saved checkpoints.<T extends TransactionReceiver>
Tinitialize(T receiver)
Initialize and replay transaction log.long
prepareCheckpoint()
Close current traction log.long
prepareCheckpoint(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
.int
recoverableCheckpoints()
void
truncate()
protected void
writeFrame(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.IOException
Add a document update to the transaction log.- Throws:
java.io.IOException
-
deleteDocument
public void deleteDocument(java.lang.String id) throws java.io.IOException
Add a document deletion to the transaction log.- Throws:
java.io.IOException
-
deleteDocument
public void deleteDocument(byte[] id) throws java.io.IOException
Add 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 aPlatformMessage
to 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.IOException
Delete all transaction logs older than (but not including)flushId
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
initialize
public long initialize() throws java.io.IOException
Initialize 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
-
-