- if (dbSchema == null) {
- logger.error("Unable to get Database Schema for the ovsdb connection : {} , database : {}", client.getConnectionInfo(), database);
- return;
- }
- Set<String> tables = dbSchema.getTables();
- if (tables == null) {
- logger.warn("Database {} without any tables. Strange !", database);
- continue;
- }
- List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
- for (String tableName : tables) {
- GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
- monitorRequests.add(this.getAllColumnsMonitorRequest(tableSchema));
- }
- MonitorHandle monitor = client.monitor(dbSchema, monitorRequests, new UpdateMonitor(node));
+ TableUpdates updates = this.monitorTables(connection.getNode(), dbSchema);
+ inventoryServiceInternal.processTableUpdates(connection.getNode(), dbSchema.getName(), updates);
+ }
+ inventoryServiceInternal.notifyNodeAdded(connection.getNode());
+ }
+
+ public TableUpdates monitorTables(Node node, DatabaseSchema dbSchema) throws ExecutionException, InterruptedException, IOException {
+ String identifier = (String) node.getID();
+ Connection connection = ovsdbConnections.get(identifier);
+ OvsdbClient client = connection.getClient();
+ if (dbSchema == null) {
+ logger.error("Unable to get Database Schema for the ovsdb connection : {} , database : {}", client.getConnectionInfo(), dbSchema.getName());
+ return null;
+ }
+ Set<String> tables = dbSchema.getTables();
+ if (tables == null) {
+ logger.warn("Database {} without any tables. Strange !", dbSchema.getName());
+ return null;
+ }
+ List<MonitorRequest<GenericTableSchema>> monitorRequests = Lists.newArrayList();
+ for (String tableName : tables) {
+ GenericTableSchema tableSchema = dbSchema.table(tableName, GenericTableSchema.class);
+ monitorRequests.add(this.getAllColumnsMonitorRequest(tableSchema));