Package org.apache.accumulo.fate
Class ReadOnlyStore<T>
- java.lang.Object
-
- org.apache.accumulo.fate.ReadOnlyStore<T>
-
- All Implemented Interfaces:
ReadOnlyTStore<T>
public class ReadOnlyStore<T> extends Object implements ReadOnlyTStore<T>
This store decorates a TStore to make sure it can not be modified. Unlike relying directly on the ReadOnlyTStore interface, this class will not allow subsequent users to cast back to a mutable TStore successfully.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ReadOnlyStore.ReadOnlyRepoWrapper<X>
Decorates a Repo to make sure it is treated as a ReadOnlyRepo.-
Nested classes/interfaces inherited from interface org.apache.accumulo.fate.ReadOnlyTStore
ReadOnlyTStore.TStatus
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyStore(TStore<T> store)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Serializable
getProperty(long tid, String prop)
Retrieve a transaction-specific property.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.List<Long>
list()
list all transaction ids in store.long
reserve()
Reserve a transaction that is IN_PROGRESS or FAILED_IN_PROGRESS.void
reserve(long tid)
Reserve the specific tid.ReadOnlyRepo<T>
top(long tid)
Get the current operation for the given transaction id.void
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
-
-
-
Method Detail
-
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>
-
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 ReadOnlyRepo<T> top(long tid)
Description copied from interface:ReadOnlyTStore
Get the current operation for the given transaction id. Caller must have already reserved tid.- Specified by:
top
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, previously reserved.- Returns:
- a read-only view of the operation
-
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.
-
getProperty
public Serializable getProperty(long tid, String prop)
Description copied from interface:ReadOnlyTStore
Retrieve a transaction-specific property. Caller must have already reserved tid.- Specified by:
getProperty
in interfaceReadOnlyTStore<T>
- Parameters:
tid
- transaction id, previously reserved.prop
- name of property 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.
-
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>
-
-