com.sun.corba.se.spi.monitoring

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules com.sun » corba » com.sun.corba.se.spi.monitoring 
com.sun.corba.se.spi.monitoring
package General Information

Monitoring Framework SPI's is used internally by the ORB to instrument for JMX based Management and Monitoring. The
framework is very generic and easy to use and acts as facade to retrieve the information from the running CORBA system.

This framework helps in building a nice Hierarchical Structure of Monitored Objects that contains Monitored Attributes.
com.sun.corba.se.spi.orb.ORB has an API to get the RootMonitoredObject and then User can traverse through the tree to
either instrument or retrieve the information for Monitoring.

Code Snippet to Instrument Connection Monitored Object

This example shows on how to instrument CorbaConnectionImpl 's attributes. It exposes two
attributes, namely

1. Connection State
2. Response time statistics to Appeserver Admin Console or CLI
 

1. Instrumenting Connection State

/**
 *  Code Snippet to Instrument Connection Monitored Object with
 *  ConnectionState Monitored Attribute. Steps to follow
 *
 *  Step 1: Define a Monitored Attribute (ConnectionStateMonitoredAttribute) Class by extending
 *               StringMonitoredAttributeBase
 *
 *  Step 2: Create Connection Manager Monitored Object and add that to
 *                Root Monitored Object.
 *
 *  Step 3: Create Connection Monitored Object  and add it to Connection Manager Monitored Object
 *
 *  Step 4: Instantiate Concrete Attribute (ConnectionStateMonitoredAttribute) Class and add that to
 *                the Connection MonitoredObject
 *
 *  Step 5: Adds ConnectionMonitoredObject to ConnectionManagerMonitoredObject
 *
 */

/**
  *  Step 1: Define a Monitored Attribute Class by extending
  *                StringMonitoredAttributeBase
  */

/**
  *  ConnectionState gets the value on demand.
  */
#import com.sun.corba.se.spi.monitoring.LongMonitoredAttributeBase
#import com.sun.corba.se.spi.transport.CorbaConnection;

public class ConnectionStateMonitoredAttribute extends StringMonitoredAttributeBase
{
    CorbaConnection connection;
    public ConnectionInUseMonitoredAttribute( String name, String desc,
        CorbaConnection con )
    {
        super( name, desc );
        connection = con;
    }

    public Object getValue( ) {
        // Delegate the getValue call to connection
        // so, there is no state maintained in this attribute object itself
        // and also the locking will be the responsibility of Connection
        // Object. By doing this we will avoid global locking and possibly
        // avoiding the bottleneck
        return connection.getState( );
    }

    // IMPORTANT: In this case we don't have to implement clearState() method
    // If there is a need to implement this method like for POACounter, the
    // call again can be delegated to the Object which maintains the real
    // state. clearState() is invoked whenever there is a call to CORBAMBean.startMonitoring()
}
 

/**
 *  Step 2: Create Connection Manager Monitored Object and add that to
 *          Root Monitored Object.
 */
import com.sun.corba.se.spi.monitoring.MonitoringFactories;
import com.sun.corba.se.spi.monitoring.MonitoredObject;

private static MonitoredObject connectionManagerMonitoredObject;
private static MonitoredObject connectionMonitoredObject;
 

    private void instrumentConnectionManager( ) {
        connectionManagerMonitoredObject =
            MonitoringFactories.getMonitoredObjectFactory().createMonitoredObject(
                "ConnectionManagerMonitoredObject",
                "Used to Monitor the stats on All IIOP Connections " );
        orb.getRootMonitoredObject().addChild(connectionManagerMonitoredObject );
    }
 

/**
  *  Step 3: Create Connection Monitored Object  and add it to Connection Manager Monitored Object
  *
  *  Step 4: Instantiate Concrete Attribute (ConnectionStateMonitoredAttribute) Class and add that to
  *                the Connection MonitoredObject
  *
  *  Step 5: Add ConnectionMonitoredObject to ConnectionManagerMonitoredObject
  */
private void instrumentConnectionObject( CorbConnection connection ) {
    // Step 3
    MonitoredObject connectionMonitoredObject =
        MonitoringFactories.getMonitoredObjectFactory().createMonitoredObject(
            connection.getName(),
            "Used to Monitor the stats on one connection" );
    // Step 4
    ConnectionStateMonitoredAttribute connectionState =
        new ConnectionStateMonitoredAttribute( "Connection_State",
            "Provides the state of the IIOP Connection ...",  connection );
    connectionMonitoredObject.addAttribute( connectionState );
    // Step 5
    connectionManagerMonitoredObject.addChild( connectionMonitoredObject );
}
 
 

Code Snippet to Instrument A Statistic Type Monitored Attribute

