Search in sources :

Example 1 with ExperimenterInputBuilder

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);
}
Also used : BundleAddMessageSalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSalBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message) SalAddMessageDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.add.message.sal.SalAddMessageDataBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SendExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInputBuilder)

Example 2 with ExperimenterInputBuilder

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();
}
Also used : TypeVersionKey(org.opendaylight.openflowplugin.extension.api.TypeVersionKey) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ServiceException(org.opendaylight.openflowplugin.impl.services.util.ServiceException) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ConverterNotFoundException(org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException) BundleMessageDataInjector(org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)

Example 3 with ExperimenterInputBuilder

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);
}
Also used : ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput) Test(org.junit.Test)

Example 4 with ExperimenterInputBuilder

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);
}
Also used : ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput) Test(org.junit.Test)

Example 5 with ExperimenterInputBuilder

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);
}
Also used : ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput) Test(org.junit.Test)

Aggregations

ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)6 Test (org.junit.Test)5 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)5 ExperimenterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput)5 SendExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInputBuilder)2 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 BundleMessageDataInjector (org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector)1 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)1 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)1 ExperimenterMessageOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice)1 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message)1 BundleAddMessageSalBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSalBuilder)1 BundleControlSalBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleControlSalBuilder)1 SalAddMessageDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.add.message.sal.SalAddMessageDataBuilder)1 SalControlDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.control.sal.SalControlDataBuilder)1