public interface ResourceManager extends Status
Modifier and Type | Field and Description |
---|---|
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
|
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN
Modifier and Type | Method and Description |
---|---|
void |
commitTransaction(Object txId)
Commis the transaction specified by the given transaction identifier.
|
void |
createResource(Object txId,
Object resourceId)
Creates a resource.
|
void |
createResource(Object txId,
Object resourceId,
boolean assureOnly)
Creates a resource.
|
void |
deleteResource(Object txId,
Object resourceId)
Deletes a resource.
|
void |
deleteResource(Object txId,
Object resourceId,
boolean assureOnly)
Deletes a resource.
|
int |
getDefaultIsolationLevel()
Gets the default isolation level as an integer.
|
long |
getDefaultTransactionTimeout()
Gets the default transaction timeout in milliseconds.
|
int |
getIsolationLevel(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(Object txId)
Gets the state of the transaction specified by the given transaction identifier.
|
long |
getTransactionTimeout(Object txId)
Gets the transaction timeout of the specified transaction in milliseconds.
|
boolean |
isIsolationLevelSupported(int level)
Tests if the specified isolation level is supported by this resource manager.
|
boolean |
lockResource(Object resourceId,
Object txId)
Explicitly locks a resource exclusively, i.e.
|
boolean |
lockResource(Object resourceId,
Object txId,
boolean shared)
Explicitly locks a resource in reentrant style.
|
boolean |
lockResource(Object resourceId,
Object txId,
boolean shared,
boolean wait,
long timeoutMSecs,
boolean reentrant)
Explicitly locks a resource.
|
void |
markTransactionForRollback(Object txId)
Marks the transaction specified by the given transaction identifier for rollback.
|
int |
prepareTransaction(Object txId)
Prepares the transaction specified by the given transaction identifier for commit.
|
InputStream |
readResource(Object resourceId)
Opens a streamable resource for a single reading request not inside the scope of a transaction.
|
InputStream |
readResource(Object txId,
Object resourceId)
Opens a streamable resource for reading.
|
boolean |
recover()
Tries to bring this resource manager back to a consistent state.
|
boolean |
resourceExists(Object resourceId)
Checks if a resource exists wihtout being in a transaction.
|
boolean |
resourceExists(Object txId,
Object resourceId)
Checks if a resource exists.
|
void |
rollbackTransaction(Object txId)
Rolls back the transaction specified by the given transaction identifier.
|
void |
setIsolationLevel(Object txId,
int level)
Sets the isolation level for the specified transaction.
|
void |
setTransactionTimeout(Object txId,
long mSecs)
Sets the transaction timeout of the specified transaction in milliseconds.
|
void |
start()
Starts this resource manager.
|
void |
startTransaction(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.
|
OutputStream |
writeResource(Object txId,
Object resourceId)
Opens a resource for writing.
|
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
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 millisecondstrue
if resource manager stopped within given timeoutResourceManagerSystemException
- 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 modetrue
if resource manager stopped within given timeoutResourceManagerSystemException
- if anything fatal hapened during shutdownboolean recover() throws ResourceManagerSystemException
true
upon successful recovery of the resource managerResourceManagerSystemException
- if anything fatal hapened during recoveryint 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 levelResourceManagerException
- 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 levelResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
boolean isIsolationLevelSupported(int level) throws ResourceManagerException
level
- isolation level whose support is to be testedtrue
if the isolation level is supportedResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
int getIsolationLevel(Object txId) throws ResourceManagerException
txId
- identifier for the concerned transactionISOLATION_LEVEL_READ_UNCOMMITTED
,
ISOLATION_LEVEL_READ_COMMITTED
, ISOLATION_LEVEL_REPEATABLE_READ
or ISOLATION_LEVEL_SERIALIZABLE
or any other int representing an isolation levelResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
void setIsolationLevel(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 levelResourceManagerException
- if an error occuredgetDefaultIsolationLevel()
long getDefaultTransactionTimeout() throws ResourceManagerException
ResourceManagerException
- if an error occuredlong getTransactionTimeout(Object txId) throws ResourceManagerException
txId
- identifier for the concerned transactionResourceManagerException
- if an error occuredgetDefaultTransactionTimeout()
void setTransactionTimeout(Object txId, long mSecs) throws ResourceManagerException
txId
- identifier for the concerned transactionmSecs
- transaction timeout of the specified transaction in millisecondsResourceManagerException
- if an error occuredgetDefaultTransactionTimeout()
void startTransaction(Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be startedResourceManagerException
- if an error occuredint prepareTransaction(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 preparedPREPARE_SUCCESS
, PREPARE_SUCCESS_READONLY
or PREPARE_FAILURE
ResourceManagerException
- alternative way to signal prepare failedvoid markTransactionForRollback(Object txId) throws ResourceManagerException
rollback
is permitted.txId
- identifier for the transaction to be marked for rollbackResourceManagerException
- if an error occuredvoid rollbackTransaction(Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be rolled backResourceManagerException
- if an error occuredvoid commitTransaction(Object txId) throws ResourceManagerException
txId
- identifier for the transaction to be committedResourceManagerException
- if an error occuredint getTransactionState(Object txId) throws ResourceManagerException
int
code as defined
in the Status
interface.txId
- identifier for the transaction for which the state is returnedStatus
ResourceManagerException
- if an error occuredboolean lockResource(Object resourceId, 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 locktrue
when the lock has been acquiredResourceManagerException
- if an error occuredboolean lockResource(Object resourceId, 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 locksResourceManagerException
- if an error occuredlockResource(Object, Object, boolean, boolean, long, boolean)
boolean lockResource(Object resourceId, Object txId) throws ResourceManagerException
resourceId
- identifier for the resource to be lockedtxId
- identifier for the transaction that tries to acquire a lockResourceManagerException
- if an error occuredlockResource(Object, Object, boolean)
,
lockResource(Object, Object, boolean, boolean, long, boolean)
boolean resourceExists(Object txId, Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be checked forresourceId
- identifier for the resource to check fortrue
if the resource existsResourceManagerException
- if an error occuredboolean resourceExists(Object resourceId) throws ResourceManagerException
resourceId
- identifier for the resource to check fortrue
if the resource existsResourceManagerException
- if an error occuredvoid deleteResource(Object txId, Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be deletedresourceId
- identifier for the resource to be deletedResourceManagerException
- if the resource does not exist or any other error occuredvoid deleteResource(Object txId, 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 existResourceManagerException
- if the resource does not exist and assureOnly
was not set to true
or any other error occuredvoid createResource(Object txId, Object resourceId) throws ResourceManagerException
txId
- identifier for the transaction in which the resource is to be createdresourceId
- identifier for the resource to be createdResourceManagerException
- if the resource already exist or any other error occuredvoid createResource(Object txId, 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 existsResourceManagerException
- if the resource already exists and assureOnly
was not set to true
or any other error occuredInputStream readResource(Object txId, 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 openedResourceManagerException
- if the resource does not exist or any other error occuredInputStream readResource(Object resourceId) throws ResourceManagerException
resourceId
- identifier for the streamable resource to be openedResourceManagerException
- if the resource does not exist or any other error occuredOutputStream writeResource(Object txId, 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 openedResourceManagerException
- if the resource does not exist or any other error occuredCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.