+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.lispflowmapping.southbound;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
-
-/**
- * Object to hold statistics about LISP southbound events.
- *
- * @author Lorand Jakab
- *
- */
-public class LispSouthboundStats {
- public static final int MAX_LISP_TYPES = getMaxMessageTypeValue();
-
- private long[] rx = new long[MAX_LISP_TYPES + 1];
- private long[] tx = new long[MAX_LISP_TYPES + 1];
- private long rxUnknown = 0;
- private long txErrors = 0;
- private long cacheHits = 0;
- private long cacheMisses = 0;
-
- public LispSouthboundStats() {
- resetStats();
- }
-
- public void resetStats() {
- for (int i = 0; i <= MAX_LISP_TYPES; i++) {
- rx[i] = 0;
- tx[i] = 0;
- }
- }
-
- public long[] getRx() {
- return rx;
- }
-
- public void incrementRx(int type) {
- this.rx[type] = incrementWithWrap(rx[type]);
- }
-
- public long[] getTx() {
- return tx;
- }
-
- public void incrementTx(int type) {
- this.tx[type] = incrementWithWrap(tx[type]);
- }
-
- public long getRxUnknown() {
- return rxUnknown;
- }
-
- public void incrementRxUnknown() {
- this.rxUnknown = incrementWithWrap(rxUnknown);
- }
-
- public long getTxErrors() {
- return txErrors;
- }
-
- public void incrementTxErrors() {
- this.txErrors = incrementWithWrap(txErrors);
- }
-
- public long getCacheHits() {
- return cacheHits;
- }
-
- public void incrementCacheHits() {
- this.cacheHits = incrementWithWrap(cacheHits);
- }
-
- public long getCacheMisses() {
- return cacheMisses;
- }
-
- public void incrementCacheMisses() {
- this.cacheMisses = incrementWithWrap(cacheMisses);
- }
-
- private static long incrementWithWrap(long value) {
- if (value == Long.MAX_VALUE) {
- return 0;
- } else {
- return value + 1;
- }
- }
-
- // TODO move this method to the appropriate helper class if we start using MessageType in other places
- public static int getMaxMessageTypeValue() {
- int max = 0;
- for (MessageType mt : MessageType.values()) {
- if (mt.getIntValue() > max) {
- max = mt.getIntValue();
- }
- }
- return max;
- }
-}
private final DataBroker broker;
private final InstanceIdentifier<AuthenticationKey> path;
private ListenerRegistration<ClusteredDataTreeChangeListener<AuthenticationKey>> registration;
- private boolean authKeyRefreshing = false;
- private long authKeyRefreshingDate;
+ private volatile boolean authKeyRefreshing = false;
+ private volatile long authKeyRefreshingDate;
public AuthenticationKeyDataListener(final DataBroker broker, final AuthKeyDb akdb) {
}
}
- public MapRegisterCacheValue refreshEntry(final MapRegisterCacheKey mapRegisterCacheKey) {
+ public synchronized MapRegisterCacheValue refreshEntry(final MapRegisterCacheKey mapRegisterCacheKey) {
final MapRegisterCacheValue mapRegisterCacheValueOld = getEntry(mapRegisterCacheKey);
final MapRegisterCacheMetadata mapRegisterCacheMetadataOld = mapRegisterCacheValueOld
.getMapRegisterCacheMetadata();
import org.junit.Before;
import org.junit.Test;
-public class LispSouthboundStatsTest {
+public class ConcurrentLispSouthboundStatsTest {
- private static LispSouthboundStats lispSouthboundStats;
+ private static ConcurrentLispSouthboundStats lispSouthboundStats;
@Before
public void init() {
- lispSouthboundStats = new LispSouthboundStats();
+ lispSouthboundStats = new ConcurrentLispSouthboundStats();
}
/**
- * Tests {@link LispSouthboundStats#resetStats} method.
+ * Tests {@link ConcurrentLispSouthboundStats#resetStats} method.
*/
@Test
}
/**
- * Tests {@link LispSouthboundStats#incrementRx} method.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementRx} method.
*/
@Test
public void incrementRxTest() {
}
/**
- * Tests {@link LispSouthboundStats#incrementRx} method.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementRx} method.
*/
@Test
public void incrementRxTest_withMaxValue() throws NoSuchFieldException, IllegalAccessException {
}
/**
- * Tests {@link LispSouthboundStats#incrementTx} method.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementTx} method.
*/
@Test
public void incrementTxTest() {
}
/**
- * Tests {@link LispSouthboundStats#incrementRxUnknown} method.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementRxUnknown} method.
*/
@Test
public void incrementRxUnknownTest() throws NoSuchFieldException, IllegalAccessException {
}
/**
- * Tests {@link LispSouthboundStats#incrementRxUnknown} method with Long.MAX_VALUE.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementRxUnknown} method with Long.MAX_VALUE.
*/
@Test
public void incrementRxUnknownTest_withMaxValue() throws NoSuchFieldException, IllegalAccessException {
}
/**
- * Tests {@link LispSouthboundStats#incrementTxErrors} method.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementTxErrors} method.
*/
@Test
public void incrementTxErrorsTest() throws NoSuchFieldException, IllegalAccessException {
}
/**
- * Tests {@link LispSouthboundStats#incrementTxErrors} method with Long.MAX_VALUE.
+ * Tests {@link ConcurrentLispSouthboundStats#incrementTxErrors} method with Long.MAX_VALUE.
*/
@Test
public void incrementTxErrorsTest_withMaxValue() throws NoSuchFieldException, IllegalAccessException {
}
private static void setRxField(long[] array) throws NoSuchFieldException, IllegalAccessException {
- Field rx = LispSouthboundStats.class.getDeclaredField("rx");
+ Field rx = ConcurrentLispSouthboundStats.class.getDeclaredField("rx");
rx.setAccessible(true);
rx.set(lispSouthboundStats, array);
}
private static void setRxUnkownField(long value) throws NoSuchFieldException, IllegalAccessException {
- Field rxUnknown = LispSouthboundStats.class.getDeclaredField("rxUnknown");
+ Field rxUnknown = ConcurrentLispSouthboundStats.class.getDeclaredField("rxUnknown");
rxUnknown.setAccessible(true);
rxUnknown.set(lispSouthboundStats, value);
}
private static void setTxErrorsField(long value) throws NoSuchFieldException, IllegalAccessException {
- Field txErrors = LispSouthboundStats.class.getDeclaredField("txErrors");
+ Field txErrors = ConcurrentLispSouthboundStats.class.getDeclaredField("txErrors");
txErrors.setAccessible(true);
txErrors.set(lispSouthboundStats, value);
}