class TxnManagerImpl extends Object implements TxnManager, LeaseExpirationMgr.Expirer, LogRecovery, TxnSettler, TimeConstants, LocalLandlord, ServerProxyTrust, ProxyAccessor
Modifier and Type | Class and Description |
---|---|
private class |
TxnManagerImpl.DestroyThread
Termination thread code.
|
Landlord.RenewResults
TransactionManager.Created
Modifier and Type | Field and Description |
---|---|
private ActivationID |
activationID |
private boolean |
activationPrepared
Whether the activation ID has been prepared
|
private ActivationSystem |
activationSystem
The activation system, prepared
|
(package private) static Logger |
destroyLogger
Logger for service destruction related messages
|
private LeaseExpirationMgr |
expMgr
LeaseExpirationMgr used by our LeasePolicy . |
protected Exporter |
exporter
The exporter for exporting and unexporting
|
private static SecureRandom |
idGen
The generator for our IDs.
|
private static byte[] |
idGenBuf
The buffer for generating IDs.
|
(package private) static Logger |
initLogger
Logger for service re/initialization related messages
|
private JoinStateManager |
joinStateManager |
private LeaseFactory |
leaseFactory
LandLordLeaseFactory we use to create leases |
private LifeCycle |
lifeCycle
Cache of our
LifeCycle object |
protected LoginContext |
loginContext
The login context, for logging out
|
private LogManager |
logmgr |
private static long |
MAX_UNEXPORT_DELAY
Maximum delay for unexport attempts
|
(package private) static Logger |
operationsLogger
Logger for service operation messages
|
(package private) static Logger |
participantLogger
Logger for transaction participant related messages
|
private ProxyPreparer |
participantPreparer
Proxy preparer for listeners
|
private String |
persistenceDirectory |
(package private) static Logger |
persistenceLogger
Logger for transaction persistence related messages
|
private boolean |
persistent
boolean flag used to determine persistence support. |
private ReadyState |
readyState
Object used to prevent access to this service during the service's
initialization or shutdown processing.
|
private TxnManager |
serverStub
Cache of our inner proxy.
|
private float |
settlerload |
private TaskManager |
settlerpool |
private int |
settlerthreads |
private long |
settlertimeout |
private WakeupManager |
settlerWakeupMgr
wakeup manager for
SettlerTask |
private InterruptedStatusThread |
settleThread |
(package private) static Logger |
startupLogger
Logger for (successful) service startup message
|
private float |
taskload |
private TaskManager |
taskpool |
private int |
taskthreads |
private long |
tasktimeout |
private WakeupManager |
taskWakeupMgr
wakeup manager for
ParticipantTask |
private Uuid |
topUuid
The
Uuid for this service. |
(package private) static Logger |
transactionsLogger
Logger for transaction related messages
(creation, destruction, transition, etc.)
|
private LeasePeriodPolicy |
txnLeasePeriodPolicy |
private TxnMgrAdminProxy |
txnMgrAdminProxy
The admin proxy of this server
|
private TxnMgrProxy |
txnMgrProxy
The outter proxy of this server
|
private Map |
txns |
private Vector |
unsettledtxns |
MAHALO
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
DAYS, HOURS, MINUTES, SECONDS
Constructor and Description |
---|
TxnManagerImpl(ActivationID activationID,
MarshalledObject data)
Constructs an activatable transaction manager.
|
TxnManagerImpl(String[] args,
LifeCycle lc,
boolean persistent)
Constructs a non-activatable transaction manager.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(long id)
Abort the transaction.
|
private void |
abort(long id,
boolean doExpiryCheck) |
void |
abort(long id,
long waitFor)
Abort the transaction, waiting for participants to be notified of
the decision.
|
private void |
abort(long id,
long waitFor,
boolean doExpiryCheck) |
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 static Entry[] |
attributesFor()
Create the service owned attributes for an Mahalo server
|
void |
cancel(Uuid uuid)
Cancels the lease on a
Transaction . |
Map |
cancelAll(Uuid[] cookies)
Bulk cancel of leases on
Transaction s. |
private void |
cleanup() |
void |
commit(long id)
Commit the transaction.
|
void |
commit(long id,
long waitFor)
Commit the transaction, waiting for participants to be notified of
the decision.
|
TransactionManager.Created |
create(long lease)
Begin a new top-level transaction.
|
private Uuid |
createLeaseUuid(long txnId) |
void |
destroy()
Cleans up and exits the transaction manager.
|
private void |
doInit(Configuration config) |
private void |
doInitWithLogin(Configuration config,
LoginContext loginContext) |
private static boolean |
ensureCurrent(LeasedResource resource)
Utility method that check for valid resource
|
private TxnManagerTransaction |
enterTMT(long cookie) |
Object |
getAdmin()
Returns the administration object for the
transaction manager.
|
private Long |
getLeaseTid(Uuid uuid) |
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.
|
Object |
getProxy()
Returns a proxy object for this remote object.
|
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. |
Object |
getServiceProxy()
Returns a proxy object for this object.
|
int |
getState(long id)
Returns the current state of the given transaction.
|
Transaction |
getTransaction(long id)
Method from
TxnManager which produces
a Transaction from its ID. |
private void |
init(String[] configArgs)
Initialization common to both activatable and transient instances.
|
protected void |
initFailed(Throwable e)
Log information about failing to initialize the service and rethrow the
appropriate exception.
|
void |
join(long id,
TransactionParticipant part,
long crashCount)
Join a transaction that is managed by this transaction manager.
|
TransactionManager |
manager()
Returns a reference to the
TransactionManager
interface. |
void |
modifyLookupAttributes(Entry[] attrSetTemplates,
Entry[] attrSets)
Modify the current attribute sets, using the same semantics as
ServiceRegistration.modifyAttributes.
|
(package private) static long |
nextID()
gets the next available transaction ID.
|
void |
noteUnsettledTxn(long tid)
Informs the transaction manager to attempt to
settle a given transaction.
|
void |
recover(long cookie,
LogRecord rec)
This method recovers state changes resulting from
committing a transaction.
|
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 uuid,
long extension)
Requests the renewal of a lease on a
Transaction . |
Landlord.RenewResults |
renewAll(Uuid[] cookies,
long[] extensions)
Bulk renewal request of leases on
Transaction s. |
private ServerTransaction |
serverTransaction(Transaction baseTr) |
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 void |
settleTxns() |
private void |
verifyLeaseUuid(Uuid uuid) |
static final Logger startupLogger
static final Logger initLogger
static final Logger destroyLogger
static final Logger operationsLogger
static final Logger transactionsLogger
static final Logger participantLogger
static final Logger persistenceLogger
private LogManager logmgr
private transient int settlerthreads
private transient long settlertimeout
private transient float settlerload
private transient int taskthreads
private transient long tasktimeout
private transient float taskload
private transient TaskManager settlerpool
private WakeupManager settlerWakeupMgr
SettlerTask
private transient TaskManager taskpool
private WakeupManager taskWakeupMgr
ParticipantTask
private transient Map txns
private transient Vector unsettledtxns
private transient InterruptedStatusThread settleThread
private String persistenceDirectory
private ActivationID activationID
private boolean activationPrepared
private ActivationSystem activationSystem
private ProxyPreparer participantPreparer
protected Exporter exporter
protected LoginContext loginContext
private static transient SecureRandom idGen
private static final transient byte[] idGenBuf
private LeaseExpirationMgr expMgr
LeaseExpirationMgr
used by our LeasePolicy
.private LeasePeriodPolicy txnLeasePeriodPolicy
private LeaseFactory leaseFactory
LandLordLeaseFactory
we use to create leasesprivate JoinStateManager joinStateManager
private Uuid topUuid
Uuid
for this service. Used in the
TxnMgrProxy
and TxnMgrAdminProxy
to
implement reference equality. We also derive our
ServiceID
from it.private TxnMgrProxy txnMgrProxy
private TxnMgrAdminProxy txnMgrAdminProxy
private TxnManager serverStub
private LifeCycle lifeCycle
LifeCycle
objectprivate final ReadyState readyState
private boolean persistent
boolean
flag used to determine persistence support.
Defaulted to true, and overridden in the constructor overload that takes
a boolean
argument.private static final long MAX_UNEXPORT_DELAY
TxnManagerImpl(String[] args, LifeCycle lc, boolean persistent) throws Exception
args
- Service configuration optionslc
- LifeCycle
reference used for callbackException
TxnManagerImpl(ActivationID activationID, MarshalledObject data) throws Exception
activationID
- activation ID passed in by the activation daemon.data
- state data needed to re-activate a transaction manager.Exception
private void init(String[] configArgs) throws Exception
Exception
private void doInitWithLogin(Configuration config, LoginContext loginContext) throws Exception
Exception
private void doInit(Configuration config) throws Exception
Exception
public TransactionManager.Created create(long lease) throws LeaseDeniedException
TransactionManager
create
in interface TransactionManager
lease
- the requested lease time for the transactionLeaseDeniedException
- if this manager is unwilling to
grant the requested lease timepublic void join(long id, TransactionParticipant part, long crashCount) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
TransactionManager
crashCount
marks the state of the storage used by
the participant for transactions. If the participant attempts to
join a transaction more than once, the crash counts must be the same.
Each system crash or other event that destroys the state of the
participant's unprepared transaction storage must cause the crash
count to increase by at least one.join
in interface TransactionManager
id
- the transaction IDpart
- the participant joining the transactioncrashCount
- the participant's current crash countUnknownTransactionException
- 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.CannotJoinException
- if the transaction is known
to the manager but is no longer active.CrashCountException
- if the crash count provided
for the participant differs from the crash count
in a previous invocation of the same pairing of
participant and transactionRemoteException
- if there is a communication errorServerTransaction.join(net.jini.core.transaction.server.TransactionParticipant, long)
public int getState(long id) throws UnknownTransactionException
TransactionManager
TransactionConstants
values.getState
in interface TransactionManager
id
- the transaction IDint
representing the state of the transactionUnknownTransactionException
- 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.ServerTransaction.getState()
,
TransactionConstants
public void commit(long id) throws UnknownTransactionException, CannotCommitException, RemoteException
TransactionManager
NOTCHANGED
or the COMMITTED
state, without waiting for the
transaction manager to notify all participants of the decision.
If the transaction must be aborted (because one or more participants
are unable to prepare), CannotCommitException
is thrown
without waiting for the transaction manager to notify all participants
of the decision.commit
in interface TransactionManager
id
- 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.CannotCommitException
- if the transaction is being or already
has been abortedRemoteException
- if there is a communication errorpublic void commit(long id, long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException
TransactionManager
NOTCHANGED
or the
COMMITTED
state, and the transaction manager has
notified all participants of the decision, before the specified
timeout expires. If the transaction must be aborted (because one
or more participants are unable to prepare),
CannotCommitException
is thrown if the transaction
manager is able to notify all participants of the decision before
the specified timeout expires. If the transaction manager reaches
a decision, but is unable to notify all participants of that
decision before the specified timeout expires, then
TimeoutExpiredException
is thrown. If the specified
timeout expires before the transaction manager reaches a decision,
TimeoutExpiredException
is not thrown until the
manager reaches a decision.commit
in interface TransactionManager
id
- the transaction IDwaitFor
- timeout to wait, from the start of the call until
all participants have been notified of the transaction manager's
decisionUnknownTransactionException
- 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.CannotCommitException
- if the transaction is being or already
has been abortedTimeoutExpiredException
- if the transaction manager reaches
a decision, but is unable to notify all participants of that
decision before the specified timeout expiresRemoteException
- if there is a communication errorpublic void abort(long id) throws UnknownTransactionException, CannotAbortException
TransactionManager
abort
in interface TransactionManager
id
- 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.CannotAbortException
- if the transaction is known to have
previously reached the COMMITTED state due to an earlier
commitprivate void abort(long id, boolean doExpiryCheck) throws UnknownTransactionException, CannotAbortException
public void abort(long id, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException
TransactionManager
TimeoutExpiredException
is thrown.abort
in interface TransactionManager
id
- the transaction IDwaitFor
- timeout to wait, from the start of the call until
all participants have been notified of the transaction manager's
decisionUnknownTransactionException
- 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.CannotAbortException
- if the transaction is known to have
previously reached the COMMITTED state due to an earlier
commitTimeoutExpiredException
- if the timeout expires before
all participants have been notifiedprivate void abort(long id, long waitFor, boolean doExpiryCheck) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException
public void recover(long cookie, LogRecord rec) throws LogException
recover
in interface LogRecovery
cookie
- the transaction's IDrec
- the LogRecord
LogException
public void noteUnsettledTxn(long tid)
noteUnsettledTxn
in interface TxnSettler
tid
- the transaction's IDprivate void settleTxns() throws InterruptedException
InterruptedException
public Transaction getTransaction(long id) throws UnknownTransactionException
TxnManager
which produces
a Transaction
from its ID.getTransaction
in interface TxnManager
id
- the IDUnknownTransactionException
Transaction
,
TxnManager
public long renew(Uuid uuid, long extension) throws UnknownLeaseException, LeaseDeniedException
Transaction
.renew
in interface Landlord
renew
in interface LocalLandlord
uuid
- identifies the leased resourceextension
- requested lease extensionUnknownLeaseException
- if landlord does not know about
a lease with the specified cookie
LeaseDeniedException
- if the landlord is unwilling to
renew the leaseLease
,
LeasedResource
,
LeaseManager
public void cancel(Uuid uuid) throws UnknownLeaseException
Transaction
.cancel
in interface Landlord
cancel
in interface LocalLandlord
cancel
in interface LeaseExpirationMgr.Expirer
uuid
- identifies the leased resourceUnknownLeaseException
- if landlord does not know about
a lease with the specified cookie
Lease
,
LeasedResource
,
LeaseManager
public Landlord.RenewResults renewAll(Uuid[] cookies, long[] extensions)
Transaction
s.renewAll
in interface Landlord
cookies
- identifies the leased resourcesextensions
- requested lease extensionsLease
,
LeasedResource
,
LeaseManager
public Map cancelAll(Uuid[] cookies)
Transaction
s.cancelAll
in interface Landlord
cookies
- identifies the leased resourcescookies
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.Lease
,
LeasedResource
,
LeaseManager
static long nextID()
private ServerTransaction serverTransaction(Transaction baseTr) throws UnknownTransactionException
UnknownTransactionException
public TransactionManager manager()
TransactionManager
interface.manager
in interface TxnManager
TransactionManager
private TxnManagerTransaction enterTMT(long cookie)
public void destroy()
destroy
in interface DestroyAdmin
public Object getAdmin()
getAdmin
in interface Administrable
JoinAdmin
public Entry[] getLookupAttributes()
JoinAdmin
getLookupAttributes
in interface JoinAdmin
public void addLookupAttributes(Entry[] attrSets)
JoinAdmin
addLookupAttributes
in interface JoinAdmin
attrSets
- the attribute sets to addpublic void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
JoinAdmin
modifyLookupAttributes
in interface JoinAdmin
attrSetTemplates
- 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()
JoinAdmin
getLookupGroups
in interface JoinAdmin
JoinAdmin.setLookupGroups(java.lang.String[])
public void addLookupGroups(String[] groups)
JoinAdmin
addLookupGroups
in interface JoinAdmin
groups
- groups to joinJoinAdmin.removeLookupGroups(java.lang.String[])
public void removeLookupGroups(String[] groups)
JoinAdmin
removeLookupGroups
in interface JoinAdmin
groups
- groups to leaveJoinAdmin.addLookupGroups(java.lang.String[])
public void setLookupGroups(String[] groups)
JoinAdmin
setLookupGroups
in interface JoinAdmin
groups
- groups to joinJoinAdmin.getLookupGroups()
public LookupLocator[] getLookupLocators()
JoinAdmin
getLookupLocators
in interface JoinAdmin
JoinAdmin.setLookupLocators(net.jini.core.discovery.LookupLocator[])
public void addLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdmin
addLookupLocators
in interface JoinAdmin
locators
- locators of specific lookup services to joinRemoteException
JoinAdmin.removeLookupLocators(net.jini.core.discovery.LookupLocator[])
public void removeLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdmin
removeLookupLocators
in interface JoinAdmin
locators
- locators of specific lookup services to leaveRemoteException
JoinAdmin.addLookupLocators(net.jini.core.discovery.LookupLocator[])
public void setLookupLocators(LookupLocator[] locators) throws RemoteException
JoinAdmin
setLookupLocators
in interface JoinAdmin
locators
- locators of specific lookup services to joinRemoteException
JoinAdmin.getLookupLocators()
private static Entry[] attributesFor()
public Object getProxy()
ProxyAccessor
null
is returned.getProxy
in interface ProxyAccessor
null
public Object getServiceProxy()
ServiceProxyAccessor
null
.getServiceProxy
in interface ServiceProxyAccessor
protected void initFailed(Throwable e) throws Exception
e
- the exception produced by the failureException
private void cleanup()
public TrustVerifier getProxyVerifier()
ServerProxyTrust
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. The verifier
should be able to verify all proxies for the service, including
proxies for resources (such as leases and registrations).getProxyVerifier
in interface ServerProxyTrust
TrustVerifier
that can be used to verify that
a proxy can be trusted as a proxy for the serviceprivate static boolean ensureCurrent(LeasedResource resource)
private Uuid createLeaseUuid(long txnId)
private void verifyLeaseUuid(Uuid uuid) throws UnknownLeaseException
UnknownLeaseException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.