2 * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.lispflowmapping.southbound;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
13 * Object to hold statistics about LISP southbound events
15 * @author Lorand Jakab
18 public class LispSouthboundStats {
19 public final static int MAX_LISP_TYPES = getMaxMessageTypeValue();
21 private long rx[] = new long[MAX_LISP_TYPES + 1];
22 private long tx[] = new long[MAX_LISP_TYPES + 1];
23 private long rxUnknown = 0;
24 private long txErrors = 0;
26 public LispSouthboundStats() {
30 public void resetStats() {
31 for (int i = 0; i <= MAX_LISP_TYPES; i++) {
37 public long[] getRx() {
41 public void incrementRx(int type) {
42 this.rx[type] = incrementWithWrap(rx[type]);
45 public long[] getTx() {
49 public void incrementTx(int type) {
50 this.tx[type] = incrementWithWrap(tx[type]);
53 public long getRxUnknown() {
57 public void incrementRxUnknown() {
58 this.rxUnknown = incrementWithWrap(rxUnknown);
61 public long getTxErrors() {
65 public void incrementTxErrors() {
66 this.txErrors = incrementWithWrap(txErrors);
69 private static long incrementWithWrap(long value) {
70 if (value == Long.MAX_VALUE) {
77 // TODO move this method to the appropriate helper class if we start using MessageType in other places
78 public static int getMaxMessageTypeValue() {
80 for (MessageType mt : MessageType.values()) {
81 if (mt.getIntValue() > max) {
82 max = mt.getIntValue();