}
}
+ grouping cache-stats {
+ leaf hits {
+ type int64;
+ }
+ leaf misses {
+ type int64;
+ }
+ }
+
rpc send-map-request {
input {
uses lisp-proto:MapRequestMessage;
container control-message-stats {
uses ctrl-msg-stats;
}
+ container map-register-cache-stats {
+ uses cache-stats;
+ }
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.MapRegisterCacheStatsBuilder;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
}
cmsb.setControlMessage(messages);
- return new GetStatsOutputBuilder().setControlMessageStats(cmsb.build()).build();
+
+ MapRegisterCacheStatsBuilder mrcsb = new MapRegisterCacheStatsBuilder();
+ mrcsb.setHits(stats.getCacheHits());
+ mrcsb.setMisses(stats.getCacheMisses());
+
+ return new GetStatsOutputBuilder().setControlMessageStats(cmsb.build())
+ .setMapRegisterCacheStats(mrcsb.build()).build();
}
}
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();
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;
if (mapRegisterValue.isWantMapNotify()) {
sendMapNotifyMsg(inBuffer, sourceAddress, port, mapRegisterValue.getEidLispAddress());
}
+ lispSbStats.incrementCacheHits();
} else {
MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(inBuffer, sourceAddress);
if (isAuthenticationSuccessful(mapRegister, inBuffer)) {
mapRegisterCache.addEntry(cacheKey, cacheValueBldNew.build());
}
}
+ lispSbStats.incrementCacheMisses();
}
} catch (RuntimeException re) {
throw new LispMalformedPacketException("Couldn't deserialize Map-Register (len="
import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
+import org.opendaylight.lispflowmapping.southbound.LispSouthboundStats;
import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException;
import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
// mapResolver = context.mock(IMapResolver.class);
// mapServer = context.mock(IMapServer.class);
mockLispSouthboundPlugin = mock(LispSouthboundPlugin.class);
+ Mockito.when(mockLispSouthboundPlugin.getStats()).thenReturn(Mockito.mock(LispSouthboundStats.class));
testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
mapRegisterCache = new MapRegisterCache();
testedLispService.setMapRegisterCache(mapRegisterCache);