Skip to content
Snippets Groups Projects
Commit e8894cbf authored by abat's avatar abat
Browse files

Merge into master from pull request #42:

add per port broadcast cache hit counter and expose them through debug REST API (https://github.com/floodlight/floodlight/pull/42)
parents 341b0e28 38264975
No related branches found
No related tags found
No related merge requests found
...@@ -308,11 +308,18 @@ public interface IOFSwitch { ...@@ -308,11 +308,18 @@ public interface IOFSwitch {
public void clearAllFlowMods(); public void clearAllFlowMods();
/** /**
* Return a TimedHashMap associated with the switch * Update broadcast cache
* @param data * @param data
* @return true if there is a cache hit
* false if there is no cache hit.
*/
public boolean updateBroadcastCache(Long entry, Short port);
/**
* Get the portBroadcastCacheHits
* @return * @return
*/ */
public TimedCache<Long> getTimedCache(); public Map<Short, Long> getPortBroadcastHits();
/** /**
* Send a flow statistics request to the switch. This call returns after * Send a flow statistics request to the switch. This call returns after
......
...@@ -80,6 +80,7 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -80,6 +80,7 @@ public class OFSwitchImpl implements IOFSwitch {
protected Role role; protected Role role;
protected TimedCache<Long> timedCache; protected TimedCache<Long> timedCache;
protected ReentrantReadWriteLock listenerLock; protected ReentrantReadWriteLock listenerLock;
protected ConcurrentMap<Short, Long> portBroadcastCacheHitMap;
public static IOFSwitchFeatures switchFeatures; public static IOFSwitchFeatures switchFeatures;
protected static final ThreadLocal<Map<OFSwitchImpl,List<OFMessage>>> local_msg_buffer = protected static final ThreadLocal<Map<OFSwitchImpl,List<OFMessage>>> local_msg_buffer =
...@@ -105,6 +106,8 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -105,6 +106,8 @@ public class OFSwitchImpl implements IOFSwitch {
this.role = null; this.role = null;
this.timedCache = new TimedCache<Long>(100, 5*1000 ); // 5 seconds interval this.timedCache = new TimedCache<Long>(100, 5*1000 ); // 5 seconds interval
this.listenerLock = new ReentrantReadWriteLock(); this.listenerLock = new ReentrantReadWriteLock();
this.portBroadcastCacheHitMap = new ConcurrentHashMap<Short, Long>();
// Defaults properties for an ideal switch // Defaults properties for an ideal switch
this.setAttribute(PROP_FASTWILDCARDS, (Integer) OFMatch.OFPFW_ALL); this.setAttribute(PROP_FASTWILDCARDS, (Integer) OFMatch.OFPFW_ALL);
this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, new Boolean(true)); this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, new Boolean(true));
...@@ -447,11 +450,24 @@ public class OFSwitchImpl implements IOFSwitch { ...@@ -447,11 +450,24 @@ public class OFSwitchImpl implements IOFSwitch {
} }
@Override @Override
public TimedCache<Long> getTimedCache() { public boolean updateBroadcastCache(Long entry, Short port) {
return timedCache; if (timedCache.update(entry)) {
} Long count = portBroadcastCacheHitMap.putIfAbsent(port, new Long(1));
if (count != null) {
count++;
}
return true;
} else {
return false;
}
}
@Override @Override
public Map<Short, Long> getPortBroadcastHits() {
return this.portBroadcastCacheHitMap;
}
public void flush() { public void flush() {
Map<OFSwitchImpl,List<OFMessage>> msg_buffer_map = local_msg_buffer.get(); Map<OFSwitchImpl,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
List<OFMessage> msglist = msg_buffer_map.get(this); List<OFMessage> msglist = msg_buffer_map.get(this);
......
...@@ -234,7 +234,7 @@ public class CounterStore implements IFloodlightModule, ICounterStoreService { ...@@ -234,7 +234,7 @@ public class CounterStore implements IFloodlightModule, ICounterStoreService {
String l4Type = String.format("%02x", ipV4.getProtocol()); String l4Type = String.format("%02x", ipV4.getProtocol());
if (TypeAliases.l4TypeAliasMap != null && if (TypeAliases.l4TypeAliasMap != null &&
TypeAliases.l4TypeAliasMap.containsKey(l4Type)) { TypeAliases.l4TypeAliasMap.containsKey(l4Type)) {
l4Type = "L4_" + TypeAliases.l4TypeAliasMap.get(l4Type); l4Type = TypeAliases.l4TypeAliasMap.get(l4Type);
} else { } else {
l4Type = "L4_" + l4Type; l4Type = "L4_" + l4Type;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment