KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > monitor > ConnectionPoolStatsTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/tests/com/sun/enterprise/management/monitor/ConnectionPoolStatsTest.java,v 1.4 2005/12/25 03:41:54 tcfujii Exp $
26  * $Revision: 1.4 $
27  * $Date: 2005/12/25 03:41:54 $
28  */

29 package com.sun.enterprise.management.monitor;
30
31 import java.util.Set JavaDoc;
32 import java.util.Iterator JavaDoc;
33
34 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
35 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
36
37 import com.sun.appserv.management.base.QueryMgr;
38 import com.sun.appserv.management.monitor.statistics.ConnectionPoolStats;
39 import com.sun.appserv.management.monitor.MonitoringStats;
40
41
42 import com.sun.enterprise.management.AMXTestBase;
43 import com.sun.enterprise.management.Capabilities;
44
45
46 abstract class ConnectionPoolStatsTest extends AMXMonitorTestBase
47 {
48         public
49     ConnectionPoolStatsTest()
50     {
51     }
52     
53     
54     protected abstract void nextMonitor( final MonitoringStats ms);
55     
56         protected int
57     iterateAllMonitors( final String JavaDoc j2eeType )
58     {
59         final Set JavaDoc monitors = getQueryMgr().queryJ2EETypeSet( j2eeType );
60         final Iterator JavaDoc iter = monitors.iterator();
61         
62         int numMonitors = 0;
63         while ( iter.hasNext() )
64         {
65             final MonitoringStats ms = (MonitoringStats)iter.next();
66             ++numMonitors;
67             nextMonitor( ms );
68         }
69         
70         return numMonitors;
71     }
72     
73     /**
74         Verify that every Statistic can be successfully accessed.
75      */

76         protected void
77     accessAllStatistics( final ConnectionPoolStats s )
78     {
79         final RangeStatistic JavaDoc r1 = s.getNumConnUsed();
80         assert( r1 != null );
81         
82         final RangeStatistic JavaDoc r2 = s.getNumConnFree() ;
83         assert( r2 != null );
84         
85         final RangeStatistic JavaDoc r3 = s.getConnRequestWaitTime();
86         assert( r3 != null );
87
88         final CountStatistic JavaDoc c1 = s.getNumConnFailedValidation() ;
89         assert( c1 != null );
90         
91         final CountStatistic JavaDoc c2 = s.getNumConnTimedOut();
92         assert( c2 != null );
93         
94         final CountStatistic JavaDoc c3 = s.getWaitQueueLength();
95         assert( c3 != null );
96         
97         final CountStatistic JavaDoc c4 = s.getNumConnCreated();
98         assert( c4 != null );
99         
100         final CountStatistic JavaDoc c5 = s.getNumConnDestroyed();
101         assert( c5 != null );
102         
103         //final CountStatistic c6 = s.getNumConnOpened();
104
// assert( c6 != null );
105

106         //final CountStatistic c7 = s.getNumConnClosed();
107
// assert( c7 != null );
108

109         final CountStatistic JavaDoc c8 = s.getAverageConnWaitTime();
110         assert( c8 != null );
111     }
112  
113 }
114
115
116
117
118
119
120
Popular Tags