com.netflix.astyanax.recipes.uniqueness
Class ColumnPrefixUniquenessConstraint<K>

java.lang.Object
  extended by com.netflix.astyanax.recipes.uniqueness.ColumnPrefixUniquenessConstraint<K>
Type Parameters:
K -
All Implemented Interfaces:
UniquenessConstraint

public class ColumnPrefixUniquenessConstraint<K>
extends Object
implements UniquenessConstraint

Perform a uniqueness constraint using the locking recipe. The usage here is to take the lock and then re-write the column without a TTL to 'persist' it in cassandra.

Author:
elandau

Constructor Summary
ColumnPrefixUniquenessConstraint(Keyspace keyspace, ColumnFamily<K,String> columnFamily, K key)
           
 
Method Summary
 void acquire()
          Acquire the row(s) for uniqueness.
 void acquireAndMutate(MutationBatch m)
          Acquire the uniqueness constraint and apply the final mutation if the row if found to be unique
 String readUniqueColumn()
           
 void release()
          Release the uniqueness lock for this row.
 ColumnPrefixUniquenessConstraint<K> withConsistencyLevel(ConsistencyLevel consistencyLevel)
           
 ColumnPrefixUniquenessConstraint<K> withPrefix(String prefix)
           
 ColumnPrefixUniquenessConstraint<K> withTtl(Integer ttl)
           
 ColumnPrefixUniquenessConstraint<K> withUniqueId(String unique)
          Specify the unique value to use for the column name when doing the uniqueness constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnPrefixUniquenessConstraint

public ColumnPrefixUniquenessConstraint(Keyspace keyspace,
                                        ColumnFamily<K,String> columnFamily,
                                        K key)
Method Detail

withTtl

public ColumnPrefixUniquenessConstraint<K> withTtl(Integer ttl)

withConsistencyLevel

public ColumnPrefixUniquenessConstraint<K> withConsistencyLevel(ConsistencyLevel consistencyLevel)

withPrefix

public ColumnPrefixUniquenessConstraint<K> withPrefix(String prefix)

withUniqueId

public ColumnPrefixUniquenessConstraint<K> withUniqueId(String unique)
Specify the unique value to use for the column name when doing the uniqueness constraint. In many cases this will be a TimeUUID that is used as the row key to store the actual data for the unique key tracked in this column family.

Parameters:
unique -
Returns:

readUniqueColumn

public String readUniqueColumn()
                        throws Exception
Throws:
Exception

acquire

public void acquire()
             throws NotUniqueException,
                    Exception
Description copied from interface: UniquenessConstraint
Acquire the row(s) for uniqueness. Call release() when the uniqueness on the row(s) is no longer needed, such as when deleting the rows.

Specified by:
acquire in interface UniquenessConstraint
Throws:
NotUniqueException
Exception

acquireAndMutate

public void acquireAndMutate(MutationBatch m)
                      throws NotUniqueException,
                             Exception
Description copied from interface: UniquenessConstraint
Acquire the uniqueness constraint and apply the final mutation if the row if found to be unique

Specified by:
acquireAndMutate in interface UniquenessConstraint
Throws:
NotUniqueException
Exception

release

public void release()
             throws Exception
Description copied from interface: UniquenessConstraint
Release the uniqueness lock for this row. Only call this when you no longer need the uniqueness lock

Specified by:
release in interface UniquenessConstraint
Throws:
Exception


Copyright © 2012. All Rights Reserved.