use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
flags.toByteBuf(body);
body.writeZero(RESERVED);
Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
writeUnsignedInt(specObj.getRouterId(), body);
Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
writeUnsignedInt(specObj.getInterfaceId(), body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project bgpcep by opendaylight.
the class AdminStatusObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final AdminStatusObjectBuilder adm = new AdminStatusObjectBuilder();
final BitArray reflect = BitArray.valueOf(byteBuf, FLAGS_SIZE);
adm.setReflect(reflect.get(REFLECT));
byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
final BitArray flags = BitArray.valueOf(byteBuf, FLAGS_SIZE);
adm.setTesting(flags.get(TESTING));
adm.setAdministrativelyDown(flags.get(DOWN));
adm.setDeletionInProgress(flags.get(DELETION));
return adm.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project openflowplugin by opendaylight.
the class BundleAddMessageConverterTest method testConvert.
private void testConvert(final BundleInnerMessage message, Class clazz, final boolean withProperty) throws Exception {
final BundleAddMessageSal original = createMessage(withProperty, message);
final BundleAddMessageOnf converted = converter.convert(original);
Assert.assertEquals("Wrong BundleId", new BundleId(original.getSalAddMessageData().getBundleId().getValue()), converted.getOnfAddMessageGroupingData().getBundleId());
Assert.assertEquals("Wrong flags", new BundleFlags(original.getSalAddMessageData().getFlags().isAtomic(), original.getSalAddMessageData().getFlags().isOrdered()), converted.getOnfAddMessageGroupingData().getFlags());
Assert.assertEquals("Wrong inner message conversion", clazz, converted.getOnfAddMessageGroupingData().getBundleInnerMessage().getImplementedInterface());
if (withProperty) {
final BundlePropertyExperimenter originalProperty = (BundlePropertyExperimenter) original.getSalAddMessageData().getBundleProperty().get(0).getBundlePropertyEntry();
final BundlePropertyExperimenter convertedProperty = (BundlePropertyExperimenter) converted.getOnfAddMessageGroupingData().getBundleProperty().get(0).getBundlePropertyEntry();
Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()), convertedProperty.getExperimenter());
Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(), convertedProperty.getExpType());
Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(), convertedProperty.getBundlePropertyExperimenterData());
} else {
Assert.assertTrue("Properties not empty", converted.getOnfAddMessageGroupingData().getBundleProperty().isEmpty());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags in project openflowplugin by opendaylight.
the class BundleAddMessageFactoryTest method testSerialize.
private void testSerialize(final boolean withProperty, final BundleInnerMessage innerMessage) {
final BundleAddMessageOnfBuilder builder = new BundleAddMessageOnfBuilder();
final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
dataBuilder.setBundleId(new BundleId(1L));
dataBuilder.setFlags(new BundleFlags(true, false));
dataBuilder.setBundleInnerMessage(innerMessage);
if (withProperty) {
dataBuilder.setBundleProperty(new ArrayList<>(Collections.singleton(BundleTestUtils.createExperimenterProperty(propertyExperimenterData))));
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer).thenReturn(propertySerializer);
} else {
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer);
}
builder.setOnfAddMessageGroupingData(dataBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
((SerializerRegistryInjector) factory).injectSerializerRegistry(registry);
factory.serialize(builder.build(), out);
Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt());
long padding = out.readUnsignedShort();
Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
Mockito.verify(caseSerializer).serialize(Mockito.any(), Mockito.any());
if (withProperty) {
Mockito.verify(propertySerializer).serialize(propertyExperimenterData, out);
}
}
Aggregations