use of org.onosproject.ovsdb.controller.OvsdbRowStore 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.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method removeRow.
@Override
public void removeRow(String dbName, String tableName, String uuid) {
OvsdbTableStore tableStore = getTableStore(dbName);
if (tableStore == null) {
return;
}
OvsdbRowStore rowStore = tableStore.getRows(tableName);
if (rowStore == null) {
return;
}
rowStore.deleteRow(uuid);
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropQueue.
@Override
public void dropQueue(QueueId queueId) {
OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
if (queueRowStore == null) {
return;
}
ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
Row queueRow = queueTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return queueId.name().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (queueRow == null) {
return;
}
String queueUuid = queueRow.uuid().value();
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore != null) {
Map<Long, Uuid> queueMap = new HashMap<>();
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
qosTableRows.values().stream().filter(r -> {
Map<Integer, Uuid> ovsdbMap = ((OvsdbMap) r.getColumn(QUEUES).data()).map();
Set<Integer> keySet = ovsdbMap.keySet();
for (Integer keyId : keySet) {
if (ovsdbMap.get(keyId).equals(Uuid.uuid(queueUuid))) {
queueMap.put(keyId.longValue(), Uuid.uuid(queueUuid));
return true;
}
}
return false;
}).findFirst().orElse(null);
deleteConfig(QUEUE, UUID, queueUuid, QOS, QUEUES, OvsdbMap.ovsdbMap(queueMap));
} else {
deleteConfig(QUEUE, UUID, queueUuid, null, null, null);
}
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method unbindQueues.
@SuppressWarnings("unchecked")
@Override
public void unbindQueues(QosId qosId, List<Long> queueKeys) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore == null) {
return;
}
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
Row qosRow = qosTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return qosId.name().equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (qosRow == null) {
log.warn("Can't find QoS {}", qosId);
return;
}
Map<Long, Uuid> deleteQueuesMap;
Map<Integer, Uuid> queuesMap = ((OvsdbMap) qosRow.getColumn(QUEUES).data()).map();
deleteQueuesMap = queueKeys.stream().filter(key -> queuesMap.containsKey(key.intValue())).collect(Collectors.toMap(key -> key, key -> queuesMap.get(key.intValue()), (a, b) -> b));
if (deleteQueuesMap.size() != 0) {
TableSchema parentTableSchema = dbSchema.getTableSchema(QOS);
ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(QUEUES);
Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), OvsdbMap.ovsdbMap(deleteQueuesMap));
List<Mutation> mutations = Collections.singletonList(mutation);
Condition condition = ConditionUtil.isEqual(UUID, qosRow.uuid());
List<Condition> conditionList = Collections.singletonList(condition);
List<Operation> operations = Collections.singletonList(new Mutate(parentTableSchema, conditionList, mutations));
transactConfig(DATABASENAME, operations);
}
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getQueues.
@Override
public Set<OvsdbQueue> getQueues() {
Set<OvsdbQueue> ovsdbqueues = new HashSet<>();
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QUEUE);
if (rowStore == null) {
log.debug("The queue uuid is null");
return ovsdbqueues;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
ovsdbqueues = rows.keySet().stream().map(uuid -> getRow(DATABASENAME, QUEUE, uuid)).map(this::getOvsdbQueue).filter(Objects::nonNull).collect(Collectors.toSet());
return ovsdbqueues;
}
Aggregations