Search in sources :

Example 1 with ExperimenterIdTypeDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey in project openflowplugin by opendaylight.

the class MultipartReplyExperimenterDeserializer method deserialize.

@Override
@SuppressWarnings("unchecked")
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
    final long expId = message.readUnsignedInt();
    final long expType = message.readUnsignedInt();
    try {
        final OFDeserializer<ExperimenterMessageOfChoice> deserializer = registry.getDeserializer(new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType, ExperimenterMessageOfChoice.class));
        builder.setExperimenterMessageOfChoice(deserializer.deserialize(message));
    } catch (ClassCastException | IllegalStateException es) {
        final OFDeserializer<ExperimenterDataOfChoice> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, expType));
        final ExperimenterDataOfChoice data = deserializer.deserialize(message);
        final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, (Class<? extends ExperimenterDataOfChoice>) data.getImplementedInterface());
        final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> convertor = OFSessionUtil.getExtensionConvertorProvider().getMessageConverter(key);
        try {
            builder.setExperimenterMessageOfChoice(convertor.convert(data, MessagePath.MPMESSAGE_RPC_OUTPUT));
        } catch (ConversionException ce) {
            LOG.debug("Failed to deserialize multipart reply experimenter for key: {}", key);
        }
    }
    return builder.build();
}
Also used : OFDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) ConvertorMessageFromOFJava(org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava) MultipartReplyExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterIdTypeDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey) MessageTypeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)

Example 2 with ExperimenterIdTypeDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey in project openflowplugin by opendaylight.

the class BundleControlFactory method createExperimenterBundleProperty.

// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
private BundleProperty createExperimenterBundleProperty(final int length, final ByteBuf message) {
    Objects.requireNonNull(deserializerRegistry);
    BundlePropertyExperimenterBuilder experimenterProperty = new BundlePropertyExperimenterBuilder();
    long experimenterId = message.readUnsignedInt();
    long expType = message.readUnsignedInt();
    experimenterProperty.setExperimenter(new ExperimenterId(experimenterId));
    experimenterProperty.setExpType(expType);
    OFDeserializer<BundlePropertyExperimenterData> deserializer = deserializerRegistry.getDeserializer(new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF13_VERSION_ID, experimenterId, expType, BundlePropertyExperimenterData.class));
    experimenterProperty.setBundlePropertyExperimenterData(deserializer.deserialize(message.readBytes(length - 12)));
    return new BundlePropertyBuilder().setType(BundlePropertyType.ONFETBPTEXPERIMENTER).setBundlePropertyEntry(experimenterProperty.build()).build();
}
Also used : BundlePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundlePropertyBuilder) BundlePropertyExperimenterData(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.bundle.property.experimenter.BundlePropertyExperimenterData) BundlePropertyExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenterBuilder) ExperimenterIdTypeDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 3 with ExperimenterIdTypeDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey in project openflowplugin by opendaylight.

the class OnfExtensionProvider method registerDeserializers.

private void registerDeserializers() {
    switchConnectionProvider.registerExperimenterMessageDeserializer(new ExperimenterIdTypeDeserializerKey(OFConstants.OFP_VERSION_1_3, OnfConstants.ONF_EXPERIMENTER_ID, OnfConstants.ONF_ET_BUNDLE_CONTROL, ExperimenterDataOfChoice.class), new org.opendaylight.openflowplugin.extension.onf.deserializer.BundleControlFactory());
    switchConnectionProvider.registerErrorDeserializer(new ExperimenterIdDeserializerKey(OFConstants.OFP_VERSION_1_3, OnfConstants.ONF_EXPERIMENTER_ID, ErrorMessage.class), new OnfExperimenterErrorFactory());
}
Also used : OnfExperimenterErrorFactory(org.opendaylight.openflowplugin.extension.onf.deserializer.OnfExperimenterErrorFactory) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterIdTypeDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)

Example 4 with ExperimenterIdTypeDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey in project openflowplugin by opendaylight.

the class ExperimenterDeserializerKeyFactoryTest method testCreateExperimenterMessageDeserializerKey.

@Test
public void testCreateExperimenterMessageDeserializerKey() throws Exception {
    ExperimenterIdDeserializerKey createdKey;
    ExperimenterIdDeserializerKey comparationKey;
    createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(EncodeConstants.OF10_VERSION_ID, 43L, 1L);
    comparationKey = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 43L, 1L, ExperimenterDataOfChoice.class);
    Assert.assertEquals("Wrong key created", comparationKey, createdKey);
}
Also used : ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterIdTypeDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) Test(org.junit.Test)

Example 5 with ExperimenterIdTypeDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey in project openflowplugin by opendaylight.

the class ExperimenterIdTypeDeserializerKeyTest method testHashCodeAndEquals.

/**
 * Test ExperimenterIdTypeDeserializerKey equals and hashCode.
 */
@Test
public void testHashCodeAndEquals() {
    ExperimenterIdTypeDeserializerKey key1 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
    ExperimenterIdTypeDeserializerKey key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
    Assert.assertTrue("Wrong equals", key1.equals(key2));
    Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
    key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, 1L, ExperimenterMessage.class);
    Assert.assertFalse("Wrong equals", key1.equals(key2));
    Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
    key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ExperimenterMessage.class);
    Assert.assertFalse("Wrong equals", key1.equals(key2));
    Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
    key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, null);
    Assert.assertFalse("Wrong equals", key1.equals(key2));
    Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
    key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ErrorMessage.class);
    Assert.assertFalse("Wrong equals", key1.equals(key2));
    Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
    key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 2L, ExperimenterMessage.class);
    Assert.assertFalse("Wrong equals", key1.equals(key2));
    Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
}
Also used : ExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage) ExperimenterIdTypeDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) Test(org.junit.Test)

Aggregations

ExperimenterIdTypeDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey)6 Test (org.junit.Test)3 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)3 ExperimenterIdDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)2 ErrorMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)1 ExperimenterIdSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey)1 MessageTypeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)1 ConvertorMessageFromOFJava (org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 OnfExperimenterErrorFactory (org.opendaylight.openflowplugin.extension.onf.deserializer.OnfExperimenterErrorFactory)1 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)1 ExperimenterMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage)1 ExperimenterMessageOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice)1 MultipartReplyExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder)1 BundlePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundlePropertyBuilder)1 BundlePropertyExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenterBuilder)1 BundlePropertyExperimenterData (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.bundle.property.experimenter.BundlePropertyExperimenterData)1