public ListenableFuture<DatabaseSchema> getSchema(String database) { return client.getSchema(database); }
public static Row<GenericTableSchema> getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, JsonParseException, IOException { DatabaseSchema dbSchema = client.getSchema(dbName).get(); GenericTableSchema schema = dbSchema.table(tableName, GenericTableSchema.class); return schema.createRow((ObjectNode)rowJson); }
private Node handleNewConnection(String identifier, OvsdbClient client) throws InterruptedException, ExecutionException { Connection connection = new Connection(identifier, client); Node node = connection.getNode(); ovsdbConnections.put(identifier, connection); List<String> dbs = client.getDatabases().get(); for (String db : dbs) { client.getSchema(db).get(); } // Keeping the Initial inventory update(s) on its own thread. new Thread() { Connection connection; String identifier; @Override public void run() { try { logger.info("Initialize inventory for {}", connection.toString()); initializeInventoryForNewNode(connection); } catch (InterruptedException | ExecutionException | IOException e) { logger.error("Failed to initialize inventory for node with identifier " + identifier, e); ovsdbConnections.remove(identifier); } } public Thread initializeConnectionParams(String identifier, Connection connection) { this.identifier = identifier; this.connection = connection; return this; } }.initializeConnectionParams(identifier, connection).start(); return node; }
private void initializeInventoryForNewNode (Connection connection) throws InterruptedException, ExecutionException, IOException { OvsdbClient client = connection.getClient(); InetAddress address = client.getConnectionInfo().getRemoteAddress(); int port = client.getConnectionInfo().getRemotePort(); List<String> databases = client.getDatabases().get(); if (databases == null) { logger.error("Unable to get Databases for the ovsdb connection : {}", client.getConnectionInfo()); return; } for (String database : databases) { DatabaseSchema dbSchema = client.getSchema(database).get(); TableUpdates updates = this.monitorTables(connection.getNode(), dbSchema); ovsdbInventoryService.processTableUpdates(connection.getNode(), dbSchema.getName(), updates); } logger.info("Notifying Inventory Listeners for Node Added: {}", connection.getNode().toString()); ovsdbInventoryService.notifyNodeAdded(connection.getNode(), address, port); }
column.setData(refUuid); try { DatabaseSchema dbSchema = client.getSchema(dbName).get(); GenericTableSchema schema = dbSchema.table(refRowObject.getRefTable(), GenericTableSchema.class); Row<GenericTableSchema> refRow = schema.createRow((ObjectNode)refRowObject.getJsonNode()); modifiedSet.add(refUuid); try { DatabaseSchema dbSchema = client.getSchema(dbName).get(); GenericTableSchema schema = dbSchema.table(refRowObject.getRefTable(), GenericTableSchema.class); Row<GenericTableSchema> refRow = schema.createRow((ObjectNode)refRowObject.getJsonNode());