use of org.onosproject.ovsdb.rfc.message.TableUpdate in project onos by opennetworkinglab.
the class FromJsonUtil method jsonNodeToTableUpdates.
/**
* convert the params of Update Notification into TableUpdates.
* @param updatesJson the params of Update Notification
* @param dbSchema DatabaseSchema entity
* @return TableUpdates
*/
public static TableUpdates jsonNodeToTableUpdates(JsonNode updatesJson, DatabaseSchema dbSchema) {
Map<String, TableUpdate> tableUpdateMap = Maps.newHashMap();
Iterator<Map.Entry<String, JsonNode>> tableUpdatesItr = updatesJson.fields();
while (tableUpdatesItr.hasNext()) {
Map.Entry<String, JsonNode> entry = tableUpdatesItr.next();
TableSchema tableSchema = dbSchema.getTableSchema(entry.getKey());
TableUpdate tableUpdate = jsonNodeToTableUpdate(tableSchema, entry.getValue());
tableUpdateMap.put(entry.getKey(), tableUpdate);
}
return TableUpdates.tableUpdates(tableUpdateMap);
}
use of org.onosproject.ovsdb.rfc.message.TableUpdate in project onos by opennetworkinglab.
the class OvsdbControllerImpl method processTableUpdates.
/**
* Processes table updates.
*
* @param clientService OvsdbClientService instance
* @param updates TableUpdates instance
* @param dbName ovsdb database name
*/
private void processTableUpdates(OvsdbClientService clientService, TableUpdates updates, String dbName) throws InterruptedException {
checkNotNull(clientService, "OvsdbClientService is not null");
DatabaseSchema dbSchema = clientService.getDatabaseSchema(dbName);
for (String tableName : updates.result().keySet()) {
TableUpdate update = updates.result().get(tableName);
for (Uuid uuid : (Set<Uuid>) update.rows().keySet()) {
log.debug("Begin to process table updates uuid: {}, databaseName: {}, tableName: {}", uuid.value(), dbName, tableName);
Row newRow = update.getNew(uuid);
if (newRow != null) {
clientService.updateOvsdbStore(dbName, tableName, uuid.value(), newRow);
if (OvsdbConstant.INTERFACE.equals(tableName)) {
dispatchInterfaceEvent(clientService, newRow, OvsdbEvent.Type.PORT_ADDED, dbSchema);
}
} else if (update.getOld(uuid) != null) {
if (OvsdbConstant.INTERFACE.equals(tableName)) {
Row row = clientService.getRow(OvsdbConstant.DATABASENAME, tableName, uuid.value());
dispatchInterfaceEvent(clientService, row, OvsdbEvent.Type.PORT_REMOVED, dbSchema);
}
clientService.removeRow(dbName, tableName, uuid.value());
}
}
}
}
Aggregations