Jini Transaction Manager

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: The Jini Distributed Transactions provide a two-phase commit protocol.

Overview

The Jini Distributed Transactions provide a two-phase commit protocol. The two-phase commit protocol defines the communication patterns that allow distributed objects and resources to wrap a set of operations in such a way that they appear to be a single operation. The protocol requires a manager that will enable consistent resolution of the operations by a guarantee that all participants will eventually know whether they should commit the operations (roll forward) or abort them (roll backward). A participant can be any object that supports the participant contract by implementing the appropriate interface. Participants are not limited to databases or other persistent storage services.

The Jini Transaction Manager should be used mainly with partitioned spaces when you want to write, take, or update Entries that might be located in different physical spaces.

To create the Jini Transaction Manager:

 /*
 * Use the Look-up Service to look-up & get Jini's Txn-Manager
 * The Transactions created under THIS Transaction Manager can
 * span Multiple Gigaspace instances present in different places...
 */ TransactionManager trManager = (TransactionManager)LookupFinder.find(
                               null,       // service name
                               new Class[] { net.jini.core.transaction.server.TransactionManager.class },
                               null,       // service attributes
                               "localhost", // unicast lookup host
                              null,       // lookup groups
                                   10*1000     // timeout 10 seconds
                              );
For additional methods to look up the Transaction Manager, see Javadoc.
static object find(Class[] classes,Entry[] srvAttr,String lookupHost, long timeout)
Finds a specified service according to service classes and service attributes.
static object find(String serviceName,Class[] classes, Entry[] serviceAttributes, String lookupHost, String groups, long timeout)
Finds a specified server using all the criterions: service name, service classes and service attributes.
static object find(String serviceName,Class srvClass,String lookupHost, long timeout)
Finds a specified service according to service name and service class only.

To create the transaction:

// Now, use trManager as usual to create Transactions ...
// But now, you can use the SAME transaction across different Spaces...
Transaction.Created tCreated =TransactionFactory.create(trManager, 1000 * 60);
Transaction  tr = tCreated.transaction;

Using the transaction and committing:

IJSpace space = SpaceFinder.find(url);

Lease lease = space.write(entry, tr, leaseTime);

// committing the transaction
tr.commit(10000);

You can always extend the transaction's lease time or cancel it via the lease object:

tCreated.lease.renew(1000);
tCreated.lease.cancel();
Make sure you start the Jini Transaction Manager by running <GigaSpaces Root>\bin\gsServer or <GigaSpaces Root>\bin\startJiniTX_Mahalo.

Committing or Aborting the Jini Transaction

When using the Jini transaction Manager, consider using the Transaction.commit(long waitFor) and Transaction.abort(long waitFor) methods – these return acknowledgements to the caller application, only after the transaction commit or abort operation has been fully completed by all transaction participants, or until the timeout period expires.

When using the Transaction.abort() and the Transaction.commit() methods, the client gets the acknowledgement immediately after the abort or commit call without waiting for all transaction participants to complete. This may lead to inconsistency.

The waitFor parameter timeout allows you to choose the maximum amount of time you would like to wait for the transaction to be completed by all participants.
Please make sure you do not place large amount of time (in millisecond units). This is important since one of the transaction participates might hang without returning to the caller. This will result in client hang.

This behavior will not happen when using the Local Transaction Manager, since the client gets an acknowledgement for the commit or abort operation only after the space has completed the commit or abort processing.

Troubleshooting

In general, you can look up any Jini service based on different attributes, name, interface etc. You can have several Jini Transaction Managers running. Once you got a proxy to one of them you should be OK.

The default name for the Jini Transaction Manager is Transaction Manager.

You can get this information by:

  • Running <GigaSpaces Root>\bin\startJiniLUS – starts the Jini Lookup Service.
  • Running <GigaSpaces Root>\bin\startJiniTX_Mahalo – starts the Jini Transaction Manager service.
  • Running <GigaSpaces Root>\bin\lookupbrowser – select the relevant machine using the Register menu:

Double click the TransactionManager, and the ServiceItem Editor will be displayed with the Transaction Manager properties:

For details on viewing the exact configuration in which the system is currently running, refer to the Container Maintenance section.

Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels