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

Merge into master from pull request #307:

BSC-2322 Fix counter creation issue (https://github.com/floodlight/floodlight/pull/307)
parents 5d2c766e b86645e9
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ public class CounterStore implements IFloodlightModule, ICounterStoreService {
/**
* A map of counterName --> Counter
*/
protected Map<String, CounterEntry> nameToCEIndex =
protected ConcurrentHashMap<String, CounterEntry> nameToCEIndex =
new ConcurrentHashMap<String, CounterEntry>();
protected ICounter heartbeatCounter;
......@@ -389,17 +389,13 @@ public class CounterStore implements IFloodlightModule, ICounterStoreService {
CounterEntry ce;
ICounter c;
if (!nameToCEIndex.containsKey(key)) {
c = SimpleCounter.createCounter(new Date(), type);
ce = new CounterEntry();
ce.counter = c;
ce.title = key;
nameToCEIndex.put(key, ce);
} else {
throw new IllegalArgumentException("Title for counters must be unique, and there is already a counter with title " + key);
}
return c;
c = SimpleCounter.createCounter(new Date(), type);
ce = new CounterEntry();
ce.counter = c;
ce.title = key;
nameToCEIndex.putIfAbsent(key, ce);
return nameToCEIndex.get(key).counter;
}
/**
......
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