org.jgroups.blocks
Class TransactionalHashtable

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.jgroups.blocks.TransactionalHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, MessageListener, ReplicationReceiver, java.io.Serializable

public class TransactionalHashtable
extends java.util.HashMap
implements ReplicationReceiver, MessageListener

Hashtable which replicates its contents to all members of the group. Reads and writes can optionally be forced to acquire locks (r/w locks) to ensure total serializability between replicas. The update modes can be chosen per method and are (in order of cost)

  1. asynchronous (non-blocking) updates
  2. synchronous (blocking) updates (optionally with a timeout)
  3. synchronous (blocking) updates with locking
This class needs to have a state transfer protocol present in the protocol stack used (e.g. pbcast.STATE_TRANSFER).

Author:
Bela Ban Nov 2002
See Also:
Serialized Form

Nested Class Summary
static class TransactionalHashtable.Data
          Class used to transport updates to all replicas
static interface TransactionalHashtable.Notification
           
 
Field Summary
protected  boolean auto_commit
           
protected  Channel channel
           
protected  boolean default_sync_repl
           
protected  long default_sync_repl_timeout
           
protected  java.lang.String groupname
           
protected  Address local_addr
           
protected  long lock_acquisition_timeout
           
protected  long lock_lease_timeout
           
protected  Log log
           
protected  java.util.List notifs
           
protected  java.lang.String properties
           
protected  ReplicationManager repl_mgr
           
protected  java.util.HashMap row_locks
           
protected  long state_timeout
           
protected  RWLock table_lock
           
protected  int transaction_mode
           
 
Constructor Summary
TransactionalHashtable(java.lang.String groupname, java.lang.String properties, long state_timeout)
           
TransactionalHashtable(java.lang.String groupname, java.lang.String properties, long state_timeout, int initialCapacity)
           
TransactionalHashtable(java.lang.String groupname, java.lang.String properties, long state_timeout, int initialCapacity, float loadFactor)
           
TransactionalHashtable(java.lang.String groupname, java.lang.String properties, long state_timeout, java.util.Map m)
           
 
Method Summary
 void addNotifier(TransactionalHashtable.Notification n)
           
 void begin()
          Starts a new transaction and associates it with the current thread.
 void begin(int transaction_mode)
          Starts a new transaction and associates it with the current thread.
protected  void checkResults(RspList rsps)
          Checks whether responses from members contain exceptions or timeouts.
 void clear()
          Replicates the update to all members.
 void clear(boolean synchronous, long timeout)
          Replicates the update to all members.
 void clear(long sync_timeout, long lock_acquisition_timeout, long lock_lease_timeout, boolean commit)
          Replicated the update to all members, and use locks at each member to ensure serializability.
 java.lang.Object clone()
           
 void commit()
          Commits all modifications done in the current transaction (kept in temporary storage) to the hashtable.
 void commit(Xid transaction)
          Commit the modifications to the locally replicated data and release all locks.
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
 boolean getAutoCommit()
           
static Xid getCurrentTransaction()
          Returns the transaction associated with the current thread.
 long getDefaultSyncReplTimeout()
           
 long getLockAcquisitionTimeout()
           
 long getLockLeaseTimeout()
           
 byte[] getState()
          TODO: use read lock on entire hashmap while making copy
 int getTransactionMode()
           
protected  java.lang.Object handleClear(Xid transaction, long lock_acquisition_timeout, long lock_lease_timeout, boolean use_locks)
           
protected  java.lang.Object handlePut(java.io.Serializable key, java.io.Serializable value, Xid transaction, long lock_acquisition_timeout, long lock_lease_timeout, boolean use_locks)
           
protected  java.lang.Object handlePutAll(java.util.Map map, Xid transaction, long lock_acquisition_timeout, long lock_lease_timeout, boolean use_locks)
           
protected  java.lang.Object handleRemove(java.io.Serializable key, Xid transaction, long lock_acquisition_timeout, long lock_lease_timeout, boolean use_locks)
           
protected  void initChannel(java.lang.String groupname, java.lang.String properties, long state_timeout)
           
 boolean isDefaultSyncRepl()
           
 java.util.Set keySet()
           
 void lclear()
           
 java.lang.Object lput(java.lang.Object key, java.lang.Object value)
           
 void lputAll(java.util.Map m)
           
 java.lang.Object lremove(java.lang.Object key, java.lang.Object value)
           
static void main(java.lang.String[] args)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Replicates the update to all members.
 java.lang.Object put(java.lang.Object key, java.lang.Object value, boolean synchronous, long timeout)
          Replicates the update to all members.
 java.lang.Object put(java.lang.Object key, java.lang.Object value, long sync_timeout, long lock_acquisition_timeout, long lock_lease_timeout, boolean commit)
          Replicates the update to all members, and use locks at each member to ensure serializability.
 void putAll(java.util.Map m)
          Replicates the update to all members.
 void putAll(java.util.Map m, boolean synchronous, long timeout)
          Replicates the update to all members.
 void putAll(java.util.Map m, long sync_timeout, long lock_acquisition_timeout, long lock_lease_timeout, boolean commit)
          Replicated the update to all members, and use locks at each member to ensure serializability.
 void receive(Message msg)
           
 java.lang.Object receive(Xid transaction, byte[] buf, byte[] lock_info, long lock_acquisition_timeout, long lock_lease_timeout, boolean use_locks)
          Receives an update.
 java.lang.Object remove(java.lang.Object key)
          Replicates the update to all members.
 java.lang.Object remove(java.lang.Object key, boolean synchronous, long timeout)
          Replicates the update to all members.
 java.lang.Object remove(java.lang.Object key, long sync_timeout, long lock_acquisition_timeout, long lock_lease_timeout, boolean commit)
          Replicated the update to all members, and use locks at each member to ensure serializability.
 void rollback()
          Discards all changes done within the current transaction.
 void rollback(Xid transaction)
          Discard all modifications and release all locks.
 void setAutoCommit(boolean b)
           
 void setDefaultSyncRepl(boolean b)
          Sets the default replication mode.
 void setDefaultSyncReplTimeout(long timeout)
           
 void setLockAcquisitionTimeout(long l)
           
 void setLockLeaseTimeout(long l)
           
 void setMembershipListener(MembershipListener ml)
           
 void setState(byte[] state)
          TODO: use write lock on entire hashmap to set state
 void setTransactionMode(int m)
           
 void stop()
          Leaves the group.
 java.util.Collection values()
           
 
Methods inherited from class java.util.HashMap
isEmpty, size
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

repl_mgr

protected ReplicationManager repl_mgr

channel

protected Channel channel

local_addr

protected Address local_addr

groupname

protected java.lang.String groupname

properties

protected java.lang.String properties

state_timeout

protected long state_timeout

default_sync_repl

protected boolean default_sync_repl

default_sync_repl_timeout

protected long default_sync_repl_timeout

lock_acquisition_timeout

protected long lock_acquisition_timeout

lock_lease_timeout

protected long lock_lease_timeout

transaction_mode

protected int transaction_mode

table_lock

protected RWLock table_lock

row_locks

protected java.util.HashMap row_locks

auto_commit

protected boolean auto_commit

notifs

protected java.util.List notifs

log

protected Log log
Constructor Detail

TransactionalHashtable

public TransactionalHashtable(java.lang.String groupname,
                              java.lang.String properties,
                              long state_timeout)
                       throws java.lang.Exception

TransactionalHashtable

public TransactionalHashtable(java.lang.String groupname,
                              java.lang.String properties,
                              long state_timeout,
                              java.util.Map m)
                       throws java.lang.Exception

TransactionalHashtable

public TransactionalHashtable(java.lang.String groupname,
                              java.lang.String properties,
                              long state_timeout,
                              int initialCapacity)
                       throws java.lang.Exception

TransactionalHashtable

public TransactionalHashtable(java.lang.String groupname,
                              java.lang.String properties,
                              long state_timeout,
                              int initialCapacity,
                              float loadFactor)
                       throws java.lang.Exception
Method Detail

addNotifier

public void addNotifier(TransactionalHashtable.Notification n)

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Replicates the update to all members. Depending on the value of default_sync_repl_timeout the update will be sent synchronously or asynchronously

Specified by:
put in interface java.util.Map
Parameters:
key - The key to be set. Needs to be serializable. Can be null.
value - The value to be set. Needs to be serializable. Can be null.
Returns:
Object The previous value associated with the given key, or null if none was associated

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value,
                            boolean synchronous,
                            long timeout)
Replicates the update to all members. Depending on the value of the parameters the update will be synchronous or asynchronous.

Parameters:
key - The key to be set. Needs to be serializable. Can be null.
value - The value to be set. Needs to be serializable. Can be null.
synchronous - If true the update will be synchronous, ie. the caller will block until all responses have been received. If timeout is 0, we will block indefinitely (until all responses have been received), otherwise the call is guaranteed to return after at most timeout milliseconds. If false, the call will be asynchronous.
timeout - The number of milliseconds to wait for a synchronous call. 0 means to wait forever. This parameter is not used if synchronous is false.
Returns:
Object The previous value associated with the given key, or null if none was associated

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value,
                            long sync_timeout,
                            long lock_acquisition_timeout,
                            long lock_lease_timeout,
                            boolean commit)
                     throws LockingException,
                            TimeoutException
Replicates the update to all members, and use locks at each member to ensure serializability. When a lock in a member cannot be acquired, a LockingException will be thrown. Typically the caller will then abort the transaction (releasing all locks) and retry.

This call can be one of many inside the same transaction, or it may be the only one. In the first case, the caller is responsible to call commit() or rollback() once the transaction is done. In the latter case, the transaction can be committed by setting commit to true.
A transaction (Xid) is always associated with the current thread. If this call is invoked, and there is no transaction associated with the current thread, a default transaction will be created. Otherwise the current transaction will be used.

Parameters:
key - The key to be set. Needs to be serializable. Can be null.
value - The value to be set. Needs to be serializable. Can be null.
sync_timeout - Max number of milliseconds to wait for all responses. Note that this needs to be higher than lock_acquisition_timeout. 0 means to wait forever for all responses.
lock_acquisition_timeout - Number of milliseonds to wait until a lock becomes available. Needs to be lower than sync_timeout. 0 means to wait forever. 0 will block forever in case of deadlocks. Once we have deadlock detection in place, this parameter may be deprecated.
lock_lease_timeout - Number of milliseonds until a lock is released automatically (if not released before). Not currently used.
commit - If true the transaction will be committed after this call if the call was successful.
Returns:
Object The previous value associated with the given key, or null if none was associated
Throws:
LockingException - Throw when one or more of the members failed acquiring the lock within lock_acquisition_timeout milliseconds
TimeoutException - Thrown when one or more of the members didn't send a response. LockingExceptions take precedence over TimeoutExceptions, e.g. if we have both locking and timeout exceptions, a LockingException will be thrown.

lput

public java.lang.Object lput(java.lang.Object key,
                             java.lang.Object value)
                      throws LockingException,
                             TimeoutException
Throws:
LockingException
TimeoutException

putAll

public void putAll(java.util.Map m)
Replicates the update to all members. Depending on the value of default_sync_repl_timeout the update will be sent synchronously or asynchronously

Specified by:
putAll in interface java.util.Map
Parameters:
m - The map to be set. All entries need to be serializable. Cannot be null.

putAll

public void putAll(java.util.Map m,
                   boolean synchronous,
                   long timeout)
Replicates the update to all members. Depending on the value of the parameters the update will be synchronous or asynchronous.

Parameters:
m - The map to be set. All entries need to be serializable. Cannot be null.
synchronous - If true the update will be synchronous, ie. the caller will block until all responses have been received. If timeout is 0, we will block indefinitely (until all responses have been received), otherwise the call is guaranteed to return after at most timeout milliseconds. If false, the call will be asynchronous.
timeout - The number of milliseconds to wait for a synchronous call. 0 means to wait forever. This parameter is not used if synchronous is false.

putAll

public void putAll(java.util.Map m,
                   long sync_timeout,
                   long lock_acquisition_timeout,
                   long lock_lease_timeout,
                   boolean commit)
            throws LockingException,
                   TimeoutException
Replicated the update to all members, and use locks at each member to ensure serializability. When a lock in a member cannot be acquired, a LockingException will be thrown. Typically the caller will then abort the transaction (releasing all locks) and retry.

This call can be one of many inside the same transaction, or it may be the only one. In the first case, the caller is responsible to call commit() or rollback() once the transaction is done. In the latter case, the transaction can be committed by setting commit to true.
A transaction (Xid) is always associated with the current thread. If this call is invoked, and there is no transaction associated with the current thread, a default transaction will be created. Otherwise the current transaction will be used.

