Package org.apache.accumulo.fate
Class ZooStore<T>
- java.lang.Object
-
- org.apache.accumulo.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.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 longcreate()Create a new transaction idvoiddelete(long tid)Remove the transaction from the store.SerializablegetProperty(long tid, String prop)Retrieve a transaction-specific property.List<ReadOnlyRepo<T>>getStack(long tid)Get all operations on a transactions stack.ReadOnlyTStore.TStatusgetStatus(long tid)Get the state of a given transaction.List<Long>list()list all transaction ids in store.voidpop(long tid)Remove the last pushed operation from the given transaction.voidpush(long tid, Repo<T> repo)Update the given transaction with the next operationlongreserve()Reserve a transaction that is IN_PROGRESS or FAILED_IN_PROGRESS.voidreserve(long tid)Reserve the specific tid.voidsetProperty(long tid, String prop, Serializable so)voidsetStatus(long tid, ReadOnlyTStore.TStatus status)Update the state of a given transactionRepo<T>top(long tid)Get the current operation for the given transaction id.voidunreserve(long tid, long deferTime)Return the given transaction to the store.ReadOnlyTStore.TStatuswaitForStatusChange(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.KeeperExceptionInterruptedException
-
-
Method Detail
-
create
public long create()
Description copied from interface:TStoreCreate a new transaction id
-
reserve
public long reserve()
Description copied from interface:ReadOnlyTStoreReserve 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:
reservein 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:ReadOnlyTStoreReserve 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:
reservein interfaceReadOnlyTStore<T>
-
unreserve
public void unreserve(long tid, long deferTime)Description copied from interface:ReadOnlyTStoreReturn 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:
unreservein interfaceReadOnlyTStore<T>- Parameters:
tid- transaction id, previously reserved.deferTime- time in millis to keep this transaction out of the pool used in thereservemethod. must be non-negative.
-
top
public Repo<T> top(long tid)
Description copied from interface:ReadOnlyTStoreGet the current operation for the given transaction id. Caller must have already reserved tid.
-
push
public void push(long tid, Repo<T> repo) throws StackOverflowExceptionDescription copied from interface:TStoreUpdate the given transaction with the next operation- Specified by:
pushin interfaceTStore<T>- Parameters:
tid- the transaction idrepo- the operation- Throws:
StackOverflowException
-
pop
public void pop(long tid)
Description copied from interface:TStoreRemove the last pushed operation from the given transaction.
-
getStatus
public ReadOnlyTStore.TStatus getStatus(long tid)
Description copied from interface:ReadOnlyTStoreGet the state of a given transaction. Caller must have already reserved tid.- Specified by:
getStatusin 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:ReadOnlyTStoreWait for the status of a transaction to change- Specified by:
waitForStatusChangein 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:TStoreUpdate the state of a given transaction
-
delete
public void delete(long tid)
Description copied from interface:TStoreRemove the transaction from the store.
-
setProperty
public void setProperty(long tid, String prop, Serializable so)- Specified by:
setPropertyin interfaceTStore<T>
-
getProperty
public Serializable getProperty(long tid, String prop)
Description copied from interface:ReadOnlyTStoreRetrieve a transaction-specific property. Caller must have already reserved tid.- Specified by:
getPropertyin interfaceReadOnlyTStore<T>- Parameters:
tid- transaction id, previously reserved.prop- name of property to retrieve.
-
list
public List<Long> list()
Description copied from interface:ReadOnlyTStorelist all transaction ids in store.- Specified by:
listin interfaceReadOnlyTStore<T>- Returns:
- all outstanding transactions, including those reserved by others.
-
getStack
public List<ReadOnlyRepo<T>> getStack(long tid)
Description copied from interface:ReadOnlyTStoreGet all operations on a transactions stack. Element 0 contains the most recent operation pushed or the top.- Specified by:
getStackin interfaceReadOnlyTStore<T>
-
-