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 AT jboss DOT org)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.cache.Region
Region.Status, Region.Type
 
Constructor Summary
RegionImpl(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.
 Region clone()
          Deprecated. 
 int compareTo(Region other)
           
 Region copy(Fqn newRoot)
          copies the region - including eviction queue events - to a new Region instance, attached to a new Fqn root.
 void deactivate()
          Deactivates this region from being replicated.
 boolean equals(Object o)
           
 Configuration getCacheConfiguration()
           
 ClassLoader getClassLoader()
          Returns the configured ClassLoader for this region.
 BlockingQueue<EvictionEvent> getEvictionEventQueue()
           
 EvictionPolicy getEvictionPolicy()
          Deprecated. 
 EvictionPolicyConfig getEvictionPolicyConfig()
          Deprecated. 
 EvictionRegionConfig getEvictionRegionConfig()
           
 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()
          Deprecated. 
 void processEvictionQueues()
          Processes the eviction queues (primary and recycle queues) associated with this region.
 void putNodeEvent(EvictedEventNode event)
          Deprecated. 
 void registerContextClassLoader(ClassLoader classLoader)
          Registers a specific ClassLoader for this region, overridding the default cache class loader.
 EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType)
          An overloaded version of Region.registerEvictionEvent(Fqn, org.jboss.cache.eviction.EvictionEvent.Type, int) which uses a default elementDifference value.
 EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType, int elementDifference)
          Registers an eviction event on the region's eviction event queue for later processing by Region.processEvictionQueues().
 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)
          Deprecated. 
 void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
          Configures this region for eviction.
 void setStatus(Region.Status status)
          A mechanism to set status of a region, more fine grained control than just setActive();
 EvictedEventNode takeLastEventNode()
          Deprecated. 
 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
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(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

processEvictionQueues

public void processEvictionQueues()
Description copied from interface: Region
Processes the eviction queues (primary and recycle queues) associated with this region. A no-op if this is not an eviction region.

Specified by:
processEvictionQueues in interface Region

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

getEvictionEventQueue

public BlockingQueue<EvictionEvent> getEvictionEventQueue()

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 EvictionRegionConfig associated with this region, and it respects this event (e.g., LRUAlgorithm 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

resetEvictionQueues

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

Specified by:
resetEvictionQueues in interface Region

setEvictionRegionConfig

public void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
Description copied from interface: Region
Configures this region for eviction.

Specified by:
setEvictionRegionConfig in interface Region
Parameters:
evictionRegionConfig - configuration to set

getEvictionRegionConfig

public EvictionRegionConfig getEvictionRegionConfig()
Specified by:
getEvictionRegionConfig in interface Region
Returns:
the eviction region config, if any, set on the current region.

registerEvictionEvent

public EvictionEvent registerEvictionEvent(Fqn fqn,
                                           EvictionEvent.Type eventType)
Description copied from interface: Region
An overloaded version of Region.registerEvictionEvent(Fqn, org.jboss.cache.eviction.EvictionEvent.Type, int) which uses a default elementDifference value.

Specified by:
registerEvictionEvent in interface Region
Parameters:
fqn - passed in to the constructor of EvictionEvent
eventType - passed in to the constructor of EvictionEvent
Returns:
an EvictedEventNode that has been created for this queue

registerEvictionEvent

public EvictionEvent registerEvictionEvent(Fqn fqn,
                                           EvictionEvent.Type eventType,
                                           int elementDifference)
Description copied from interface: Region
Registers an eviction event on the region's eviction event queue for later processing by Region.processEvictionQueues().

Specified by:
registerEvictionEvent in interface Region
Parameters:
fqn - passed in to the constructor of EvictionEvent
eventType - passed in to the constructor of EvictionEvent
elementDifference - passed in to the constructor of EvictionEvent
Returns:
an EvictedEventNode that has been created for this queue

copy

public Region copy(Fqn newRoot)
Description copied from interface: Region
copies the region - including eviction queue events - to a new Region instance, attached to a new Fqn root. Typically used with Buddy Replication where region roots need to be adjusted.

Specified by:
copy in interface Region
Parameters:
newRoot - new root for the region - e.g., a buddy backup root.
Returns:
a new Region instance.

setEvictionPolicy

@Deprecated
public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
Deprecated. 

Description copied from interface: Region
Configures an eviction policy for this region.

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

getEvictionPolicyConfig

@Deprecated
public EvictionPolicyConfig getEvictionPolicyConfig()
Deprecated. 

Description copied from interface: Region
Returns an eviction policy configuration.

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

getEvictionPolicy

@Deprecated
public EvictionPolicy getEvictionPolicy()
Deprecated. 

Description copied from interface: Region
Returns an eviction policy.

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

nodeEventQueueSize

@Deprecated
public int nodeEventQueueSize()
Deprecated. 

Description copied from interface: Region
Returns the size of the node event queue, used by the eviction thread.

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

takeLastEventNode

@Deprecated
public EvictedEventNode takeLastEventNode()
Deprecated. 

Description copied from interface: Region
Returns the most recent EvictedEventNode added to the event queue by Region.putNodeEvent(org.jboss.cache.eviction.EvictedEventNode).

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

putNodeEvent

@Deprecated
public void putNodeEvent(EvictedEventNode event)
Deprecated. 

Description copied from interface: Region
Adds an EvictedEventNode to the internal queue for processing by the eviction thread.

Note: This is deprecated since this is an internal method and never was meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release and its functionality is not guaranteed.

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

clone

@Deprecated
public Region clone()
             throws CloneNotSupportedException
Deprecated. 

Specified by:
clone in interface Region
Overrides:
clone in class Object
Returns:
a clone
Throws:
CloneNotSupportedException


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