com.sleepycat.je
Class TransactionConfig

java.lang.Object
  extended by com.sleepycat.je.TransactionConfig
All Implemented Interfaces:
java.lang.Cloneable

public class TransactionConfig
extends java.lang.Object
implements java.lang.Cloneable

Specifies the attributes of a database environment transaction.


Field Summary
static TransactionConfig DEFAULT
          Default configuration used if null is passed to methods that create a transaction.
static Durability NO_SYNC
           
static Durability SYNC
           
static Durability WRITE_NO_SYNC
           
 
Constructor Summary
TransactionConfig()
          An instance created using the default constructor is initialized with the system's default settings.
 
Method Summary
 ReplicaConsistencyPolicy getConsistencyPolicy()
           
 boolean getDirtyRead()
          Deprecated. This has been replaced by getReadUncommitted() to conform to ANSI database isolation terminology.
 Durability getDurability()
           
 Durability getDurabilityFromSync()
           
 boolean getNoSync()
          Returns true if the transaction is configured to not write or synchronously flush the log it when commits.
 boolean getNoWait()
          Returns true if the transaction is configured to not wait if a lock request cannot be immediately granted.
 boolean getReadCommitted()
          Returns true if the transaction is configured for read committed isolation.
 boolean getReadUncommitted()
          Returns true if read operations performed by the transaction are configured to return modified but not yet committed data.
 boolean getSerializableIsolation()
          Returns true if the transaction has been explicitly configured to have serializable (degree 3) isolation.
 boolean getSync()
          Returns true if the transaction is configured to write and synchronously flush the log it when commits.
 boolean getWriteNoSync()
          Returns true if the transaction is configured to write but not synchronously flush the log it when commits.
 void setConsistencyPolicy(ReplicaConsistencyPolicy consistencyPolicy)
           
 void setDirtyRead(boolean dirtyRead)
          Deprecated. This has been replaced by setReadUncommitted(boolean) to conform to ANSI database isolation terminology.
 void setDurability(Durability durability)
           
 void setNoSync(boolean noSync)
          Configures the transaction to not write or synchronously flush the log it when commits.
 void setNoWait(boolean noWait)
          Configures the transaction to not wait if a lock request cannot be immediately granted.
 void setReadCommitted(boolean readCommitted)
          Configures the transaction for read committed isolation.
 void setReadUncommitted(boolean readUncommitted)
          Configures read operations performed by the transaction to return modified but not yet committed data.
 void setSerializableIsolation(boolean serializableIsolation)
          Configures this transaction to have serializable (degree 3) isolation.
 void setSync(boolean sync)
          Configures the transaction to write and synchronously flush the log it when commits.
 void setWriteNoSync(boolean writeNoSync)
          Configures the transaction to write but not synchronously flush the log it when commits.
 java.lang.String toString()
          Returns the values for each configuration attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final TransactionConfig DEFAULT
Default configuration used if null is passed to methods that create a transaction.


SYNC

public static final Durability SYNC

NO_SYNC

public static final Durability NO_SYNC

WRITE_NO_SYNC

public static final Durability WRITE_NO_SYNC
Constructor Detail

TransactionConfig

public TransactionConfig()
An instance created using the default constructor is initialized with the system's default settings.

Method Detail

getDurabilityFromSync

public Durability getDurabilityFromSync()
Returns:
the equivalent durability

setSync

public void setSync(boolean sync)
Configures the transaction to write and synchronously flush the log it when commits.

This behavior may be set for a database environment using the Environment.setMutableConfig method. Any value specified to this method overrides that setting.

The default is false for this class and true for the database environment.

If true is passed to both setSync and setNoSync, setSync will take precedence.

Parameters:
sync - If true, transactions exhibit all the ACID (atomicity, consistency, isolation, and durability) properties.

getSync

public boolean getSync()
Returns true if the transaction is configured to write and synchronously flush the log it when commits.

Returns:
true if the transaction is configured to write and synchronously flush the log it when commits.

setNoSync

public void setNoSync(boolean noSync)
Configures the transaction to not write or synchronously flush the log it when commits.

This behavior may be set for a database environment using the Environment.setMutableConfig method. Any value specified to this method overrides that setting.

The default is false for this class and the database environment.

Parameters:
noSync - If true, transactions exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the application or system fails, it is possible some number of the most recently committed transactions may be undone during recovery. The number of transactions at risk is governed by how many log updates can fit into the log buffer, how often the operating system flushes dirty buffers to disk, and how often the log is checkpointed.

getNoSync

public boolean getNoSync()
Returns true if the transaction is configured to not write or synchronously flush the log it when commits.

Returns:
true if the transaction is configured to not write or synchronously flush the log it when commits.

setWriteNoSync

public void setWriteNoSync(boolean writeNoSync)
Configures the transaction to write but not synchronously flush the log it when commits.

This behavior may be set for a database environment using the Environment.setMutableConfig method. Any value specified to this method overrides that setting.

The default is false for this class and the database environment.

Parameters:
writeNoSync - If true, transactions exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the operating system fails, it is possible some number of the most recently committed transactions may be undone during recovery. The number of transactions at risk is governed by how often the operating system flushes dirty buffers to disk, and how often the log is checkpointed.

getWriteNoSync

public boolean getWriteNoSync()
Returns true if the transaction is configured to write but not synchronously flush the log it when commits.

Returns:
true if the transaction is configured to not write or synchronously flush the log it when commits.

setDurability

public void setDurability(Durability durability)
Parameters:
durability - the durability definition

getDurability

public Durability getDurability()
Returns:
the durability setting currently associated with this config.

setConsistencyPolicy

public void setConsistencyPolicy(ReplicaConsistencyPolicy consistencyPolicy)
Parameters:
consistencyPolicy - the consistency definition

getConsistencyPolicy

public ReplicaConsistencyPolicy getConsistencyPolicy()
Returns:
the consistency policy currently associated with this config.

setNoWait

public void setNoWait(boolean noWait)
Configures the transaction to not wait if a lock request cannot be immediately granted.

The default is false for this class and the database environment.

Parameters:
noWait - If true, transactions will not wait if a lock request cannot be immediately granted, instead DeadlockException will be thrown.

getNoWait

public boolean getNoWait()
Returns true if the transaction is configured to not wait if a lock request cannot be immediately granted.

Returns:
true if the transaction is configured to not wait if a lock request cannot be immediately granted.

setReadUncommitted

public void setReadUncommitted(boolean readUncommitted)
Configures read operations performed by the transaction to return modified but not yet committed data.

Parameters:
readUncommitted - If true, configure read operations performed by the transaction to return modified but not yet committed data.
See Also:
LockMode.READ_UNCOMMITTED

getReadUncommitted

public boolean getReadUncommitted()
Returns true if read operations performed by the transaction are configured to return modified but not yet committed data.

Returns:
true if read operations performed by the transaction are configured to return modified but not yet committed data.
See Also:
LockMode.READ_UNCOMMITTED

setDirtyRead

public void setDirtyRead(boolean dirtyRead)
Deprecated. This has been replaced by setReadUncommitted(boolean) to conform to ANSI database isolation terminology.

Configures read operations performed by the transaction to return modified but not yet committed data.

Parameters:
dirtyRead - If true, configure read operations performed by the transaction to return modified but not yet committed data.

getDirtyRead

public boolean getDirtyRead()
Deprecated. This has been replaced by getReadUncommitted() to conform to ANSI database isolation terminology.

Returns true if read operations performed by the transaction are configured to return modified but not yet committed data.

Returns:
true if read operations performed by the transaction are configured to return modified but not yet committed data.

setReadCommitted

public void setReadCommitted(boolean readCommitted)
Configures the transaction for read committed isolation.

This ensures the stability of the current data item read by the cursor but permits data read by this transaction to be modified or deleted prior to the commit of the transaction.

Parameters:
readCommitted - If true, configure the transaction for read committed isolation.
See Also:
LockMode.READ_COMMITTED

getReadCommitted

public boolean getReadCommitted()
Returns true if the transaction is configured for read committed isolation.

Returns:
true if the transaction is configured for read committed isolation.
See Also:
LockMode.READ_COMMITTED

setSerializableIsolation

public void setSerializableIsolation(boolean serializableIsolation)
Configures this transaction to have serializable (degree 3) isolation. By setting serializable isolation, phantoms will be prevented.

By default a transaction provides Repeatable Read isolation; EnvironmentConfig.setTxnSerializableIsolation(boolean) may be called to override the default. If the environment is configured for serializable isolation, all transactions will be serializable regardless of whether this method is called; calling setSerializableIsolation(boolean) with a false parameter will not disable serializable isolation.

The default is false for this class and the database environment.

See Also:
LockMode

getSerializableIsolation

public boolean getSerializableIsolation()
Returns true if the transaction has been explicitly configured to have serializable (degree 3) isolation.

Returns:
true if the transaction has been configured to have serializable isolation.
See Also:
LockMode

toString

public java.lang.String toString()
Returns the values for each configuration attribute.

Overrides:
toString in class java.lang.Object
Returns:
the values for each configuration attribute.