import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
} else if (Open_vSwitch.NAME.getName().equalsIgnoreCase(tableName)) {
logger.debug("{} Added / Updated {} , {}, {}", tableName, node, uuid, row);
try {
- Map<String, Table<?>> interfaces = this.ovsdbConfigService.getRows(node, Interface.NAME.getName());
+ ConcurrentMap<String, Table<?>> interfaces = this.ovsdbConfigService.getRows(node, Interface.NAME.getName());
if (interfaces != null) {
for (String intfUUID : interfaces.keySet()) {
Interface intf = (Interface) interfaces.get(intfUUID);
import static org.mockito.Mockito.when;
import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import org.junit.Test;
import org.junit.runner.RunWith;
Node mockNode = mock(Node.class);
- Map<String, Table<?>> ovsMap = new HashMap<String, Table<?>>();
+ ConcurrentMap<String, Table<?>> ovsMap = new ConcurrentHashMap<>();
Open_vSwitch ovsTable = new Open_vSwitch();
OvsDBMap localIp = new OvsDBMap();
Node mockNode = mock(Node.class);
- Map<String, Table<?>> ovsMap = new HashMap<String, Table<?>>();
+ ConcurrentMap<String, Table<?>> ovsMap = new ConcurrentHashMap<>();
Open_vSwitch nullRow = new Open_vSwitch();
Open_vSwitch ovsRow1 = new Open_vSwitch();
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
}
@Override
- public Map<String, Table<?>> getRows(Node node, String tableName) throws Exception{
+ public ConcurrentMap<String, Table<?>> getRows(Node node, String tableName) throws Exception{
try{
if (inventoryServiceInternal == null) {
throw new Exception("Inventory Service is Unavailable.");
}
- Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, tableName);
+ ConcurrentMap<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, tableName);
return ovsTable;
} catch(Exception e){
throw new Exception("Unable to read table due to "+e.getMessage());
@Override
public List<String> getTables(Node node) {
- Map<String, Map<String, Table<?>>> cache = inventoryServiceInternal.getCache(node);
+ ConcurrentMap<String, ConcurrentMap<String, Table<?>>> cache = inventoryServiceInternal.getCache(node);
if (cache == null) return null;
return new ArrayList<String>(cache.keySet());
}
new CopyOnWriteArraySet<IPluginOutInventoryService>();
private ConcurrentMap<Node, Map<String, Property>> nodeProps;
private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps;
- private Map<Node, NodeDB> dbCache = Maps.newHashMap();
+ private ConcurrentMap<Node, NodeDB> dbCache = Maps.newConcurrentMap();
private ScheduledExecutorService executor;
/**
@Override
- public Map<String, Map<String, Table<?>>> getCache(Node n) {
+ public ConcurrentMap<String, ConcurrentMap<String, Table<?>>> getCache(Node n) {
NodeDB db = dbCache.get(n);
if (db == null) return null;
return db.getTableCache();
@Override
- public Map<String, Table<?>> getTableCache(Node n, String tableName) {
+ public ConcurrentMap<String, Table<?>> getTableCache(Node n, String tableName) {
NodeDB db = dbCache.get(n);
if (db == null) return null;
return db.getTableCache(tableName);
*/
package org.opendaylight.ovsdb.plugin;
-import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.ovsdb.lib.table.internal.Table;
public interface InventoryServiceInternal extends IPluginInInventoryService {
- public Map<String, Map<String, Table<?>>> getCache(Node n);
- public Map<String, Table<?>> getTableCache(Node n, String tableName);
+ public ConcurrentMap<String, ConcurrentMap<String, Table<?>>> getCache(Node n);
+ public ConcurrentMap<String, Table<?>> getTableCache(Node n, String tableName);
public Table<?> getRow (Node n, String tableName, String uuid);
public void updateRow(Node n, String tableName, String uuid, Table<?> row);
public void removeRow(Node n, String tableName, String uuid);
package org.opendaylight.ovsdb.plugin;
import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
import com.google.common.collect.Maps;
public class NodeDB {
private DatabaseSchema schema;
- Map<String, Map<String, Table<?>>> cache = Maps.newHashMap();
+ ConcurrentMap<String, ConcurrentMap<String, Table<?>>> cache = Maps.newConcurrentMap();
public DatabaseSchema getSchema() {
return schema;
this.schema = schema;
}
- public Map<String, Map<String, Table<?>>> getTableCache() {
+ public ConcurrentMap<String, ConcurrentMap<String, Table<?>>> getTableCache() {
return cache;
}
- public Map<String, Table<?>> getTableCache(String tableName) {
+ public ConcurrentMap<String, Table<?>> getTableCache(String tableName) {
return cache.get(tableName);
}
- private void setTableCache(String tableName, Map<String, Table<?>> tableCache) {
+ private void setTableCache(String tableName, ConcurrentMap<String, Table<?>> tableCache) {
cache.put(tableName, tableCache);
}
}
public void updateRow(String tableName, String uuid, Table<?> row) {
- Map<String, Table<?>> tableCache = getTableCache(tableName);
+ ConcurrentMap<String, Table<?>> tableCache = getTableCache(tableName);
if (tableCache == null) {
- tableCache = Maps.newHashMap();
+ tableCache = Maps.newConcurrentMap();
setTableCache(tableName, tableCache);
}
tableCache.put(uuid, row);
package org.opendaylight.ovsdb.plugin;
import java.util.List;
-import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
public String getSerializedRow(Node node, String tableName, String uuid) throws Exception;
public String getSerializedRows(Node node, String tableName) throws Exception;
public Table<?> getRow(Node node, String tableName, String uuid) throws Exception;
- public Map<String, Table<?>> getRows(Node node, String tableName) throws Exception;
+ public ConcurrentMap<String, Table<?>> getRows(Node node, String tableName) throws Exception;
public List<String> getTables(Node node) throws Exception;
}