use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method startUp.
/**
* Initializes deserializer registry and lookups correct deserializer.
*/
@Before
public void startUp() {
DeserializerRegistry registry = new DeserializerRegistryImpl();
registry.init();
featuresFactory = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, GetFeaturesOutput.class));
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class GetAsyncRequestMessageFactoryTest method startUp.
@Before
public void startUp() {
DeserializerRegistry desRegistry = new DeserializerRegistryImpl();
desRegistry.init();
factory = desRegistry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 26, GetAsyncInput.class));
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class BarrierInputMessageFactoryTest method testVersions.
/**
* Testing of {@link BarrierInputMessageFactory} for correct header version.
*/
@Test
public void testVersions() {
List<Byte> versions = new ArrayList<>(Arrays.asList(EncodeConstants.OF13_VERSION_ID, EncodeConstants.OF14_VERSION_ID, EncodeConstants.OF15_VERSION_ID));
ByteBuf bb = BufferHelper.buildBuffer();
testHeaderVersions(versions, bb);
// OFP v1.0 need to be tested separately cause of different message type value
messageCodeKey = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class);
testHeaderVersions(Collections.singletonList(EncodeConstants.OF10_VERSION_ID), bb);
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class ListDeserializer method deserializeHeaders.
/**
* Deserializes headers of items into list (used in MultipartReplyMessage - Table features).
*
* @param version openflow wire version
* @param length length of list in ByteBuf (bytes)
* @param input input buffer
* @param keyMaker creates keys for deserializer lookup
* @param registry stores deserializers
* @return list of items
*/
public static <E extends DataObject> List<E> deserializeHeaders(short version, int length, ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) {
List<E> items = null;
if (input.readableBytes() > 0) {
items = new ArrayList<>();
int startIndex = input.readerIndex();
boolean exceptionLogged = false;
while (input.readerIndex() - startIndex < length) {
HeaderDeserializer<E> deserializer;
MessageCodeKey key = keyMaker.make(input);
try {
deserializer = registry.getDeserializer(key);
} catch (ClassCastException | IllegalStateException e) {
// TODO - simplify to correctly report exception during deserialization
if (!exceptionLogged) {
LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}." + "If more information is needed, set org.opendaylight.openflowjava do DEBUG log level.", key, e.getMessage());
if (LOG.isDebugEnabled()) {
LOG.debug("Detailed exception: {}", e);
LOG.debug("This exception is logged only once for each multipart reply (table features) to " + "prevent log flooding. There might be more of table features related exceptions.");
}
exceptionLogged = true;
}
input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
continue;
}
E item = deserializer.deserializeHeader(input);
items.add(item);
}
}
return items;
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class CodeKeyMakerFactoryTest method testActionKeyMaker.
/**
* Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)}.
*/
@Test
public void testActionKeyMaker() {
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
Assert.assertNotNull("Null key maker", keyMaker);
ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00");
// skip XID
buffer.skipBytes(4);
MessageCodeKey codeKey = keyMaker.make(buffer);
Assert.assertNotNull("Null key", codeKey);
Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0, null), codeKey);
Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes());
}
Aggregations