Parameters:
m - The map to be set. All entries need to be serializable. Cannot be null.
sync_timeout - Max number of milliseconds to wait for all responses. Note that this needs to be higher than lock_acquisition_timeout. 0 means to wait forever for all responses.
lock_acquisition_timeout - Number of milliseonds to wait until a lock becomes available. Needs to be lower than sync_timeout. 0 means to wait forever. 0 will block forever in case of deadlocks. Once we have deadlock detection in place, this parameter may be deprecated.
lock_lease_timeout - Number of milliseonds until a lock is released automatically (if not released before). Not currently used.
commit - If true the transaction will be committed after this call if the call was successful.
Throws:
LockingException - Throw when one or more of the members failed acquiring the lock within lock_acquisition_timeout milliseconds
TimeoutException - Thrown when one or more of the members didn't send a response. LockingExceptions take precedence over TimeoutExceptions, e.g. if we have both locking and timeout exceptions, a LockingException will be thrown.

lputAll

public void lputAll(java.util.Map m)
             throws LockingException,
                    TimeoutException
Throws:
LockingException
TimeoutException

remove

public java.lang.Object remove(java.lang.Object key)
Replicates the update to all members. Depending on the value of default_sync_repl_timeout the update will be sent synchronously or asynchronously

Specified by:
remove in interface java.util.Map
Parameters:
key - The key to be set. Needs to be serializable. Can be null.
Returns:
Object The previous value associated with the given key, or null if none was associated

remove

public java.lang.Object remove(java.lang.Object key,
                               boolean synchronous,
                               long timeout)
Replicates the update to all members. Depending on the value of the parameters the update will be synchronous or asynchronous.

Parameters:
key - The key to be set. Needs to be serializable. Can be null.
synchronous - If true the update will be synchronous, ie. the caller will block until all responses have been received. If timeout is 0, we will block indefinitely (until all responses have been received), otherwise the call is guaranteed to return after at most timeout milliseconds. If false, the call will be asynchronous.
timeout - The number of milliseconds to wait for a synchronous call. 0 means to wait forever. This parameter is not used if synchronous is false.
Returns:
Object The previous value associated with the given key, or null if none was associated

remove

public java.lang.Object remove(java.lang.Object key,
                               long sync_timeout,
                               long lock_acquisition_timeout,
                               long lock_lease_timeout,
                               boolean commit)
                        throws LockingException,
                               TimeoutException
Replicated the update to all members, and use locks at each member to ensure serializability. When a lock in a member cannot be acquired, a LockingException will be thrown. Typically the caller will then abort the transaction (releasing all locks) and retry.

This call can be one of many inside the same transaction, or it may be the only one. In the first case, the caller is responsible to call commit() or rollback() once the transaction is done. In the latter case, the transaction can be committed by setting commit to true.
A transaction (Xid) is always associated with the current thread. If this call is invoked, and there is no transaction associated with the current thread, a default transaction will be created. Otherwise the current transaction will be used.

Parameters:
key - The key to be set. Needs to be serializable. Can be null.
sync_timeout - Max number of milliseconds to wait for all responses. Note that this needs to be higher than lock_acquisition_timeout. 0 means to wait forever for all responses.
lock_acquisition_timeout - Number of milliseonds to wait until a lock becomes available. Needs to be lower than sync_timeout. 0 means to wait forever. 0 will block forever in case of deadlocks. Once we have deadlock detection in place, this parameter may be deprecated.
lock_lease_timeout - Number of milliseonds until a lock is released automatically (if not released before). Not currently used.
commit - If true the transaction will be committed after this call if the call was successful.
Returns:
Object The previous value associated with the given key, or null if none was associated
Throws:
LockingException - Throw when one or more of the members failed acquiring the lock within lock_acquisition_timeout milliseconds
TimeoutException - Thrown when one or more of the members didn't send a response. LockingExceptions take precedence over TimeoutExceptions, e.g. if we have both locking and timeout exceptions, a LockingException will be thrown.

lremove

public java.lang.Object lremove(java.lang.Object key,
                                java.lang.Object value)
                         throws LockingException,
                                TimeoutException
Throws:
LockingException
TimeoutException

clear

public void clear()
Replicates the update to all members. Depending on the value of default_sync_repl_timeout the update will be sent synchronously or asynchronously

Specified by:
clear in interface java.util.Map

clear

public void clear(boolean synchronous,
                  long timeout)
Replicates the update to all members. Depending on the value of the parameters the update will be synchronous or asynchronous.

Parameters:
synchronous - If true the update will be synchronous, ie. the caller will block until all responses have been received. If timeout is 0, we will block indefinitely (until all responses have been received), otherwise the call is guaranteed to return after at most timeout milliseconds. If false, the call will be asynchronous.
timeout - The number of milliseconds to wait for a synchronous call. 0 means to wait forever. This parameter is not used if synchronous is false.

