Class TransMonitor
- java.lang.Object
-
- org.apache.jena.dboe.transaction.TransMonitor
-
- All Implemented Interfaces:
TransactionalComponent
public class TransMonitor extends java.lang.Object implements TransactionalComponent
This class is stateless in the transaction but it records counts of everyTransactionalComponentoperations. For each operation called "ABC" there is a member field "counterABC".
-
-
Field Summary
Fields Modifier and Type Field Description java.util.concurrent.atomic.LongAddercounterAbortjava.util.concurrent.atomic.LongAddercounterAttachjava.util.concurrent.atomic.LongAddercounterBeginjava.util.concurrent.atomic.LongAddercounterCleanStartjava.util.concurrent.atomic.LongAddercounterCommitjava.util.concurrent.atomic.LongAddercounterCommitEndjava.util.concurrent.atomic.LongAddercounterCommitPreparejava.util.concurrent.atomic.LongAddercounterCompletejava.util.concurrent.atomic.LongAddercounterDetachjava.util.concurrent.atomic.LongAddercounterFinishRecoveryjava.util.concurrent.atomic.LongAddercounterGetComponentIdjava.util.concurrent.atomic.LongAddercounterPromotejava.util.concurrent.atomic.LongAddercounterRecoverjava.util.concurrent.atomic.LongAddercounterShutdownjava.util.concurrent.atomic.LongAddercounterStartRecovery
-
Constructor Summary
Constructors Constructor Description TransMonitor(ComponentId cid)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(Transaction transaction)Abort a transaction (undo the effect of a transaction)voidattach(SysTransState systemState)Set the current thread to be in the transaction.voidbegin(Transaction transaction)Start a transaction; return an identifier for this components use.voidcleanStart()Indicate that no recovery is being done (the journal thinks everything was completed last time)voidcommit(Transaction transaction)Commit a transaction (make durable).voidcommitEnd(Transaction transaction)Signal all commits on all components are done and replay from the journal will not happen.java.nio.ByteBuffercommitPrepare(Transaction transaction)Prepare for a commit.voidcomplete(Transaction transaction)Finalization - the coordinator will not mention the transaction again.SysTransStatedetach()Detach this component from the transaction of the current thread and return some internal state that can be used in a future call ofTransactionalComponent.attach(SysTransState)voidfinishRecovery()End of the recovery phasejava.util.Map<java.lang.String,java.lang.Long>getAll()Get a copy of the counters with current values.ComponentIdgetComponentId()Every component instance must supplied a unique number.voidprint()Print the counters state.voidprint(java.io.PrintStream ps)Print the counters state.booleanpromote(Transaction transaction)Promote a component in a transaction.voidrecover(java.nio.ByteBuffer ref)Notification thatrefwas really committed and is being recovered.voidreset()Reset all counters to zerovoidshutdown()Shutdown component, aborting any in-progress transactions.voidstartRecovery()
-
-
-
Field Detail
-
counterGetComponentId
public java.util.concurrent.atomic.LongAdder counterGetComponentId
-
counterStartRecovery
public java.util.concurrent.atomic.LongAdder counterStartRecovery
-
counterRecover
public java.util.concurrent.atomic.LongAdder counterRecover
-
counterFinishRecovery
public java.util.concurrent.atomic.LongAdder counterFinishRecovery
-
counterCleanStart
public java.util.concurrent.atomic.LongAdder counterCleanStart
-
counterBegin
public java.util.concurrent.atomic.LongAdder counterBegin
-
counterPromote
public java.util.concurrent.atomic.LongAdder counterPromote
-
counterCommitPrepare
public java.util.concurrent.atomic.LongAdder counterCommitPrepare
-
counterCommit
public java.util.concurrent.atomic.LongAdder counterCommit
-
counterCommitEnd
public java.util.concurrent.atomic.LongAdder counterCommitEnd
-
counterAbort
public java.util.concurrent.atomic.LongAdder counterAbort
-
counterComplete
public java.util.concurrent.atomic.LongAdder counterComplete
-
counterDetach
public java.util.concurrent.atomic.LongAdder counterDetach
-
counterAttach
public java.util.concurrent.atomic.LongAdder counterAttach
-
counterShutdown
public java.util.concurrent.atomic.LongAdder counterShutdown
-
-
Constructor Detail
-
TransMonitor
public TransMonitor(ComponentId cid)
-
-
Method Detail
-
reset
public void reset()
Reset all counters to zero
-
getAll
public java.util.Map<java.lang.String,java.lang.Long> getAll()
Get a copy of the counters with current values. The values are as of the point of this being called and are not changed by any later calls to monitored operations.
-
print
public void print()
Print the counters state.
-
print
public void print(java.io.PrintStream ps)
Print the counters state.
-
getComponentId
public ComponentId getComponentId()
Description copied from interface:TransactionalComponentEvery component instance must supplied a unique number. It is used to route journal entries to subsystems, including across restarts/recovery. Uniqueness scope is within the sameTransactionCoordinator, and the same across restarts.If a component imposes the rule of one-per-
TransactionCoordinator, the same number can be used (if different from all other component type instances).If a component can have multiple instances per
TransactionCoordinator, for example indexes, each must have a unique instance id.- Specified by:
getComponentIdin interfaceTransactionalComponent
-
startRecovery
public void startRecovery()
- Specified by:
startRecoveryin interfaceTransactionalComponent
-
recover
public void recover(java.nio.ByteBuffer ref)
Description copied from interface:TransactionalComponentNotification thatrefwas really committed and is being recovered.- Specified by:
recoverin interfaceTransactionalComponent- Parameters:
ref- Same bytes as were written during prepare originally.
-
finishRecovery
public void finishRecovery()
Description copied from interface:TransactionalComponentEnd of the recovery phase- Specified by:
finishRecoveryin interfaceTransactionalComponent
-
cleanStart
public void cleanStart()
Description copied from interface:TransactionalComponentIndicate that no recovery is being done (the journal thinks everything was completed last time)- Specified by:
cleanStartin interfaceTransactionalComponent
-
begin
public void begin(Transaction transaction)
Description copied from interface:TransactionalComponentStart a transaction; return an identifier for this components use.- Specified by:
beginin interfaceTransactionalComponent
-
promote
public boolean promote(Transaction transaction)
Description copied from interface:TransactionalComponentPromote a component in a transaction.May return "false" for "can't do that" if the transaction can not be promoted.
May throw
UnsupportedOperationExceptionif promotion is not supported.- Specified by:
promotein interfaceTransactionalComponent
-
commitPrepare
public java.nio.ByteBuffer commitPrepare(Transaction transaction)
Description copied from interface:TransactionalComponentPrepare for a commit. Returns some bytes that will be written to the journal. The journal remains valid untilTransactionalComponent.commitEnd(org.apache.jena.dboe.transaction.txn.Transaction)is called.- Specified by:
commitPreparein interfaceTransactionalComponent
-
commit
public void commit(Transaction transaction)
Description copied from interface:TransactionalComponentCommit a transaction (make durable). The transaction will commit and not abort. Other components may not have committed yet and recovery may occur still causing replay of the commit step.- Specified by:
commitin interfaceTransactionalComponent
-
commitEnd
public void commitEnd(Transaction transaction)
Description copied from interface:TransactionalComponentSignal all commits on all components are done and replay from the journal will not happen. The component can clear up now.- Specified by:
commitEndin interfaceTransactionalComponent
-
abort
public void abort(Transaction transaction)
Description copied from interface:TransactionalComponentAbort a transaction (undo the effect of a transaction)- Specified by:
abortin interfaceTransactionalComponent
-
complete
public void complete(Transaction transaction)
Description copied from interface:TransactionalComponentFinalization - the coordinator will not mention the transaction again.- Specified by:
completein interfaceTransactionalComponent
-
detach
public SysTransState detach()
Description copied from interface:TransactionalComponentDetach this component from the transaction of the current thread and return some internal state that can be used in a future call ofTransactionalComponent.attach(SysTransState)After this call, the component is not in a transaction but the existing transaction still exists. The thread may start a new transaction; that transaction is completely independent of the detached transaction.
Returns
nullif the current thread not in a transaction. The component may return null to indicate it has no state. The return system state should be used in a call toTransactionalComponent.attach(SysTransState)and the transaction ended in the usual way.- Specified by:
detachin interfaceTransactionalComponent
-
attach
public void attach(SysTransState systemState)
Description copied from interface:TransactionalComponentSet the current thread to be in the transaction. ThesystemStatemust be obtained from a call ofTransactionalComponent.detach(). This method can only be called once persystemState.- Specified by:
attachin interfaceTransactionalComponent
-
shutdown
public void shutdown()
Description copied from interface:TransactionalComponentShutdown component, aborting any in-progress transactions. This operation is not guaranteed to be called.- Specified by:
shutdownin interfaceTransactionalComponent
-
-