Search in sources :

Example 1 with TypeToClassKey

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

the class MessageDeserializerInjector method revertLegacyDeserializers.

@VisibleForTesting
static void revertLegacyDeserializers(final DeserializerExtensionProvider provider) {
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 14));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 14), FlowModInput.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 15));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 15), GroupModInput.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 29));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 29), MeterModInput.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 16));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 16), PortModInput.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 19));
}
Also used : TypeToClassKey(org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with TypeToClassKey

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

the class DeserializationFactory method deserialize.

/**
 * Transforms ByteBuf into correct POJO message.
 *
 * @param rawMessage the message
 * @param version
 *            version decoded from OpenFlow protocol message
 * @return correct POJO as DataObject
 */
public DataObject deserialize(final ByteBuf rawMessage, final short version) {
    DataObject dataObject = null;
    int type = rawMessage.readUnsignedByte();
    Class<?> clazz = messageClassMap.get(new TypeToClassKey(version, type));
    rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    OFDeserializer<DataObject> deserializer = registry.getDeserializer(new MessageCodeKey(version, type, clazz));
    dataObject = deserializer.deserialize(rawMessage);
    return dataObject;
}
Also used : TypeToClassKey(org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)

Example 3 with TypeToClassKey

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

the class MessageDeserializerInjectorTest method injectDeserializers.

@Test
public void injectDeserializers() throws Exception {
    injector.apply(10).apply(OfHeader.class).accept(ofDeserializer);
    verify(switchConnectionProvider).unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 10));
    verify(switchConnectionProvider).registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 10), OfHeader.class);
    verify(switchConnectionProvider).registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 10, OfHeader.class), ofDeserializer);
}
Also used : TypeToClassKey(org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) Test(org.junit.Test)

Example 4 with TypeToClassKey

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

the class MessageDeserializerInjector method revertDeserializers.

/**
 * Reverts original message deserializers in provided.
 * {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}
 *
 * @param provider OpenflowJava deserializer extension provider
 */
static void revertDeserializers(final DeserializerExtensionProvider provider) {
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 10));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 10), PacketInMessage.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 19));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 19), MultipartReplyMessage.class);
    provider.unregisterDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 27));
    provider.registerDeserializerMapping(new TypeToClassKey(EncodeConstants.OF13_VERSION_ID, 27), GetAsyncOutput.class);
}
Also used : TypeToClassKey(org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey)

Aggregations

TypeToClassKey (org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey)4 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Test (org.junit.Test)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1