|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ResourceManager
Interface for resource managers. A resource manager is an entity that manages the processing and administration of resources. What is specified here are methods
Field Summary | |
---|---|
static int |
ISOLATION_LEVEL_READ_COMMITTED
Isolation level read committed: data written by other transactions can be read after they commit |
static int |
ISOLATION_LEVEL_READ_UNCOMMITTED
Isolation level read uncommitted: data written by other transactions can be read even before they commit |
static int |
ISOLATION_LEVEL_REPEATABLE_READ
Isolation level repeatable read: data written by other transactions can be read after they commit if this transaction has not read this data before |
static int |
ISOLATION_LEVEL_SERIALIZABLE
Isolation level serializable: result of other transactions will not influence the result of this transaction in any way |
static int |
PREPARE_FAILURE
Prepare result: transaction can not commit |
static int |
PREPARE_SUCCESS
Prepare result: resource manager guarantees a successful commit |
static int |
PREPARE_SUCCESS_READONLY
Prepare result: resource manager guarantees a successful commit as there is nothing to commit |
static int |
SHUTDOWN_MODE_KILL
Shutdown mode: Try to stop active transaction NOW, do no rollbacks |
static int |
SHUTDOWN_MODE_NORMAL
Shutdown mode: Wait for all transactions to complete |
static int |
SHUTDOWN_MODE_ROLLBACK
Shutdown mode: Try to roll back all active transactions |
Fields inherited from interface javax.transaction.Status |
---|
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN |
Method Summary | |
---|---|
void |
commitTransaction(java.lang.Object txId)
Commis the transaction specified by the given transaction identifier. |
void |
createResource(java.lang.Object txId,
java.lang.Object resourceId)
Creates a resource. |
void |
createResource(java.lang.Object txId,
java.lang.Object resourceId,
boolean assureOnly)
Creates a resource. |
void |
deleteResource(java.lang.Object txId,
java.lang.Object resourceId)
Deletes a resource. |
void |
deleteResource(java.lang.Object txId,
java.lang.Object resourceId,
boolean assureOnly)
Deletes a resource. |
int |
getDefaultIsolationLevel()
Gets the default isolation level as an integer. |
long |
getDefaultTransactionTimeout()
Gets the default transaction timeout. |
int |
getIsolationLevel(java.lang.Object txId)
Gets the isolation level for the specified transaction. |
int[] |
getSupportedIsolationLevels()
Gets an array of all isolation levels supported by this resource manager. |
int |
getTransactionState(java.lang.Object txId)
Gets the state of the transaction specified by the given transaction identifier. |
long |
getTransactionTimeout(java.lang.Object txId)
Gets the transaction timeout of the specified transaction. |
boolean |
isIsolationLevelSupported(int level)
Tests if the specified isolation level is supported by this resource manager. |
boolean |
lockResource(java.lang.Object resourceId,
java.lang.Object txId)
Explicitly locks a resource exclusively, i.e. |
boolean |
lockResource(java.lang.Object resourceId,
java.lang.Object txId,
boolean shared)
Explicitly locks a resource in reentrant style. |
boolean |
lockResource(java.lang.Object resourceId,
java.lang.Object txId,
boolean shared,
boolean wait,
long timeoutMSecs,
boolean reentrant)
Explicitly locks a resource. |
void |
markTransactionForRollback(java.lang.Object txId)
Marks the transaction specified by the given transaction identifier for rollback. |
int |
prepareTransaction(java.lang.Object txId)
Prepares the transaction specified by the given transaction identifier for commit. |
java.io.InputStream |
readResource(java.lang.Object resourceId)
Opens a streamable resource for a single reading request not inside the scope of a transaction. |
java.io.InputStream |
readResource(java.lang.Object txId,
java.lang.Object resourceId)
Opens a streamable resource for reading. |
boolean |
recover()
Tries to bring this resource manager back to a consistent state. |
boolean |
resourceExists(java.lang.Object resourceId)
Checks if a resource exists wihtout being in a transaction. |
boolean |
resourceExists(java.lang.Object txId,
java.lang.Object resourceId)
Checks if a resource exists. |
void |
rollbackTransaction(java.lang.Object txId)
Rolls back the transaction specified by the given transaction identifier. |
void |
setIsolationLevel(java.lang.Object txId,
int level)
Sets the isolation level for the specified transaction. |
void |
setTransactionTimeout(java.lang.Object txId,
long mSecs)
Sets the transaction timeout of the specified transaction. |
void |
start()
Starts this resource manager. |
void |
startTransaction(java.lang.Object txId)
Creates and starts a transaction using the specified transaction identifier. |
boolean |
stop(int mode)
Tries to stop this resource manager within a default timeout. |
boolean |
stop(int mode,
long timeoutMSecs)
Tries to stop this resource manager within the given timeout. |
java.io.OutputStream |
writeResource(java.lang.Object txId,
java.lang.Object resourceId)
Opens a resource for writing. |
Field Detail |
---|
static final int ISOLATION_LEVEL_READ_UNCOMMITTED
static final int ISOLATION_LEVEL_READ_COMMITTED
static final int ISOLATION_LEVEL_REPEATABLE_READ
static final int ISOLATION_LEVEL_SERIALIZABLE
static final int SHUTDOWN_MODE_NORMAL
static final int SHUTDOWN_MODE_ROLLBACK
static final int SHUTDOWN_MODE_KILL
static final int PREPARE_SUCCESS
static final int PREPARE_SUCCESS_READONLY
static final int PREPARE_FAILURE
Method Detail |
---|
void start() throws ResourceManagerSystemException
ResourceManagerSystemException
- if start failed due to internal problemsboolean stop(int mode, long timeoutMSecs) throws ResourceManagerSystemException
mode
- one of SHUTDOWN_MODE_NORMAL
, SHUTDOWN_MODE_ROLLBACK
or SHUTDOWN_MODE_KILL
timeoutMSecs
- timeout for shutdown in milliseconds
true
if resource manager stopped within given timeout
ResourceManagerSystemException
- if something fatal hapened during shutdownboolean stop(int mode) throws ResourceManagerSystemException
mode
- one of predefined shutdown modes SHUTDOWN_MODE_NORMAL
, SHUTDOWN_MODE_ROLLBACK
or SHUTDOWN_MODE_KILL
or any other int representing a shutdown mode
true
if resource manager stopped within given timeout
ResourceManagerSystemException
- if anything fatal hapened during shutdownboolean recover() throws ResourceManagerSystemException
true
upon successful recovery of the resource manager
ResourceManagerSystemException
- if anything fatal hapened during shutdownint getDefaultIsolationLevel() throws ResourceManagerException
ISOLATION_LEVEL_READ_UNCOMMITTED
,
ISOLATION_LEVEL_READ_COMMITTED
, ISOLATION_LEVEL_REPEATABLE_READ
or ISOLATION_LEVEL_SERIALIZABLE
or any other int representing an isolation level
ResourceManagerException
- if an error occuredint[] getSupportedIsolationLevels() throws ResourceManagerException
null
or empty as every resource manager has some sort of isolation level.
ISOLATION_LEVEL_READ_UNCOMMITTED
,
ISOLATION_LEVEL_READ_COMMITTED
, ISOLATION_LEVEL_REPEATABLE_READ
or ISOLATION_LEVEL_SERIALIZABLE
or any other int representing an isolation level
ResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
boolean isIsolationLevelSupported(int level) throws ResourceManagerException
level
- isolation level whose support is to be tested
true
if the isolation level is supported
ResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
int getIsolationLevel(java.lang.Object txId) throws ResourceManagerException
txId
- identifier for the concerned transaction
ISOLATION_LEVEL_READ_UNCOMMITTED
,
ISOLATION_LEVEL_READ_COMMITTED
, ISOLATION_LEVEL_REPEATABLE_READ
or ISOLATION_LEVEL_SERIALIZABLE
or any other int representing an isolation level
ResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
void setIsolationLevel(java.lang.Object txId, int level) throws ResourceManagerException
txId
- identifier for the concerned transactionlevel
- one of the predefined isolation levels ISOLATION_LEVEL_READ_UNCOMMITTED
,
ISOLATION_LEVEL_READ_COMMITTED
, ISOLATION_LEVEL_REPEATABLE_READ
or ISOLATION_LEVEL_SERIALIZABLE
or any other int representing an isolation level
ResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
long getDefaultTransactionTimeout() throws ResourceManagerException
ResourceManagerException
- if an error occuredlong getTransactionTimeout(java.lang.Object txId) throws ResourceManagerException
txId
- identifier for the concerned transaction
ResourceManagerException
- if an error occuredgetDefaultTransactionTimeout()
void setTransactionTimeout(java.lang.Object txId, long mSecs) throws ResourceManagerException
txId
- identifier for the concerned transactionmSecs
- transaction timeout of the specified transaction in milliseconds
ResourceManagerException
- if an error occuredgetDefaultTransactionTimeout()
void startTransaction(java.lang.Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be started
ResourceManagerException
- if an error occuredint prepareTransaction(java.lang.Object txId) throws ResourceManagerException
PREPARE_SUCCESS
),
succeed as there is nothing to commit (PREPARE_SUCCESS_READONLY
)
or fail (PREPARE_FAILURE
). If the preparation fails, commit will
fail as well and the transaction should be marked for rollback. However, if it
succeeds the resource manager must guarantee that a following commit will succeed as well.
txId
- identifier for the transaction to be prepared
PREPARE_SUCCESS
, PREPARE_SUCCESS_READONLY
or PREPARE_FAILURE
ResourceManagerException
- alternative way to signal prepare failedvoid markTransactionForRollback(java.lang.Object txId) throws ResourceManagerException
rollback
is permitted.
txId
- identifier for the transaction to be marked for rollback
ResourceManagerException
- if an error occuredvoid rollbackTransaction(java.lang.Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be rolled back
ResourceManagerException
- if an error occuredvoid commitTransaction(java.lang.Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be committed
ResourceManagerException
- if an error occuredint getTransactionState(java.lang.Object txId) throws ResourceManagerException
int
code as defined
in the Status
interface.
txId
- identifier for the transaction for which the state is returned
Status
ResourceManagerException
- if an error occuredboolean lockResource(java.lang.Object resourceId, java.lang.Object txId, boolean shared, boolean wait, long timeoutMSecs, boolean reentrant) throws ResourceManagerException
txId
does not come first) is different than in other methods of this interface.
This is done to make clear locking affects all transactions, not only the locking one.
This should be clear anyhow, but seems to be worth noting.
resourceId
- identifier for the resource to be lockedtxId
- identifier for the transaction that tries to acquire a lockshared
- true
if this lock may be shared by other shared lockswait
- true
if the method shall block when lock can not be acquired nowtimeoutMSecs
- timeout in millisecondsreentrant
- true
if the lock should be acquired even when the requesting transaction and no other holds an incompatible lock
true
when the lock has been acquired
ResourceManagerException
- if an error occuredboolean lockResource(java.lang.Object resourceId, java.lang.Object txId, boolean shared) throws ResourceManagerException
resourceId
- identifier for the resource to be lockedtxId
- identifier for the transaction that tries to acquire a lockshared
- true
if this lock may be shared by other shared locks
ResourceManagerException
- if an error occuredlockResource(Object, Object, boolean, boolean, long, boolean)
boolean lockResource(java.lang.Object resourceId, java.lang.Object txId) throws ResourceManagerException
resourceId
- identifier for the resource to be lockedtxId
- identifier for the transaction that tries to acquire a lock
ResourceManagerException
- if an error occuredlockResource(Object, Object, boolean)
,
lockResource(Object, Object, boolean, boolean, long, boolean)
boolean resourceExists(java.lang.Object txId, java.lang.Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be checked forresourceId
- identifier for the resource to check for
true
if the resource exists
ResourceManagerException
- if an error occuredboolean resourceExists(java.lang.Object resourceId) throws ResourceManagerException
resourceId
- identifier for the resource to check for
true
if the resource exists
ResourceManagerException
- if an error occuredvoid deleteResource(java.lang.Object txId, java.lang.Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be deletedresourceId
- identifier for the resource to be deleted
ResourceManagerException
- if the resource does not exist or any other error occuredvoid deleteResource(java.lang.Object txId, java.lang.Object resourceId, boolean assureOnly) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be deletedresourceId
- identifier for the resource to be deletedassureOnly
- if set to true
this method will not throw an exception when the resource does not exist
ResourceManagerException
- if the resource does not exist and assureOnly
was not set to true
or any other error occuredvoid createResource(java.lang.Object txId, java.lang.Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be createdresourceId
- identifier for the resource to be created
ResourceManagerException
- if the resource already exist or any other error occuredvoid createResource(java.lang.Object txId, java.lang.Object resourceId, boolean assureOnly) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be createdresourceId
- identifier for the resource to be createdassureOnly
- if set to true
this method will not throw an exception when the resource already exists
ResourceManagerException
- if the resource already exists and assureOnly
was not set to true
or any other error occuredjava.io.InputStream readResource(java.lang.Object txId, java.lang.Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the streamable resource is to be openendresourceId
- identifier for the streamable resource to be opened
ResourceManagerException
- if the resource does not exist or any other error occuredjava.io.InputStream readResource(java.lang.Object resourceId) throws ResourceManagerException
resourceId
- identifier for the streamable resource to be opened
ResourceManagerException
- if the resource does not exist or any other error occuredjava.io.OutputStream writeResource(java.lang.Object txId, java.lang.Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the streamable resource is to be openendresourceId
- identifier for the streamable resource to be opened
ResourceManagerException
- if the resource does not exist or any other error occured
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |