Using Predefined Consistency

You can use static instances of the Consistency base class to specify certain rigid consistency guarantees. There are two such instances that you can use:

  1. Consistency.ABSOLUTE

    Requires that the operation be serviced at the master node. In this way, the record(s) will always be consistent with the master.

    This is the strongest possible consistency guarantee that you can require, but it comes at the cost of servicing all read and write requests at the master node. If you direct all your traffic to the master node (which is just one machine for each partition), then you will not be distributing your read operations across your replicas. You also will slow your write operations because your master will be busy servicing read requests. For this reason, you should use this consistency guarantee sparingly.

  2. Consistency.NONE_REQUIRED

    Allows the store operation to proceed regardless of the state of the replica relative to the master. This is the most relaxed consistency guarantee that you can require. It allows for the maximum possible store performance, but at the high possibility that your application will be operating on stale or out-of-date information.


    Requires read operations to be serviced on a replica; never the Master. When this policy is used, the read operation will not be performed if the only node available is the Master.

    Where possible, this consistency policy should be avoided in favor of the secondary zones feature.

For example, suppose you are performing a critical read operation that you know must absolutely have the most up-to-date data. Then do this:

package kvstore.basicExample;


import oracle.kv.Consistency;
import oracle.kv.ConsistencyException;
import oracle.kv.Key;
import oracle.kv.Value;
import oracle.kv.ValueVersion;

import java.util.ArrayList;


ArrayList<String> majorComponents = new ArrayList<String>();


// Define the major path components for the key

// Create the key
Key myKey = Key.createKey(majorComponents);

// Now retrieve the record. Note that we do not show the creation of 
// the kvstore handle here.

try {
    ValueVersion vv = kvstore.get(myKey,
                        0,     // Timeout parameter. 
                               // 0 means use the default.
                        null); // Timeout units. Null because
                               // the Timeout is 0. 
    Value v = vv.getValue();
     * From here, deserialize using your Avro binding.
} catch (ConsistencyException ce) {
    // The consistency guarantee was not met