org.jboss.cache
Class RegionManager

java.lang.Object
  extended by org.jboss.cache.RegionManager

@ThreadSafe
public class RegionManager
extends java.lang.Object

Manages multiple Regions for a Cache instance.

Since:
2.0.0
Author:
Manik Surtani

Field Summary
protected  java.util.Set<Fqn> activationChangeNodes
           
static Fqn DEFAULT_REGION
          The default region used in XML configuration files when defining eviction policies.
 
Constructor Summary
RegionManager()
          Constructs a new instance not attached to a cache.
RegionManager(CacheImpl cache)
          Constructs a new instance attached to a cache.
 
Method Summary
 void activate(Fqn fqn)
          Activates unmarshalling of replication messages for the region rooted in the given Fqn.
 void activateIfEmpty(Fqn fqn)
          Attempts to activate a given region rooted at a given Fqn, similar to activate(Fqn) except that if the fqn is currently already in use (probably already been activated) this method is a no-op.
 void deactivate(Fqn fqn)
          Disables unmarshalling of replication messages for the region rooted in the given Fqn.
 java.lang.String dumpRegions()
          Returns a string containing debug information on every region.
 java.util.List<Region> getAllRegions(Region.Type type)
          Returns an ordered list of all regions.
 CacheImpl getCache()
          Returns the cache for this region manager
protected  EvictionTimerTask getEvictionTimerTask()
           
 Region getRegion(Fqn fqn, boolean createIfAbsent)
          Returns a region by Fqn, creating it optionally if absent.
 Region getRegion(Fqn fqn, Region.Type type, boolean createIfAbsent)
          An overloaded form of getRegion(Fqn,boolean) that takes an additional Region.Type parameter to force regions of a specific type.
 Region getRegion(java.lang.String fqn, boolean createIfAbsent)
          Returns a region using Fqn.fromString(fqn), calling getRegion(Fqn,boolean)
 boolean hasRegion(Fqn fqn, Region.Type type)
          Returns true if the region exists
 boolean isDefaultInactive()
          Returns true if replication is by default inactive for new Regions.
 boolean isInactive(Fqn fqn)
          Convenienve method.
 boolean isUsingEvictions()
          Returns true if evictions are being processed.
 boolean removeRegion(Fqn fqn)
          Removes a Region identified by the given fqn.
 void reset()
          Resets the region manager's regions registry
 void setContextClassLoaderAsCurrent(Fqn fqn)
          Helper utility that checks for a ClassLoader registered for the given Fqn, and if found sets it as the TCCL.
 void setDefaultInactive(boolean defaultInactive)
          Sets if replication for new Regions is by default inactive.
 void setEvictionConfig(EvictionConfig evictionConfig)
          Sets the eviction configuration.
 void setUsingEvictions(boolean usingEvictions)
          Sets if evictions are processed.
 void startEvictionThread()
          Starts the eviction processing thread.
 void stopEvictionThread()
          Stops the eviction processing thread
 java.lang.String toString()
          Returns a string containing debug information on every region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_REGION

public static final Fqn DEFAULT_REGION
The default region used in XML configuration files when defining eviction policies. Any eviction settings bound under this 'default' Fqn is appplied to Fqn.ROOT internally so any region that is not explicitly defined comes under the settings defined for this default.


activationChangeNodes

protected final java.util.Set<Fqn> activationChangeNodes
Constructor Detail

RegionManager

public RegionManager()
Constructs a new instance not attached to a cache.


RegionManager

public RegionManager(CacheImpl cache)
Constructs a new instance attached to a cache.

Method Detail

isUsingEvictions

public boolean isUsingEvictions()
Returns true if evictions are being processed.


isDefaultInactive

public boolean isDefaultInactive()
Returns true if replication is by default inactive for new Regions.


setDefaultInactive

public void setDefaultInactive(boolean defaultInactive)
Sets if replication for new Regions is by default inactive.


setContextClassLoaderAsCurrent

