use of org.onosproject.ovsdb.controller.OvsdbTableStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getRow.
@Override
public Row getRow(String dbName, String tableName, String uuid) {
OvsdbTableStore tableStore = getTableStore(dbName);
if (tableStore == null) {
return null;
}
OvsdbRowStore rowStore = tableStore.getRows(tableName);
if (rowStore == null) {
return null;
}
return rowStore.getRow(uuid);
}
use of org.onosproject.ovsdb.controller.OvsdbTableStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getRowStore.
/**
* Gets the ovsdb row store.
*
* @param dbName the ovsdb database name
* @param tableName the ovsdb table name
* @return ovsRowStore, empty store if no rows exist in the table
*/
private OvsdbRowStore getRowStore(String dbName, String tableName) {
OvsdbTableStore tableStore = getTableStore(dbName);
if (tableStore == null) {
return null;
}
OvsdbRowStore rowStore = tableStore.getRows(tableName);
if (rowStore == null) {
rowStore = new OvsdbRowStore();
}
return rowStore;
}
use of org.onosproject.ovsdb.controller.OvsdbTableStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getBridges.
@Override
public Set<OvsdbBridge> getBridges() {
Set<OvsdbBridge> ovsdbBridges = new HashSet<>();
OvsdbTableStore tableStore = getTableStore(DATABASENAME);
if (tableStore == null) {
return ovsdbBridges;
}
OvsdbRowStore rowStore = tableStore.getRows(BRIDGE);
if (rowStore == null) {
return ovsdbBridges;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
for (String uuid : rows.keySet()) {
Row bridgeRow = getRow(DATABASENAME, BRIDGE, uuid);
OvsdbBridge ovsdbBridge = getOvsdbBridge(bridgeRow, Uuid.uuid(uuid));
if (ovsdbBridge != null) {
ovsdbBridges.add(ovsdbBridge);
}
}
return ovsdbBridges;
}
use of org.onosproject.ovsdb.controller.OvsdbTableStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getElements.
private Set<?> getElements(Function<Row, ?> method) {
OvsdbTableStore tableStore = getTableStore(DATABASENAME);
if (tableStore == null) {
return null;
}
OvsdbRowStore rowStore = tableStore.getRows(INTERFACE);
if (rowStore == null) {
return null;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
return rows.keySet().stream().map(uuid -> getRow(DATABASENAME, INTERFACE, uuid)).map(method).filter(Objects::nonNull).collect(Collectors.toSet());
}
use of org.onosproject.ovsdb.controller.OvsdbTableStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getFirstRow.
@Override
public Optional<Object> getFirstRow(String dbName, OvsdbTable tblName) {
DatabaseSchema dbSchema = getDatabaseSchema(dbName);
if (Objects.isNull(dbSchema)) {
return Optional.empty();
}
OvsdbTableStore tableStore = ovsdbStore.getOvsdbTableStore(dbName);
if (tableStore == null) {
return Optional.empty();
}
OvsdbRowStore rowStore = tableStore.getRows(tblName.tableName());
if (rowStore == null) {
return Optional.empty();
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
if (rows == null) {
log.debug("The {} Table Rows is null", tblName);
return Optional.empty();
}
// There should be only 1 row in this table
Optional<String> uuid = rows.keySet().stream().findFirst();
if (uuid.isPresent() && rows.containsKey(uuid.get())) {
return Optional.of(TableGenerator.getTable(dbSchema, rows.get(uuid.get()), tblName));
} else {
return Optional.empty();
}
}
Aggregations