package org.opendaylight.lispflowmapping.inmemorydb;
+import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Date;
import java.util.Map;
-import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
-
import org.opendaylight.lispflowmapping.inmemorydb.radixtrie.RadixTrie;
import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.lfm.mappingservice.dao.inmemorydb.config.rev151007.InmemorydbConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected static final Logger LOG = LoggerFactory.getLogger(HashMapDb.class);
private static final Object TABLES = (Object) "tables";
private static final int DEFAULT_RECORD_TIMEOUT = 240; // SB registered mapping entries time out after 4 min
- private ConcurrentMap<Object, ConcurrentMap<String, Object>> data = new ConcurrentHashMap<Object,
- ConcurrentMap<String, Object>>();
+ private ConcurrentMap<Object, ConcurrentMap<String, Object>> data = new ConcurrentHashMap<>();
private TimeUnit timeUnit = TimeUnit.SECONDS;
- private int recordTimeOut = DEFAULT_RECORD_TIMEOUT;
+ private int recordTimeOut;
+
+ public HashMapDb() {
+ this.recordTimeOut = DEFAULT_RECORD_TIMEOUT;
+ }
+
+ public HashMapDb(final InmemorydbConfig inmemoryConfig) {
+ if (inmemoryConfig.getRecordTimeout() <= 0) {
+ this.recordTimeOut = DEFAULT_RECORD_TIMEOUT;
+ } else {
+ this.recordTimeOut = inmemoryConfig.getRecordTimeout();
+ }
+ }
// IPv4 and IPv6 radix tries used for longest prefix matching
- private RadixTrie<Object> ip4Trie = new RadixTrie<Object>(32, true);
- private RadixTrie<Object> ip6Trie = new RadixTrie<Object>(128, true);
+ private RadixTrie<Object> ip4Trie = new RadixTrie<>(32, true);
+ private RadixTrie<Object> ip6Trie = new RadixTrie<>(128, true);
public void tryAddToIpTrie(Object key) {
if (key instanceof Eid) {
}
if (node == null) {
data = get(key);
- return (data == null) ? null : new SimpleImmutableEntry<Eid, Map<String, ?>>((Eid)key, data);
+ return (data == null) ? null : new SimpleImmutableEntry<>((Eid)key, data);
}
data = get(node.data());
- return (data == null) ? null : new SimpleImmutableEntry<Eid, Map<String, ?>>((Eid)node.data(), data);
+ return (data == null) ? null : new SimpleImmutableEntry<>((Eid)node.data(), data);
}
return null;
}
}
}
}
+
@Override
public Eid getWidestNegativePrefix(Eid key) {
RadixTrie<Object>.TrieNode node = null;