clear

public void clear(long sync_timeout,
                  long lock_acquisition_timeout,
                  long lock_lease_timeout,
                  boolean commit)
           throws LockingException,
                  TimeoutException
Replicated the update to all members, and use locks at each member to ensure serializability. When a lock in a member cannot be acquired, a LockingException will be thrown. Typically the caller will then abort the transaction (releasing all locks) and retry.

This call can be one of many inside the same transaction, or it may be the only one. In the first case, the caller is responsible to call commit() or rollback() once the transaction is done. In the latter case, the transaction can be committed by setting commit to true.
A transaction (Xid) is always associated with the current thread. If this call is invoked, and there is no transaction associated with the current thread, a default transaction will be created. Otherwise the current transaction will be used.

Parameters:
sync_timeout - Max number of milliseconds to wait for all responses. Note that this needs to be higher than lock_acquisition_timeout. 0 means to wait forever for all responses.
lock_acquisition_timeout - Number of milliseonds to wait until a lock becomes available. Needs to be lower than sync_timeout. 0 means to wait forever. 0 will block forever in case of deadlocks. Once we have deadlock detection in place, this parameter may be deprecated.
lock_lease_timeout - Number of milliseonds until a lock is released automatically (if not released before). Not currently used.
commit - If true the transaction will be committed after this call if the call was successful.
Throws:
LockingException - Throw when one or more of the members failed acquiring the lock within lock_acquisition_timeout milliseconds
TimeoutException - Thrown when one or more of the members didn't send a response. LockingExceptions take precedence over TimeoutExceptions, e.g. if we have both locking and timeout exceptions, a LockingException will be thrown.

lclear

public void lclear()
            throws LockingException,
                   TimeoutException
Throws:
LockingException
TimeoutException

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

clone

public java.lang.Object clone()

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

receive

public java.lang.Object receive(Xid transaction,
                                byte[] buf,
                                byte[] lock_info,
                                long lock_acquisition_timeout,
                                long lock_lease_timeout,
                                boolean use_locks)
                         throws LockingException,
                                UpdateException
