Skip to content

Package: HttpServerFilter$JmxWebServerProbe

HttpServerFilter$JmxWebServerProbe

nameinstructionbranchcomplexitylinemethod
HttpServerFilter.JmxWebServerProbe(HttpServerFilter)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
onRequestCancelEvent(HttpServerFilter, Connection, Request)
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
onRequestCompleteEvent(HttpServerFilter, Connection, Response)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
onRequestReceiveEvent(HttpServerFilter, Connection, Request)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
onRequestResumeEvent(HttpServerFilter, Connection, Request)
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
onRequestSuspendEvent(HttpServerFilter, Connection, Request)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
onRequestTimeoutEvent(HttpServerFilter, Connection, Request)
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly.http.server.jmx;
18:
19: import org.glassfish.grizzly.Connection;
20: import org.glassfish.grizzly.http.server.Request;
21: import org.glassfish.grizzly.http.server.Response;
22: import org.glassfish.grizzly.http.server.HttpServerProbe;
23: import org.glassfish.grizzly.monitoring.jmx.JmxObject;
24: import org.glassfish.gmbal.Description;
25: import org.glassfish.gmbal.GmbalMBean;
26: import org.glassfish.gmbal.ManagedAttribute;
27: import org.glassfish.gmbal.ManagedObject;
28:
29: import java.util.concurrent.atomic.AtomicInteger;
30: import java.util.concurrent.atomic.AtomicLong;
31: import org.glassfish.grizzly.jmxbase.GrizzlyJmxManager;
32:
33: /**
34: * JMX management object for the {@link org.glassfish.grizzly.http.server.HttpServerFilter}.
35: *
36: * @since 2.0
37: */
38: @ManagedObject
39: @Description("The HttpServerFilter is the entity responsible for providing and processing higher level abstractions based on HTTP protocol.")
40: public class HttpServerFilter extends JmxObject {
41:
42: private final org.glassfish.grizzly.http.server.HttpServerFilter httpServerFilter;
43:
44: private final AtomicLong receivedCount = new AtomicLong();
45: private final AtomicLong completedCount = new AtomicLong();
46: private final AtomicInteger suspendCount = new AtomicInteger();
47: private final AtomicLong timedOutCount = new AtomicLong();
48: private final AtomicLong cancelledCount = new AtomicLong();
49:
50: private final HttpServerProbe probe = new JmxWebServerProbe();
51:
52: // ------------------------------------------------------------ Constructors
53:
54:
55: public HttpServerFilter(org.glassfish.grizzly.http.server.HttpServerFilter httpServerFilter) {
56: this.httpServerFilter = httpServerFilter;
57: }
58:
59:
60: // -------------------------------------------------- Methods from JmxObject
61:
62:
63: @Override
64: public String getJmxName() {
65: return "HttpServerFilter";
66: }
67:
68: @Override
69: protected void onRegister(GrizzlyJmxManager mom, GmbalMBean bean) {
70: httpServerFilter.getMonitoringConfig().addProbes(probe);
71: }
72:
73: @Override
74: protected void onDeregister(GrizzlyJmxManager mom) {
75: httpServerFilter.getMonitoringConfig().removeProbes(probe);
76: }
77:
78:
79: // -------------------------------------------------------------- Attributes
80:
81:
82: /**
83: * @return the number of requests this {@link org.glassfish.grizzly.http.server.HttpServerFilter}
84: * has received.
85: */
86: @ManagedAttribute(id="requests-received-count")
87: @Description("The total number of requests received.")
88: public long getRequestsReceivedCount() {
89: return receivedCount.get();
90: }
91:
92:
93: /**
94: * @return the number of requests this {@link org.glassfish.grizzly.http.server.HttpServerFilter}
95: * has completed servicing.
96: */
97: @ManagedAttribute(id="requests-completed-count")
98: @Description("The total number of requests that have been successfully completed.")
99: public long getRequestsCompletedCount() {
100: return completedCount.get();
101: }
102:
103:
104: /**
105: * @return the number of requests currently suspended.
106: */
107: @ManagedAttribute(id="current-suspended-request-count")
108: @Description("The current number of requests that are suspended to be processed at a later point in time.")
109: public int getRequestsSuspendedCount() {
110: return suspendCount.get();
111: }
112:
113:
114: /**
115: * @return the number of suspended requests that have timed out.
116: */
117: @ManagedAttribute(id="requests-timed-out-count")
118: @Description("The total number of suspended requests that have been timed out.")
119: public long getRequestsTimedOutCount() {
120: return timedOutCount.get();
121: }
122:
123:
124: /**
125: * @return the number of requests suspended requests that have been
126: * cancelled.
127: */
128: @ManagedAttribute(id="requests-cancelled-count")
129: @Description("The total number of suspended requests that have been cancelled.")
130: public long getRequestsCancelledCount() {
131: return cancelledCount.get();
132: }
133:
134:
135: // ---------------------------------------------------------- Nested Classes
136:
137:
138: private final class JmxWebServerProbe extends HttpServerProbe.Adapter {
139:
140:
141: // ----------------------------------------- Methods from HttpServerProbe
142:
143:
144: @Override
145: public void onRequestReceiveEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Request request) {
146: receivedCount.incrementAndGet();
147: }
148:
149: @Override
150: public void onRequestCompleteEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Response response) {
151: completedCount.incrementAndGet();
152: }
153:
154: @Override
155: public void onRequestSuspendEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Request request) {
156: suspendCount.incrementAndGet();
157: }
158:
159: @Override
160: public void onRequestResumeEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Request request) {
161:• if (suspendCount.get() > 0) {
162: suspendCount.decrementAndGet();
163: }
164: }
165:
166: @Override
167: public void onRequestTimeoutEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Request request) {
168: timedOutCount.incrementAndGet();
169:• if (suspendCount.get() > 0) {
170: suspendCount.decrementAndGet();
171: }
172: }
173:
174: @Override
175: public void onRequestCancelEvent(org.glassfish.grizzly.http.server.HttpServerFilter filter, Connection connection, Request request) {
176: cancelledCount.incrementAndGet();
177:• if (suspendCount.get() > 0) {
178: suspendCount.decrementAndGet();
179: }
180: }
181:
182: } // END JmxWebServerProbe
183:
184: }