public void setContextClassLoaderAsCurrent(Fqn fqn)
Helper utility that checks for a ClassLoader registered for the given Fqn, and if found sets it as the TCCL. If the given Fqn is under the _BUDDY_BACKUP_ region, the equivalent region in the main cache is used to find the ClassLoader.

Parameters:
fqn - Fqn pointing to a region for which a special classloader may have been registered.

getRegion

public Region getRegion(Fqn fqn,
                        boolean createIfAbsent)
Returns a region by Fqn, creating it optionally if absent. If the region does not exist and createIfAbsent is false, a parent region which may apply to the Fqn is sought.


getRegion

public Region getRegion(Fqn fqn,
                        Region.Type type,
                        boolean createIfAbsent)
An overloaded form of getRegion(Fqn,boolean) that takes an additional Region.Type parameter to force regions of a specific type.

See Also:
Region.Type

getRegion

public Region getRegion(java.lang.String fqn,
                        boolean createIfAbsent)
Returns a region using Fqn.fromString(fqn), calling getRegion(Fqn,boolean)

Parameters:
fqn -
createIfAbsent -
See Also:
getRegion(Fqn,boolean)

removeRegion

public boolean removeRegion(Fqn fqn)
Removes a Region identified by the given fqn.

Parameters:
fqn - fqn of the region to remove
Returns:
true if such a region existed and was removed.

getEvictionTimerTask

protected EvictionTimerTask getEvictionTimerTask()
Returns:
the eviction timer task object associated with this Region Manager.

activate

public void activate(Fqn fqn)
              throws RegionNotEmptyException
Activates unmarshalling of replication messages for the region rooted in the given Fqn.

NOTE: This method will cause the creation of a node in the local cache at subtreeFqn whether or not that node exists anywhere else in the cluster. If the node does not exist elsewhere, the local node will be empty. The creation of this node will not be replicated.

Parameters:
fqn - representing the region to be activated.
Throws:
RegionNotEmptyException - if the node fqn exists and already has either data or children

activateIfEmpty

public void activateIfEmpty(Fqn fqn)
Attempts to activate a given region rooted at a given Fqn, similar to activate(Fqn) except that if the fqn is currently already in use (probably already been activated) this method is a no-op.

Parameters:
fqn - which represents the region to activate

isInactive

public boolean isInactive(Fqn fqn)
Convenienve method. If the region defined by fqn does not exist, isDefaultInactive() is returned, otherwise !Region.isActive() is returned.

Parameters:
fqn - fqn to test
Returns:
true if inactive

hasRegion

public boolean hasRegion(Fqn fqn,
                         Region.Type type)
Returns true if the region exists

Parameters:
fqn - FQN of the region
type - type of region to search for
Returns:
true if the region exists

deactivate

public void deactivate(Fqn fqn)
Disables unmarshalling of replication messages for the region rooted in the given Fqn.

Parameters:
fqn -

reset

public void reset()
Resets the region manager's regions registry


getAllRegions

public java.util.List<Region> getAllRegions(Region.Type type)
Returns an ordered list of all regions. Note that the ordered list returned is sorted according to the natural order defined in the Comparable interface, which Region extends.

Parameters:
type - Type of region to return
Returns:
an ordered list of all regions, based on the type requested.

setUsingEvictions

public void setUsingEvictions(boolean usingEvictions)
Sets if evictions are processed.


setEvictionConfig

public void setEvictionConfig(EvictionConfig evictionConfig)
Sets the eviction configuration.


startEvictionThread

public void startEvictionThread()
Starts the eviction processing thread.


stopEvictionThread

public void stopEvictionThread()
Stops the eviction processing thread


dumpRegions

public java.lang.String dumpRegions()
Returns a string containing debug information on every region.


toString

public java.lang.String toString()
Returns a string containing debug information on every region.

Overrides:
toString in class java.lang.Object

getCache

public CacheImpl getCache()
Returns the cache for this region manager