use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput in project openflowplugin by opendaylight.
the class TableForwarderTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Mockito.when(salTableService.updateTable(updateTableInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().setTransactionId(txId).build()).buildFuture());
final TableFeatures tableFeaturesUpdate = new TableFeaturesBuilder(tableFeatures).setName("another-table").build();
final Future<RpcResult<UpdateTableOutput>> updateResult = tableForwarder.update(tableFeaturesPath, tableFeatures, tableFeaturesUpdate, flowCapableNodePath);
Mockito.verify(salTableService).updateTable(Matchers.<UpdateTableInput>any());
Assert.assertTrue(updateResult.isDone());
final RpcResult<UpdateTableOutput> updateTableResult = updateResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(updateTableResult.isSuccessful());
Assert.assertEquals(1, updateTableResult.getResult().getTransactionId().getValue().intValue());
final UpdateTableInput updateTableInput = updateTableInputCpt.getValue();
Assert.assertEquals(tablePath, updateTableInput.getTableRef().getValue());
Assert.assertEquals(nodePath, updateTableInput.getNode().getValue());
Assert.assertEquals(1, updateTableInput.getOriginalTable().getTableFeatures().size());
Assert.assertEquals("test-table", updateTableInput.getOriginalTable().getTableFeatures().get(0).getName());
Assert.assertEquals(1, updateTableInput.getUpdatedTable().getTableFeatures().size());
Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().getTableFeatures().get(0).getName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput in project openflowplugin by opendaylight.
the class TableFeaturesListenerTest method updateFlowTest.
@Test
public void updateFlowTest() {
TableKey tableKey = new TableKey((short) 2);
TableFeaturesKey tableFeaturesKey = new TableFeaturesKey(tableKey.getId());
addTable(tableKey, NODE_KEY);
TableFeatures tableFeaturesData = new TableFeaturesBuilder().setKey(tableFeaturesKey).build();
InstanceIdentifier<TableFeatures> tableFeaturesII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(TableFeatures.class, tableFeaturesKey);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData);
assertCommit(writeTx.submit());
tableFeaturesData = new TableFeaturesBuilder().setKey(tableFeaturesKey).setName("dummy name").build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData);
assertCommit(writeTx.submit());
SalTableServiceMock salTableServiceMock = (SalTableServiceMock) forwardingRulesManager.getSalTableService();
List<UpdateTableInput> updateTableInputs = salTableServiceMock.getUpdateTableInput();
assertEquals(1, updateTableInputs.size());
assertEquals("DOM-0", updateTableInputs.get(0).getTransactionUri().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput in project openflowplugin by opendaylight.
the class SingleLayerTableMultipartServiceTest method buildRequest.
@Test
public void buildRequest() throws Exception {
final UpdateTableInput input = new UpdateTableInputBuilder().setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setMaxEntries(MAX_ENTRIES).build())).build()).build();
final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
assertEquals(MultipartRequest.class, ofHeader.getImplementedInterface());
final MultipartRequestTableFeatures result = MultipartRequestTableFeatures.class.cast(MultipartRequest.class.cast(ofHeader).getMultipartRequestBody());
assertEquals(MAX_ENTRIES, result.getTableFeatures().get(0).getMaxEntries().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput in project openflowplugin by opendaylight.
the class SingleLayerTableMultipartServiceTest method handleAndReply.
@Test
public void handleAndReply() throws Exception {
mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder().setXid(XID).setMultipartReplyBody(new MultipartReplyTableFeaturesBuilder().setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setMaxEntries(MAX_ENTRIES).build())).build()).build()));
final UpdateTableInput input = new UpdateTableInputBuilder().setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setMaxEntries(MAX_ENTRIES).build())).build()).build();
final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = service.handleAndReply(input);
final RpcResult<UpdateTableOutput> result = rpcResultFuture.get();
assertTrue(result.isSuccessful());
assertEquals(XID, result.getResult().getTransactionId().getValue().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput in project openflowplugin by opendaylight.
the class MultiLayerTableMultipartService method handleAndReply.
@Override
public Future<RpcResult<UpdateTableOutput>> handleAndReply(UpdateTableInput input) {
final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(input);
final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
if (result.isSuccessful()) {
final List<MultipartReply> multipartReplies = result.getResult();
if (multipartReplies.isEmpty()) {
LOG.debug("Multipart reply to table features request shouldn't be empty list.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withError(ErrorType.RPC, "Multipart reply list is empty.").build());
} else {
final Long xid = multipartReplies.get(0).getXid();
LOG.debug("OnSuccess, rpc result successful," + " multipart response for rpc update-table with xid {} obtained.", xid);
final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder();
updateTableOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
finalFuture.set(RpcResultBuilder.success(updateTableOutputBuilder.build()).build());
try {
storeStatistics(convertToSalTableFeatures(multipartReplies));
} catch (Exception e) {
LOG.warn("Not able to write to operational datastore: {}", e.getMessage());
}
}
} else {
LOG.debug("OnSuccess, rpc result unsuccessful," + " multipart response for rpc update-table was unsuccessful.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withRpcErrors(result.getErrors()).build());
}
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failure multipart response for table features request. Exception: {}", throwable);
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withError(ErrorType.RPC, "Future error", throwable).build());
}
}
Futures.addCallback(multipartFuture, new CallBackImpl(), MoreExecutors.directExecutor());
return finalFuture;
}
Aggregations