public class STransaction
extends java.lang.Object
Once the abort()
, or commit()
methods are called, the handle
may not be accessed again, regardless of the success or failure of the
method. In addition, parent transactions may not issue any Berkeley DB
driver operations while they have active child transactions (child
transactions that have not yet been committed or aborted) except for SEnvironment.beginTransaction(com.sleepycat.client.STransaction, com.sleepycat.client.STransactionConfig)
, abort()
and commit()
.
To obtain a transaction with default attributes:
STransaction txn = myEnvironment.beginTransaction(null, null);To customize the attributes of a transaction:
STransactionConfig config = new STransactionConfig(); config.setReadUncommitted(true); STransaction txn = myEnvironment.beginTransaction(null, config);
Modifier and Type | Method and Description |
---|---|
void |
abort()
Cause an abnormal termination of the transaction.
|
void |
commit()
End the transaction.
|
void |
commitNoSync()
End the transaction, not committing synchronously.
|
void |
commitSync()
End the transaction, committing synchronously.
|
void |
commitWriteNoSync()
End the transaction, writing but not flushing the log.
|
int |
getPriority()
Get the transaction's deadlock priority.
|
default <V> V |
handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote) |
default <V> V |
remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote) |
default <V> V |
remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote) |
void |
setPriority(int priority)
Set the deadlock priority for this transaction.
|
public void abort() throws SDatabaseException
The log is played backward, and any necessary undo operations are done. Before this method returns, any locks held by the transaction will have been released.
In the case of nested transactions, aborting a parent transaction causes all children (unresolved or not) of the parent transaction to be aborted.
All cursors opened within the transaction must be closed before the
transaction is aborted. This method closes all open SCursor
handles. And if a close operation fails, the rest of the cursors are
closed, and the database environment is set to the panic state.
After this method has been called, regardless of its return, this handle may not be accessed again.
SDatabaseException
- if any error occurspublic void commit() throws SDatabaseException
If the environment is not configured for synchronous commit, the commit will not necessarily have been committed to stable storage before the call returns. This means the transaction will exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but it is possible this transaction may be undone during recovery.
In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.
All cursors opened within the transaction must be closed before the
transaction is committed. If there are SCursor
handles open when
this method is called, they are all closed inside this method. And if
there are errors when closing the cursor handles, the transaction is
aborted and the first such error is returned.
After this method returns, this handle may not be accessed again, regardless of the method's success or failure. If the method encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.
SDatabaseException
- if any error occurspublic void commitNoSync() throws SDatabaseException
This behavior may be set for a database environment using the
SEnvironmentConfig.setTxnNoSync(boolean)
method or for a single
transaction using the SEnvironment.beginTransaction(com.sleepycat.client.STransaction, com.sleepycat.client.STransactionConfig)
method. Any
value specified to this method overrides both of those settings.
In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.
All cursors opened within the transaction must be closed before the
transaction is committed. If there are SCursor
handles open when
this method is called, they are all closed inside this method. And if
there are errors when closing the cursor handles, the transaction is
aborted and the first such error is returned.
After this method returns, this handle may not be accessed again, regardless of the method's success or failure. If the method encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.
SDatabaseException
- if any error occurspublic void commitSync() throws SDatabaseException
This behavior is the default for database environments unless otherwise
configured using the SEnvironmentConfig.setTxnNoSync(boolean)
method.
This behavior may also be set for a single transaction using the
SEnvironment.beginTransaction(com.sleepycat.client.STransaction, com.sleepycat.client.STransactionConfig)
method. Any value specified to
this method overrides both of those settings.
In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.
All cursors opened within the transaction must be closed before the
transaction is committed. If there are SCursor
handles open when
this method is called, they are all closed inside this method. And if
there are errors when closing the cursor handles, the transaction is
aborted and the first such error is returned.
After this method returns, this handle may not be accessed again, regardless of the method's success or failure. If the method encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.
SDatabaseException
- if any error occurspublic void commitWriteNoSync() throws SDatabaseException
This behavior may be set for a database environment using the SEnvironmentConfig.setTxnWriteNoSync(boolean)
method or for a single transaction
using the SEnvironment.beginTransaction(com.sleepycat.client.STransaction, com.sleepycat.client.STransactionConfig)
method. Any value
specified to this method overrides both of those settings.
In the case of nested transactions, if the transaction is a parent transaction, committing the parent transaction causes all unresolved children of the parent to be committed. In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. Although the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted; that is, if its parent transaction commits, it will be committed; and if its parent transaction aborts, it will be aborted.
All cursors opened within the transaction must be closed before the
transaction is committed. If there are SCursor
handles open when
this method is called, they are all closed inside this method. And if
there are errors when closing the cursor handles, the transaction is
aborted and the first such error is returned.
After this method returns, this handle may not be accessed again, regardless of the method's success or failure. If the method encounters an error, the transaction and all child transactions of the transaction will have been aborted when the call returns.
SDatabaseException
- if any error occurspublic int getPriority() throws SDatabaseException
SDatabaseException
- if any error occurspublic void setPriority(int priority) throws SDatabaseException
priority
- the deadlock priority for the transaction.SDatabaseException
- if any error occurspublic <V> V remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote) throws java.io.IOException
java.io.IOException
public <V> V remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote)
public <V> V handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote) throws org.apache.thrift.TException
org.apache.thrift.TException
Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved.