org.jboss.cache
Interface Region

All Superinterfaces:
Comparable<Region>
All Known Implementing Classes:
RegionImpl

public interface Region
extends Comparable<Region>

Defines characteristics such as class loading and eviction of Nodes belonging to a Region in a Cache. A Region is described by an Fqn relative to the root of the cache. All nodes and child nodes of this Fqn belong to this region.

If a region is to be recognised as an eviction region (region of type Region.Type.EVICTION then it must have an EvictionPolicyConfig set using setEvictionPolicy(org.jboss.cache.config.EvictionPolicyConfig).

Similarly, to be recognised as a marshalling region (region of type Region.Type.MARSHALLING then it must have a ClassLoader registered using registerContextClassLoader(ClassLoader).

Note that a single region can be both an eviction and marshalling region at the same time.

Since:
2.0.0
Author:
Manik Surtani (manik@jboss.org)
See Also:
RegionManager

Nested Class Summary
static class Region.Status
          Region status
static class Region.Type
          Types of regions.
 
Method Summary
 void activate()
          Activates this region for replication.
 void activateIfEmpty()
          Activates this region for replication, but if the Fqn that represents this region already exists and either contains data or children, no state transfers take place.
 void deactivate()
          Deactivates this region from being replicated.
 Configuration getCacheConfiguration()
           
 ClassLoader getClassLoader()
          Returns the configured ClassLoader for this region.
 EvictionPolicy getEvictionPolicy()
          Returns an eviction policy.
 EvictionPolicyConfig getEvictionPolicyConfig()
          Returns an eviction policy configuration.
 EvictionRegionConfig getEvictionRegionConfig()
          Returns an eviction region configuration for this region.
 Fqn getFqn()
          Returns the Fqn of this region.
 Region.Status getStatus()
           
 boolean isActive()
          Returns true if this region has been activated.
 void markNodeCurrentlyInUse(Fqn fqn, long timeout)
          Marks a Node as currently in use, by adding an event to the eviction queue.
 int nodeEventQueueSize()
          Returns the size of the node event queue, used by the eviction thread.
 void putNodeEvent(EvictedEventNode event)
          Adds an EvictedEventNode to the internal queue for processing by the eviction thread.
 void registerContextClassLoader(ClassLoader classLoader)
          Registers a specific ClassLoader for this region, overridding the default cache class loader.
 void resetEvictionQueues()
          Clears the node event queue used for processing eviction.
 void setActive(boolean b)
          Sets this region as active - this only marks a flag and does not actually activates or deactivates this region.
 void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
          Configures an eviction policy for this region.
 void setStatus(Region.Status status)
          A mechanism to set status of a region, more fine grained control than just setActive();
 EvictedEventNode takeLastEventNode()
          Returns the most recent EvictedEventNode added to the event queue by putNodeEvent(EvictedEventNode).
 void unmarkNodeCurrentlyInUse(Fqn fqn)
          Adds an event to the eviction queue indicating that a node is no longer in use.
 void unregisterContextClassLoader()
          Unregisters a registered ClassLoaders for this region.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

registerContextClassLoader

void registerContextClassLoader(ClassLoader classLoader)
Registers a specific ClassLoader for this region, overridding the default cache class loader.

Parameters:
classLoader - specific class loader

getCacheConfiguration

Configuration getCacheConfiguration()
Returns:
the cache-wide configuration
Since:
2.1.0

unregisterContextClassLoader

void unregisterContextClassLoader()
Unregisters a registered ClassLoaders for this region.


activate

void activate()
              throws RegionNotEmptyException
Activates this region for replication. By default, the entire cache is activated for replication at start-up.

Throws:
RegionNotEmptyException - if the Fqn that represents this region already exists and contains data or children.

activateIfEmpty

void activateIfEmpty()
Activates this region for replication, but if the Fqn that represents this region already exists and either contains data or children, no state transfers take place. The region is simply marked as active in this case.


deactivate

void deactivate()
Deactivates this region from being replicated.


setActive

void setActive(boolean b)
Sets this region as active - this only marks a flag and does not actually activates or deactivates this region. Use activate() and deactivate() for the full process.

Parameters:
b -

isActive

boolean isActive()
Returns true if this region has been activated.

Returns:
true if this region has been activated.

getClassLoader

ClassLoader getClassLoader()
Returns the configured ClassLoader for this region.

Returns:
a ClassLoader

setEvictionPolicy

void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
Configures an eviction policy for this region.

Parameters:
evictionPolicyConfig - configuration to set

getEvictionPolicyConfig

EvictionPolicyConfig getEvictionPolicyConfig()
Returns an eviction policy configuration.

Returns:
an eviction policy configuration

getEvictionPolicy

EvictionPolicy getEvictionPolicy()
Returns an eviction policy.

Returns:
an eviction policy

getEvictionRegionConfig

EvictionRegionConfig getEvictionRegionConfig()
Returns an eviction region configuration for this region.

Returns:
an eviction region configuration

resetEvictionQueues

void resetEvictionQueues()
Clears the node event queue used for processing eviction.

See Also:
nodeEventQueueSize()

nodeEventQueueSize

int nodeEventQueueSize()
Returns the size of the node event queue, used by the eviction thread.

Returns:
number of events

takeLastEventNode

EvictedEventNode takeLastEventNode()
Returns the most recent EvictedEventNode added to the event queue by putNodeEvent(EvictedEventNode).

Returns:
the last EvictedEventNode, or null if no more events exist

putNodeEvent

void putNodeEvent(EvictedEventNode event)
Adds an EvictedEventNode to the internal queue for processing by the eviction thread.

Parameters:
event - event to add

markNodeCurrentlyInUse

void markNodeCurrentlyInUse(Fqn fqn,
                            long timeout)
Marks a Node as currently in use, by adding an event to the eviction queue. If there is an EvictionPolicy associated with this region, and it respects this event (e.g., LRUPolicy does), then the Node will not be evicted until unmarkNodeCurrentlyInUse(Fqn) is invoked.

This mechanism can be used to prevent eviction of data that the application is currently using, in the absence of any locks on the Node where the data is stored.

Parameters:
fqn - Fqn of the node.
See Also:
unmarkNodeCurrentlyInUse(Fqn)

unmarkNodeCurrentlyInUse

void unmarkNodeCurrentlyInUse(Fqn fqn)
Adds an event to the eviction queue indicating that a node is no longer in use.

Parameters:
fqn - Fqn of the node.
See Also:
markNodeCurrentlyInUse(Fqn,long)

getFqn

Fqn getFqn()
Returns the Fqn of this region.

Returns:
the Fqn

setStatus

void setStatus(Region.Status status)
A mechanism to set status of a region, more fine grained control than just setActive();

Parameters:
status - status of the region
Since:
2.1.0

getStatus

Region.Status getStatus()
Returns:
the region's status


Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.