class EntryHolder extends Object implements TransactionConstants
EntryHolders hold all the entries of a exact given
class. OutriggerServerImpl has one
EntryHolder for each entry class it knows about. A
simple implementation is used that simply stores the entries in a
list.| Modifier and Type | Class and Description |
|---|---|
(package private) class |
EntryHolder.ContinuingQuery
Object that can be used to perform a query that can
return multiple matches and be restarted in another thread.
|
private class |
EntryHolder.SimpleRepEnum
The class that implements
RepEnum for this class. |
| Modifier and Type | Field and Description |
|---|---|
private Queue<EntryHandle> |
content
The list that holds the handles
|
private java.util.concurrent.ConcurrentMap<Uuid,EntryHandle> |
idMap
The map of cookies to handles, shared with the
EntryHolderSet and every other
EntryHolder. |
private static Logger |
iteratorLogger
Logger for logging information about iterators
|
private static Logger |
matchingLogger
Logger for logging information about entry matching
|
private OutriggerServerImpl |
space
The server we are working for
|
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING| Constructor and Description |
|---|
EntryHolder(OutriggerServerImpl space,
java.util.concurrent.ConcurrentMap<Uuid,EntryHandle> idMap)
Create a new
EntryHolder with the shared
idMap, and which will hold classes of the given
className. |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
add(EntryHandle handle,
TransactableMgr txn)
Add new new entry to the holder.
|
(package private) boolean |
attemptCapture(EntryHandle handle,
TransactableMgr txn,
boolean takeIt,
Set conflictSet,
Set lockedEntrySet,
Set provisionallyRemovedEntrySet,
long now)
Atomically check to see if the passed entry can be read/taken by
the specified operation using the specified transaction and if
it can read/take it and return
true, otherwise
return false. |
private boolean |
confirmAvailability(EntryRep rep,
EntryHandle handle,
TransactableMgr txn,
boolean takeIt,
long time,
Set conflictSet,
Set<Uuid> lockedEntrySet,
Set<EntryHandle> provisionallyRemovedEntrySet)
With the EntryRep
rep passed in, verify that the
entry hasn't been taken by someone else, hasn't expired, etc. |
private boolean |
confirmAvailabilityWithTxn(EntryRep rep,
EntryHandle handle,
TransactableMgr txnMgr,
boolean takeIt,
long time,
Set conflictSet,
Set<Uuid> lockedEntrySet,
Set<EntryHandle> provisionallyRemovedEntrySet) |
(package private) RepEnum |
contents(TransactableMgr mgr)
Return an enumerator over the contents of this space that are visible
from the given mgr.
|
(package private) EntryHolder.ContinuingQuery |
continuingQuery(EntryRep[] tmpls,
TransactableMgr txn,
boolean takeThem,
long now)
Return an object that can be used to perform a query that can
return multiple matches and be restarted in another thread.
|
(package private) void |
dump(String name)
Debug method: Dump out the state of this holder, printing out
the name of the dump first.
|
private EntryHandle |
getContentsHead()
Get the head of the contents list
|
private boolean |
grab(EntryHandle handle,
TransactableMgr txn,
int op,
boolean takeIt,
boolean recovery)
Given an entry that we want to return as the result of a query
and we have confirmed we can return it, make the results of the
query visible to the rest of the service.
|
(package private) EntryHandle |
hasMatch(EntryRep tmpl,
TransactableMgr txn,
boolean takeIt,
Set conflictSet,
Set lockedEntrySet,
Set provisionallyRemovedEntrySet)
Return an
EntryHandle object that matches the given
template, or null if none does. |
private boolean |
isExpired(long now,
EntryHandle handle)
Return
true if the entry held by the given
handle has expired by the time in now. |
(package private) EntryHandle |
newEntryHandle(EntryRep rep,
TransactableMgr mgr) |
(package private) void |
reap()
Reap the expired elements.
|
(package private) void |
recoverTake(EntryHandle handle,
Txn txn)
Recover a logged take.
|
(package private) boolean |
remove(EntryHandle h,
boolean recovery)
Remove the given handle from this holder and the
idMap. |
(package private) String[] |
supertypes()
Return an array of the class names of the super classes of the
entries in this holder, or
null if the holder is
empty. |
private final Queue<EntryHandle> content
private final java.util.concurrent.ConcurrentMap<Uuid,EntryHandle> idMap
EntryHolderSet and every other
EntryHolder.private final OutriggerServerImpl space
private static final Logger matchingLogger
private static final Logger iteratorLogger
EntryHolder(OutriggerServerImpl space, java.util.concurrent.ConcurrentMap<Uuid,EntryHandle> idMap)
EntryHolder with the shared
idMap, and which will hold classes of the given
className. The idMap is shared with
EntryHolderSet so that there is one table that can
map ID to EntryRepEntryHandle newEntryHandle(EntryRep rep, TransactableMgr mgr)
EntryHandle hasMatch(EntryRep tmpl, TransactableMgr txn, boolean takeIt, Set conflictSet, Set lockedEntrySet, Set provisionallyRemovedEntrySet) throws CannotJoinException
EntryHandle object that matches the given
template, or null if none does. Optionally
removes (perhaps provisionally) the found entry.tmpl - The template to match againsttxn - If non-null the transaction (represented as
a TransactableMgr to perform
the operation under. May be null
if the operation is not to be done under
a transaction.takeIt - true if hasMatch should
remove the matching entry.conflictSet - If non-null the TransactableMgr
objects of any transactions that prevent
a non-null value from being retured will
be added to conflictSet. May
be null in which case
conflicting transaction will not be recorded.
This method assumes that any concurrent access
is being arbitrated by the set or by the caller.lockedEntrySet - If non-null the ID of any entries that
can't be retured because of conflicting
transaction will be added to
lockedEntrySet. May be
null in which case unavailable
entries will not be recorded. This method
assumes that any concurrent access is being
arbitrated by the set or by the caller.provisionallyRemovedEntrySet - If the entry can not be
read/taken because it has been provisionally
removed then its handle will be placed in the
passed WeakHashMap as a key (with
null as the value). May be null in
which case provisionally removed entries will not
be recorded. This method assumes that any
concurrent access is being arbitrated by the set
or by the caller.CannotJoinException - if a match is found and
the operation is to be performed under a transaction,
but the transaction is no longer active.attemptCapture(org.apache.river.outrigger.EntryHandle, org.apache.river.outrigger.TransactableMgr, boolean, java.util.Set, java.util.Set, java.util.Set, long)void dump(String name)
boolean attemptCapture(EntryHandle handle, TransactableMgr txn, boolean takeIt, Set conflictSet, Set lockedEntrySet, Set provisionallyRemovedEntrySet, long now)
true, otherwise
return false. If the entry is removed. Note,
if the entry is removed, removal is logged.handle - The EntryHandle of the entry
the caller wants to read/take.txn - If non-null the transaction to perform
this operation under. Note, if non-null and
txn is not active false
will be returned.takeIt - true if the caller is trying
take the passed entry, false
otherwise.conflictSet - If non-null and the entry can not be
read/taken because of transaction conflicts the
conflicting transaction(s) will be added to this set.
This method assumes that any concurrent access is
being arbitrated by the set or by the caller.lockedEntrySet - If the entry can not be read/taken
because of a transaction conflict, the ID of the
entry will be added to this set. This method
assumes that any concurrent access is being arbitrated
by the set or by the caller.provisionallyRemovedEntrySet - If the entry can not be
read/taken because it has been provisionally
removed then its handle will be placed in the
passed WeakHashMap as a key (with
null as the value). May be null in
which case provisionally removed entries will not
be recorded. This method assumes that any
concurrent access is being arbitrated by the set
or by the caller.now - an estimate of the current time in milliseconds
since the beginning of the epoch.true if the entry could be read/taken and
false otherwise.NullPointerException - if entry is null.private boolean confirmAvailabilityWithTxn(EntryRep rep, EntryHandle handle, TransactableMgr txnMgr, boolean takeIt, long time, Set conflictSet, Set<Uuid> lockedEntrySet, Set<EntryHandle> provisionallyRemovedEntrySet) throws CannotJoinException
CannotJoinExceptionprivate boolean confirmAvailability(EntryRep rep, EntryHandle handle, TransactableMgr txn, boolean takeIt, long time, Set conflictSet, Set<Uuid> lockedEntrySet, Set<EntryHandle> provisionallyRemovedEntrySet)
rep passed in, verify that the
entry hasn't been taken by someone else, hasn't expired, etc.
Also, verify that the entry is really (legally) visible to this
transaction at this time. If this is a take, it it
is removed or provisionally removed. If this operation is under
a transaction, the entry is locked appropriately.private boolean grab(EntryHandle handle, TransactableMgr txn, int op, boolean takeIt, boolean recovery)
Also used during log recovery to recover takes.
handle - The handle attached to the particular EntryReptxn - The Txn objectop - TAKE or READ (as a TransactableMgr constant)takeIt - Is this a TAKE (or is it [false] a READ)recovery - true if being called as
part of store recovery.true if the entry could be grabbed.NullPointerException - if handle is
null.void recoverTake(EntryHandle handle, Txn txn)
handle - The EntryHandle of the entry who's
take is being logged.txn - If non-null the transaction the take was performed
under.NullPointerException - if handle is
null.private boolean isExpired(long now,
EntryHandle handle)
true if the entry held by the given
handle has expired by the time in now.private EntryHandle getContentsHead()
void add(EntryHandle handle, TransactableMgr txn)
handle - The EntryHandle for the
entry being added.txn - If the add is being done under a
transaction the TransactableMgr for
that transaction.NullPointerException - if handle is
null.String[] supertypes()
null if the holder is
empty.RepEnum contents(TransactableMgr mgr)
EntryHolder.ContinuingQuery continuingQuery(EntryRep[] tmpls, TransactableMgr txn, boolean takeThem, long now)
tmpls - An array of templates. Query will yield any
entry that matches one or more of the templates.txn - Transaction that should be used with the query.
May be null. If
non-null any entries yielded by the
query will be locked under the transaction.takeThem - If true any entries yielded by
the query should be removed.now - Estimate of current time used to weed out
expired entries, ok if oldboolean remove(EntryHandle h, boolean recovery)
idMap.
If the handle isn't in this holder, this does nothing.h - the EntryHandle to remove.recovery - true if being called as part
of log recovery.true if this call removed h and
false otherwise.void reap()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.