/**
  *  Assuming ConnectionMonitoredObject is already added to the MonitoredObject Hierarchy.
  *  This example code shows how to instrument ConnectionMonitoredObject with a new
  *   StatisticMonitoredAttribute.
  *
  *    IMPORTANT: StatisticsMonitoredAttribute is mostly write mostly and read sparingly, i.e.,
  *    the frequency of writes(Collecting samples) is high.  It is the responsibility of user to synchronize
  *    the sample() method and the StatisticMonitoredAttribute will synchronize clearState() and
  *    getValue() using the mutex object sent.
  */
private void instrumentStatsToConnectionObject( MonitoredObject connectionMonitoredObject  ) {
     // Step 4
    StatisticsAccumulator connectRequestStatsAccumulator =
        // Microseconds is the unit used for statistics measure
        new StatisticsAccumulator( "Micro Seconds" );

    // Pass Name, Description, Statistic Accumulator Instance, Mutex (The
    // Object on which we need to synchronize for stats sample collection)
    StatisticMonitoredAttribute sm = new StatisticMonitoredAttribute(
        connection.getName() + "Stats",
        "Connection Request Stats", connectRequestStatsAccumulator, this );

    connectionMonitoredObject.addAttribute( sm );
 

    // Now, The user can accumulate the samples by calling into
    // connectRequestStatsAccumulator.sample( <value> );
    // Finally When ASAdmin request for the value of this Stats Monitored Attribute
    // by using standard getValue() call. It will return a formatted Stats Value like
    //  For Example
    //
    //  Minimum Value = 200 Microseconds
    //  Maximum Value = 928 Microseconds
    //  Average Value = 523 Microseconds
    //  Standard Deviation = 53.72 Microseconds
    //  Sample Collected = 435

}

Caution On Global Locking (Synchronization):

It's important to make sure that collecting Stats and other state information for monitoring doesn't impact performance. Please look at the following don'ts
to understand better.

Do not add a special mutex for synchronizing MonitoredObject:
Let's take an example of exposing a counter that counts Requests on this connection and 2 possible ways of doing this
1. Define Counter by extending LongMonitoredAttributeBase
     public class Counter extends LongMonitoredAttributeBase {
        private long counter;
 
        Counter( String name, String desc ) {
            super( name, desc );
        }
 
         public synchronized void increment( ) {
              counter++;
         }

          public synchronized Object getValue( ) {
              return new Long( counter );
          }
    }
 

2. Or Define a RequestCounter by extending LongMonitoredAttributeBase again, but no special
    synchronization is done

    public class RequestCounter extends LongMonitoredAttributeBase {
        private CorbaConnection connection;
        RequestCounter( String name, String desc, CorbaConnection con ) {
            super( name, desc );
            connection = con;
        }

        public Object getValue( ) {
            return connection.getRequestCount( );
       }
    }

    The problem with Alternative (1) is that there may be unneccesary extra synchronization happening for every method and it may become a bottle neck
     particularly if this object is accessed quite often. In Alternative (2), the synchronization happens only in the Connection object and no special sync
     is required in the RequestCounter object.
 

Important Thing To Know On StatisticMonitoredAttribute type:
The clearState() and getValue() call will be synchronized using the mutex passed by the external object, but sample() method in StatisticsAccumulator
is not synchronized. It is the responsibility of user to synchronize to make sure that the samples collected (The mutex passed into the StatisticsAccumulator must be the one used to synchronize calls to sample() ).
 

@since JDK1.5 @serial exclude

Java Source File NameTypeComment
LongMonitoredAttributeBase.javaClass
MonitoredAttribute.javaInterface


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   Monitored Attribute is the interface to represent a Monitorable
author:
   Attribute.

MonitoredAttributeBase.javaClass
MonitoredAttributeInfo.javaInterface
MonitoredAttributeInfoFactory.javaInterface


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   MonitoredAttributeInfoFactory used mostly by internal classes.

MonitoredObject.javaInterface


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   Monitored Object provides an Hierarchichal view of the ORB Monitoring
author:
   System.

MonitoredObjectFactory.javaInterface


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   MonitoredObject Factory to create Monitored Object.

MonitoringConstants.javaInterface
MonitoringFactories.javaClass


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   This is used for getting the default factories for
author:
   MonitoredObject, MonitoredAttributeInfo and MonitoringManager.

MonitoringManager.javaInterface

Monitoring Manager will have a 1 to 1 association with the ORB.

MonitoringManagerFactory.javaInterface
StatisticMonitoredAttribute.javaClass


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   StatisticsMonitoredAttribute is provided as a convenience to collect the
author:
   Statistics of any entity.

StatisticsAccumulator.javaClass


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   StatisticsAccumulator accumulates the samples provided by the user and
author:
   computes the value of minimum, maximum, sum and sample square sum.

StringMonitoredAttributeBase.javaClass


author:
   Hemanth Puttaswamy
author:
  


author:
  


author:
   A Convenient Abstraction to present String type Monitored Attribute.

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.