org.exolab.jms.gc
Class GarbageCollectionService

java.lang.Object
  |
  +--org.exolab.jms.service.Service
        |
        +--org.exolab.jms.gc.GarbageCollectionService
All Implemented Interfaces:
EventHandler, Serviceable

public class GarbageCollectionService
extends Service
implements EventHandler

The garbage collection service is responsible for managing all transient garbage collection for OpenJMS, which includes messages, destinations, endpoints etc. It does not deal with persistent data, which is handled through the database service. Other services or managers can register themselves with GarbageCollectionService if they implement the GarbageCollectable interface.

Gargabe collection will be initiated when the amount of free memory falls below a low water mark, which is calculated as a percentage of total memory. By default garbage collection will run when free memory falls below 20% of total memory, this can be changed through the configuration file.

The service will check the memory usage every 30 seconds by default. but this can also be modified through the configuration file.

In addition the garbage collection service can also be configured to execute at regular intervals regardless the amount of residual free memory. This option can be employed to ease the burden of performing wholesale garbage collection when memory falls below the low water mark threshold. The default value for this is 300 seconds. Setting this value to 0 will disable this capability.

This service makes use of the BasicEventManager to register events for garbage collection.

Version:
$Revision: 1.2 $ $Date: 2005/08/30 05:09:45 $
Author:
Jim Alateras

Constructor Summary
GarbageCollectionService(Configuration config, EventManager eventMgr)
          Create an instance of a garbage collection service.
 
Method Summary
 boolean belowLowWaterThreshold()
          Check whether the low water threshold has been reached.
 void doStart()
          Start the service.
 void handleEvent(int event, java.lang.Object callback, long time)
          Handle the specified event, generated by the EventManager.
 void register(GarbageCollectable entry)
          Register an entity that wishes to participate in the garbage collection process.
 void unregister(GarbageCollectable entry)
          Unregister the specified entry from the list of garbge collectable entities
 
Methods inherited from class org.exolab.jms.service.Service
doStop, getName, isStarted, restart, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GarbageCollectionService

public GarbageCollectionService(Configuration config,
                                EventManager eventMgr)
Create an instance of a garbage collection service. It uses the configuration manager to extract the service parameters.
Parameters:
config - the configuration to use
eventMgr - the event manager
Method Detail

belowLowWaterThreshold

public boolean belowLowWaterThreshold()
Check whether the low water threshold has been reached.
Returns:
boolean - true if it has; false otherwise

register

public void register(GarbageCollectable entry)
Register an entity that wishes to participate in the garbage collection process. This entity will be added to the list of other registered entities and will be called when GC is triggered.
Parameters:
entry - the entry to add to list

unregister

public void unregister(GarbageCollectable entry)
Unregister the specified entry from the list of garbge collectable entities
Parameters:
entry - - entry to remove

doStart

public void doStart()
             throws ServiceException
Description copied from class: Service
Start the service.
Overrides:
doStart in class Service
Following copied from class: org.exolab.jms.service.Service
Throws:
ServiceException - if the service fails to start

handleEvent

public void handleEvent(int event,
                        java.lang.Object callback,
                        long time)
Description copied from interface: EventHandler
Handle the specified event, generated by the EventManager.
Specified by:
handleEvent in interface EventHandler
Following copied from interface: org.exolab.jms.events.EventHandler
Parameters:
event - the event to handle
callback - the callback object
time - the absolute time, in ms, that the event fired


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.