Receives an update. Handles the update depending on whether locks are to be used (use_locks):
  1. No locks: simply apply the update to the hashmap
  2. Use locks: lock the corresponding resource (e.g. entire table in case of clear(), or individual row in case of (remove()) and apply the update.If the lock cannot be acquired, throw a LockingException.

Specified by:
receive in interface ReplicationReceiver
Parameters:
transaction - The transaction under which all locks will be acquired. Will be null if no locks are used (e.g. use_locks is null).
buf - The data to be modified. In case of a database, this data would have to be stored in stable storage, and would only be applied on a commit(). In case of a distributed replicated in-memory data structure, the update might be applied directly and the subsequent commit() or rollback() might be ignored. Note that this argument may contain the resource to be locked; in this case the lock_info parameter might be null.
lock_info - Information about the resource(s) to be locked. Will be null if no locks are used (e.g. use_locks is null). Can also be null even if locks are used, e.g. when the resource(s) to be locked are an implicit part of data.
lock_acquisition_timeout - If locks are used, the number of milliseconds to wait for a lock to be acquired. If this time elapses, a TimeoutException will be thrown. A value of 0 means to wait forever. If use_locks is false, this value is ignored.
lock_lease_timeout - The number of milliseconds to hold on to the lock, once it is acquired. A value of 0 means to never release the lock until commit() or rollback() are called.
use_locks - Whether to use locking or not. If this value is false, all lock-related arguments will be ignored, regardless of whether they are non-null.
Returns:
Object A return value, the semantics of which are determined by caller of ReplicationManager.send and the receiver. If no special value should be returned, null can be returned. Note that in the latter case, null is still treated as a response (in the synchronous call).
Throws:
UpdateException - Thrown when the update fails (application semantics)
LockingException - Thrown when a lock on a resource cannot be acquired

commit

public void commit(Xid transaction)
Description copied from interface: ReplicationReceiver
Commit the modifications to the locally replicated data and release all locks. If the receive() call already applied the changes, then this method is a nop.

Specified by:
commit in interface ReplicationReceiver

rollback

public void rollback(Xid transaction)
Description copied from interface: ReplicationReceiver
Discard all modifications and release all locks. If the receive() call already applied the changes, this method will not be able to rollback the modifications, but will only release the locks.

Specified by:
rollback in interface ReplicationReceiver

receive

public void receive(Message msg)
Specified by:
receive in interface MessageListener

getState

public byte[] getState()
TODO: use read lock on entire hashmap while making copy

Specified by:
getState in interface MessageListener

setState

public void setState(byte[] state)
TODO: use write lock on entire hashmap to set state

Specified by:
setState in interface MessageListener

stop

public void stop()
Leaves the group. The instance is unusable after this call, ie. a new instance should be created. Behavior is undefined if the instance is still used after this call.


setMembershipListener

public void setMembershipListener(MembershipListener ml)

isDefaultSyncRepl

public boolean isDefaultSyncRepl()

setDefaultSyncRepl

public void setDefaultSyncRepl(boolean b)
Sets the default replication mode. This will be used if the methods inherited from HashMap are used. However, if one of the methods provided by TransactionalHashtable are used, they will override the default mode.


getDefaultSyncReplTimeout

public long getDefaultSyncReplTimeout()

setDefaultSyncReplTimeout

public void setDefaultSyncReplTimeout(long timeout)

getAutoCommit

public boolean getAutoCommit()

setAutoCommit

public void setAutoCommit(boolean b)

getLockAcquisitionTimeout

public long getLockAcquisitionTimeout()

setLockAcquisitionTimeout

public void setLockAcquisitionTimeout(long l)

getLockLeaseTimeout

public long getLockLeaseTimeout()

setLockLeaseTimeout

public void setLockLeaseTimeout(long l)

getTransactionMode

public int getTransactionMode()

setTransactionMode

public void setTransactionMode(int m)

begin

public void begin()
           throws java.lang.Exception
Starts a new transaction and associates it with the current thread. Reuses the transaction if the current thread already has a transaction.

Throws:
java.lang.Exception

begin

public void begin(int transaction_mode)
           throws java.lang.Exception
Starts a new transaction and associates it with the current thread. Reuses the transaction if the current thread already has a transaction.

Parameters:
transaction_mode - Mode in which the transaction should run. Possible values are Xid.DIRTY_READS, Xid.READ_COMMITTED, Xid.REPEATABLE_READ and Xid.SERIALIZABLE
Throws:
java.lang.Exception

commit

public void commit()
Commits all modifications done in the current transaction (kept in temporary storage) to the hashtable. Releases all locks acquired by the current transaction.


rollback

public void rollback()
Discards all changes done within the current transaction. Releases all locks acquired by the current transaction.


getCurrentTransaction

public static Xid getCurrentTransaction()
Returns the transaction associated with the current thread.

Returns:
Xid The current transaction. Null if no transaction is associated.

initChannel

protected void initChannel(java.lang.String groupname,
                           java.lang.String properties,
                           long state_timeout)
                    throws java.lang.Exception
Throws:
java.lang.Exception

handlePut

protected java.lang.Object handlePut(java.io.Serializable key,
                                     java.io.Serializable value,
                                     Xid transaction,
                                     long lock_acquisition_timeout,
                                     long lock_lease_timeout,
                                     boolean use_locks)
                              throws LockingException,
                                     UpdateException
Throws:
LockingException
UpdateException

handlePutAll

protected java.lang.Object handlePutAll(java.util.Map map,
                                        Xid transaction,
                                        long lock_acquisition_timeout,
                                        long lock_lease_timeout,
                                        boolean use_locks)
                                 throws LockingException,
                                        UpdateException
Throws:
LockingException
UpdateException

handleRemove

protected java.lang.Object handleRemove(java.io.Serializable key,
                                        Xid transaction,
                                        long lock_acquisition_timeout,
                                        long lock_lease_timeout,
                                        boolean use_locks)
                                 throws LockingException,
                                        UpdateException
Throws:
LockingException
UpdateException

handleClear

protected java.lang.Object handleClear(Xid transaction,
                                       long lock_acquisition_timeout,
                                       long lock_lease_timeout,
                                       boolean use_locks)
                                throws LockingException,
                                       UpdateException
Throws:
LockingException
UpdateException

checkResults

protected void checkResults(RspList rsps)
                     throws LockingException,
                            TimeoutException
Checks whether responses from members contain exceptions or timeouts. Throws an exception if that is the case

Throws:
LockingException
TimeoutException

main

public static void main(java.lang.String[] args)


Copyright ? 2001,2002 www.jgroups.com . All Rights Reserved.