public static List<Insert> extractInsert(TransactionBuilder transaction, GenericTableSchema schema) { List<Operation> operations = transaction.getOperations(); List<Insert> inserts = new ArrayList<>(); for (Operation operation : operations) { if (operation instanceof Insert && operation.getTableSchema().equals(schema)) { inserts.add((Insert) operation); } } return inserts; }
private void invoke(TransactionBuilder txBuilder) { ListenableFuture<List<OperationResult>> result = txBuilder.execute(); LOG.debug("invoke: tb: {}", txBuilder); if (txBuilder.getOperations().size() > 0) { try { List<OperationResult> got = result.get(); LOG.debug("OVSDB transaction result: {}", got); } catch (InterruptedException | ExecutionException e) { LOG.warn("Transact execution exception: ", e); } LOG.trace("invoke exit tb: {}", txBuilder); } }
private void invoke(TransactCommand command, TransactionBuilder tb) { ListenableFuture<List<OperationResult>> result = tb.execute(); LOG.debug("invoke: command: {}, tb: {}", command, tb); if (tb.getOperations().size() > 0) { try { if (!result.isCancelled()) { List<OperationResult> got = result.get(); LOG.debug("OVSDB transaction result: {}", got); } else { LOG.debug("Operation task cancelled for transaction : {}", tb); } } catch (InterruptedException | ExecutionException | CancellationException e) { LOG.warn("Transact execution exception: ", e); } LOG.trace("invoke exit command: {}, tb: {}", command, tb); } } }
private void handleSpecialInsertCase(OvsdbClient client, String databaseName, String tableName, String uuid, Row<GenericTableSchema> row, TransactionBuilder transactionBuilder) { Port port = client.getTypedRowWrapper(Port.class, null); if (databaseName.equals(OvsVswitchdSchemaConstants.DATABASE_NAME) && tableName.equals(port.getSchema().getName())) { port = client.getTypedRowWrapper(Port.class, row); DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName); TableSchema<GenericTableSchema> tableSchema = dbSchema.table(tableName, GenericTableSchema.class); ColumnSchema<GenericTableSchema, Set<UUID>> columnSchema = tableSchema.multiValuedColumn("interfaces", UUID.class); String namedUuid = "Special_"+tableName; List<Operation> priorOperations = transactionBuilder.getOperations(); Insert portOperation = (Insert)priorOperations.get(0); portOperation.value(columnSchema, new UUID(namedUuid)); Column<GenericTableSchema, ?> nameColumn = port.getNameColumn(); List<Column<GenericTableSchema, ?>> columns = new ArrayList<Column<GenericTableSchema, ?>>(); columns.add(nameColumn); Row<GenericTableSchema> intfRow = new Row<GenericTableSchema>(tableSchema, columns); this.processTypedInsertTransaction(client, databaseName, "Interface", null, null, null, namedUuid, intfRow, transactionBuilder); } }
try { operationResults = results.get(); if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) { return new StatusWithUuid(StatusCode.INTERNALERROR);
try { operationResults = results.get(); if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) { return new StatusWithUuid(StatusCode.INTERNALERROR);
try { operationResults = results.get(); if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) { throw new OvsdbPluginException("Delete Operation Failed");
parentColumn, namedUuid, row, transactionBuilder); int referencedRowsInsertIndex = transactionBuilder.getOperations().size(); try { operationResults = results.get(); if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) { throw new OvsdbPluginException("Insert Operation Failed");
if (operationResults.isEmpty() || (transactionBuilder.getOperations().size() != operationResults.size())) { throw new OvsdbPluginException("Failed to update row. Please check OVS logs for more info.");