org.terracotta.api
Class TerracottaToolkit

java.lang.Object
  extended by org.terracotta.api.TerracottaToolkit
All Implemented Interfaces:
ClusteringToolkit, ClusteringToolkitExtension

public class TerracottaToolkit
extends Object
implements ClusteringToolkitExtension

A ClusteringToolkit implementation that accesses the cluster instance associated with the current context.


Constructor Summary
TerracottaToolkit()
           
 
Method Summary
 ClusteredLock createLock(Object monitor, LockType type)
          Create a clustered lock around the supplied clustered monitor object.
 ClusteredAtomicLong getAtomicLong(String name)
          Get or create a clustered atomic long value.
 Barrier getBarrier(String name, int parties)
          Get or create a clustered barrier identified by the given name.
<E> BlockingQueue<E>
getBlockingQueue(String name)
          Get or create a clustered blocking queue with no capacity limit
<E> BlockingQueue<E>
getBlockingQueue(String name, int capacity)
          Get or create a clustered blocking queue with a capacity limit.
 ClusterInfo getClusterInfo()
          Retrieve a ClusterInfo object for the cluster this toolkit instance is related to.
<E> List<E>
getList(String name)
          Get or create a clustered list.
<K,V> ClusteredMap<K,V>
getMap(String name)
          Get or create a clustered map.
 ReadWriteLock getReadWriteLock(String name)
          Get or create a clustered read-write lock identified by the given name.
 ClusteredTextBucket getTextBucket(String name)
          Get or create a clustered text bucket identified by the given name.
 void unregisterAtomicLong(String name)
          Unregister a clustered atomic long identified by the given name from the cluster.
 void unregisterBarrier(String name)
          Unregister a clustered barrier identified by the given name from the cluster.
 void unregisterBlockingQueue(String name)
          Unregister a clustered blocking queue identified by the given name from the cluster.
 void unregisterList(String name)
          Unregister a clustered list identified by the given name from the cluster.
 void unregisterMap(String name)
          Unregister a clustered map identified by the given name from the cluster.
 void unregisterReadWriteLock(String name)
          Unregister a clustered read-write lock identified by the given name from the cluster.
 void unregisterTextBucket(String name)
          Unregister a clustered text bucket identified by the given name from the cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerracottaToolkit

public TerracottaToolkit()
Method Detail

getBarrier

public Barrier getBarrier(String name,
                          int parties)
Description copied from interface: ClusteringToolkit
Get or create a clustered barrier identified by the given name.

If the named barrier already exists with the same number of parties then it is returned. If it doesn't exist it is created and registered. If the named barrier already exists but has a different number of parties then IllegalArgumentException is thrown.

Specified by:
getBarrier in interface ClusteringToolkit
Parameters:
name - identifier for the barrier
parties - number of parties
Returns:
a clustered barrier with the required number of parties

unregisterBarrier

