About the Thread Management Framework
ThreadManagementFramework is a
tool for the control of threads created by an application. It can ensure that,
during the entire life cycle of the application, never more than X threads will
run at the same time. The organization for managing threads inside the framework can
be represented by a graph of areas, as described below. Users can configure this graph according to their needs via an XML file. For example, the XML declaration for the graph above is : <!DOCTYPE area PUBLIC "-//objectweb.org//DTD ObjectWeb Area Management 1.0//EN" "ow_area.dtd"> <area name="OTM" description="ObjectWeb Thread Management" limit="200"> <alarm class="org.objectweb.area.lib.DefaultAlarm"/> <!-- Alarm2 --> <area name="java" description="Java packages" limit="100"> <alarm class="org.objectweb.area.lib.OutOfMemoryAlarm"/> <!-- Alarm1 --> <java package="java."/> <java package="javax."/> <java package="sun."/> </area> <area name="OW packages" description="ObjectWeb packages" limit="100"> <java package="org.objectweb."/> </area> <area name="local" description="Local packages" limit="100"> <java package=""/> </area> </area> Areas have been defined for managing a group of resources, in this case threads. Thus, management of every Area can be separate, with a specific behaviour associated to each one. As illustrated in the figure above, an area is a node of the graph. Therefore, each area has a parent (except for the root area), can have a limit, and can trigger an alarm (also represented in the graph) when the limit is reached. Each area is dedicated to accept threads, according to a specific criteria, like the package in which the threads are created. When a thread enters an area, it enters in the parent area also. Thus, the root area (at the top of the graph) counts all the threads created by the application. To ensure this property, the Thread class is modified via ASM for entering an Area before start, and exiting the Area after exit. Table of Contents1. Integration of TMF in JOnASWith TMF, it is possible to control all the threads that are created inside JOnAS. Specifically, the property that specifies that an EJB is not allowed to create threads is ensured by assigning a specific Area for EJBs, with 0 for the limit. ConfigurationTo use TMF with JOnAS:
shell> controlTMF enable This activation will proceed as follows:
# Set the list of the services launched in the JOnAS Server. # Possible services are: registry,jmx,security,jtm,db,mail,dbm,resource,jms,ejb,ws,web,ear,discovery. # registry,jmx,jtm,ejb are mandatory. # (registry and jmx are automatically started even if not present in the list) # Order in the list is important (see 'Configuring JOnAS services' in JOnAS documentation) # jonas.services registry,jmx,thread,jtm,security,resource,ejb,ws,web,ear ... ###################### JOnAS Thread # # jonas.service.thread.class org.objectweb.area.jonas.AreaService jonas.service.thread.file jonas_areas.xml jonas.service.thread.ejbareaname EJB
Then, start JOnAS and the Thead management will be activated. A more complex configuration for the jonas_areas.xml graph could be : whose definition is: <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- ==================================================================== ObjectWeb Area Management Framework Copyright (C) 2005 INRIA - Jacquard Team Contact: [email protected] This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Initial developer(s): Philippe Merle. Contributor(s): Nicolas Dolet. For the configuration of the ObjectWeb Area Management Framework. ==================================================================== --> <!DOCTYPE area PUBLIC "-//objectweb.org//DTD ObjectWeb Area Management 1.0//EN" "ow_area.dtd"> <area name="jonas_areas" description="ObjectWeb Thread Management" class="org.objectweb.area.lib.NoLockArea" limit="500"> <area name="rmi" description="Java RMI" class="org.objectweb.area.lib.NoLockArea" limit="100"> <alarm class="org.objectweb.area.jonas.LogAlarm"/> <java package="java.rmi."/> <java package="javax.rmi."/> <java package="sun.rmi."/> <java package="javax.management.remote.rmi."/> <java package="org.omg.stub.java.rmi."/> </area> <area name="jmx" description="Java JMX" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="javax.management.remote."/> </area> <area name="resource" description="Resource service (JCA)" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="org.objectweb.jonas.resource."/> </area> <area name="logger" description="Logger" class="org.objectweb.area.lib.NoLockArea" limit="10"> <java package="java.util.logging.LogManager."/> </area> <area name="timer" description="Timer service" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="org.objectweb.jonas_timer."/> </area> <area name="webserver" description="Web server packages" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="org.objectweb.jonas.web."/> </area> <area name="JMS-Joram" description="JMS and Joram packages" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="javax.jms."/> <java package="org.objectweb.joram."/> <java package="fr.dyade.aaa."/> </area> <area name="transaction" description="Transactions" class="org.objectweb.area.lib.NoLockArea" limit="100"> <java package="org.objectweb.jotm."/> <java package="org.objectweb.transaction.jta."/> </area> <area name="DBConnection" description="Database connections" class="org.objectweb.area.lib.NoLockArea" limit="100"> <area name="JavaDbConnection" description="DB connections for java packages" class="org.objectweb.area.lib.NoLockArea" limit="70"> <java package="java.sql."/> <java package="javax.sql."/> </area> <area name="OWDbConnection" description="DB connections for objectweb packages" class="org.objectweb.area.lib.NoLockArea" limit="70"> <java package="org.objectweb.jonas.jdbc."/> <java package="org.objectweb.jonas.dbm."/> </area> <area name="HSQL" description="HSQL database embedded in JOnAS" class="org.objectweb.area.lib.NoLockArea" limit="50"> <java package="org.hsqldb."/> </area> </area> <area name="EJB" description="EJB" limit="0"/> </area> In this configuration, only one alarm is defined (LogAlarm), in the RMI Area. It will be the default alarm for all areas in the graph. If there is no alarm defined for an area, the default alarm will be searched in the parent area, recursively. Management
When JOnAS is started, MBeans can be visualized via the jonasAdmin
The new thread service is defined on a domain named jconsole
The jconsole provides MBeans management services via JMX. The connection is
available in the 'advanced' tab. Local Management with jconsole
Another way to manage the JVM with jconsole is via local management. To enable local
management, the application must be launched with Sample Scenario
For testing the thread control, an EJB that only creates and runs a thread can be deployed. 2. Build and Use Thread Management FrameworkGenerate the Distribution VersionThe framework can be downloaded at http://gforge.inria.fr/projects/tmf.
The mode used for building TMF (Object Oriented, or Component
Oriented) can be selected in the
Call the shell> ant dist How TMF works
The core of TMF is the adapted Libraries Organization
TMF is encapsulated in two libraries:
A third library is used for defining a new service (cf
Using TMF on the ExamplesGo to the 'dist' directory: shell> cd dist Four examples are available. For each one, there are three modes of execution (loaded in sequence) :
'bench'Make a bench, i.e., create threads and calculate the execution time. 'queens'Calculate the solutions of the Queens puzzle problem for chessboards with dimensions from 1*1 to 10*10, and calculate the execution time. 'rmi'Create threads with the client and use an RMI interface to display a message referring to threads on the server. 'thread'
Create threads in a loop, until the user stops the program
( An example:
To use TMF with another example, give the JVM
the location of the jars for loading the new
|
|
Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster | Last modified at 2006-07-28 11:40 AM |