001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)ProxyBindingStatisticsBase.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.proxy;
030:
031: import java.util.Date;
032: import com.sun.jbi.util.monitoring.StatisticsBaseImpl;
033: import com.sun.jbi.monitoring.ProxyBindingStatisticsBaseMBean;
034:
035: /**
036: * This class provides the statistics implementation for the ProxyBinding.
037: * All statistics are since the last JBI startup; they are all reset when
038: * JBI is restarted.
039: *
040: * @author Sun Microsystems, Inc.
041: */
042: public class ProxyBindingStatisticsBase implements
043: ProxyBindingStatisticsBaseMBean {
044: /**
045: * Instance of StatisticsBase for manipulating the object tree
046: */
047: private StatisticsBaseImpl mStatisticsBase;
048:
049: /**
050: * exchanges sent by the ProxyBinding for all consumers
051: */
052: private long mExchangesSent;
053:
054: /**
055: * exchanges received by the ProxyBinding for all producers
056: */
057: private long mExchangesReceived;
058:
059: /**
060: * bytes sent by the ProxyBinding for all consumers
061: */
062: private long mBytesSent;
063:
064: /**
065: * bytes received by the ProxyBinding for all producers
066: */
067: private long mBytesReceived;
068:
069: /**
070: * messages received by the ProxyBinding for all producers
071: */
072: private long mMessagesReceived;
073:
074: /**
075: * messages sent by the ProxyBinding for all consumers
076: */
077: private long mMessagesSent;
078:
079: /**
080: * messages faults generated in the ProxyBinding
081: */
082: private long mMessageFaults;
083:
084: /**
085: * messages errors generated in the ProxyBinding
086: */
087: private long mMessageErrors;
088:
089: /**
090: * message exchanges in COMPLETED state
091: */
092: private long mCompletedExchanges;
093:
094: /** constructor. */
095: public ProxyBindingStatisticsBase() {
096: mStatisticsBase = new StatisticsBaseImpl("SunProxyBinding");
097: }
098:
099: /**
100: * Increment the current Exchanges sent by the PB.
101: */
102: public synchronized void incrementSentExchanges() {
103: mExchangesSent++;
104: }
105:
106: /**
107: * Increment the current Exchanges received by the PB.
108: */
109: public synchronized void incrementReceivedExchanges() {
110: mExchangesReceived++;
111: }
112:
113: /**
114: * Increment the current bytes sent by the PB.
115: * @param bytes the number of bytes to increment.
116: */
117: public synchronized void incrementSentBytes(long bytes) {
118: mBytesSent += bytes;
119: }
120:
121: /**
122: * Increment the current bytes received by the PB.
123: * @param bytes the number of bytes to increment.
124: */
125: public synchronized void incrementReceivedBytes(long bytes) {
126: mBytesReceived += bytes;
127: }
128:
129: /**
130: * Increment the total number of Messages sent by the PB.
131: * @param messages the number of incremental sent messages
132: */
133: public synchronized void incrementSentMessages(int messages) {
134: mMessagesSent += messages;
135: }
136:
137: /**
138: * Increment the total number of Messages received by the PB.
139: * @param messages the number of incremental received messages
140: */
141: public synchronized void incrementReceivedMessages(int messages) {
142: mMessagesReceived += messages;
143: }
144:
145: /**
146: * Increment the current number of Message faults
147: * since the last PB startup.
148: */
149: public synchronized void incrementMessageFaults() {
150: mMessageFaults++;
151: }
152:
153: /**
154: * Increment the current number of Message errors
155: * since the last PB startup.
156: */
157: public synchronized void incrementMessageErrors() {
158: mMessageErrors++;
159: }
160:
161: /**
162: * Increment the total number of completed Exchanges
163: * since the last PB startup.
164: */
165: public synchronized void incrementCompletedExchanges() {
166: mCompletedExchanges++;
167: }
168:
169: /**
170: * Reset all statistics.
171: */
172: public synchronized void resetAllStatistics() {
173: mExchangesSent = 0;
174: mExchangesReceived = 0;
175: mBytesSent = 0;
176: mBytesReceived = 0;
177: mMessagesReceived = 0;
178: mMessagesSent = 0;
179: mMessageFaults = 0;
180: mMessageErrors = 0;
181: mCompletedExchanges = 0;
182: }
183:
184: // methods on StatisticsBase
185: /**
186: * Test whether or not statistics are enabled.
187: * @return true if statistics are enabled, false if not.
188: */
189: public boolean isEnabled() {
190: return mStatisticsBase.isEnabled();
191: }
192:
193: /**
194: * Disable statistics.
195: */
196: public void setDisabled() {
197: mStatisticsBase.setDisabled();
198: }
199:
200: // methods on ProxyBindingStatisticsBaseMBean
201: /**
202: * Get the number of ME's sent by the PB for all JBI components
203: * as consumers.
204: * @return The current number of sent exchanges.
205: */
206: public long getSentExchanges() {
207: return mExchangesSent;
208: }
209:
210: /**
211: * Get the number of ME's received by the PB for all JBI components
212: * as providers.
213: * @return The current number of received exchanges.
214: */
215: public long getReceivedExchanges() {
216: return mExchangesReceived;
217: }
218:
219: /**
220: * Get the total bytes sent by the PB for all JBI components
221: * as consumers.
222: * @return The current bytes sent by the PB.
223: */
224: public long getSentBytes() {
225: return mBytesSent;
226: }
227:
228: /**
229: * Get the total bytes received by the PB for all JBI components
230: * as providers.
231: * @return The current bytes received by the PB.
232: */
233: public long getReceivedBytes() {
234: return mBytesReceived;
235: }
236:
237: /**
238: * Get the total messages sent by the PB for all JBI components
239: * as consumers.
240: * @return The current messages sent by the PB.
241: */
242: public long getSentMessages() {
243: return mMessagesSent;
244: }
245:
246: /**
247: * Get the total messages received by the PB for all JBI components
248: * as providers.
249: * @return The current messages received by the PB.
250: */
251: public long getReceivedMessages() {
252: return mMessagesReceived;
253: }
254:
255: /**
256: * Get the total number of Message Faults created since the
257: * last NMR startup.
258: * @return The number of message faults.
259: */
260: public long getMessageFaults() {
261: return mMessageFaults;
262: }
263:
264: /**
265: * Get the total number of Message Errors created since the
266: * last NMR startup.
267: * @return The number of message errors.
268: */
269: public long getMessageErrors() {
270: return mMessageErrors;
271: }
272:
273: /**
274: * Get the total number of completed Message Exchanges created since the
275: * last NMR startup.
276: * @return The number of completed MEs.
277: */
278: public long getCompletedExchanges() {
279: return mCompletedExchanges;
280: }
281: }
|