use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput in project openflowplugin by opendaylight.
the class SalBundleServiceImpl method addBundleMessages.
@Override
public Future<RpcResult<Void>> addBundleMessages(AddBundleMessagesInput input) {
final List<ListenableFuture<RpcResult<Void>>> partialResults = new ArrayList<>();
final SendExperimenterInputBuilder experimenterInputBuilder = new SendExperimenterInputBuilder();
final BundleAddMessageSalBuilder bundleAddMessageBuilder = new BundleAddMessageSalBuilder();
final SalAddMessageDataBuilder dataBuilder = new SalAddMessageDataBuilder();
experimenterInputBuilder.setNode(input.getNode());
dataBuilder.setNode(input.getNode());
dataBuilder.setBundleId(input.getBundleId());
dataBuilder.setFlags(input.getFlags());
dataBuilder.setBundleProperty(input.getBundleProperty());
for (Message message : input.getMessages().getMessage()) {
dataBuilder.setBundleInnerMessage(message.getBundleInnerMessage());
experimenterInputBuilder.setExperimenterMessageOfChoice(bundleAddMessageBuilder.setSalAddMessageData(dataBuilder.build()).build());
ListenableFuture<RpcResult<Void>> res = JdkFutureAdapters.listenInPoolThread(experimenterMessageService.sendExperimenter(experimenterInputBuilder.build()));
partialResults.add(res);
}
return processResults(partialResults);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput in project openflowplugin by opendaylight.
the class SalBundleServiceImplTest method testAddBundleMessages.
@Test
public void testAddBundleMessages() throws Exception {
final List<Message> innerMessages = createMessages();
final Messages messages = new MessagesBuilder().setMessage(innerMessages).build();
final AddBundleMessagesInput input = new AddBundleMessagesInputBuilder().setNode(NODE_REF).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setBundleProperty(properties).setMessages(messages).build();
final SalAddMessageDataBuilder dataBuilder = new SalAddMessageDataBuilder();
dataBuilder.setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setBundleProperty(properties);
final BundleAddMessageSalBuilder addMessageBuilder = new BundleAddMessageSalBuilder();
final SendExperimenterInputBuilder experimenterBuilder = new SendExperimenterInputBuilder().setNode(NODE_REF);
Mockito.when(experimenterMessageService.sendExperimenter(Matchers.any())).thenReturn(SettableFuture.create());
service.addBundleMessages(input);
for (Message msg : innerMessages) {
Mockito.verify(experimenterMessageService).sendExperimenter(experimenterBuilder.setExperimenterMessageOfChoice(addMessageBuilder.setSalAddMessageData(dataBuilder.setNode(NODE_REF).setBundleInnerMessage(msg.getBundleInnerMessage()).build()).build()).build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.AddBundleMessagesInput in project openflowplugin by opendaylight.
the class Activator method onDataTreeChanged.
@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
LOG.info("Node connected: {}", modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
final NodeRef nodeRef = new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
final ControlBundleInput openBundleInput = new ControlBundleInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setType(BundleControlType.ONFBCTOPENREQUEST).build();
final ControlBundleInput commitBundleInput = new ControlBundleInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setType(BundleControlType.ONFBCTCOMMITREQUEST).build();
final List<Message> innerMessages = createMessages(nodeRef);
final Messages messages = new MessagesBuilder().setMessage(innerMessages).build();
final AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setMessages(messages).build();
makeCompletableFuture(bundleService.controlBundle(openBundleInput)).thenComposeAsync(voidRpcResult -> {
LOG.debug("Open successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
final CompletableFuture<RpcResult<Void>> addFuture = makeCompletableFuture(bundleService.addBundleMessages(addBundleMessagesInput));
return addFuture;
}).thenComposeAsync(voidRpcResult -> {
LOG.debug("AddBundleMessages successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
final CompletableFuture<RpcResult<Void>> controlCommitFuture = makeCompletableFuture(bundleService.controlBundle(commitBundleInput));
return controlCommitFuture;
}).thenAccept(voidRpcResult -> {
LOG.debug("Commit successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
});
}
}
}
Aggregations