Search in sources :

Example 1 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleControlFactory method deserialize.

@Override
public BundleControlOnf deserialize(ByteBuf message) {
    BundleId bundleId = new BundleId(message.readUnsignedInt());
    BundleControlType type = BundleControlType.forValue(message.readUnsignedShort());
    BundleFlags flags = createBundleFlags(message.readUnsignedShort());
    OnfControlGroupingDataBuilder builder = new OnfControlGroupingDataBuilder();
    List<BundleProperty> properties = createBundleProperties(message);
    builder.setBundleId(bundleId).setType(type).setFlags(flags).setBundleProperty(properties);
    return new BundleControlOnfBuilder().setOnfControlGroupingData(builder.build()).build();
}
Also used : BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) OnfControlGroupingDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundleControlOnfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags) BundleControlType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleControlType)

Example 2 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty 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 BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleAddMessageConverterTest method createMessage.

private static BundleAddMessageSal createMessage(final boolean withProperty, final BundleInnerMessage innerMessage) {
    final SalAddMessageDataBuilder dataBuilder = new SalAddMessageDataBuilder();
    dataBuilder.setBundleId(new BundleId(1L));
    dataBuilder.setFlags(new BundleFlags(true, false));
    List<BundleProperty> properties = new ArrayList<>();
    if (withProperty) {
        properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
    }
    dataBuilder.setBundleProperty(properties);
    dataBuilder.setBundleInnerMessage(innerMessage);
    return new BundleAddMessageSalBuilder().setSalAddMessageData(dataBuilder.build()).build();
}
Also used : BundleAddMessageSalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSalBuilder) BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) 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) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Example 4 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleControlFactory method createBundleProperties.

private List<BundleProperty> createBundleProperties(final ByteBuf message) {
    List<BundleProperty> properties = new ArrayList<>();
    while (message.readableBytes() > 0) {
        BundlePropertyType type = BundlePropertyType.forValue(message.readUnsignedShort());
        int length = message.readUnsignedShort();
        if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) {
            properties.add(createExperimenterBundleProperty(length, message));
        } else {
            message.skipBytes(length);
        }
    }
    return properties;
}
Also used : ArrayList(java.util.ArrayList) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundlePropertyType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)

Example 5 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class AbstractBundleMessageFactory method writeBundleProperties.

void writeBundleProperties(final List<BundleProperty> properties, final ByteBuf outBuffer) {
    for (BundleProperty property : properties) {
        BundlePropertyType type = property.getType();
        if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) {
            final int startIndex = outBuffer.writerIndex();
            outBuffer.writeShort(type.getIntValue());
            int lengthIndex = outBuffer.writerIndex();
            outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            writeBundleExperimenterProperty((BundlePropertyExperimenter) property.getBundlePropertyEntry(), outBuffer);
            outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
        } else {
            LOG.warn("Trying to serialize unknown bundle property (type: {}), skipping", type != null ? type.getIntValue() : 0);
        }
    }
}
Also used : BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundlePropertyType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)

Aggregations

BundleProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty)8 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)5 ArrayList (java.util.ArrayList)4 BundleId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId)4 BundlePropertyType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)2 BundleControlOnfBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder)2 OnfControlGroupingDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 DeserializerRegistryInjector (org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector)1 ExperimenterIdTypeDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey)1 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)1 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)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 BundleControlType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleControlType)1 BundleInnerMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.BundleInnerMessage)1