org.apache.cassandra.thrift
Enum ConsistencyLevel

java.lang.Object
  extended by java.lang.Enum<ConsistencyLevel>
      extended by org.apache.cassandra.thrift.ConsistencyLevel
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ConsistencyLevel>, org.apache.thrift.TEnum

public enum ConsistencyLevel
extends java.lang.Enum<ConsistencyLevel>
implements org.apache.thrift.TEnum

The ConsistencyLevel is an enum that controls both read and write behavior based on in your storage-conf.xml. The different consistency levels have different meanings, depending on if you're doing a write or read operation. Note that if W + R > ReplicationFactor, where W is the number of nodes to block for on write, and R the number to block for on reads, you will have strongly consistent behavior; that is, readers will always see the most recent write. Of these, the most interesting is to do QUORUM reads and writes, which gives you consistency while still allowing availability in the face of node failures up to half of . Of course if latency is more important than consistency then you can use lower values for either or both. Write: ZERO Ensure nothing. A write happens asynchronously in background ANY Ensure that the write has been written once somewhere, including possibly being hinted in a non-target node. ONE Ensure that the write has been written to at least 1 node's commit log and memory table before responding to the client. QUORUM Ensure that the write has been written to / 2 + 1 nodes before responding to the client. ALL Ensure that the write is written to <ReplicationFactor> nodes before responding to the client. Read: ZERO Not supported, because it doesn't make sense. ANY Not supported. You probably want ONE instead. ONE Will return the record returned by the first node to respond. A consistency check is always done in a background thread to fix any consistency issues when ConsistencyLevel.ONE is used. This means subsequent calls will have correct data even if the initial read gets an older value. (This is called 'read repair'.) QUORUM Will query all storage nodes and return the record with the most recent timestamp once it has at least a majority of replicas reported. Again, the remaining replicas will be checked in the background. ALL Queries all storage nodes and returns the record with the most recent timestamp.


Enum Constant Summary
ALL
           
ANY
           
DCQUORUM
           
DCQUORUMSYNC
           
ONE
           
QUORUM
           
ZERO
           
 
Method Summary
static ConsistencyLevel findByValue(int value)
          Find a the enum type by its integer value, as defined in the Thrift IDL.
 int getValue()
          Get the integer value of this enum value, as defined in the Thrift IDL.
static ConsistencyLevel valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ConsistencyLevel[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ZERO

public static final ConsistencyLevel ZERO

ONE

public static final ConsistencyLevel ONE

QUORUM

public static final ConsistencyLevel QUORUM

DCQUORUM

public static final ConsistencyLevel DCQUORUM

DCQUORUMSYNC

public static final ConsistencyLevel DCQUORUMSYNC

ALL

public static final ConsistencyLevel ALL

ANY

public static final ConsistencyLevel ANY
Method Detail

values

public static ConsistencyLevel[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ConsistencyLevel c : ConsistencyLevel.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ConsistencyLevel valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getValue

public int getValue()
Get the integer value of this enum value, as defined in the Thrift IDL.

Specified by:
getValue in interface org.apache.thrift.TEnum

findByValue

public static ConsistencyLevel findByValue(int value)
Find a the enum type by its integer value, as defined in the Thrift IDL.

Returns:
null if the value is not found.


Copyright © 2010 The Apache Software Foundation