KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > connector > grizzly > KeepAliveStats


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 package com.sun.enterprise.web.connector.grizzly;
24
25 /**
26  * Class collecting keep-alive statistics.
27  *
28  * There is one instance of this class per HTTP listener (ie., SelectorThread).
29  * Each instance exposes its stats as an MBean with an object name of the
30  * form "<domain>:type=KeepAlive,name=http<port>", where <port> is replaced
31  * with the port number of the associated HTTP listener.
32  *
33  * @author Jan Luehe
34  */

35 public class KeepAliveStats {
36
37     private int countConnections;
38     private int maxConnections;
39     private int countHits;
40     private int countFlushes;
41     private int countRefusals;
42     private int countTimeouts;
43     private int secondsTimeouts;
44
45
46     /**
47      * Gets the number of connections in keep-alive mode.
48      *
49      * @return Number of connections in keep-alive mode
50      */

51     public synchronized int getCountConnections() {
52         return countConnections;
53     }
54
55     
56     /**
57      * Increments the number of connections in keep-alive mode.
58      */

59     public synchronized void incrementCountConnections() {
60         countConnections++;
61     }
62
63
64     /**
65      * Sets the maximum number of concurrent connections in keep-alive mode.
66      *
67      * @param maxConnections Maximum number of concurrent connections in
68      * keep-alive mode.
69      */

70     public void setMaxConnections(int maxConnections) {
71         this.maxConnections = maxConnections;
72     }
73
74
75     /**
76      * Gets the maximum number of concurrent connections in keep-alive mode.
77      *
78      * @return Maximum number of concurrent connections in keep-alive mode
79      */

80     public int getMaxConnections() {
81         return maxConnections;
82     }
83
84     
85     /**
86      * Gets the number of requests received by connections in keep-alive mode.
87      *
88      * @return Number of requests received by connections in keep-alive mode.
89      */

90     public synchronized int getCountHits() {
91         return countHits;
92     }
93
94
95     /**
96      * Increments the number of requests received by connections in
97      * keep-alive mode.
98      */

99     public synchronized void incrementCountHits() {
100         countHits++;
101     }
102
103     
104     /**
105      * Gets the number of keep-alive connections that were closed
106      *
107      * @return Number of keep-alive connections that were closed
108      */

109     public synchronized int getCountFlushes() {
110         return countFlushes;
111     }
112
113     
114     /**
115      * Increments the number of keep-alive connections that were closed
116      */

117     public synchronized void incrementCountFlushes() {
118         countFlushes++;
119     }
120
121
122     /**
123      * Gets the number of keep-alive connections that were rejected.
124      *
125      * @return Number of keep-alive connections that were rejected.
126      */

127     public synchronized int getCountRefusals() {
128         return countRefusals;
129     }
130     
131
132     /**
133      * Increments the number of keep-alive connections that were rejected.
134      */

135     public synchronized void incrementCountRefusals() {
136         countRefusals++;
137     }
138
139
140     /**
141      * Gets the number of keep-alive connections that timed out.
142      *
143      * @return Number of keep-alive connections that timed out.
144      */

145     public synchronized int getCountTimeouts() {
146         return countTimeouts;
147     }
148
149     
150     /**
151      * Increments the number of keep-alive connections that timed out.
152      */

153     public synchronized void incrementCountTimeouts() {
154         countTimeouts++;
155     }
156
157
158     /**
159      * Sets the number of seconds before a keep-alive connection that has
160      * been idle times out and is closed.
161      *
162      * @param timeout Keep-alive timeout in number of seconds
163      */

164     public void setSecondsTimeouts(int timeout) {
165         secondsTimeouts = timeout;
166     }
167
168
169     /**
170      * Gets the number of seconds before a keep-alive connection that has
171      * been idle times out and is closed.
172      *
173      * @return Keep-alive timeout in number of seconds
174      */

175     public int getSecondsTimeouts() {
176         return secondsTimeouts;
177     }
178 }
179
Popular Tags