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;
25 private long cacheHits = 0;
26 private long cacheMisses = 0;
28 public LispSouthboundStats() {
32 public void resetStats() {
33 for (int i = 0; i <= MAX_LISP_TYPES; i++) {
39 public long[] getRx() {
43 public void incrementRx(int type) {
44 this.rx[type] = incrementWithWrap(rx[type]);
47 public long[] getTx() {
51 public void incrementTx(int type) {
52 this.tx[type] = incrementWithWrap(tx[type]);
55 public long getRxUnknown() {
59 public void incrementRxUnknown() {
60 this.rxUnknown = incrementWithWrap(rxUnknown);
63 public long getTxErrors() {
67 public void incrementTxErrors() {
68 this.txErrors = incrementWithWrap(txErrors);
71 public long getCacheHits() {
75 public void incrementCacheHits() {
76 this.cacheHits = incrementWithWrap(cacheHits);
79 public long getCacheMisses() {
83 public void incrementCacheMisses() {
84 this.cacheMisses = incrementWithWrap(cacheMisses);
87 private static long incrementWithWrap(long value) {
88 if (value == Long.MAX_VALUE) {
95 // TODO move this method to the appropriate helper class if we start using MessageType in other places
96 public static int getMaxMessageTypeValue() {
98 for (MessageType mt : MessageType.values()) {
99 if (mt.getIntValue() > max) {
100 max = mt.getIntValue();