jrun.jms.core.gc
Class GarbageCollectionService

jrunx.kernel.ServiceAdapter
  |
  +--jrun.jms.core.util.JMSServiceAdapter
        |
        +--jrun.jms.core.gc.GarbageCollectionService
All Implemented Interfaces:
GarbageCollectionServiceMBean, JMSService, JMSServiceAdapterMBean, javax.naming.Referenceable, SchedulableEventListener, java.io.Serializable, Service, ServiceMBean

public class GarbageCollectionService
extends JMSServiceAdapter
implements GarbageCollectionServiceMBean, SchedulableEventListener

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 EventManager to register events for garabage collection.

Version:
$Revision: 1.4 $ $Date: 2001/10/11 21:17:32 $
Author:
Jim Alateras
See Also:
Serialized Form

Field Summary
static java.lang.String OBJECT_NAME
          The name of the service
 
Fields inherited from class jrunx.kernel.ServiceAdapter
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER
 
Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
GarbageCollectionService()
          Create an instance of a garbage collection service.
 
Method Summary
 boolean belowLowWaterThreshold()
          Check whether the low water threshold has been reached.
 void init()
          Not every service needs to init, implement it out of convenience.
static GarbageCollectionService instance()
          Return the singleton instance of the GarbageCollectionService
 void onSchedulableEvent(java.lang.Object Handle, int type)
          This method is called whenever a schedulableEvent gets fired.
 void register(GarbageCollectable entry)
          Register an entity that wishes to participate in the garbage collection process.
 void run()
           
 void start()
          Every service other than mere data collections should start
 void stop()
          Every service other than mere data collections should stop
 void unregister(GarbageCollectable entry)
          Unregister the specified entry from the list of garbge collectable entities
 
Methods inherited from class jrun.jms.core.util.JMSServiceAdapter
getMetaData, restart, resume, setMetaData, suspend
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, destroy, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, updateStatus
 

Field Detail

OBJECT_NAME

public static final java.lang.String OBJECT_NAME
The name of the service
Constructor Detail

GarbageCollectionService

public GarbageCollectionService()
                         throws GarbageCollectionServiceException
Create an instance of a garbage collection service. It uses the configuration manager to extract the service parameters.

It will throw a GarbageCollectionServiceException, if it cannot construct the service

Throws:
GarbageCollectionServiceException -  
Method Detail

instance

public static GarbageCollectionService instance()
                                         throws GarbageCollectionServiceException
Return the singleton instance of the GarbageCollectionService
Returns:
GarbageCollectionService
Throws:
GarbageCollectionServiceException -  

init

public void init()
          throws java.lang.Exception
Description copied from class: ServiceAdapter
Not every service needs to init, implement it out of convenience.
Specified by:
init in interface Service
Overrides:
init in class ServiceAdapter

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 - - 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

run

public void run()

start

public void start()
           throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should start
Specified by:
start in interface Service
Overrides:
start in class ServiceAdapter

stop

public void stop()
          throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should stop
Specified by:
stop in interface Service
Overrides:
stop in class ServiceAdapter

onSchedulableEvent

public void onSchedulableEvent(java.lang.Object Handle,
                               int type)
Description copied from interface: SchedulableEventListener
This method is called whenever a schedulableEvent gets fired. It passes the object associated with event.
Specified by:
onSchedulableEvent in interface SchedulableEventListener


Copyright � 2002 Macromedia Corporation. All Rights Reserved.