Package org.apache.accumulo.core.fate
Class ZooStore<T>
- java.lang.Object
-
- org.apache.accumulo.core.fate.ZooStore<T>
-
- All Implemented Interfaces:
ReadOnlyTStore<T>
,TStore<T>
public class ZooStore<T> extends Object implements TStore<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.accumulo.core.fate.ReadOnlyTStore
ReadOnlyTStore.TStatus
-
-
Constructor Summary
Constructors Constructor Description ZooStore(String path, ZooReaderWriter zk)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
create()
Create a new transaction idvoid
delete(long tid)
Remove the transaction from the store.List<ReadOnlyRepo<T>>
getStack(long tid)
Get all operations on a transactions stack.ReadOnlyTStore.TStatus
getStatus(long tid)
Get the state of a given transaction.Serializable
getTransactionInfo(long tid, Fate.TxInfo txInfo)
Retrieve transaction-specific information.List<Long>
list()
list all transaction ids in store.void
pop(long tid)
Remove the last pushed operation from the given transaction.void
push(long tid, Repo<T> repo)
Update the given transaction with the next operationlong
reserve()
Reserve a transaction that is IN_PROGRESS or FAILED_IN_PROGRESS.void
reserve(long tid)
Reserve the specific tid.void
setStatus(long tid, ReadOnlyTStore.TStatus status)
Update the state of a given transactionvoid
setTransactionInfo(long tid, Fate.TxInfo txInfo, Serializable so)
Set transaction-specific information.long
timeCreated(long tid)
Retrieve the creation time of a FaTE transaction.Repo<T>
top(long tid)
Get the current operation for the given transaction id.boolean
tryReserve(long tid)
Attempt to reserve transactionvoid
unreserve(long tid, long deferTime)
Return the given transaction to the store.ReadOnlyTStore.TStatus
waitForStatusChange(long tid, EnumSet<ReadOnlyTStore.TStatus> expected)
Wait for the status of a transaction to change
-
-
-
Constructor Detail
-
ZooStore
public ZooStore(String path, ZooReaderWriter zk) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
-
Method Detail
-
create
public long create()
Description copied from interface:TStore
Create a new transaction id
-
reserve
public long reserve()
Description copied from interface:ReadOnlyTStore
Reserve a transaction that is IN_PROGRESS or FAILED_IN_PROGRESS. Reserving a transaction id ensures that nothing else in-process interacting via the same instance will be operating on that transaction id.- Specified by:
reserve
in interfaceReadOnlyTStore<T>
- Returns:
- a transaction id that is safe to interact with, chosen by the store.
-
reserve
public void reserve(long tid)
Description copied from interface:ReadOnlyTStore
Reserve the specific tid. Reserving a transaction id ensures that nothing else in-process interacting via the same instance will be operating on that transaction id.- Specified by:
reserve
in interfaceReadOnlyTStore<T>
-
tryReserve
public boolean tryReserve(long tid)
Attempt to reserve transaction- Specified by:
tryReserve
in interfaceTStore<T>
- Parameters:
tid
- transaction id- Returns:
- true if reserved by this call, false if already reserved
-
unreserve
public void unreserve(long tid, long deferTime)
Description copied from interface:ReadOnlyTStore
Return the given transaction to the store. upon successful return the store now controls the referenced transaction id. caller should no longer interact with it.- Specified by:
unreserve
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, previously reserved.deferTime
- time in millis to keep this transaction out of the pool used in thereserve
method. must be non-negative.
-
top
public Repo<T> top(long tid)
Description copied from interface:ReadOnlyTStore
Get the current operation for the given transaction id. Caller must have already reserved tid.
-
push
public void push(long tid, Repo<T> repo) throws StackOverflowException
Description copied from interface:TStore
Update the given transaction with the next operation- Specified by:
push
in interfaceTStore<T>
- Parameters:
tid
- the transaction idrepo
- the operation- Throws:
StackOverflowException
-
pop
public void pop(long tid)
Description copied from interface:TStore
Remove the last pushed operation from the given transaction.
-
getStatus
public ReadOnlyTStore.TStatus getStatus(long tid)
Description copied from interface:ReadOnlyTStore
Get the state of a given transaction. Caller must have already reserved tid.- Specified by:
getStatus
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, previously reserved.- Returns:
- execution status
-
waitForStatusChange
public ReadOnlyTStore.TStatus waitForStatusChange(long tid, EnumSet<ReadOnlyTStore.TStatus> expected)
Description copied from interface:ReadOnlyTStore
Wait for the status of a transaction to change- Specified by:
waitForStatusChange
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, need not have been reserved.expected
- a set of possible statuses we are interested in being notified about. may not be null.- Returns:
- execution status.
-
setStatus
public void setStatus(long tid, ReadOnlyTStore.TStatus status)
Description copied from interface:TStore
Update the state of a given transaction
-
delete
public void delete(long tid)
Description copied from interface:TStore
Remove the transaction from the store.
-
setTransactionInfo
public void setTransactionInfo(long tid, Fate.TxInfo txInfo, Serializable so)
Description copied from interface:TStore
Set transaction-specific information.- Specified by:
setTransactionInfo
in interfaceTStore<T>
- Parameters:
tid
- transaction idtxInfo
- name of attribute of a transaction to set.so
- transaction data to store
-
getTransactionInfo
public Serializable getTransactionInfo(long tid, Fate.TxInfo txInfo)
Description copied from interface:ReadOnlyTStore
Retrieve transaction-specific information. Caller must have already reserved tid.- Specified by:
getTransactionInfo
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, previously reserved.txInfo
- name of attribute of a transaction to retrieve.
-
list
public List<Long> list()
Description copied from interface:ReadOnlyTStore
list all transaction ids in store.- Specified by:
list
in interfaceReadOnlyTStore<T>
- Returns:
- all outstanding transactions, including those reserved by others.
-
timeCreated
public long timeCreated(long tid)
Description copied from interface:ReadOnlyTStore
Retrieve the creation time of a FaTE transaction.- Specified by:
timeCreated
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- Transaction id, previously reserved.- Returns:
- creation time of transaction.
-
getStack
public List<ReadOnlyRepo<T>> getStack(long tid)
Description copied from interface:ReadOnlyTStore
Get all operations on a transactions stack. Element 0 contains the most recent operation pushed or the top.- Specified by:
getStack
in interfaceReadOnlyTStore<T>
-
-