|
IBM WebSphere Extended Deployment (XD)TM, Release 6.1 ObjectGrid API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Session
This interface represents a session container for ObjectMaps. A thread must get its own Session
object to interact with ObjectGrid. You can think of this interface as a session that can only be used by a single
thread at a time. A 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, that won't be shareable across threads and will
prevent the Session object from being shared across threads. A good analogy for this object is a JDBC connection to a
database.
ObjectGrid.getSession(),
ObjectGrid.getSession(Subject),
ObjectGrid.getSession(CredentialGenerator)| Field Summary | |
|---|---|
static int |
TRANSACTION_NO_TIMEOUT
A special value for the timeout parameter of the setTransactionTimeout(int) method. |
static java.lang.String |
TRANSACTION_TYPE_DEFAULT
A string indicating the default transaction type |
| Method Summary | |
|---|---|
void |
begin()
Begins a new transaction. |
void |
beginNoWriteThrough()
Starts a new transaction that does not write changes through to a Loader or ObjectGrid server. |
void |
commit()
Commits a transaction. |
ObjectQuery |
createObjectQuery(java.lang.String qlString)
Creates an instance of an object query for executing a query over the ObjectMaps visible to this session. |
void |
flush()
Forces the current changes in the Session to the Loader or ObjectGrid server. |
EntityManager |
getEntityManager()
Retrieve the EntityManager associated with this Session. |
ObjectMap |
getMap(java.lang.String cacheName)
Returns the ObjectMap for the specified name. |
ObjectGrid |
getObjectGrid()
Returns the ObjectGrid that owns this session. |
int |
getTransactionTimeout()
Gets current transaction timeofut for this Session. |
TxID |
getTxID()
Gets the TxID transaction identifier, if a transaction is active. |
ObjectMap |
getViewMap(java.lang.String mapName)
Get an ObjectMap for the stream query view result map. |
boolean |
isCommitting()
Returns whether the current session transaction is performing a session commit() operation. |
boolean |
isFlushing()
Returns whether the current session transaction is performing a session flush() operation. |
boolean |
isMarkedRollbackOnly()
Returns whether or not the current active session transaction is marked as being rollback only as a result of a prior call to the markRollbackOnly(Throwable) method on this Session. |
boolean |
isWriteThroughEnabled()
Returns whether the current session transaction is writing through to the backend Loader or
ObjectGrid server(true), or if the changes are only applying to the BackingMap (false)
or client respectively. |
void |
markRollbackOnly(java.lang.Throwable t)
Marks the current transaction as being rollback only. |
void |
processLogSequence(LogSequence logSequence)
Processes a LogSequence. |
void |
rollback()
Rolls back a transaction. |
void |
setTransactionTimeout(int timeout)
Sets the transaction timeout for the next transaction started by this Session object to a specified number of seconds. |
void |
setTransactionType(java.lang.String tranType)
Sets the transaction type for future transactions. |
boolean |
transactionTimedOut()
Determines whether the current session transaction has timed out. |
| Field Detail |
|---|
static final java.lang.String TRANSACTION_TYPE_DEFAULT
static final int TRANSACTION_NO_TIMEOUT
setTransactionTimeout(int) method. This special
value is used to indicate that the next transaction started by this Session is allowed unlimited amount of time.
setTransactionTimeout(int),
Constant Field Values| Method Detail |
|---|
void beginNoWriteThrough()
throws TransactionAlreadyActiveException,
TransactionException
Loader or ObjectGrid server.
Changes made by the session transaction started by this method are only applied to the BackingMap
and not given to the Loader. This method can be used to apply changes made in a peer cache to the
local BackingMap only. In addition, with a distributed map, this method can be used to start a
session transaction which changes will only be applied to the client BackingMap, but not the
BackingMap on the server side.
TransactionAlreadyActiveException - if there is already an active transaction
TransactionException - a TransactionCallbackException occurred or some other error occurred starting a new
transaction
ObjectMap getMap(java.lang.String cacheName)
throws UndefinedMapException
The ObjectMap is used to retrieve and modify values in the BackingMap. Multiple invocations of this method on the same Session object will always return the same object.
cacheName - name of desired map
UndefinedMapException - if the map is not defined.ObjectGrid.defineMap(String),
ObjectMap
void begin()
throws TransactionAlreadyActiveException,
TransactionException
TransactionAlreadyActiveException - if this method is invoked with an active transaction
TransactionException - a TransactionCallbackException occurred or some other error occurred starting a new
transaction
void commit()
throws NoActiveTransactionException,
TransactionException
NoActiveTransactionException - if this method is invoked with no active transaction
TransactionException - if an error occurred during commit processing, see the caused by to determine the root errormarkRollbackOnly(Throwable)
void rollback()
throws NoActiveTransactionException,
TransactionException
NoActiveTransactionException - if this method is invoked with no active transaction
TransactionException - if an error occurred during rollback processing, see the caused by to determine the root error
void flush()
throws NoActiveTransactionException,
TransactionException
Loader or ObjectGrid server. This method does not
commit the changes, it just applies the changes.
NoActiveTransactionException - if this method is invoked with no active transaction
TransactionException - if an error occurred during flush processing, see the caused by to determine the root errorObjectGrid getObjectGrid()
TxID getTxID()
throws NoActiveTransactionException
TxID transaction identifier, if a transaction is active.
NoActiveTransactionException - if this method is invoked with no active transactionboolean isWriteThroughEnabled()
Loader or
ObjectGrid server(true), or if the changes are only applying to the BackingMap (false)
or client respectively.
true, if write through is enabledbegin(),
beginNoWriteThrough()void setTransactionType(java.lang.String tranType)
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.
tranType - the transaction type for future transactions.TRANSACTION_TYPE_DEFAULT
void processLogSequence(LogSequence logSequence)
throws NoActiveTransactionException,
UndefinedMapException,
ObjectGridException
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 map name. An ObjectGrid Session must be active before this method is invoked.
The caller is responsible for issuing the appropriate commit or rollback invocation 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 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 method, and commit the Session transaction.
logSequence - LogSequence of changes to be applied to an active transaction
NoActiveTransactionException - if this method is invoked with no active transaction
UndefinedMapException - if the map referenced by the LogSequence cannot be found
ObjectGridException - if the LogSequence elements cannot be processedbeginNoWriteThrough(),
LogSequence,
ObjectGridEventListenerboolean isFlushing()
flush() operation. It is
helpful to know if a session flush() is active (true), or if only an
ObjectMap.flush() is in progress (returns false in this case).
flush() call.flush(),
ObjectMap.flush()boolean isCommitting()
commit() operation. It is
helpful to know if a session commit is active (true), or if an ObjectMap.flush()
or session flush() is in progress (returns false in these cases).
commit() call.commit(),
flush(),
ObjectMap.flush()
void markRollbackOnly(java.lang.Throwable t)
throws NoActiveTransactionException
Marking a transaction rollback only ensures that even if the commit() method is called for this
session transaction, the transaction is rolled back. A rollback is typically done when either ObjectGrid itself
or the application knows that data corruption could occur if the commit() method 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 the commit method is ever called. Any subsequent calls to
this method for the current active transaction is ignored (e.g. only the first call that passes a non null
Throwable reference is used). Once the transaction is completed, the rollback only mark is removed so that the
next transaction that is started using this session can be committed.
t - the Throwable that caused this method to be called.
NoActiveTransactionException - if there is no active transaction for this Session.commit(),
TransactionExceptionboolean isMarkedRollbackOnly()
markRollbackOnly(Throwable) method on this Session.
markRollbackOnly(Throwable)void setTransactionTimeout(int timeout)
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, the ObjectGrid configured transaction timeout value is used.
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.TRANSACTION_NO_TIMEOUT,
ObjectGrid.setTxTimeout(int),
TransactionTimeoutExceptionint getTransactionTimeout()
The transaction timeout value returned is the value that was configured for the ObjectGrid using
ObjectGrid.setTxTimeout(int) or the value passed to setTransactionTimeout(int) to
override the value configured on ObjectGrid. The return value is in seconds.
setTransactionTimeout(int),
ObjectGrid.setTxTimeout(int)boolean transactionTimedOut()
setTransactionTimeout(int)
ObjectQuery createObjectQuery(java.lang.String qlString)
throws ObjectQueryException
When ObjectGrid security is enabled, this method requires an com.ibm.websphere.objectgrid.security.ObjectGridPermission with action "query".
qlString - a query string
ObjectQueryException - if an error occurs creating the object query.EntityManager getEntityManager()
ObjectMap getViewMap(java.lang.String mapName)
throws UndefinedMapException,
ObjectGridRuntimeException
If the ObjectGrid is a client side ObjectGrid, the returned map is a client-side near cache map, and it is also replcated from the server-side map to make sure the near cache reflects the latest data on the server side.
A stream query view ObjectMap is read-only, and should not be updated.
mapName - the view map name
UndefinedMapException - the map is undefined
ObjectGridRuntimeException - the map cannot be replicated from the server if the ObjectGrid
represents a client side ObjectGrid.
|
IBM WebSphere Extended Deployment (XD)TM, Release 6.1 ObjectGrid API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||