IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.plugins
Class OptimisticCollisionException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.ibm.websphere.objectgrid.ObjectGridException
              extended by com.ibm.websphere.objectgrid.plugins.OptimisticCollisionException
All Implemented Interfaces:
IObjectGridException, Serializable

public class OptimisticCollisionException
extends ObjectGridException

This exception is thrown when optimistic locking strategy is used and more than one update transaction collides on the same map entry of a ObjectGrid instance. The first transaction to commit updates the version object for the map entry. Other transactions that read this same map entry prior to the commit have the prior version object. When the other transactions try to commit, the version object it read will not match the version that was last committed. Thus the other transactions are prevented from updating a map entry using "stale" data.

The default OptimisticCallback used by the runtime if one is not provided by the application will cause this exception to be thrown if there is not a well constructed equals(Object) method on your value object since the entire value object is used as the version object.

Since this exception indicates the map entry contains stale data, ObjectGrid will invalidate the stale map entry or entries as identified by the key parameter that is passed to the OptimisticCollisionException(String, String, String, Object) method. If this exception is thrown by a Loader plugin and a null reference is used as the key parameter by the loader, ObjectGrid assumes the loader does not know which entry caused the exception. In this case, ObjectGrid will use the LogSequence that was passed to the Loader.batchUpdate(TxID, LogSequence) method to determine which map entries to invalidate. Each LogElement in the LogSequence of type update or delete will be invalidated.

Since:
WAS XD 6.0
See Also:
NoVersioningOptimisticCallback, OptimisticCallback, BackingMap.setOptimisticCallback(OptimisticCallback), Loader.batchUpdate(TxID, LogSequence), LogElement.DELETE, LogElement.UPDATE, Serialized Form

Constructor Summary
OptimisticCollisionException(String message, String gridName, String mapName, Object key)
          Constructs a new OptimisticCollisionException with the specified detail message and key of a map of an ObjectGrid.
 
Method Summary
 String getGridName()
          Gets the name of the ObjectGrid instance the optimistic collision occurred in.
 Object getKey()
          Gets the key(s) that caused this exception to occur.
 String getMapName()
          Gets the map name the optimistic collision occurred in.
 
Methods inherited from class com.ibm.websphere.objectgrid.ObjectGridException
getCause, initCause
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OptimisticCollisionException

public OptimisticCollisionException(String message,
                                    String gridName,
                                    String mapName,
                                    Object key)
Constructs a new OptimisticCollisionException with the specified detail message and key of a map of an ObjectGrid. The cause is not initialized, and may subsequently be initialized by a call to the initCause method.

Parameters:
message - the detail message. The detail message is saved for later retrieval by the getMessage method.
gridName - the name of the grid the map belongs to.
mapName - the name of the map.
key - the key or array of keys that caused the optimistic collision exception to occur. If more than a single key caused the exception, then an array of object should be used for this parameter. Each array element in this case identifies a single map entry that caused the exception to occur. This is useful when a Loader uses the batch update support of a JDBC driver. A null reference should be passed if unable to determine which key or set of keys caused this exception to occur.
See Also:
getGridName(), getKey(), getMapName(), Throwable.getMessage(), ObjectGridException.initCause(Throwable)
Method Detail

getGridName

public final String getGridName()
Gets the name of the ObjectGrid instance the optimistic collision occurred in.

Returns:
the name of the ObjectGrid instance.

getMapName

public final String getMapName()
Gets the map name the optimistic collision occurred in.

Returns:
name of map.

getKey

public final Object getKey()
Gets the key(s) that caused this exception to occur.

Returns:
key object or array of key objects that caused this exception to occur.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.