IBM WebSphere Extended Deployment (XD)TM
Release 6.0

com.ibm.websphere.objectgrid
Session



This interface represents a session container for the ObjectMaps. A thread must get its own Session object to interact with the ObjectGrid. You can think of this as a session that can only be used by a single thread at a time. The Session itself is shareable across threads so long as only one thread uses it at a time. However, if a J2EE connection/transaction infrastructure is being used then that won't be shareable across threads and that will then prevent the Session object from being shared across threads. A good analogy for this object is a JDBC connection to a database.
See Also:
    getSession()getSession(Subject)


Field Summary
public  StringTRANSACTION_TYPE_DEFAULT
          
public  intTRANSACTION_NO_TIMEOUT
           A special value for the timeout parameter of the #setTransactionTimeout(int) method.

Method Summary
public  voidbeginNoWriteThrough()
           Changes made are just applied to the BackingMap and not given to the Loader. This method can be used.
public  ObjectMapgetMap(java.lang.String)
           Returns the Object Map for the specific name. .
public  voidbegin()
           Begin an explicit transactional context.
public  voidcommit()
           Commits an explicit transactional context.
public  voidrollback()
           Rolls back an explicit transactional context.
public  voidflush()
           Forces the current changes in the Session to the Loader. It does not.
public  ObjectGridgetObjectGrid()
           Returns the ObjectGrid that owns this session.
public  TxIDgetTxID()
           Gets the transaction id, if a transaction is active.
public  booleanisWriteThroughEnabled()
           Returns whether the current session transaction is writing through to the backend Loader (True), or if the changes are only applying to the BackingMap (False).
public  voidsetTransactionType(java.lang.String)
           Sets the transaction type for future transactions. .
public  voidprocessLogSequence(com.ibm.websphere.objectgrid.plugins.LogSequence)
           This method can be used to process a LogSequence. Each LogElement within.
public  booleanisFlushing()
           Returns whether the current session transaction is in a session.flush().
public  booleanisCommitting()
           Returns whether the current session transaction is in a session.commit().
public  voidmarkRollbackOnly(java.lang.Throwable)
           Mark the current transaction as being rollback only. Marking a .
public  booleanisMarkedRollbackOnly()
           Returns whether or not this currently marked as being rollback only as a result of a prior call to the #markRollbackOnly(Throwable) method on this Session.
public  voidsetTransactionTimeout(int)
           Set transaction timeout for next transaction started by this Session to a specified number of seconds.
public  intgetTransactionTimeout()
           Get current transaction timeout for this Session.
public  booleantransactionTimedOut()
           Get whether current transaction has timed out.

Field Detail

TRANSACTION_TYPE_DEFAULT

public 
  static TRANSACTION_TYPE_DEFAULT
A string indicating the default transaction type

TRANSACTION_NO_TIMEOUT

public 
  static TRANSACTION_NO_TIMEOUT
A special value for the timeout parameter of the #setTransactionTimeout(int) method. This special value is used to indicate that the next transaction started by this Session is allowed unlimited amount of time.

Method Detail

beginNoWriteThrough

public void beginNoWriteThrough()
Changes made are just applied to the BackingMap and not given to the Loader. This method can be used to apply changes made at another peer cache to the local BackingMap only.


Throws:
    com.ibm.websphere.objectgrid.TransactionAlreadyActiveExceptioncom.ibm.websphere.objectgrid.TransactionException


getMap

public ObjectMap getMap(String cacheName)
Returns the Object Map for the specific name.

The ObjectMap is used to retrieve and modify values in the BackingMap.
See Also:

    ObjectMap
Parameters:
    cacheName - name of desired map


Returns:
     ObjectMap


Throws:
    com.ibm.websphere.objectgrid.UndefinedMapException


begin

public void begin()
Begin an explicit transactional context.


Throws:
    com.ibm.websphere.objectgrid.TransactionAlreadyActiveExceptioncom.ibm.websphere.objectgrid.TransactionException


commit

public void commit()
Commits an explicit transactional context.


Throws:
    com.ibm.websphere.objectgrid.NoActiveTransactionExceptioncom.ibm.websphere.objectgrid.TransactionException


rollback

public void rollback()
Rolls back an explicit transactional context.


Throws:
    com.ibm.websphere.objectgrid.NoActiveTransactionExceptioncom.ibm.websphere.objectgrid.TransactionException


flush

public void flush()
Forces the current changes in the Session to the Loader. It does not commit the changes, it just applies them.


Throws:
    com.ibm.websphere.objectgrid.TransactionException


getObjectGrid

public ObjectGrid getObjectGrid()
Returns the ObjectGrid that owns this session.


Returns:
     The owning ObjectGrid instance.


getTxID

public TxID getTxID()
Gets the transaction id, if a transaction is active.


Returns:
     The current TxID object.


Throws:
    


isWriteThroughEnabled

public boolean isWriteThroughEnabled()
Returns whether the current session transaction is writing through to the backend Loader (True), or if the changes are only applying to the BackingMap (False).


Returns:
     True, if write-through has been enabled


setTransactionType

public void setTransactionType(String tranType)
Sets the transaction type for future transactions.

After this method is called, all future transactions will have the same type until another transaction type is set. If no transaction type is set, the default transaction type #TRANSACTION_TYPE_DEFAULT will be used.

Transaction types are used mainly for statistical data tracking purpose. Users can predefine types of transactions that will be executed in an application. The idea is to categorize transactions with the same characteristics to one category (type), so one transaction response time statistics can be used to track each transaction type. This approach is useful when your application has different types of transactions. Some types of transactions, such as update transactions, process longer than others transactions, such as read-only transactions. By using the transaction type, different transactions are tracked by different statistics, so the statistics can be more useful.

Parameters:
    tranType - the transaction type for future transactions.


processLogSequence

public void processLogSequence(LogSequence logSequence)
This method can be used to process a LogSequence. Each LogElement within the LogSequence will be examined and the appropriate operation (insert, update, invalidate, etc) will be performed against the BackingMap identified by the LogSequence's MapName. An ObjectGrid Session must be active before this method is invoked. The caller is then responsible for issuing the appropriate commit or rollback calls to complete the Session. Autocommit processing is not available for this method invocation. The main use of this method is for processing a LogSequence that was received by a remote JVM. For example, using the Distributed Commit support, the LogSequences associated with a given committed Session are then distributed to other listening ObjectGrids in other JVMs. After receiving the LogSequences at the remote JVM, the listener could start a Session using beginNoWriteThrough(), invoke this processLogSequence() method, and then commit() the Session.
Parameters:
    logSequence - LogSequence as received by remote ObjectGrid listener


Throws:
    com.ibm.websphere.objectgrid.NoActiveTransactionExceptioncom.ibm.websphere.objectgrid.UndefinedMapExceptioncom.ibm.websphere.objectgrid.ObjectGridException


isFlushing

public boolean isFlushing()
Returns whether the current session transaction is in a session.flush() sequence. It is helpful to know if the session flush is active (True), or if only a map.flush() is in progress (return False in this case).


Returns:
     True, if session is executing within the scope of a session.flush() call.


isCommitting

public boolean isCommitting()
Returns whether the current session transaction is in a session.commit() sequence. It is helpful to know if the session commit is active (True), or if a map.flush() or session.flush() is in progress (return False in these cases) via the loader.


Returns:
     True, if session is executing within the scope of a session.commit() call.


markRollbackOnly

public void markRollbackOnly(Throwable t)
Mark the current transaction as being rollback only. Marking a transaction rollback only ensures that even if #commit() method is called by client for this Session, the transaction is rolled back. The rollback only is typically done when either ObjectGrid itself or the application knows that data corruption could occur if commit was allowed to commit the transaction. Once this method is called, the Throwable object that is passed to it is chained to the TransactionException that is thrown if commit method is ever called. Any subsequent calls to this method for this transaction is ignored (e.g. only the first call that passes a non null Throwable reference is used). Once transaction is completed, the rollback only mark is removed so that the next transaction that is started using this session can be committed.
Parameters:
    t - is the Throwable that caused this method to be called.


isMarkedRollbackOnly

public boolean isMarkedRollbackOnly()
Returns whether or not this currently marked as being rollback only as a result of a prior call to the #markRollbackOnly(Throwable) method on this Session.


Returns:
     true if and only if Session is marked rollback only.


setTransactionTimeout

public void setTransactionTimeout(int timeout)
Set transaction timeout for next transaction started by this Session to a specified number of seconds. This method does not affect the transaction timeout of any transactions previously started by this Session. It only affects transactions that are started after this method is called. If this method is never called, then the ObjectGrid configured transaction timeout value is used.
Parameters:
    timeout - is the transaction timeout value in seconds. Use the special value #TRANSACTION_NO_TIMEOUT if transaction is allowed unlimited amount of time and no transaction timeout should occur.


getTransactionTimeout

public int getTransactionTimeout()
Get current transaction timeout for this Session.


Returns:
     timeout value that was passed to the #setTransactionTimeout(int) method.


transactionTimedOut

public boolean transactionTimedOut()
Get whether current transaction has timed out.


Returns:
     true if and only if transaction has timed out.


IBM WebSphere Extended Deployment (XD)TM
Release 6.0