|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TransactionLogger
Typically adding a command, the following pattern would be used:
if (txLogger.logIfNeeded(cmd)) {
// do NOT proceed with executing this command!
} else {
// proceed with executing this command as per normal!
}
When draining, the following pattern should be used:
List<WriteCommand> c = null;
while (txLogger.shouldDrainWithoutLock()) {
c = txLogger.drain();
applyCommands(c);
}
c = txLogger.drainAndLock();
applyCommands(c);
applyPendingPrepares(txLogger.getPendingPrepares());
txLogger.unlockAndDisable();
Method Summary | |
---|---|
List<WriteCommand> |
drain()
Drains the transaction log and returns a list of what has been drained. |
List<WriteCommand> |
drainAndLock()
Similar to drain() except that relevant locks are acquired so that no more commands are added to the
transaction log during this process, and transaction logging is disabled after draining. |
void |
enable()
Enables transaction logging |
Collection<PrepareCommand> |
getPendingPrepares()
Drains pending prepares. |
boolean |
isEnabled()
Checks whether transaction logging is enabled |
boolean |
logIfNeeded(Collection<WriteCommand> commands)
If logging is enabled, will log the commands and return true. |
void |
logIfNeeded(CommitCommand command)
Logs a CommitCommand if needed. |
void |
logIfNeeded(PrepareCommand command)
Logs a PrepareCommand if needed. |
void |
logIfNeeded(RollbackCommand command)
Logs a RollbackCommand if needed. |
boolean |
logIfNeeded(WriteCommand command)
If logging is enabled, will log the command and return true. |
boolean |
shouldDrainWithoutLock()
Tests whether the drain() method can be called without a lock. |
void |
unlockAndDisable()
Unlocks and disables the transaction logger. |
Method Detail |
---|
void enable()
List<WriteCommand> drain()
List<WriteCommand> drainAndLock()
drain()
except that relevant locks are acquired so that no more commands are added to the
transaction log during this process, and transaction logging is disabled after draining.
void unlockAndDisable()
drainAndLock()
.
boolean logIfNeeded(WriteCommand command)
command
- command to log
void logIfNeeded(PrepareCommand command)
command
- PrepoareCommand to logvoid logIfNeeded(CommitCommand command)
command
- CommitCommand to logvoid logIfNeeded(RollbackCommand command)
command
- RollbackCommand to logboolean logIfNeeded(Collection<WriteCommand> commands)
commands
- commands to log
boolean isEnabled()
boolean shouldDrainWithoutLock()
Collection<PrepareCommand> getPendingPrepares()
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |