Package com.sun.jini.mahalo
Class TxnManagerImpl
java.lang.Object
com.sun.jini.mahalo.TxnManagerImpl
- All Implemented Interfaces:
DestroyAdmin,TimeConstants,Landlord,LocalLandlord,LeaseExpirationMgr.Expirer,LogRecovery,TxnManager,TxnSettler,ServiceProxyAccessor,Remote,Administrable,JoinAdmin,ExtendedTransactionManager,TransactionConstants,TransactionManager,ProxyAccessor,ServerProxyTrust
- Direct Known Subclasses:
TransientMahaloImpl
public class TxnManagerImpl
extends Object
implements TxnManager, LeaseExpirationMgr.Expirer, LogRecovery, TxnSettler, TimeConstants, LocalLandlord, ServerProxyTrust, ProxyAccessor
An implementation of the Jini(TM) Transaction Specification.
- Author:
- Sun Microsystems, Inc.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.sun.jini.landlord.Landlord
Landlord.RenewResultsNested classes/interfaces inherited from interface net.jini.core.transaction.server.TransactionManager
TransactionManager.Created -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExporterThe exporter for exporting and unexportingprotected LoginContextThe login context, for logging outFields inherited from interface com.sun.jini.constants.TimeConstants
DAYS, HOURS, MINUTES, SECONDSFields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTINGFields inherited from interface com.sun.jini.mahalo.TxnManager
MAHALO -
Method Summary
Modifier and TypeMethodDescriptionvoidabort(long id) Abort the transaction.voidabort(long id, long waitFor) Abort the transaction, waiting for participants to be notified of the decision.voidvoidvoidabort_impl(Object id, long waitFor) voidaddLookupAttributes(Entry[] attrSets) Add attribute sets for the service.voidaddLookupGroups(String[] groups) Add new groups to the set to join.voidaddLookupLocators(LookupLocator[] locators) Add locators for specific new lookup services to join.voidCancels the lease on aTransaction.Bulk cancel of leases onTransactions.voidcommit(long id) Commit the transaction.voidcommit(long id, long waitFor) Commit the transaction, waiting for participants to be notified of the decision.voidvoidcreate(long lease) Begin a new top-level transaction.voiddestroy()Cleans up and exits the transaction manager.booleandisJoin(long id, TransactionParticipant part) Remove a participant that was joined for a first time.booleandisJoin(Object id, TransactionParticipant part) getAdmin()Returns the administration object for the transaction manager.Entry[]Get the current attribute sets for the service.String[]Get the list of groups to join.Get the list of locators of specific lookup services to join.getProxy()Returns a proxy object for this remote object.Returns aTrustVerifierthat can be used to verify that a proxy can be trusted as a proxy for the service; that is, theisTrustedObjectmethod of the returned verifier can be called with a candidate proxy.Returns a proxy object for this object.intgetState(long id) Returns the current state of the given transaction.intgetTransaction(long id) Method fromTxnManagerwhich produces aTransactionfrom its ID.protected voidLog information about failing to initialize the service and rethrow the appropriate exception.voidjoin(long id, TransactionParticipant part, long crashCount) Join a transaction that is managed by this transaction manager.voidjoin(long id, TransactionParticipant part, long crashCount, int partitionId, String clusterName) voidjoin(long id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) voidjoin(long id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject, int partitionId, String clusterName, Object clusterProxy) voidjoin(Object xid, TransactionParticipant part, long crashCount) voidjoin(Object xid, TransactionParticipant part, long crashCount, int partitionId, String clusterName) voidjoin(Object xid, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) voidjoin(Object xid, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject, int partitionId, String clusterName, Object clusterProxy) manager()Returns a reference to theTransactionManagerinterface.voidmodifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets) Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.booleanreturns true if this mgr which requires that the txn participants join into the txn in contrary to a mgr which the participants are known prior to txn propagationvoidnoteUnsettledTxn(Object tid) Informs the transaction manager to attempt to settle a given transaction.intprepare the underlying xtn designated by the rendered xidvoidThis method recovers state changes resulting from committing a transaction.voidreenterPreparedExternalXid(Object xid, List<TransactionParticipant> parts) given a prepared xid (retrieved from participants) reenlist it and its participants- used in XAvoidremoveLookupGroups(String[] groups) Remove groups from the set to join.voidremoveLookupLocators(LookupLocator[] locators) Remove locators for specific lookup services from the set to join.longRequests the renewal of a lease on aTransaction.Bulk renewal request of leases onTransactions.voidsetLookupGroups(String[] groups) Replace the list of groups to join with a new list.voidsetLookupLocators(LookupLocator[] locators) Replace the list of locators of specific lookup services to join with a new list.
-
Field Details
-
exporter
The exporter for exporting and unexporting -
loginContext
The login context, for logging out
-
-
Method Details
-
create
Description copied from interface:TransactionManagerBegin a new top-level transaction.- Specified by:
createin interfaceTransactionManager- Parameters:
lease- the requested lease time for the transaction- Returns:
- the transaction ID and the lease granted
- Throws:
LeaseDeniedException- if this manager is unwilling to grant the requested lease time
-
create
public TransactionManager.Created create(Object externalXid, long lease) throws LeaseDeniedException - Specified by:
createin interfaceExtendedTransactionManager- Throws:
LeaseDeniedException
-
join
public void join(long id, TransactionParticipant part, long crashCount) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException Description copied from interface:TransactionManagerJoin a transaction that is managed by this transaction manager. ThecrashCountmarks 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.- Specified by:
joinin interfaceTransactionManager- Parameters:
id- the transaction IDpart- the participant joining the transactioncrashCount- the participant's current crash count- Throws:
UnknownTransactionException- 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 error- See Also:
-
join
public void join(Object xid, TransactionParticipant part, long crashCount) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(long id, TransactionParticipant part, long crashCount, int partitionId, String clusterName) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(Object xid, TransactionParticipant part, long crashCount, int partitionId, String clusterName) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(long id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(Object xid, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(long id, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject, int partitionId, String clusterName, Object clusterProxy) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
join
public void join(Object xid, TransactionParticipant part, long crashCount, ServerTransaction userXtnObject, int partitionId, String clusterName, Object clusterProxy) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException - Specified by:
joinin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotJoinExceptionCrashCountExceptionRemoteException
-
disJoin
public boolean disJoin(long id, TransactionParticipant part) throws UnknownTransactionException, RemoteException Description copied from interface:ExtendedTransactionManagerRemove a participant that was joined for a first time. called when a call to a participant returned empty so we can spare calling commit or abort on it, usually used in embedded mahalo- Specified by:
disJoinin interfaceExtendedTransactionManagerpart- The joiningTransactionParticpant- Returns:
- true if participant disjoined
- Throws:
UnknownTransactionExceptionRemoteException- See Also:
-
disJoin
public boolean disJoin(Object id, TransactionParticipant part) throws UnknownTransactionException, RemoteException -
prepare
public int prepare(Object xid) throws CannotCommitException, UnknownTransactionException, RemoteException prepare the underlying xtn designated by the rendered xid- Specified by:
preparein interfaceExtendedTransactionManager- Returns:
- int
- Throws:
CannotCommitExceptionUnknownTransactionExceptionRemoteException
-
getState
Description copied from interface:TransactionManagerReturns the current state of the given transaction. The returned state can be any of theTransactionConstantsvalues.- Specified by:
getStatein interfaceTransactionManager- Parameters:
id- the transaction ID- Returns:
- an
intrepresenting the state of the transaction - Throws:
UnknownTransactionException- 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.- See Also:
-
getState
- Specified by:
getStatein interfaceExtendedTransactionManager- Throws:
UnknownTransactionException
-
commit
public void commit(long id) throws UnknownTransactionException, CannotCommitException, RemoteException Description copied from interface:TransactionManagerCommit the transaction. Commit asks the transaction manager to execute the voting process with the participants. Returns if the transaction successfully reaches either theNOTCHANGEDor theCOMMITTEDstate, 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),CannotCommitExceptionis thrown without waiting for the transaction manager to notify all participants of the decision.- Specified by:
commitin interfaceTransactionManager- Parameters:
id- the transaction ID- Throws:
UnknownTransactionException- 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 error
-
commit
public void commit(long id, long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException Description copied from interface:TransactionManagerCommit the transaction, waiting for participants to be notified of the decision. Commit asks the transaction manager to execute the voting process with the participants. Returns if the transaction successfully reaches either theNOTCHANGEDor theCOMMITTEDstate, 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),CannotCommitExceptionis 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, thenTimeoutExpiredExceptionis thrown. If the specified timeout expires before the transaction manager reaches a decision,TimeoutExpiredExceptionis not thrown until the manager reaches a decision.- Specified by:
commitin interfaceTransactionManager- Parameters:
id- the transaction IDwaitFor- timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision- Throws:
UnknownTransactionException- 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 error
-
commit
public void commit(Object xid) throws UnknownTransactionException, CannotCommitException, RemoteException - Specified by:
commitin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotCommitExceptionRemoteException
-
commit
public void commit(Object xid, long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException - Specified by:
commitin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotCommitExceptionTimeoutExpiredExceptionRemoteException
-
abort
Description copied from interface:TransactionManagerAbort the transaction. This can be called at any time by any object holding a reference to the transaction. Abort asks the transaction manager to abort the transaction and to notify each participant of the decision, resulting in them rolling back any state changes made as part of the transaction. Returns as soon as the transaction manager records the abort decision, without waiting for the transaction manager to notify all participants of the decision.- Specified by:
abortin interfaceTransactionManager- Parameters:
id- the transaction ID- Throws:
UnknownTransactionException- 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 commit
-
abort
public void abort(long id, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException Description copied from interface:TransactionManagerAbort the transaction, waiting for participants to be notified of the decision. This can be called at any time by any object holding a reference to the transaction. Abort asks the transaction manager to abort the transaction and to notify each participant of the decision, resulting in them rolling back any state changes made as part of the transaction. Returns if the transaction manager records the decision and is able to notify all participants of the decision before the specified timeout expires. If the transaction manager is unable to notify all participants of the decision before the specified timeout expires, thenTimeoutExpiredExceptionis thrown.- Specified by:
abortin interfaceTransactionManager- Parameters:
id- the transaction IDwaitFor- timeout to wait, from the start of the call until all participants have been notified of the transaction manager's decision- Throws:
UnknownTransactionException- 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 notified
-
abort_impl
public void abort_impl(Object id, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException -
abort
public void abort(Object xid) throws UnknownTransactionException, CannotAbortException, RemoteException - Specified by:
abortin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotAbortExceptionRemoteException
-
abort
public void abort(Object xid, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException, RemoteException - Specified by:
abortin interfaceExtendedTransactionManager- Throws:
UnknownTransactionExceptionCannotAbortExceptionTimeoutExpiredExceptionRemoteException
-
recover
This method recovers state changes resulting from committing a transaction. This re-creates the internal representation of the transaction.- Specified by:
recoverin interfaceLogRecovery- Parameters:
cookie- the transaction's IDrec- theLogRecord- Throws:
LogException
-
noteUnsettledTxn
Informs the transaction manager to attempt to settle a given transaction.- Specified by:
noteUnsettledTxnin interfaceTxnSettler- Parameters:
tid- the transaction's ID
-
getTransaction
Method fromTxnManagerwhich produces aTransactionfrom its ID.- Specified by:
getTransactionin interfaceTxnManager- Parameters:
id- the ID- Throws:
UnknownTransactionException- See Also:
-
renew
Requests the renewal of a lease on aTransaction.- Specified by:
renewin interfaceLandlord- Specified by:
renewin interfaceLocalLandlord- Parameters:
uuid- identifies the leased resourceextension- requested lease extension- Returns:
- The new duration the lease should have
- Throws:
UnknownLeaseException- if landlord does not know about a lease with the specifiedcookieLeaseDeniedException- if the landlord is unwilling to renew the lease- See Also:
-
cancel
Cancels the lease on aTransaction.- Specified by:
cancelin interfaceLandlord- Specified by:
cancelin interfaceLeaseExpirationMgr.Expirer- Specified by:
cancelin interfaceLocalLandlord- Parameters:
uuid- identifies the leased resource- Throws:
UnknownLeaseException- if landlord does not know about a lease with the specifiedcookie- See Also:
-
renewAll
Bulk renewal request of leases onTransactions.- Specified by:
renewAllin interfaceLandlord- Parameters:
cookies- identifies the leased resourcesextensions- requested lease extensions- Returns:
- A RenewResults object that contains the new duration of each lease that was successfully renewed or the exception encountered for each lease that could not be renewed
- See Also:
-
cancelAll
Bulk cancel of leases onTransactions.- Specified by:
cancelAllin interfaceLandlord- Parameters:
cookies- identifies the leased resources- Returns:
- If all the leases specified in the
cookiescould be cancelled returnnull. Otherwise, return aMapthat for each failed cancel attempt maps the corresponding cookie object to an exception describing the failure. - See Also:
-
manager
Returns a reference to theTransactionManagerinterface.- Specified by:
managerin interfaceTxnManager- See Also:
-
reenterPreparedExternalXid
public void reenterPreparedExternalXid(Object xid, List<TransactionParticipant> parts) throws CannotCommitException Description copied from interface:TxnManagergiven a prepared xid (retrieved from participants) reenlist it and its participants- used in XA- Specified by:
reenterPreparedExternalXidin interfaceTxnManager- Throws:
CannotCommitException
-
destroy
public void destroy()Cleans up and exits the transaction manager.- Specified by:
destroyin interfaceDestroyAdmin
-
getAdmin
Returns the administration object for the transaction manager.- Specified by:
getAdminin interfaceAdministrable- Returns:
- an object that implements whatever administration interfaces are appropriate for the particular service.
- See Also:
-
getLookupAttributes
Description copied from interface:JoinAdminGet the current attribute sets for the service.- Specified by:
getLookupAttributesin interfaceJoinAdmin- Returns:
- the current attribute sets for the service
-
addLookupAttributes
Description copied from interface:JoinAdminAdd attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added to all currently-joined lookup services.- Specified by:
addLookupAttributesin interfaceJoinAdmin- Parameters:
attrSets- the attribute sets to add
-
modifyLookupAttributes
Description copied from interface:JoinAdminModify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes. The resulting set will be used for all future joins. The same modifications are also made to all currently-joined lookup services.- Specified by:
modifyLookupAttributesin interfaceJoinAdmin- Parameters:
attrSetTemplates- the templates for matching attribute setsattrSets- the modifications to make to matching sets- See Also:
-
getLookupGroups
Description copied from interface:JoinAdminGet the list of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).- Specified by:
getLookupGroupsin interfaceJoinAdmin- Returns:
- an array of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).
- See Also:
-
addLookupGroups
Description copied from interface:JoinAdminAdd new groups to the set to join. Lookup services in the new groups will be discovered and joined.- Specified by:
addLookupGroupsin interfaceJoinAdmin- Parameters:
groups- groups to join- See Also:
-
removeLookupGroups
Description copied from interface:JoinAdminRemove groups from the set to join. Leases are cancelled at lookup services that are not members of any of the remaining groups.- Specified by:
removeLookupGroupsin interfaceJoinAdmin- Parameters:
groups- groups to leave- See Also:
-
setLookupGroups
Description copied from interface:JoinAdminReplace the list of groups to join with a new list. Leases are cancelled at lookup services that are not members of any of the new groups. Lookup services in the new groups will be discovered and joined.- Specified by:
setLookupGroupsin interfaceJoinAdmin- Parameters:
groups- groups to join- See Also:
-
getLookupLocators
Description copied from interface:JoinAdminGet the list of locators of specific lookup services to join.- Specified by:
getLookupLocatorsin interfaceJoinAdmin- Returns:
- the list of locators of specific lookup services to join
- See Also:
-
addLookupLocators
Description copied from interface:JoinAdminAdd locators for specific new lookup services to join. The new lookup services will be discovered and joined.- Specified by:
addLookupLocatorsin interfaceJoinAdmin- Parameters:
locators- locators of specific lookup services to join- Throws:
RemoteException- See Also:
-
removeLookupLocators
Description copied from interface:JoinAdminRemove locators for specific lookup services from the set to join. Any leases held at the lookup services are cancelled.- Specified by:
removeLookupLocatorsin interfaceJoinAdmin- Parameters:
locators- locators of specific lookup services to leave- Throws:
RemoteException- See Also:
-
setLookupLocators
Description copied from interface:JoinAdminReplace the list of locators of specific lookup services to join with a new list. Leases are cancelled at lookup services that were in the old list but are not in the new list. Any new lookup services will be discovered and joined.- Specified by:
setLookupLocatorsin interfaceJoinAdmin- Parameters:
locators- locators of specific lookup services to join- Throws:
RemoteException- See Also:
-
getProxy
Description copied from interface:ProxyAccessorReturns a proxy object for this remote object. If this remote object is not exported (and hence, no proxy is available), thennullis returned.- Specified by:
getProxyin interfaceProxyAccessor- Returns:
- a proxy, or
null
-
getLocalProxy
- Specified by:
getLocalProxyin interfaceTxnManager
-
getServiceProxy
Description copied from interface:ServiceProxyAccessorReturns a proxy object for this object. This value should not benull.- Specified by:
getServiceProxyin interfaceServiceProxyAccessor- Returns:
- a proxy object reference
-
initFailed
Log information about failing to initialize the service and rethrow the appropriate exception.- Parameters:
e- the exception produced by the failure- Throws:
Exception
-
getProxyVerifier
Description copied from interface:ServerProxyTrustReturns aTrustVerifierthat can be used to verify that a proxy can be trusted as a proxy for the service; that is, theisTrustedObjectmethod 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).- Specified by:
getProxyVerifierin interfaceServerProxyTrust- Returns:
- a
TrustVerifierthat can be used to verify that a proxy can be trusted as a proxy for the service
-
needParticipantsJoin
returns true if this mgr which requires that the txn participants join into the txn in contrary to a mgr which the participants are known prior to txn propagation- Specified by:
needParticipantsJoinin interfaceTransactionManager- Returns:
- true if its a mgr which requires that the txn participants to join
- Throws:
RemoteException
-
getTransactionManagerId
- Specified by:
getTransactionManagerIdin interfaceTransactionManager- Throws:
RemoteException
-