org.jboss.cache
Class RegionImpl

java.lang.Object
  extended by org.jboss.cache.RegionImpl
All Implemented Interfaces:
Cloneable, Comparable<Region>, Region

public class RegionImpl
extends Object
implements Region

Default implementation of a Region

Author:
Manik Surtani (manik@jboss.org)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.cache.Region
Region.Status, Region.Type
 
Constructor Summary
RegionImpl(EvictionPolicy policy, EvictionRegionConfig config, Fqn fqn, RegionManager regionManager)
          Constructs an eviction region from a policy and configuration, defined by an fqn and region manager.
RegionImpl(Fqn fqn, RegionManager regionManager)
          Constructs a marshalling region from an fqn and region manager.
 
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.
 RegionImpl clone(Fqn newRoot)
           
 int compareTo(Region other)
           
 void deactivate()
          Deactivates this region from being replicated.
 boolean equals(Object o)
           
 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()
           
 int hashCode()
           
 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 Region.putNodeEvent(EvictedEventNode).
 String toString()
           
 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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegionImpl

public RegionImpl(Fqn fqn,
                  RegionManager regionManager)
Constructs a marshalling region from an fqn and region manager.


RegionImpl

public RegionImpl(EvictionPolicy policy,
                  EvictionRegionConfig config,
                  Fqn fqn,
                  RegionManager regionManager)
Constructs an eviction region from a policy and configuration, defined by an fqn and region manager.

Method Detail

getCacheConfiguration

public Configuration getCacheConfiguration()
Specified by:
getCacheConfiguration in interface Region
Returns:
the cache-wide configuration

registerContextClassLoader

public void registerContextClassLoader(ClassLoader classLoader)
Description copied from interface: Region
Registers a specific ClassLoader for this region, overridding the default cache class loader.

Specified by:
registerContextClassLoader in interface Region
Parameters:
classLoader - specific class loader

unregisterContextClassLoader

public void unregisterContextClassLoader()
Description copied from interface: Region
Unregisters a registered ClassLoaders for this region.

Specified by:
unregisterContextClassLoader in interface Region

activate

public void activate()
Description copied from interface: Region
Activates this region for replication. By default, the entire cache is activated for replication at start-up.

Specified by:
activate in interface Region

activateIfEmpty

public void activateIfEmpty()
Description copied from interface: Region
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.

Specified by:
activateIfEmpty in interface Region

deactivate

public void deactivate()
Description copied from interface: Region
Deactivates this region from being replicated.

Specified by:
deactivate in interface Region

isActive

public boolean isActive()
Description copied from interface: Region
Returns true if this region has been activated.

Specified by:
isActive in interface Region
Returns:
true if this region has been activated.

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: Region
Returns the configured ClassLoader for this region.

Specified by:
getClassLoader in interface Region
Returns:
a ClassLoader

getFqn

public Fqn getFqn()
Description copied from interface: Region
Returns the Fqn of this region.

Specified by:
getFqn in interface Region
Returns:
the Fqn

setStatus

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

Specified by:
setStatus in interface Region
Parameters:
status - status of the region

getStatus

public Region.Status getStatus()
Specified by:
getStatus in interface Region
Returns:
the region's status

setActive

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

Specified by:
setActive in interface Region

markNodeCurrentlyInUse

public void markNodeCurrentlyInUse(Fqn fqn,
                                   long timeout)
Description copied from interface: Region
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 Region.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.

Specified by:
markNodeCurrentlyInUse in interface Region
Parameters:
fqn - Fqn of the node.
See Also:
Region.unmarkNodeCurrentlyInUse(Fqn)

unmarkNodeCurrentlyInUse

public void unmarkNodeCurrentlyInUse(Fqn fqn)
Description copied from interface: Region
Adds an event to the eviction queue indicating that a node is no longer in use.

Specified by:
unmarkNodeCurrentlyInUse in interface Region
Parameters:
fqn - Fqn of the node.
See Also:
Region.markNodeCurrentlyInUse(Fqn,long)

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Region other)
Specified by:
compareTo in interface Comparable<Region>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

putNodeEvent

public void putNodeEvent(EvictedEventNode event)
Description copied from interface: Region
Adds an EvictedEventNode to the internal queue for processing by the eviction thread.

Specified by:
putNodeEvent in interface Region
Parameters:
event - event to add

takeLastEventNode

public EvictedEventNode takeLastEventNode()
Description copied from interface: Region
Returns the most recent EvictedEventNode added to the event queue by Region.putNodeEvent(EvictedEventNode).

Specified by:
takeLastEventNode in interface Region
Returns:
the last EvictedEventNode, or null if no more events exist

nodeEventQueueSize

public int nodeEventQueueSize()
Description copied from interface: Region
Returns the size of the node event queue, used by the eviction thread.

Specified by:
nodeEventQueueSize in interface Region
Returns:
number of events

resetEvictionQueues

public void resetEvictionQueues()
Description copied from interface: Region
Clears the node event queue used for processing eviction.

Specified by:
resetEvictionQueues in interface Region
See Also:
Region.nodeEventQueueSize()

getEvictionRegionConfig

public EvictionRegionConfig getEvictionRegionConfig()
Description copied from interface: Region
Returns an eviction region configuration for this region.

Specified by:
getEvictionRegionConfig in interface Region
Returns:
an eviction region configuration

getEvictionPolicyConfig

public EvictionPolicyConfig getEvictionPolicyConfig()
Description copied from interface: Region
Returns an eviction policy configuration.

Specified by:
getEvictionPolicyConfig in interface Region
Returns:
an eviction policy configuration

getEvictionPolicy

public EvictionPolicy getEvictionPolicy()
Description copied from interface: Region
Returns an eviction policy.

Specified by:
getEvictionPolicy in interface Region
Returns:
an eviction policy

setEvictionPolicy

public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
Description copied from interface: Region
Configures an eviction policy for this region.

Specified by:
setEvictionPolicy in interface Region
Parameters:
evictionPolicyConfig - configuration to set

clone

public RegionImpl clone(Fqn newRoot)
Specified by:
clone in interface Region


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