public class OutriggerServerImpl extends Object implements OutriggerServer, TimeConstants, LocalLandlord, Recover, ServerProxyTrust, Startable
Store
and LogOps objects which handles the details
of implementing a particular persistence strategy. If transient
a null value is used for the LogOps object.
OutriggerServerImpl maintains a list of types of
entries it has seen and their subtypes using a
TypeTree object. Each type of entry has an
EntryHolder that is stored in the
EntryHolderSet object named contents.
On write, the written entry's class and superclass are
added to the known types, and its EntryRep
is added to the space's contents.
On read, the find method searches through
the entries of its type and subtypes, asking each entry holder if it
has an entry that matches the template. If a match is found, the
matching EntryRep is returned. If none of the
appropriate holders has a match, it will return null.
On take we also use find with a
boolean that says to remove the entry that matches.
Notification requires a separate Notifier queue and
thread. When an entry is written, a reference to it is added to the
queue of "unexamined entries". The notifier thread pulls entries
off the queue and checks them against registered notification
templates. When it has found all matches for the template, the
Notifier thread adds the notifications for this write
to its list of undelivered notifications, which it periodically
attempts to deliver.
On notify, the template is added to the
TemplateHolderSet named template. This
stores TemplateHolder objects for each known type.
In this implementation, EntryRep ID's are approximate
time stamps.
| Modifier and Type | Class and Description |
|---|---|
private class |
OutriggerServerImpl.AllReps
An iterator that returns all the reps in the space that are of
at least the given class.
|
private class |
OutriggerServerImpl.ContentsQuery
Object that keeps the current state of contents queries.
|
private class |
OutriggerServerImpl.ContentsQueryReaper
Entry reaping thread class
|
private class |
OutriggerServerImpl.DestroyThread
Termination thread code.
|
private class |
OutriggerServerImpl.EntryReaper
Entry reaping thread class
|
private static class |
OutriggerServerImpl.InitHolder |
private class |
OutriggerServerImpl.IteratorImpl
Implementation of the remote iteration interface.
|
private static class |
OutriggerServerImpl.Reaper
Base class for our house keeping threads.
|
private class |
OutriggerServerImpl.TemplateReaper
Template reaping thread class
|
OutriggerServer.QueryCookieLandlord.RenewResults| Modifier and Type | Field and Description |
|---|---|
private ActivationID |
activationID
Our activation ID,
null if we are not activatable |
private ActivationSystem |
activationSystem
A prepared reference to the activation system,
null if
we are not activatable. |
private AdminProxy |
adminProxy
The admin proxy for this space.
|
static String |
COMPONENT_NAME
Component name we use to find items in the configuration and loggers.
|
private Configuration |
config
Temporary start state Object variables set to null after start
|
private EntryHolderSet |
contents
List of
org.apache.river.outrigger.EntryHolders for
each specific type. |
private LeasePeriodPolicy |
contentsLeasePolicy
Policy used to create and renew leases on event contents queries
|
private Map<Uuid,LeasedResource> |
contentsQueries
A map from contents result cookies to
ContentsQuery objects. |
private OutriggerServerImpl.ContentsQueryReaper |
contentsQueryReaperThread
The reaper thread for expired contents queries
|
private AccessControlContext |
context |
private long |
crashCount
The crash count.
|
private LeasePeriodPolicy |
entryLeasePolicy
Policy used to create and renew leases on entries
|
private OutriggerServerImpl.EntryReaper |
entryReaperThread
The reaper thread for removed entries.
|
private LeasePeriodPolicy |
eventLeasePolicy
Policy used to create and renew leases on event registrations
|
(package private) static String |
eventLoggerName
Logger name for information related to events
|
private Map<Uuid,LeasedResource> |
eventRegistrations
A map from event registration cookies to
EventRegistrationRecord instances |
private Exception |
except |
private ExpirationOpQueue |
expirationOpQueue
Object that queues up lease expirations for future logging.
|
private Exporter |
exporter
Object we used to export ourselves.
|
private static SecureRandom |
idGen
Our IDs 64 bits secure random numbers, this is
SecureRandom instance we use to create them. |
private Map |
iterations
The map of
Uuid to active iterations |
private static Logger |
iteratorLogger
Logger for logging information to iterators
|
(package private) static String |
iteratorLoggerName
Logger name for information related to iterators
|
private static Logger |
joinLogger
Logger for logging information about join state
|
(package private) static String |
joinLoggerName
Logger name for information related to join state
|
private JoinStateManager |
joinStateManager |
private LeaseFactory |
leaseFactory
Factory we use to create leases
|
private static Logger |
leaseLogger
Logger for information related to leases and leasing
|
(package private) static String |
leaseLoggerName
Logger name for information related to leases and leasing
|
private LifeCycle |
lifeCycle
Object to notify if we destroy ourselves, may be
null |
private static Logger |
lifecycleLogger
Logger for information related to starting/restarting/destroying
the service
|
(package private) static String |
lifecycleLoggerName
Logger name for information related to starting/restarting/destroying
the service
|
private ProxyPreparer |
listenerPreparer
ProxyPreparer for event listeners |
private LogOps |
log
Log object to record state and operation information.
|
private LoginContext |
loginContext
The login context, for logging out
|
(package private) static String |
matchingLoggerName
Logger name for information related to entry matching
|
private long |
maxServerQueryTimeout |
private long |
maxUnexportDelay
When destroying the space, how long to wait for a clean
unexport (which allows the destroy call to return) before
giving up calling
unexport(true) |
private int |
nextLimit
Max number of entries to return in a next call
|
private Notifier |
notifier
The notification object
|
private OperationJournal |
operationJournal
Object that recored operations on entries and makes sure they
get seen by the watchers in
templates. |
private static Logger |
opsLogger
Logger for information related to top level operations
|
(package private) static String |
opsLoggerName
Logger name for information related top level operations
|
private OutriggerServer |
ourRemoteRef
The remote ref (e.g. stub or dynamic proxy) for this
server.
|
private ParticipantProxy |
participantProxy
The participant proxy for this space
|
static String |
PERSISTENCE_DIR_CONFIG_ENTRY
The name of the configuration entry we use to get the
the name of the log directory from.
|
private boolean |
persistent |
private ProxyPreparer |
recoveredListenerPreparer
ProxyPreparer for event listeners
that get recovered from the store. |
private ProxyPreparer |
recoveredTransactionManagerPreparer
ProxyPreparer for transaction managers
that get recovered from the store. |
private Map<Long,Txn> |
recoveredTxns
The transactions recovered after restart.
|
private OutriggerServerWrapper |
serverGate
The wrapper that intercepts incoming remote calls for locking
purposes and then delegates to us.
|
private java.util.concurrent.atomic.AtomicLong |
sessionId
Holds the basis/lower bound for all sequence numbers issued.
|
private SpaceProxy2 |
spaceProxy
The proxy for this space.
|
private boolean |
started |
private Thread |
starter |
private Store |
store
Store - The reference to the persistent store, if any.
|
static String |
storeLoggerName
Logger name for information related to persistence
|
private int |
takeLimit
Max number of entries to return in a take multiple call
|
private OutriggerServerImpl.TemplateReaper |
templateReaperThread
The reaper thread for expired notifications
|
private TransitionWatchers |
templates
Templates for which someone has registered interest
|
private Throwable |
thrown |
private Uuid |
topUuid
The
Uuid for this service. |
private ProxyPreparer |
transactionManagerPreparer
ProxyPreparer for transaction managers |
private static Logger |
txnLogger
Logger for information related to transactions
|
(package private) static String |
txnLoggerName
Logger name for information related to transactions
|
private TxnMonitor |
txnMonitor
The monitor for ongoing transactions.
|
private TxnTable |
txnTable
The transactions in which this space is a participant.
|
private HashMap<String,Long> |
typeHashes
A list of hashes to check against class types.
|
private TypeTree |
types
A list of known subclasses of each class of entry.
|
private long |
unexportRetryDelay
Length of time to sleep between unexport attempts
|
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTINGDAYS, HOURS, MINUTES, SECONDS| Constructor and Description |
|---|
OutriggerServerImpl(ActivationID activationID,
LifeCycle lifeCycle,
String[] configArgs,
boolean persistent,
OutriggerServerWrapper wrapper)
Create a new
OutriggerServerImpl server (possibly a
new incarnation of an activatable one). |
| Modifier and Type | Method and Description |
|---|---|
void |
abort(TransactionManager mgr,
long id)
Requests that the participant roll back any changes for the specified
transaction and unlock any resources locked by the transaction.
|
void |
addLookupAttributes(Entry[] attrSets)
Add attribute sets for the service.
|
void |
addLookupGroups(String[] groups)
Add new groups to the set to join.
|
void |
addLookupLocators(LookupLocator[] locators)
Add locators for specific new lookup services to join.
|
private void |
addWrittenRep(EntryHandle handle,
EntryHolder holder,
Txn txn)
Add the written rep to the relevant data structures.
|
(package private) boolean |
attemptCapture(EntryHandle handle,
TransactableMgr txn,
boolean takeIt,
Set lockedEntrySet,
Set<EntryHandle> provisionallyRemovedEntrySet,
long now,
QueryWatcher watcher)
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 static Entry[] |
attributesFor()
Create the service-owned attributes for an Outrigger server.
|
private UnmarshalException |
brokenTxn(TransactionManager mgr,
long id,
Exception nested)
Create, log, and throw a new UnmarshalException to represent
a transaction recovery failure
|
void |
cancel(Uuid cookie)
Called by the lease when its
cancel method is
called. |
Map |
cancelAll(Uuid[] cookies)
Called by the lease map when its
cancelAll method is called. |
(package private) void |
cancelOp(Uuid cookie,
boolean expired)
Log a "cancel" operation.
|
private boolean |
checkClass(String className,
long value)
Compare the given hash with the hash stored for the given
class name, if any.
|
private void |
checkForEmpty(EntryRep[] entries,
String msg)
Utility method to check for zero length arrays of entries
and throw an exception if necessary
|
private void |
checkForNull(Object value,
String msg)
Utility method to check for null argument values and throw
an exception if necessary
|
private void |
checkLimit(long limit)
Utility method to check for non-postive limits
|
private void |
checkTimeout(long timeout)
Utility method to check for negative timeouts
|
void |
close(Uuid iterationUuid)
Forget about the indicated iteration
|
void |
commit(TransactionManager mgr,
long id)
Requests that the participant make all of its
PREPARED
changes for the specified transaction visible outside of the
transaction and unlock any resources locked by the transaction. |
private EntryRep[] |
completeTake(EntryHandle[] handles,
int found,
Txn txn) |
private EntryRep |
completeTake(EntryHandle handle,
Txn txn) |
MatchSetData |
contents(EntryRep[] tmpls,
Transaction tr,
long leaseTime,
long limit)
Start a new contents query.
|
Uuid |
contents(EntryRep tmpl,
Transaction tr)
Return the remote iterator object needed by
JavaSpaceAdmin.contents. |
private EntryHolder.ContinuingQuery |
createQuery(EntryRep[] tmpls,
String clazz,
Txn txn,
boolean takeIt,
long now)
Crerate a ContinuingQuery for the holder of the specified class.
|
private void |
debug(Object obj,
String str)
Print out a debug description of
obj, followed by
the given str. |
void |
delete(Uuid iterationUuid,
Uuid entryUuid)
Delete the given entry if the given iteration is still
valid and the entry was retured by the last call to
nextReps. |
void |
destroy()
Destroy this space, exiting when finished.
|
private void |
destroyReaper(OutriggerServerImpl.Reaper r)
Shutdown a reaper as part of a controlled tear-down
|
(package private) static void |
dump(EntryHolder holder,
String name,
EntryRep rep)
Debug method: Dump out the bucket for the given holder, for an
operation using the given rep.
|
(package private) void |
dump(String name,
EntryRep rep)
Debug method: Dump out the bucket for the holder for the given
rep.
|
(package private) void |
enqueueDelivery(EventSender sender)
Queue up an event for delivery.
|
private Txn |
enterTxn(Transaction baseTr)
This method takes a transactional semantic object
baseTr (the transaction object passed to us by the
client) and retrieves the associated Txn object
(the internal representation for that transaction) from the
space's records. |
private EntryHandle |
find(EntryRep tmplRep,
Txn txn,
boolean takeIt,
Set conflictSet,
Set lockedEntrySet,
Set<EntryHandle> provisionallyRemovedEntrySet)
Find an entry that is at least
whichClass that
matches the template tmplRep (at least the
template's type, and matches in values provided). |
Object |
getAdmin()
Return a proxy that implements that
JavaSpaceAdmin
interface. |
Entry[] |
getLookupAttributes()
Get the current attribute sets for the service.
|
String[] |
getLookupGroups()
Get the list of groups to join.
|
LookupLocator[] |
getLookupLocators()
Get the list of locators of specific lookup services to join.
|
private Object |
getMatch(EntryRep tmpl,
Transaction tr,
long timeout,
boolean takeIt,
boolean ifExists,
OutriggerServer.QueryCookie queryCookieFromClient)
Do the heavy lifting for queries.
|
(package private) Object |
getProxy() |
TrustVerifier |
getProxyVerifier()
Returns a
TrustVerifier that can be used to verify that
a proxy can be trusted as a proxy for the service; that is, the
isTrustedObject method of the
returned verifier can be called with a candidate proxy. |
(package private) ProxyPreparer |
getRecoveredTransactionManagerPreparer()
Return the proxy preparer for recovered transaction
managers, or
null if there is none. |
private Txn |
getRecoveredTxn(Long txnId) |
Object |
getServiceProxy()
Returns a proxy object for this object.
|
(package private) long |
getSessionId() |
private Txn |
getTxn(TransactionManager mgr,
long id)
Look in the table for the
Txn object for the given
manager/id pair. |
private LeasePeriodPolicy.Result |
grant(LeasedResource resource,
long requestedDuration,
LeasePeriodPolicy policy,
String policyName)
Utility method to calculate the lease duration/expiration for
a new resource and set the resource's expiration.
|
private OutriggerServerImpl.InitHolder |
init(Configuration config,
boolean persistent,
ActivationID activationID,
OutriggerServerWrapper serverGate)
The bulk of the work for creating an
OutriggerServerImpl server. |
private void |
joinThread(Thread t)
Join a thread as part of a controlled tear-down
|
private RuntimeException |
logAndThrow(RuntimeException e,
Logger logger)
Log and throw the passed runtime exception
|
private IllegalArgumentException |
logAndThrowIllegalArg(String msg)
Log and throw a new IllegalArgumentException.
|
private void |
logDestroyPhase(String part)
log phase of destroy thread
|
private void |
logDestroyProblem(String part,
Throwable t)
log exception encountered in destroy thread
|
void |
modifyLookupAttributes(Entry[] attrSetTemplates,
Entry[] attrSets)
Modify the current attribute sets, using the same semantics as
ServiceRegistration.modifyAttributes.
|
(package private) void |
monitor(Collection<Txn> toMonitor)
Make sure the transactions listed here are monitored for
a reasonable amount of time since they recently caused a conflict,
although for a non-leased event.
|
private void |
monitor(QueryWatcher watcher,
Collection<Txn> toMonitor)
Make sure the transactions listed here are monitored for as
long as the given query exists.
|
EntryRep[] |
nextBatch(Uuid contentsQueryUuid,
Uuid entryUuid)
Return the next batch of entries associated with the specified
contents query.
|
(package private) static long |
nextID()
Generate a new ID.
|
EntryRep[] |
nextReps(Uuid iterationUuid,
int max,
Uuid entryUuid)
Fetch up to
max EntryRep objects from
the specified iteration. |
EventRegistration |
notify(EntryRep tmpl,
Transaction tr,
RemoteEventListener listener,
long leaseTime,
MarshalledObject handback)
When entries are written that match this template notify the
given
listener. |
int |
prepare(TransactionManager mgr,
long id)
Requests that the participant prepare itself to commit the transaction,
and to vote on the outcome of the transaction.
|
int |
prepareAndCommit(TransactionManager mgr,
long id)
A combination of
prepare and commit, which
can be used by the manager when there is just one participant left to
prepare and all other participants (if any) have responded with
NOTCHANGED. |
Object |
read(EntryRep tmpl,
Transaction txn,
long timeout,
OutriggerServer.QueryCookie cookie)
Find an entry in the space that matches the passed template and
is visible to the passed transaction.
|
Object |
readIfExists(EntryRep tmpl,
Transaction txn,
long timeout,
OutriggerServer.QueryCookie cookie)
Find an entry in the space that matches the passed template and
is visible to the passed transaction.
|
(package private) void |
recordTransition(EntryTransition transition)
Records a transition in the visibility of
an entry.
|
void |
recoverJoinState(StoredObject state)
Recover the join state from the previous session.
|
void |
recoverRegister(StoredResource registration,
String type,
StoredObject[] storedTemplates)
Recover an event registration.
|
void |
recoverSessionId(long sessionId)
Recover the id from the previous session and determine the new basis
value for the seq numbers issued by this session.
|
void |
recoverTake(Uuid cookie,
Long txnId)
Recover a take operation.
|
void |
recoverTransaction(Long txnId,
StoredObject transaction)
Recover a prepared transaction.
|
private void |
recoverTxns()
Process the recovered transactions.
|
void |
recoverUuid(Uuid uuid)
Recover the
Uuid for the service as a whole. |
void |
recoverWrite(StoredResource entry,
Long txnId)
Recover a write operation.
|
EventRegistration |
registerForAvailabilityEvent(EntryRep[] tmpls,
Transaction tr,
boolean visibilityOnly,
RemoteEventListener listener,
long leaseTime,
MarshalledObject handback)
When entries that match one or more of the passed templates
transition from invisible to visible notify the give
listener. |
(package private) void |
removeEventRegistration(EventRegistrationRecord reg)
Remove the passed
EventRegistrationRecord from
event registrations map. |
void |
removeLookupGroups(String[] groups)
Remove groups from the set to join.
|
void |
removeLookupLocators(LookupLocator[] locators)
Remove locators for specific lookup services from the set to join.
|
long |
renew(Uuid cookie,
long extension)
Called by the lease when its
renew method is called. |
Landlord.RenewResults |
renewAll(Uuid[] cookies,
long[] extensions)
Called by the lease map when its
renewAll method is called. |
(package private) void |
scheduleCancelOp(Uuid cookie)
Schedule a cancelOp.
|
private ServerTransaction |
serverTransaction(Transaction baseTr)
We assume that each
Transaction object sent to the
space is actually the ServerTransaction subtype. |
void |
setLookupGroups(String[] groups)
Replace the list of groups to join with a new list.
|
void |
setLookupLocators(LookupLocator[] locators)
Replace the list of locators of specific lookup services to join
with a new list.
|
private EntryRep |
setupTmpl(EntryRep tmpl) |
JavaSpace |
space()
Return the space administered by this object.
|
void |
start()
Called after construction, this method enables objects to delay
starting threads or exporting until after construction is complete,
to allow safe publication of the service in accordance with the JMM.
|
Object |
take(EntryRep[] tmpls,
Transaction tr,
long timeout,
int limit,
OutriggerServer.QueryCookie queryCookieFromClient)
Find and remove up to
limit entries in the space
that match one or more of the passed templates and are visible
to the passed transaction. |
Object |
take(EntryRep tmpl,
Transaction txn,
long timeout,
OutriggerServer.QueryCookie cookie)
Find and remove an entry in the space that matches the passed
template and is visible to the passed transaction.
|
Object |
takeIfExists(EntryRep tmpl,
Transaction txn,
long timeout,
OutriggerServer.QueryCookie cookie)
Find and remove an entry in the space that matches the passed
template and is visible to the passed transaction.
|
private CannotJoinException |
throwNewCannotJoinException()
Log and throw new CannotJoinException
|
private NoSuchObjectException |
throwNewNoSuchObjectException(String msg,
Logger logger)
Log and throw new NoSuchObjectException
|
private NoSuchObjectException |
throwNewNoSuchObjectException(String msg,
Throwable t,
Logger logger)
Log and throw new NoSuchObjectException with a nested exception
|
private UnknownLeaseException |
throwNewUnknownLeaseException(Object cookie)
Log and throw a new UnknownLeaseException
|
private void |
typeCheck(EntryRep rep)
Check if an entry (or template) class definition
has changed.
|
private void |
unwindConstructor(Throwable cause)
Undo any work a failed constructor might have done without
destroying the service.
|
private void |
unwindExporter(OutriggerServer os,
Exporter e) |
private void |
unwindReaper(OutriggerServerImpl.Reaper r)
Kill the given reaper as quickly and quietly
|
private static void |
waitOnProvisionallyRemovedEntries(Set<EntryHandle> provisionallyRemovedEntrySet)
Call
waitOnCompleteRemoval on each of the EntryHandles
in the passed set. |
long[] |
write(EntryRep[] entries,
Transaction tr,
long[] leaseTimes)
Write a set of entires into the space.
|
long[] |
write(EntryRep rep,
Transaction tr,
long lease)
Write a new entry into the space.
|
public static final String COMPONENT_NAME
static final String lifecycleLoggerName
static final String opsLoggerName
static final String txnLoggerName
static final String leaseLoggerName
static final String iteratorLoggerName
static final String joinLoggerName
static final String matchingLoggerName
static final String eventLoggerName
public static final String storeLoggerName
private static final Logger lifecycleLogger
private static final Logger opsLogger
private static final Logger txnLogger
private static final Logger leaseLogger
private static final Logger iteratorLogger
private static final Logger joinLogger
public static final String PERSISTENCE_DIR_CONFIG_ENTRY
private final EntryHolderSet contents
org.apache.river.outrigger.EntryHolders for
each specific type.private final TypeTree types
private final HashMap<String,Long> typeHashes
private final TransitionWatchers templates
private final Map<Uuid,LeasedResource> eventRegistrations
EventRegistrationRecord instancesprivate final Map<Uuid,LeasedResource> contentsQueries
ContentsQuery objects.private final Map<Long,Txn> recoveredTxns
private final TxnTable txnTable
Txns.private final long crashCount
private final OutriggerServerImpl.TemplateReaper templateReaperThread
private final OutriggerServerImpl.EntryReaper entryReaperThread
private final OutriggerServerImpl.ContentsQueryReaper contentsQueryReaperThread
private final OperationJournal operationJournal
templates.private volatile Notifier notifier
private final ExpirationOpQueue expirationOpQueue
nullprivate final TxnMonitor txnMonitor
private final OutriggerServerWrapper serverGate
private final LifeCycle lifeCycle
nullprivate final Exporter exporter
private volatile OutriggerServer ourRemoteRef
private volatile Uuid topUuid
Uuid for this service. Used in the
SpaceProxy2 and AdminProxy to
implement reference equality. We also derive our
ServiceID from it.private volatile SpaceProxy2 spaceProxy
private volatile AdminProxy adminProxy
private volatile ParticipantProxy participantProxy
private final java.util.concurrent.atomic.AtomicLong sessionId
For any given invocation of Outrigger, the numbers are "fully ordered." However, when Outrigger restarts after a crash, the numbers (when compared to the previous invocation) will appear to have a [large] gap.
[See the JavaSpaces Service Specification for detail on "fully ordered".]
private final LeasePeriodPolicy entryLeasePolicy
private final LeasePeriodPolicy eventLeasePolicy
private final LeasePeriodPolicy contentsLeasePolicy
private volatile LeaseFactory leaseFactory
private final JoinStateManager joinStateManager
private static final SecureRandom idGen
SecureRandom instance we use to create them.private final ActivationID activationID
null if we are not activatableprivate final ActivationSystem activationSystem
null if
we are not activatable.private volatile Store store
private volatile LogOps log
null if
this is a transient server instance.private final Map iterations
Uuid to active iterationsprivate final LoginContext loginContext
private final ProxyPreparer transactionManagerPreparer
ProxyPreparer for transaction managersprivate final ProxyPreparer listenerPreparer
ProxyPreparer for event listenersprivate final ProxyPreparer recoveredTransactionManagerPreparer
ProxyPreparer for transaction managers
that get recovered from the store. null if
this is not a persistent space.private final ProxyPreparer recoveredListenerPreparer
ProxyPreparer for event listeners
that get recovered from the store. null if
this is not a persistent space.private final int nextLimit
private final int takeLimit
private final long maxUnexportDelay
unexport(true)private final long unexportRetryDelay
private boolean started
private Configuration config
private Thread starter
private Throwable thrown
private Exception except
private boolean persistent
private long maxServerQueryTimeout
private AccessControlContext context
OutriggerServerImpl(ActivationID activationID, LifeCycle lifeCycle, String[] configArgs, boolean persistent, OutriggerServerWrapper wrapper) throws IOException, ConfigurationException, LoginException, ActivationException
OutriggerServerImpl server (possibly a
new incarnation of an activatable one).
Exports the server as well.activationID - of the server, may be null.lifeCycle - the object to notify when this
service is destroyed, may be null.configArgs - set of strings to be used to obtain a
Configuration.persistent - If true will throw an
ConfigurationException
if there is no persistence directory or
store specified in the configuration.wrapper - the wrapper that intercepts
incoming remote calls before delegating
them to this.IOException - if there is problem recovering data
from disk, exporting the server, or unpacking
data.ConfigurationException - if the Configuration is
malformed.ActivationException - if activatable and there
is a problem getting a reference to the activation system.LoginException - if the loginContext specified
in the configuration is non-null and throws
an exception when login is attempted.public void start()
throws IOException,
ConfigurationException,
LoginException
StartableIn addition to starting threads after construction, it also allows objects to avoid throwing an exception during construction to avoid finalizer attacks.
The implementation is required to ensure start() is idempotent (only executed once, additional invocations must return immediately).
start in interface StartableIOExceptionConfigurationExceptionLoginExceptionprivate OutriggerServerImpl.InitHolder init(Configuration config, boolean persistent, ActivationID activationID, OutriggerServerWrapper serverGate) throws IOException, ConfigurationException, ActivationException
OutriggerServerImpl server. Anything that needs
to be done with a subject is done by this method. Assumes the
serverGate and activationID fields have
been set.config - The configuration being used to configure
this server.persistent - If true will throw an
ConfigurationException
if there is no persistence directory or
store specified in the configuration.IOException - if there is problem recovering data
from disk, exporting the server, or unpacking
data.ConfigurationException - if the Configuration is
malformed.ActivationExceptionprivate void unwindConstructor(Throwable cause)
cause - The exception that caused the
constructor to fail.private void unwindExporter(OutriggerServer os, Exporter e)
private void unwindReaper(OutriggerServerImpl.Reaper r)
private void recoverTxns()
long getSessionId()
void cancelOp(Uuid cookie, boolean expired)
EntryHolder and watchers.void scheduleCancelOp(Uuid cookie)
cookie - The cookie to pass to cancelOp when
it is called.private void typeCheck(EntryRep rep) throws UnmarshalException
UnmarshalExceptionprivate boolean checkClass(String className, long value) throws UnmarshalException
UnmarshalExceptionprivate LeasePeriodPolicy.Result grant(LeasedResource resource, long requestedDuration, LeasePeriodPolicy policy, String policyName)
private void checkForEmpty(EntryRep[] entries, String msg)
private void checkForNull(Object value, String msg)
private void checkTimeout(long timeout)
private void checkLimit(long limit)
public long[] write(EntryRep rep, Transaction tr, long lease) throws TransactionException, RemoteException
OutriggerServerwrite in interface OutriggerServerTransactionException - A transaction error occurredRemoteExceptionpublic long[] write(EntryRep[] entries, Transaction tr, long[] leaseTimes) throws TransactionException, RemoteException
OutriggerServerwrite in interface OutriggerServerUuid and then the lower order bits
of the Uuid.TransactionException - A transaction error occurredRemoteExceptionprivate void addWrittenRep(EntryHandle handle, EntryHolder holder, Txn txn)
write and
recoverWrite.void recordTransition(EntryTransition transition)
contents (including any subsidiary
objects such as the appropriate EntryHandle).
Currently we only post transitions that increase the visibility of an entry, or those that resolve a lock. We don't post transitions that reflect the locking of an entry or straight takes. Some of the watchers exploit this fact, so if we ever start to post transitions take and/or new lock transition the watcher may need to be updated.
transition - an object describing the visibility
transition of an entry.NullPointerException - if transition
is null or if transition.getEntry
is null.void enqueueDelivery(EventSender sender)
sender - An object that on request will
attempt to deliver its event
to the associated listener.NullPointerException - if sender is
nullboolean attemptCapture(EntryHandle handle, TransactableMgr txn, boolean takeIt, Set lockedEntrySet, Set<EntryHandle> provisionallyRemovedEntrySet, long now, QueryWatcher watcher)
true, otherwise
return false. If the entry can not be read/taken
because of transaction conflicts the conflicting transaction(s)
will be added to the list of transactions to monitor.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 this
is not active false will be returned.takeIt - true if the caller is trying
take the passed entry, false
otherwise.lockedEntrySet - If the entry can not be read/taken
because of a transaction conflict and the value of
this argument is non-null, the ID of the entry
will be added to this set. This method assumes
that any concurrent access to the set is being
arbitrated by the set or by the caller of this method.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.watcher - The QueryWatcher requesting
capture of the entry.true if the entry could be read/taken and
false otherwise.NullPointerException - if entry is null.public EventRegistration notify(EntryRep tmpl, Transaction tr, RemoteEventListener listener, long leaseTime, MarshalledObject handback) throws TransactionException, RemoteException
OutriggerServerlistener. Matching is done as for read.notify in interface OutriggerServerTransactionExceptionRemoteExceptionpublic EventRegistration registerForAvailabilityEvent(EntryRep[] tmpls, Transaction tr, boolean visibilityOnly, RemoteEventListener listener, long leaseTime, MarshalledObject handback) throws TransactionException, RemoteException
OutriggerServerlistener. Matching is done as for
read.registerForAvailabilityEvent in interface OutriggerServertmpls - the templates that specify what entries should
generate eventstr - if non-null entries that become
visible to txn should generate events even
if txn is never committed. Registration is
terminated when txn leaves the active statevisibilityOnly - if true, events will
be generated for this registration only when a
matching Entry transitions from
invisible to visible, otherwise events will be
generated when a matching Entry
makes any transition from unavailable to
availablelistener - object to notify when an entry becomes (re)visibleleaseTime - initial requested lease time for the registrationhandback - object to be included with every notificationTransactionException - if txn is
non-null and not active or otherwise invalidRemoteExceptionvoid removeEventRegistration(EventRegistrationRecord reg)
EventRegistrationRecord from
event registrations map.reg - The EventRegistrationRecord object to remove.NullPointerException - if reg is null.public void cancel(Uuid cookie) throws UnknownLeaseException
Landlordcancel method is
called. Cancels the lease that is associated with the given
cookie.cancel in interface Landlordcancel in interface LocalLandlordcookie - the Uuid associated with the lease who's
renew method was calledUnknownLeaseException - if landlord does not know about
a lease with the specified cookiepublic long renew(Uuid cookie, long extension) throws UnknownLeaseException, LeaseDeniedException
Landlordrenew method is called.
Renews the lease that is associated with the given cookie.renew in interface Landlordrenew in interface LocalLandlordcookie - the Uuid associated with the lease who's
renew method was calledextension - argument passed to the renew callUnknownLeaseException - if landlord does not know about
a lease with the specified cookieLeaseDeniedException - if the landlord is unwilling to
renew the leasepublic Landlord.RenewResults renewAll(Uuid[] cookies, long[] extensions)
LandlordrenewAll method is called. Should renew the lease that is
associated with each element of cookiesrenewAll in interface Landlordcookies - an array of Uuids, each universally and
uniquely identifying a lease granted by this
Landlordextensions - an array of longs, each representing an a
duration in milliseconds that the client
wants the lease associated with the Uuid
from the corresponding element of
cookies renewed forpublic Map cancelAll(Uuid[] cookies)
LandlordcancelAll method is called. Should cancel the lease that is
associated with each element of cookiescancelAll in interface Landlordcookies - an array of Uuids, each universally and
uniquely identifying a lease granted by this
Landlordcookies
could be cancelled return null. Otherwise,
return a Map that for each failed cancel
attempt maps the corresponding cookie object to an
exception describing the failure.public Object read(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie) throws TransactionException, RemoteException, InterruptedException
OutriggerServertimeout parameter. The proxy may choose to
breakup a query from the client with a very long timeout into a
set of sub-queries. In such cases it may get a
QueryCookie as response to the sub-queries, in
these cases it should pass the QueryCookie to the
next sub-query (if any) associated with the same request from
the client.
If a match is found it is returned as an EntryRep.
If txn is non-null the
entry is read locked by the transaction, this allows
other queries to read, but not take the entry. The lock
will be released when the transaction is aborted or prepared.
If no match is found the call will block for up to the
specified timeout for a match to appear. If there
is still no match available the call will return a
QueryCookie.
read in interface OutriggerServertmpl - The template that describes the entry being
searched for. May be null if
any visible entry is acceptable.txn - The transaction the operation should be
performed under. Maybe be null.
If non-null and entry is found it
will read locked/removed under this
transaction.timeout - The maximum number of milliseconds this
call should block in the server before
returning an answer (this not necessarily
the timeout the client asked for.) A value
of 0 indicates the initial search should
be performed, but if no match can be found
null or a QueryCookie
(as appropriate) should be returned immediately.cookie - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.RemoteException - if a network failure occurs.InterruptedException - if the thread in the server
is interrupted before the query can be completed.public Object take(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie) throws TransactionException, RemoteException, InterruptedException
OutriggerServertimeout parameter. The proxy may choose to
breakup a query from the client with a very long timeout into a
set of sub-queries. In such cases it may get a
QueryCookie as response to the sub-queries, in
these cases it should pass the QueryCookie to the
next sub-query (if any) associated with the same request from
the client.
If a match is found it is returned as an EntryRep.
If txn is null the entry is removed
from the space. If txn is non-null the
entry is exclusively locked by the transaction and will be removed
from the space if the transaction is committed.
If no match is found the call will block for up to the
specified timeout for a match to appear. If there
is still no match available the call will return a
QueryCookie.
take in interface OutriggerServertmpl - The template that describes the entry being
searched for. May be null if
any visible entry is acceptable.txn - The transaction the operation should be
performed under. Maybe be null.
If non-null and entry is found it
will read locked/removed under this
transaction.timeout - The maximum number of milliseconds this
call should block in the server before
returning an answer (this not necessarily
the timeout the client asked for.) A value
of 0 indicates the initial search should
be performed, but if no match can be found
null or a QueryCookie
(as appropriate) should be returned immediately.cookie - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.RemoteException - if a network failure occurs.InterruptedException - if the thread in the server
is interrupted before the query can be completed.public Object readIfExists(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie) throws TransactionException, RemoteException, InterruptedException
OutriggerServertimeout parameter. The proxy may choose to
breakup a query from the client with a very long timeout into a
set of sub-queries. In such cases it may get a
QueryCookie as response to the sub-queries, in
these cases it should pass the QueryCookie to the
next sub-query (if any) associated with the same request from
the client.
If a match is found it is returned as an EntryRep.
If txn is non-null the
entry is read locked by the transaction, this allows
other queries to read, but not take the entry. The lock
will be released when the transaction is aborted or prepared.
If no match can be initially found the call will block until
either the timeout expires or for a detectable period of time
there are no entries in the space (visible to the transaction
or not) that match the passed template. If at some point
there are no matching entries in the space null
will be returned. If the timeout expires and there are matching
entries in the space but none are visible to the passed
transaction a QueryCookie will be returned.
readIfExists in interface OutriggerServertmpl - The template that describes the entry being
searched for. May be null if
any visible entry is acceptable.txn - The transaction the operation should be
performed under. Maybe be null.
If non-null and entry is found it
will read locked/removed under this
transaction.timeout - The maximum number of milliseconds this
call should block in the server before
returning an answer (this not necessarily
the timeout the client asked for.) A value
of 0 indicates the initial search should
be performed, but if no match can be found
null or a QueryCookie
(as appropriate) should be returned immediately.cookie - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.RemoteException - if a network failure occurs.InterruptedException - if the thread in the server
is interrupted before the query can be completed.public Object takeIfExists(EntryRep tmpl, Transaction txn, long timeout, OutriggerServer.QueryCookie cookie) throws TransactionException, RemoteException, InterruptedException
OutriggerServertimeout parameter. The proxy may choose to
breakup a query from the client with a very long timeout into a
set of sub-queries. In such cases it may get a
QueryCookie as response to the sub-queries, in
these cases it should pass the QueryCookie to the
next sub-query (if any) associated with the same request from
the client.
If a match is found it is returned as an EntryRep.
If txn is null the entry is removed
from the space. If txn is non-null the
entry is exclusively locked by the transaction and will be removed
from the space if the transaction is committed.
If no match can be initially found the call will block until
either the timeout expires or for a detectable period of time
there are no entries in the space (visible to the transaction
or not) that match the passed template. If at some point there
are no matching entries in the space null will be
returned. If the timeout expires and there are matching entries
in the space but none are visible to the passed transaction a
QueryCookie will be returned.
takeIfExists in interface OutriggerServertmpl - The template that describes the entry being
searched for. May be null if
any visible entry is acceptable.txn - The transaction the operation should be
performed under. Maybe be null.
If non-null and entry is found it
will read locked/removed under this
transaction.timeout - The maximum number of milliseconds this
call should block in the server before
returning an answer (this not necessarily
the timeout the client asked for.) A value
of 0 indicates the initial search should
be performed, but if no match can be found
null or a QueryCookie
(as appropriate) should be returned immediately.cookie - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.RemoteException - if a network failure occurs.InterruptedException - if the thread in the server
is interrupted before the query can be completed.public Object take(EntryRep[] tmpls, Transaction tr, long timeout, int limit, OutriggerServer.QueryCookie queryCookieFromClient) throws TransactionException, RemoteException
OutriggerServerlimit entries in the space
that match one or more of the passed templates and are visible
to the passed transaction. Depending on the state of the space
and the arguments this call may block if no entry can be
immediately returned. The proxy can specify the maximum period
it is willing to wait for a response using the
timeout parameter. The proxy may choose to
breakup a query from the client with a very long timeout into a
set of sub-queries. In such cases it may get a
QueryCookie as response to the sub-queries, in
these cases it should pass the QueryCookie to the
next sub-query (if any) associated with the same request from
the client.
If matchs are found they are returned as in an array of
EntryRep. If txn is
null the entries are removed from the space. If
txn is non-null the entries are
exclusively locked by the transaction and will be removed from
the space if the transaction is committed.
If there are no matches the call will block for up to the
specified timeout for a match to appear. If there is still no
match available the call will return a
QueryCookie.
take in interface OutriggerServertmpls - The templates that describes the entries being
searched fortr - The transaction the operation should be
performed under. Maybe be null.
If non-null and entries are found they
will removed under this transaction.timeout - The maximum number of milliseconds this
call should block in the server before
returning an answer (this not necessarily
the timeout the client asked for.) A value
of 0 indicates the initial search should
be performed, but if no match can be found
a QueryCookie should be
returned immediately.limit - The maximum number of entries that should be takenqueryCookieFromClient - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.RemoteException - if a network failure occurs.private EntryRep[] completeTake(EntryHandle[] handles, int found, Txn txn) throws TransactionException
TransactionExceptionprivate EntryRep completeTake(EntryHandle handle, Txn txn) throws TransactionException
TransactionExceptionprivate EntryHolder.ContinuingQuery createQuery(EntryRep[] tmpls, String clazz, Txn txn, boolean takeIt, long now)
private static void waitOnProvisionallyRemovedEntries(Set<EntryHandle> provisionallyRemovedEntrySet) throws InterruptedException
waitOnCompleteRemoval on each of the EntryHandles
in the passed set.InterruptedExceptionprivate Object getMatch(EntryRep tmpl, Transaction tr, long timeout, boolean takeIt, boolean ifExists, OutriggerServer.QueryCookie queryCookieFromClient) throws RemoteException, InterruptedException, TransactionException
tmpl - The template for the query, may be null
if all entries match.tr - The transaction the query is being performed under,
or null if there is no transaction.timeout - Maxium time to block in milliseconds.takeIt - true if the entry found is
to be removed.ifExists - true if this query is to follow
the rules for ifExists queries.queryCookieFromClient - If this call is a continuation of
an earlier query, the cookie from the
last sub-query.RemoteException - if a network failure occurs.TransactionException - if there is a problem
with the specified transaction such as
it can not be joined, or leaves the active
state before the call is complete.InterruptedException - if the thread in the server
is interrupted before the query can be completed.SecurityException - if the server decides
the caller has insufficient privilege to carry
out the operation.IllegalArgumentException - if a negative timeout value is usedInternalSpaceException - if there is an internal problem
with the server.private void monitor(QueryWatcher watcher, Collection<Txn> toMonitor)
void monitor(Collection<Txn> toMonitor)
void dump(String name, EntryRep rep)
static void dump(EntryHolder holder, String name, EntryRep rep)
private EntryHandle find(EntryRep tmplRep, Txn txn, boolean takeIt, Set conflictSet, Set lockedEntrySet, Set<EntryHandle> provisionallyRemovedEntrySet) throws TransactionException
whichClass that
matches the template tmplRep (at least the
template's type, and matches in values provided).
whichClass is at least the type of the template.
If takeIt is true the matching entry
is removed (perhaps provisionally).TransactionExceptionstatic long nextID()
SecureRandom object so that it is next to
impossible to forge an ID and so we don't have
to remember/restore a counter cross restarts.public MatchSetData contents(EntryRep[] tmpls, Transaction tr, long leaseTime, long limit) throws TransactionException, RemoteException
OutriggerServerMatchSetData with the initial batch of
entries and (if applicable) the Uuid and initial
lease duration. If the entire result set is contained in the
returned MatchSetData the Uuid
will be null and the lease duration will be
-1.contents in interface OutriggerServertmpls - the templates to use for the iterationtr - the transaction to perform the iteration under,
may be nullleaseTime - the requested lease timelimit - the maximum number of entries to returnMatchSetData with the initial batch
of entries and (if applicable) the Uuid and initial
lease duration. Initial batch will be the empty array if
there are no matching entries in the spaceTransactionException - if
tr is non-null and can't be usedRemoteExceptionpublic EntryRep[] nextBatch(Uuid contentsQueryUuid, Uuid entryUuid) throws NoSuchObjectException
OutriggerServernextBatch in interface OutriggerServercontentsQueryUuid - the id of the contents queryentryUuid - the id of the last entry in the last batch.
If this does not match what the server has on recored
it will re-send the previous batch.EntryReps representing
the next batch of entries from the query. Query
is complete if array is not full. Returns an empty
array if there are no entries leftNoSuchObjectException - if the server has no record
of contentsQueryUuidpublic Object getServiceProxy()
ServiceProxyAccessornull.getServiceProxy in interface ServiceProxyAccessorObject getProxy()
public Object getAdmin()
JavaSpaceAdmin
interface.getAdmin in interface OutriggerServerJavaSpaceAdminpublic JavaSpace space()
OutriggerAdminspace in interface OutriggerAdminpublic Uuid contents(EntryRep tmpl, Transaction tr) throws TransactionException, RemoteException
OutriggerAdminJavaSpaceAdmin.contents.contents in interface OutriggerAdminTransactionExceptionRemoteExceptionpublic EntryRep[] nextReps(Uuid iterationUuid, int max, Uuid entryUuid) throws NoSuchObjectException
OutriggerAdminmax EntryRep objects from
the specified iteration.nextReps in interface OutriggerAdminiterationUuid - The Uuid of the iteration
to fetch entries from.max - Advice on the number of entries to returnentryUuid - Uuid of the last entry received by the
caller. If this does not match the ID of the last
entry sent by the iterator will re-send that last
batch in place of a new batch. May be
null in which case a new batch will be
sent. The first call to next() should
have id set to nullNoSuchObjectExceptionpublic void delete(Uuid iterationUuid, Uuid entryUuid) throws NoSuchObjectException
OutriggerAdminnextReps.delete in interface OutriggerAdminiterationUuid - The Uuid of a valid
iteration.entryUuid - the Uuid of the entry
to be deleted.NoSuchObjectExceptionpublic void close(Uuid iterationUuid) throws NoSuchObjectException
OutriggerAdminclose in interface OutriggerAdminiterationUuid - The Uuid iteration to close.NoSuchObjectExceptionpublic void destroy()
destroy in interface DestroyAdminprivate void destroyReaper(OutriggerServerImpl.Reaper r)
private void joinThread(Thread t)
private void logDestroyProblem(String part, Throwable t)
private void logDestroyPhase(String part)
public Entry[] getLookupAttributes()
JoinAdmingetLookupAttributes in interface JoinAdminpublic void addLookupAttributes(Entry[] attrSets)
JoinAdminaddLookupAttributes in interface JoinAdminattrSets - the attribute sets to addpublic void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
JoinAdminmodifyLookupAttributes in interface JoinAdminattrSetTemplates - the templates for matching attribute setsattrSets - the modifications to make to matching setsServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])public String[] getLookupGroups()
JoinAdmingetLookupGroups in interface JoinAdminJoinAdmin.setLookupGroups(java.lang.String[])public void addLookupGroups(String[] groups)
JoinAdminaddLookupGroups in interface JoinAdmingroups - groups to joinJoinAdmin.removeLookupGroups(java.lang.String[])public void removeLookupGroups(String[] groups)
JoinAdminremoveLookupGroups in interface JoinAdmingroups - groups to leaveJoinAdmin.addLookupGroups(java.lang.String[])public void setLookupGroups(String[] groups)
JoinAdminsetLookupGroups in interface JoinAdmingroups - groups to joinJoinAdmin.getLookupGroups()public LookupLocator[] getLookupLocators()
JoinAdmingetLookupLocators in interface JoinAdminJoinAdmin.setLookupLocators(net.jini.core.discovery.LookupLocator[])public void addLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdminaddLookupLocators in interface JoinAdminlocators - locators of specific lookup services to joinRemoteExceptionJoinAdmin.removeLookupLocators(net.jini.core.discovery.LookupLocator[])public void removeLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdminremoveLookupLocators in interface JoinAdminlocators - locators of specific lookup services to leaveRemoteExceptionJoinAdmin.addLookupLocators(net.jini.core.discovery.LookupLocator[])public void setLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdminsetLookupLocators in interface JoinAdminlocators - locators of specific lookup services to joinRemoteExceptionJoinAdmin.getLookupLocators()public void recoverSessionId(long sessionId)
recoverSessionId in interface RecoversessionId - Value used by the previous invocation of OutriggerLogOps.bootOp(long, long)public void recoverJoinState(StoredObject state) throws Exception
RecoverrecoverJoinState in interface Recoverstate - is the stored join stateExceptionLogOps.joinStateOp(org.apache.river.outrigger.StorableObject)public void recoverWrite(StoredResource entry, Long txnId) throws Exception
Recoverentry is the
stored form of the entry passed into writeOp. If the
original write was done under a transaction, and the transaction
was prepared txnId will be non-null.recoverWrite in interface Recoverentry - stored from of the written entrytxnId - transaction identifier or nullException - is thrown if any error occurs recovering the
writeLogOps.writeOp(org.apache.river.outrigger.StorableResource, java.lang.Long)public void recoverTake(Uuid cookie, Long txnId) throws Exception
RecovertxnId
will be non-null.recoverTake in interface Recovercookie - identifier of the entry to taketxnId - transaction identifier or nullException - is thrown if any error occurs recovering the takeLogOps.takeOp(net.jini.id.Uuid, java.lang.Long)public void recoverTransaction(Long txnId, StoredObject transaction) throws Exception
Recovertransaction is the stored form of the transaction
passed into prepareOp.recoverTransaction in interface RecovertxnId - transaction identifiertransaction - stored from of the prepared transactionException - is thrown if any error occurs recovering the
transactionLogOps.prepareOp(java.lang.Long, org.apache.river.outrigger.StorableObject)public void recoverRegister(StoredResource registration, String type, StoredObject[] storedTemplates) throws Exception
Recoverregistration is the stored form of the
registration passed into registerOp. The recovered
template is the stored form of the template.recoverRegister in interface Recoverregistration - stored from of the logged registrationtype - of registration, same value that was passed into
corresponding registerOp callstoredTemplates - stored from of the logged templatesException - is thrown if any error occurs recovering the
registrationLogOps.registerOp(org.apache.river.outrigger.StorableResource, java.lang.String, org.apache.river.outrigger.StorableObject[])public void recoverUuid(Uuid uuid)
RecoverUuid for the service as a whole.
Will only be called if a Uuid has be stored during
a previous incarnation.recoverUuid in interface Recoveruuid - The Uuid being recovered.LogOps.uuidOp(net.jini.id.Uuid)public TrustVerifier getProxyVerifier()
ServerProxyTrustTrustVerifier that can be used to verify that
a proxy can be trusted as a proxy for the service; that is, the
isTrustedObject method of the
returned verifier can be called with a candidate proxy. The verifier
should be able to verify all proxies for the service, including
proxies for resources (such as leases and registrations).getProxyVerifier in interface ServerProxyTrustTrustVerifier that can be used to verify that
a proxy can be trusted as a proxy for the serviceprivate Txn enterTxn(Transaction baseTr) throws TransactionException, RemoteException
baseTr (the transaction object passed to us by the
client) and retrieves the associated Txn object
(the internal representation for that transaction) from the
space's records. If no Txn object is associated
with the given semantic object, a new Txn object is
created, associated and recorded.TransactionExceptionRemoteExceptionprivate Txn getTxn(TransactionManager mgr, long id) throws UnknownTransactionException, UnmarshalException
Txn object for the given
manager/id pair. If there is one, return it. If there isn't
one, throw UnknownTransactionException.private UnmarshalException brokenTxn(TransactionManager mgr, long id, Exception nested) throws UnmarshalException
UnmarshalExceptionprivate ServerTransaction serverTransaction(Transaction baseTr) throws UnknownTransactionException
Transaction object sent to the
space is actually the ServerTransaction subtype.
This method does the downcast, and turns an error into the
appropriate UnknownTransactionException exception.UnknownTransactionExceptionpublic int prepare(TransactionManager mgr, long id) throws UnknownTransactionException, UnmarshalException
TransactionParticipantPREPARED, indicating that it is prepared;
ABORT, indicating that it will abort, or
NOTCHANGED, indicating that it did not have any state
changed by the transaction (i.e., it was read-only). If the response
is PREPARED, the participant must wait until it receives
a commit or abort call from the transaction manager; it may query the
transaction manager if needed as to the state of the transaction. If
the response is ABORT, the participant should roll its
state back to undo any changes that occurred due to operations
performed under the transaction; it can then discard any information
about the transaction. If the response is NOTCHANGED, the
participant can immediately discard any knowledge of the transaction.prepare in interface TransactionParticipantmgr - the manager of the transactionid - the transaction IDint representing this participant's stateUnknownTransactionException - if the transaction
is unknown to the transaction manager, either
because the transaction ID is incorrect or because the
transaction is complete and its state has been
discarded by the manager.UnmarshalExceptionpublic void commit(TransactionManager mgr, long id) throws UnknownTransactionException, UnmarshalException
TransactionParticipantPREPARED
changes for the specified transaction visible outside of the
transaction and unlock any resources locked by the transaction.
All state associated with the transaction can then be discarded
by the participant.commit in interface TransactionParticipantmgr - the manager of the transactionid - the transaction IDUnknownTransactionException - if the transaction
is unknown to the transaction manager, either
because the transaction ID is incorrect or because the
transaction is complete and its state has been
discarded by the manager.UnmarshalExceptionpublic void abort(TransactionManager mgr, long id) throws UnknownTransactionException, UnmarshalException
TransactionParticipantabort in interface TransactionParticipantmgr - the manager of the transactionid - the transaction IDUnknownTransactionException - if the transaction
is unknown to the transaction manager, either
because the transaction ID is incorrect or because the
transaction is complete and its state has been
discarded by the manager.UnmarshalExceptionpublic int prepareAndCommit(TransactionManager mgr, long id) throws UnknownTransactionException, UnmarshalException
TransactionParticipantprepare and commit, which
can be used by the manager when there is just one participant left to
prepare and all other participants (if any) have responded with
NOTCHANGED. The participant's implementation of this
method must be equivalent to:
public int prepareAndCommit(TransactionManager mgr, long id)
throws UnknownTransactionException, RemoteException
{
int result = prepare(mgr, id);
if (result == PREPARED) {
commit(mgr, id);
result = COMMITTED;
}
return result;
}
prepareAndCommit in interface TransactionParticipantmgr - the manager of the transactionid - the transaction IDint representing its stateUnknownTransactionException - if the transaction
is unknown to the transaction manager, either
because the transaction ID is incorrect or because the
transaction is complete and its state has been
discarded by the manager.UnmarshalExceptionTransactionParticipant.prepare(net.jini.core.transaction.server.TransactionManager, long),
TransactionParticipant.commit(net.jini.core.transaction.server.TransactionManager, long)ProxyPreparer getRecoveredTransactionManagerPreparer()
null if there is none.null if there is none.private final void debug(Object obj, String str)
obj, followed by
the given str.private static Entry[] attributesFor()
private RuntimeException logAndThrow(RuntimeException e, Logger logger)
private IllegalArgumentException logAndThrowIllegalArg(String msg)
private UnknownLeaseException throwNewUnknownLeaseException(Object cookie) throws UnknownLeaseException
UnknownLeaseExceptionprivate CannotJoinException throwNewCannotJoinException() throws CannotJoinException
CannotJoinExceptionprivate NoSuchObjectException throwNewNoSuchObjectException(String msg, Logger logger) throws NoSuchObjectException
NoSuchObjectExceptionprivate NoSuchObjectException throwNewNoSuchObjectException(String msg, Throwable t, Logger logger) throws NoSuchObjectException
NoSuchObjectExceptionCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.