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();
}
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();
}
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());
}
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);
}
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());
}
Aggregations