public void unregisterBarrier(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered barrier identified by the given name from the cluster.

If the named barrier exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a barrier after it has been unregistered leads to undefined results.

Specified by:
unregisterBarrier in interface ClusteringToolkitExtension
Parameters:
name - identifier for the barrier

getTextBucket

public ClusteredTextBucket getTextBucket(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered text bucket identified by the given name.

If the named bucket already exists then it is returned. If it doesn't exist it is created and registered.

Specified by:
getTextBucket in interface ClusteringToolkit
Parameters:
name - identifier for the bucket
Returns:
a clustered text bucket

unregisterTextBucket

public void unregisterTextBucket(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered text bucket identified by the given name from the cluster.

If the named bucket exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a text bucket after it has been unregistered leads to undefined results.

Specified by:
unregisterTextBucket in interface ClusteringToolkitExtension
Parameters:
name - identifier for the bucket

getReadWriteLock

public ReadWriteLock getReadWriteLock(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered read-write lock identified by the given name.

If the named lock already exists then it is returned. If it doesn't exist it is created and registered.

Specified by:
getReadWriteLock in interface ClusteringToolkit
Parameters:
name - identifier for the lock
Returns:
a clustered read-write lock

unregisterReadWriteLock

public void unregisterReadWriteLock(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered read-write lock identified by the given name from the cluster.

If the named lock exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a read-write lock after it has been unregistered leads to undefined results.

Specified by:
unregisterReadWriteLock in interface ClusteringToolkitExtension
Parameters:
name - identifier for the lock

getBlockingQueue

public <E> BlockingQueue<E> getBlockingQueue(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered blocking queue with no capacity limit

If the named queue already exists and has no capacity limit then it is returned. If it doesn't exist then it is created and registered. If the named queue already exists but has a capacity limit then IllegalArgumentException is thrown.

Specified by:
getBlockingQueue in interface ClusteringToolkit
Parameters:
name - identifier for the queue
Returns:
a clustered unbounded blocking queue

getBlockingQueue

public <E> BlockingQueue<E> getBlockingQueue(String name,
                                             int capacity)
Description copied from interface: ClusteringToolkit
Get or create a clustered blocking queue with a capacity limit.

If the named queue already exists and it has the same capacity limit then it is returned. If it doesn't exist then it is created and registered. If the named queue already exists but has a different capacity limit then IllegalArgumentException is thrown.

Specified by:
getBlockingQueue in interface ClusteringToolkit
Parameters:
name - identifier for the queue
capacity - the capacity limit for the queue
Returns:
a clustered capacity bounded blocking queue

unregisterBlockingQueue

public void unregisterBlockingQueue(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered blocking queue identified by the given name from the cluster.

If the named queue exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a blocking queue after it has been unregistered leads to undefined results.

Specified by:
unregisterBlockingQueue in interface ClusteringToolkitExtension
Parameters:
name - identifier for the queue

getMap

public <K,V> ClusteredMap<K,V> getMap(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered map.

If the named map already exists then it is returned. If not it is created and registered.

Specified by:
getMap in interface ClusteringToolkit
Type Parameters:
K - key type
V - value type
Parameters:
name - identifier for the map
Returns:
a clustered map

unregisterMap

public void unregisterMap(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered map identified by the given name from the cluster.

If the named map exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a map after it has been unregistered leads to undefined results.

Specified by:
unregisterMap in interface ClusteringToolkitExtension
Parameters:
name - identifier for the map

getList

public <E> List<E> getList(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered list.

If the named list already exists then it is returned. If not it is created and registered.

Specified by:
getList in interface ClusteringToolkit
Type Parameters:
E - element type
Parameters:
name - identifier for the list
Returns:
a clustered list

unregisterList

public void unregisterList(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered list identified by the given name from the cluster.

If the named list exists it is unregistered from the cluster, otherwise this method does nothing. Further use of a list after it has been unregistered leads to undefined results.

Specified by:
unregisterList in interface ClusteringToolkitExtension
Parameters:
name - identifier for the list

getAtomicLong

public ClusteredAtomicLong getAtomicLong(String name)
Description copied from interface: ClusteringToolkit
Get or create a clustered atomic long value.

If the named atomic long already exists then it is returned. If not it is created and registered.

Specified by:
getAtomicLong in interface ClusteringToolkit
Parameters:
name - identifier for the atomic long
Returns:
a clustered atomic long value

unregisterAtomicLong

public void unregisterAtomicLong(String name)
Description copied from interface: ClusteringToolkitExtension
Unregister a clustered atomic long identified by the given name from the cluster.

If the named atomic long exists it is unregistered from the cluster, otherwise this method does nothing. Further use of an atomic long after it has been unregistered leads to undefined results.

Specified by:
unregisterAtomicLong in interface ClusteringToolkitExtension
Parameters:
name - identifier for the atomic long

createLock

public ClusteredLock createLock(Object monitor,
                                LockType type)
Description copied from interface: ClusteringToolkit
Create a clustered lock around the supplied clustered monitor object.

The supplied lock type controls the lock hold acquired by the default Lock inherited methods.

If the supplied monitor object is null then NullPointerException is thrown. If it is not clustered then IllegalArgumentException is thrown.

Specified by:
createLock in interface ClusteringToolkit
Parameters:
monitor - clustered object
type - default lock hold type
Returns:
a clustered lock

getClusterInfo

public ClusterInfo getClusterInfo()
Description copied from interface: ClusteringToolkit
Retrieve a ClusterInfo object for the cluster this toolkit instance is related to.

Specified by:
getClusterInfo in interface ClusteringToolkit
Returns:
cluster info object


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.