use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder 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.openflow.protocol.rev130731.ExperimenterInputBuilder in project openflowplugin by opendaylight.
the class SalExperimenterMessageServiceImpl method buildRequest.
@Override
protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ServiceException {
final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter = extensionConverterProvider.getMessageConverter(key);
if (messageConverter == null) {
throw new ServiceException(new ConverterNotFoundException(key.toString()));
}
final ExperimenterInputBuilder experimenterInputBld;
if (messageConverter instanceof BundleMessageDataInjector) {
((BundleMessageDataInjector) messageConverter).setNode(input.getNode());
((BundleMessageDataInjector) messageConverter).setXid(xid.getValue());
}
try {
experimenterInputBld = new ExperimenterInputBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice())).setVersion(getVersion()).setXid(xid.getValue());
} catch (ConversionException e) {
throw new ServiceException(e);
}
return experimenterInputBld.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder in project openflowplugin by opendaylight.
the class VendorInputMessageFactoryTest method test.
/**
* Tests {@link VendorInputMessageFactory#serialize(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
* .protocol.rev130731.ExperimenterOfMessage, ByteBuf)}.
*/
@Test
public void test() {
Mockito.when(registry.getSerializer(Matchers.<MessageTypeKey<?>>any())).thenReturn(serializer);
VendorInputMessageFactory factory = new VendorInputMessageFactory();
factory.injectSerializerRegistry(registry);
final ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(12345L);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(84L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput experimenterInput = builder.build();
Mockito.when(registry.getSerializer(Matchers.<ExperimenterIdSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(foundSerializer);
factory.serialize(experimenterInput, buffer);
Mockito.verify(foundSerializer, Mockito.times(1)).serialize(experimenterInput.getExperimenterDataOfChoice(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder in project openflowplugin by opendaylight.
the class ExperimenterInputMessageFactoryTest method testV13.
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization.
*/
@Test
public void testV13() throws Exception {
startUp(false);
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(21L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput input = builder.build();
Mockito.when(registry.getSerializer((ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
expFactory.serialize(input, out);
Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder in project openflowplugin by opendaylight.
the class ExperimenterInputMessageFactoryTest method testV10.
/**
* Testing of {@link ExperimenterInputMessageFactory} for correct serializer
* lookup and serialization.
*/
@Test
public void testV10() throws Exception {
startUp(false);
ExperimenterInputBuilder builder = new ExperimenterInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setExperimenter(new ExperimenterId(42L));
builder.setExpType(21L);
builder.setExperimenterDataOfChoice(vendorData);
ExperimenterInput input = builder.build();
Mockito.when(registry.getSerializer((ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer);
expFactory.serialize(input, out);
Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out);
}
Aggregations