Berkeley DB Java Edition
version 5.0.34

com.sleepycat.je
Class Durability

java.lang.Object
  extended by com.sleepycat.je.Durability

public class Durability
extends Object

Durability defines the overall durability characteristics associated with a transaction. When operating on a local environment the durability of a transaction is completely determined by the local Durability.SyncPolicy that is in effect. When using replication, the overall durability is a function of the local Durability.SyncPolicy plus the Durability.ReplicaAckPolicy used by the master and the Durability.SyncPolicy in effect at each Replica.


Nested Class Summary
static class Durability.ReplicaAckPolicy
          A replicated environment makes it possible to increase an application's transaction commit guarantees by committing changes to its replicas on the network.
static class Durability.SyncPolicy
          Defines the synchronization policy to be used when committing a transaction.
 
Field Summary
static Durability COMMIT_NO_SYNC
          A convenience constant that defines a durability policy with COMMIT_NO_SYNC for local commit synchronization.
static Durability COMMIT_SYNC
          A convenience constant that defines a durability policy with COMMIT_SYNC for local commit synchronization.
static Durability COMMIT_WRITE_NO_SYNC
          A convenience constant that defines a durability policy with COMMIT_WRITE_NO_SYNC for local commit synchronization.
static Durability READ_ONLY_TXN
          A convenience constant that defines a durability policy, with ReplicaAckPolicy.NONE for use with a read only transaction.
 
Constructor Summary
Durability(Durability.SyncPolicy localSync, Durability.SyncPolicy replicaSync, Durability.ReplicaAckPolicy replicaAck)
          Creates an instance of a Durability specification.
 
Method Summary
 boolean equals(Object obj)
           
 Durability.SyncPolicy getLocalSync()
          Returns the transaction synchronization policy to be used locally when committing a transaction.
 Durability.ReplicaAckPolicy getReplicaAck()
          Returns the replica acknowledgment policy used by the master when committing changes to a replicated environment.
 Durability.SyncPolicy getReplicaSync()
          Returns the transaction synchronization policy to be used by the replica as it replays a transaction that needs an acknowledgment.
 int hashCode()
           
static Durability parse(String durabilityString)
          Parses the string and returns the durability it represents.
 String toString()
          Returns the string representation of durability in the format defined by string form of the Durability constructor.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMIT_SYNC

public static final Durability COMMIT_SYNC
A convenience constant that defines a durability policy with COMMIT_SYNC for local commit synchronization. The replicated environment policies default to COMMIT_NO_SYNC for commits of replicated transactions that need acknowledgment and SIMPLE_MAJORITY for the acknowledgment policy.


COMMIT_NO_SYNC

public static final Durability COMMIT_NO_SYNC
A convenience constant that defines a durability policy with COMMIT_NO_SYNC for local commit synchronization. The replicated environment policies default to COMMIT_NO_SYNC for commits of replicated transactions that need acknowledgment and SIMPLE_MAJORITY for the acknowledgment policy.


COMMIT_WRITE_NO_SYNC

public static final Durability COMMIT_WRITE_NO_SYNC
A convenience constant that defines a durability policy with COMMIT_WRITE_NO_SYNC for local commit synchronization. The replicated environment policies default to COMMIT_NO_SYNC for commits of replicated transactions that need acknowledgment and SIMPLE_MAJORITY for the acknowledgment policy.


READ_ONLY_TXN

public static final Durability READ_ONLY_TXN
A convenience constant that defines a durability policy, with ReplicaAckPolicy.NONE for use with a read only transaction. A read only transaction on a Master, using this Durability, will thus not be held up, or throw InsufficientReplicasException, if the Master is not in contact with a sufficient number of Replicas at the time the transaction was initiated.

It's worth noting that since the transaction is read only, the sync policies, although specified as NO_SYNC, do not really matter.

Constructor Detail

Durability

public Durability(Durability.SyncPolicy localSync,
                  Durability.SyncPolicy replicaSync,
                  Durability.ReplicaAckPolicy replicaAck)
Creates an instance of a Durability specification.

Parameters:
localSync - the SyncPolicy to be used when committing the transaction locally.
replicaSync - the SyncPolicy to be used remotely, as part of a transaction acknowledgment, at a Replica node.
replicaAck - the acknowledgment policy used when obtaining transaction acknowledgments from Replicas.
Method Detail

parse

public static Durability parse(String durabilityString)
Parses the string and returns the durability it represents. The string must have the following format:

SyncPolicy[,SyncPolicy[,ReplicaAckPolicy]]

The first SyncPolicy in the above format applies to the Master, and the optional second SyncPolicy to the replica. Specific SyncPolicy or ReplicaAckPolicy values are denoted by the name of the enumeration value.

For example, the string:sync,sync,quorum describes a durability policy where the master and replica both use Durability.SyncPolicy.SYNC to commit transactions and Durability.ReplicaAckPolicy.SIMPLE_MAJORITY to acknowledge a transaction commit.

Durability.SyncPolicy.NO_SYNC, is the default value for a node's SyncPolicy.

Durability.ReplicaAckPolicy.SIMPLE_MAJORITY is the default for the ReplicaAckPolicy.

Parameters:
durabilityString - the durability string in the above format
Returns:
the Durability resulting from the parse, or null if the durabilityString argument was itself null.
Throws:
IllegalArgumentException - if the durabilityString is invalid.

toString

public String toString()
Returns the string representation of durability in the format defined by string form of the Durability constructor.

Overrides:
toString in class Object
See Also:
parse(String)

getLocalSync

public Durability.SyncPolicy getLocalSync()
Returns the transaction synchronization policy to be used locally when committing a transaction.


getReplicaSync

public Durability.SyncPolicy getReplicaSync()
Returns the transaction synchronization policy to be used by the replica as it replays a transaction that needs an acknowledgment.


getReplicaAck

public Durability.ReplicaAckPolicy getReplicaAck()
Returns the replica acknowledgment policy used by the master when committing changes to a replicated environment.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

Berkeley DB Java Edition
version 5.0.34

Copyright (c) 2004-2011 Oracle. All rights reserved.