CommitPointConsistencyPolicy (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je.rep

## Class CommitPointConsistencyPolicy

- java.lang.Object
- - com.sleepycat.je.rep.CommitPointConsistencyPolicy

- All Implemented Interfaces:
    ReplicaConsistencyPolicy

      public class CommitPointConsistencyPolicy
      extends Object
      implements ReplicaConsistencyPolicy

  A consistency policy which ensures that the environment on a Replica node is at least as current as denoted by the specified `CommitToken`. This token represents a point in the serialized transaction schedule created by the master. In other words, this token is like a bookmark, representing a particular transaction commit in the replication stream. The Replica ensures that the commit identified by the `CommitToken` has been executed on this node before allowing the application's `Environment.beginTransaction()` operation on the Replica to proceed.

  For example, suppose the application is a web application where a replicated group is implemented within a load balanced web server group. Each request to the web server consists of an update operation followed by read operations (say from the same client), The read operations naturally expect to see the data from the updates executed by the same request. However, the read operations might have been routed to a node that did not execute the update.

  In such a case, the update request would generate a `CommitToken`, which would be resubmitted by the browser, along with subsequent read requests. The read request could be directed at any one of the available web servers by a load balancer. The node which executes the read request would create a CommitPointConsistencyPolicy with that `CommitToken` and use it at transaction begin. If the environment at the web server was already current (wrt the commit token), it could immediately execute the transaction and satisfy the request. If not, the "transaction begin" would stall until the Replica replay had caught up and the change was available at that web server.

  Consistency policies are specified at either a per-transaction level through `TransactionConfig.setConsistencyPolicy(com.sleepycat.je.ReplicaConsistencyPolicy)` or as an replication node wide default through `ReplicationConfig.setConsistencyPolicy(com.sleepycat.je.ReplicaConsistencyPolicy)`

  See Also:
    `CommitToken`, Managing Consistency

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `NAME` The name:"CommitPointConsistencyPolicy" associated with this policy.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommitPointConsistencyPolicy(CommitToken commitToken, long timeout, TimeUnit timeoutUnit)` Defines how current a Replica needs to be in terms of a specific transaction that was committed on the Master.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `CommitToken` | `getCommitToken()` Return the `CommitToken` used to create this consistency policy.
    `String` | `getName()` Returns the name:"CommitPointConsistencyPolicy", associated with this policy.
    `long` | `getTimeout(TimeUnit unit)` Return the timeout specified when creating this consistency policy.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### NAME

          public static final String NAME

      The name:"CommitPointConsistencyPolicy" associated with this policy. The name can be used when constructing policy property values for use in je.properties files.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CommitPointConsistencyPolicy

          public CommitPointConsistencyPolicy(CommitToken commitToken,
                                      long timeout,
                                      TimeUnit timeoutUnit)

      Defines how current a Replica needs to be in terms of a specific transaction that was committed on the Master. A transaction on the Replica that uses this consistency policy is allowed to start only after the transaction identified by the `commitToken` has been committed on the Replica. The `Environment.beginTransaction()` will wait for at most `timeout` for the Replica to catch up. If the Replica has not caught up in this period, the `beginTransaction()` method will throw a `ReplicaConsistencyException`.
      Parameters:
        `commitToken` - the token identifying the transaction
        `timeout` - the maximum amount of time that the transaction start will wait to allow the Replica to catch up.
        `timeoutUnit` - the `TimeUnit` for the timeout parameter.
      Throws:
        `IllegalArgumentException` - if the commitToken or timeoutUnit is null.

  - ### Method Detail

    - #### getName

          public String getName()

      Returns the name:"CommitPointConsistencyPolicy", associated with this policy.
      Specified by:
        `getName` in interface `ReplicaConsistencyPolicy`
      See Also:
        `NAME`

    - #### getCommitToken

          public CommitToken getCommitToken()

      Return the `CommitToken` used to create this consistency policy.
      Returns:
        the `CommitToken` used to create this consistency policy.

    - #### getTimeout

          public long getTimeout(TimeUnit unit)

      Return the timeout specified when creating this consistency policy.
      Specified by:
        `getTimeout` in interface `ReplicaConsistencyPolicy`
      Parameters:
        `unit` - the `TimeUnit` of the returned value.
      Returns:
        the timeout specified when creating this consistency policy

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`
      See Also:
        `Object.hashCode()`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`
      See Also:
        `Object.equals(java.lang.Object)`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.