org.terracotta.api
Class Terracotta

java.lang.Object
  extended by org.terracotta.api.Terracotta

public abstract class Terracotta
extends Object

A static-accessor for the advanced functionality of the current (classloader scoped) client instance.


Constructor Summary
Terracotta()
           
 
Method Summary
static boolean disableEviction(Object o)
          Attempt to disable eviction for the given clustered object.
static boolean enableEviction(Object o)
          Attempt to enabled eviction for the given clustered object.
static boolean isActive()
          Returns true if the cluster is active.
static boolean isManaged(Object o)
          Returns true if this object is managed by the cluster.
static
<T> T
lookupOrCreateRoot(String name, Callable<T> creator)
          Create a cluster-heap root using the given name, and creator function.
static void registerBeforeShutdownHook(Runnable beforeShutdownHook)
          Register a Runnable to be called before the client is shutdown.
static void waitForAllCurrentTransactionsToComplete()
          Causes the calling thread to be suspended until all outstanding transactions have been persisted within the cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Terracotta

public Terracotta()
Method Detail

lookupOrCreateRoot

public static <T> T lookupOrCreateRoot(String name,
                                       Callable<T> creator)
Create a cluster-heap root using the given name, and creator function.

If a root with the given identifier already exists then its value is returned. If not then the creator is called, and the returned value is installed as a new root.

If the existing value for this root is not compatible with the generic return type of the method invocation then a ClassCastException is thrown.

Type Parameters:
T - type of the held object
Parameters:
name - identifier for the root
creator - function that returns the object to store
Returns:
the newly created or existing root object
Throws:
ClassCastException - if the root exists but holds a non-compatible type

isManaged

public static boolean isManaged(Object o)
Returns true if this object is managed by the cluster.

Parameters:
o - query object.
Returns:
true if managed

isActive

public static boolean isActive()
Returns true if the cluster is active.

Returns:
true if active

disableEviction

public static boolean disableEviction(Object o)
Attempt to disable eviction for the given clustered object.

If eviction is disabled, then this object will remain in the local heap on the VM from which this method was called.

Parameters:
o - target object
Returns:
true if eviction was disabled

enableEviction

public static boolean enableEviction(Object o)
Attempt to enabled eviction for the given clustered object.

If eviction is enabled, then the cluster is free to remove this object from the local heap on the VM from which this method is called.

Parameters:
o - target object
Returns:
true if eviction was enabled

waitForAllCurrentTransactionsToComplete

public static void waitForAllCurrentTransactionsToComplete()
Causes the calling thread to be suspended until all outstanding transactions have been persisted within the cluster.


registerBeforeShutdownHook

public static void registerBeforeShutdownHook(Runnable beforeShutdownHook)
Register a Runnable to be called before the client is shutdown.

Parameters:
beforeShutdownHook - runnable to be called


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