KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > iiop > OrbConnectionManagerStatsImpl


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 package com.sun.enterprise.iiop;
25
26 import java.util.Iterator JavaDoc;
27
28 import javax.management.j2ee.statistics.CountStatistic JavaDoc;
29 import javax.management.j2ee.statistics.BoundedRangeStatistic JavaDoc;
30 import javax.management.j2ee.statistics.RangeStatistic JavaDoc;
31
32 import com.sun.enterprise.admin.monitor.stats.BoundedRangeStatisticImpl;
33 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl;
34 import com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats;
35 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl;
36 import com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl;
37 import com.sun.enterprise.admin.monitor.stats.StatisticImpl;
38
39 import com.sun.corba.ee.spi.monitoring.MonitoringConstants;
40 import com.sun.corba.ee.spi.monitoring.MonitoringManager;
41 import com.sun.corba.ee.spi.monitoring.MonitoredObject;
42
43 /**
44  * This is the implementation for the OrbConnectionManagerStats
45  * and provides the implementation required to get the statistics
46  * for an orb connection
47  *
48  * @author Pramod Gopinath
49  */

50
51 public class OrbConnectionManagerStatsImpl
52 extends ORBCommonStatsImpl
53 implements OrbConnectionManagerStats
54 {
55
56     private MonitoredObject connection;
57     private String JavaDoc connectionName;
58
59     private static String JavaDoc stringTotalConnections =
60         MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS;
61     private static String JavaDoc stringIdleConnections =
62         MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS;
63     private static String JavaDoc stringBusyConnections =
64         MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS;
65
66     private MutableBoundedRangeStatisticImpl totalConnections;
67     private MutableCountStatisticImpl idleConnections;
68     private MutableCountStatisticImpl busyConnections;
69
70
71     public OrbConnectionManagerStatsImpl( MonitoredObject connectionNode ) {
72         this.connection = connectionNode;
73         this.connectionName = connection.getName();
74
75         initializeStats();
76     }
77
78     private void initializeStats() {
79         super.initialize(
80             "com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats");
81
82         final long time = System.currentTimeMillis();
83
84         totalConnections =
85             new MutableBoundedRangeStatisticImpl(
86                 new BoundedRangeStatisticImpl( 0, 0, 0,
87                     java.lang.Long.MAX_VALUE, 0,
88                     "TotalConnections", "count",
89                     connection.getAttribute( stringTotalConnections ).
90                     getAttributeInfo( ).getDescription(),
91                     time, time ));
92
93         idleConnections =
94             new MutableCountStatisticImpl(
95                 new CountStatisticImpl(
96                     "ConnectionsIdle", "count",
97                     connection.getAttribute( stringIdleConnections ).
98                     getAttributeInfo( ).getDescription() ));
99
100         busyConnections =
101             new MutableCountStatisticImpl(
102                 new CountStatisticImpl(
103                     "ConnectionsInUse", "count",
104                     connection.getAttribute( stringBusyConnections ).
105                     getAttributeInfo( ).getDescription() ));
106     }
107
108     public BoundedRangeStatistic JavaDoc getTotalConnections() {
109
110         long totalNumberOfConnections = ((Long JavaDoc) connection.getAttribute(
111             stringTotalConnections ).getValue()).longValue();
112
113         totalConnections.setCount( totalNumberOfConnections );
114
115         return (BoundedRangeStatistic JavaDoc) totalConnections.modifiableView();
116     }
117
118
119     public CountStatistic JavaDoc getConnectionsIdle() {
120
121         long numberIdleConnections = ((Long JavaDoc) connection.getAttribute(
122         stringIdleConnections ).getValue()).longValue();
123
124
125         idleConnections.setCount( numberIdleConnections );
126
127         return (CountStatistic JavaDoc) idleConnections.modifiableView();
128     }
129
130             
131     public CountStatistic JavaDoc getConnectionsInUse() {
132
133         long numberBusyConnections = ((Long JavaDoc) connection.getAttribute(
134         stringBusyConnections ).getValue()).longValue();
135
136         busyConnections.setCount( numberBusyConnections );
137
138         return (CountStatistic JavaDoc) busyConnections.modifiableView();
139     }
140
141
142 } //OrbConnectionManagerStatsImpl{ }
143
Popular Tags