001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.synapse.transport.base;
021:
022: /**
023: * Collects metrics related to a transport that has metrics support enabled
024: */
025: public class MetricsCollector {
026:
027: private long messagesReceived;
028: private long faultsReceiving;
029: private long timeoutsReceiving;
030: private long bytesReceived;
031:
032: private long messagesSent;
033: private long faultsSending;
034: private long timeoutsSending;
035: private long bytesSent;
036:
037: public void reset() {
038: messagesReceived = 0;
039: faultsReceiving = 0;
040: timeoutsReceiving = 0;
041: bytesReceived = 0;
042: messagesSent = 0;
043: faultsSending = 0;
044: timeoutsSending = 0;
045: bytesSent = 0;
046: }
047:
048: public long getMessagesReceived() {
049: return messagesReceived;
050: }
051:
052: public long getFaultsReceiving() {
053: return faultsReceiving;
054: }
055:
056: public long getTimeoutsReceiving() {
057: return timeoutsReceiving;
058: }
059:
060: public long getBytesReceived() {
061: return bytesReceived;
062: }
063:
064: public long getMessagesSent() {
065: return messagesSent;
066: }
067:
068: public long getFaultsSending() {
069: return faultsSending;
070: }
071:
072: public long getTimeoutsSending() {
073: return timeoutsSending;
074: }
075:
076: public long getBytesSent() {
077: return bytesSent;
078: }
079:
080: public synchronized void incrementMessagesReceived() {
081: messagesReceived++;
082: }
083:
084: public synchronized void incrementFaultsReceiving() {
085: faultsReceiving++;
086: }
087:
088: public synchronized void incrementTimeoutsReceiving() {
089: timeoutsReceiving++;
090: }
091:
092: public synchronized void incrementBytesReceived(int size) {
093: bytesReceived += size;
094: }
095:
096: public synchronized void incrementMessagesSent() {
097: messagesSent++;
098: }
099:
100: public synchronized void incrementFaultsSending() {
101: faultsSending++;
102: }
103:
104: public synchronized void incrementTimeoutsSending() {
105: timeoutsSending++;
106: }
107:
108: public synchronized void incrementBytesSent(int size) {
109: bytesSent += size;
110: }
111: }
|