org.usergrid.locking.cassandra
Class HectorLockManagerImpl

java.lang.Object
  extended by org.usergrid.locking.cassandra.HectorLockManagerImpl
All Implemented Interfaces:
LockManager

public class HectorLockManagerImpl
extends Object
implements LockManager

Uses the hector based locking implementation to obtain locks

Author:
tnine

Constructor Summary
HectorLockManagerImpl()
           
 
Method Summary
 Lock createLock(UUID applicationId, String... path)
          Acquires a lock on a particular path.
 void init()
           
 void setCluster(me.prettyprint.hector.api.Cluster cluster)
           
 void setKeyspaceName(String keyspaceName)
           
 void setLockTtl(long lockTtl)
          The amount of time a lock must not be renewed before it times out.
 void setNumberOfLockObserverThreads(int numberOfLockObserverThreads)
          Set the number of threads the lock heartbeat executor uses.
 void setReplicationFactor(int replicationFactor)
          Note that in a real environment this MUST be an odd number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HectorLockManagerImpl

public HectorLockManagerImpl()
Method Detail

init

@PostConstruct
public void init()

createLock

public Lock createLock(UUID applicationId,
                       String... path)
                throws UGLockException
Description copied from interface: LockManager
Acquires a lock on a particular path.

Specified by:
createLock in interface LockManager
Parameters:
applicationId - application UUID
path - a unique path
Throws:
UGLockException - if the lock cannot be acquired

setReplicationFactor

public void setReplicationFactor(int replicationFactor)
Note that in a real environment this MUST be an odd number. Locks are read and written at QUORUM. RF >= 3 is preferred for failure tolerance and replication. Defaults to 1

Parameters:
replicationFactor - the replicationFactor to set

setNumberOfLockObserverThreads

public void setNumberOfLockObserverThreads(int numberOfLockObserverThreads)
Set the number of threads the lock heartbeat executor uses. Must accommodate the total number of locks that may exist in the system. Locks are always renewed at the ttl/2 time.

Parameters:
numberOfLockObserverThreads - the numberOfLockObserverThreads to set

setLockTtl

public void setLockTtl(long lockTtl)
The amount of time a lock must not be renewed before it times out. Set in milliseconds. 2000 is the default

Parameters:
lockTtl - the lockTtl to set

setKeyspaceName

public void setKeyspaceName(String keyspaceName)
Parameters:
keyspaceName - the keyspaceName to set

setCluster

public void setCluster(me.prettyprint.hector.api.Cluster cluster)
Parameters:
cluster - the cluster to set


Copyright © 2013. All Rights Reserved.