use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupDescBody01.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
* Test covers bodies of actions Output, Copy TTL Out, Copy TTL In.
*/
@Test
public void testMultipartReplyGroupDescBody01() {
ByteBuf bb = BufferHelper.buildBuffer("00 07 00 01 00 00 00 00 " + // len
"00 38 " + // type
"01 " + // pad
"00 " + // groupId
"00 00 00 08 " + // bucketLen
"00 30 " + // bucketWeight
"00 06 " + // bucketWatchPort
"00 00 00 05 " + // bucketWatchGroup
"00 00 00 04 " + // bucketPad
"00 00 00 00 " + // outputType
"00 00 " + // outputLen
"00 10 " + // outputPort
"00 00 10 FF " + // outputMaxLen
"FF FF " + // outputPad
"00 00 00 00 00 00 " + // copyTTLOutType
"00 0B " + // copyTTLOutLen
"00 08 " + // copyTTLOutPad
"00 00 00 00 " + // copyTTLIntType
"00 0C " + // copyTTLIntLen
"00 08 " + // copyTTLInPad
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc();
Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue());
Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue());
Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue());
Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue());
Assert.assertTrue("Wrong outputType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0).getActionChoice()).getOutputAction().getMaxLength().intValue());
Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase);
Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class GroupModInputMessageFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
// Test Message
Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
BucketsList bucket = deserializedMessage.getBucketsList().get(0);
Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setGroup.
private static MultipartReplyGroupCase setGroup(final ByteBuf input) {
MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder();
MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();
List<GroupStats> groupStatsList = new ArrayList<>();
while (input.readableBytes() > 0) {
GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
final int bodyLength = input.readUnsignedShort();
input.skipBytes(PADDING_IN_GROUP_HEADER_01);
groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
groupStatsBuilder.setRefCount(input.readUnsignedInt());
input.skipBytes(PADDING_IN_GROUP_HEADER_02);
byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(packetCount);
groupStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(byteCount);
groupStatsBuilder.setByteCount(new BigInteger(1, byteCount));
groupStatsBuilder.setDurationSec(input.readUnsignedInt());
groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
int actualLength = GROUP_BODY_LENGTH;
List<BucketStats> bucketStatsList = new ArrayList<>();
while (actualLength < bodyLength) {
BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(packetCountBucket);
bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket));
byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(byteCountBucket);
bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
bucketStatsList.add(bucketStatsBuilder.build());
actualLength += BUCKET_COUNTER_LENGTH;
}
groupStatsBuilder.setBucketStats(bucketStatsList);
groupStatsList.add(groupStatsBuilder.build());
}
builder.setGroupStats(groupStatsList);
caseBuilder.setMultipartReplyGroup(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setGroupDesc.
private MultipartReplyGroupDescCase setGroupDesc(final ByteBuf input) {
MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder();
MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder();
List<GroupDesc> groupDescsList = new ArrayList<>();
while (input.readableBytes() > 0) {
GroupDescBuilder groupDescBuilder = new GroupDescBuilder();
final int bodyLength = input.readUnsignedShort();
groupDescBuilder.setType(GroupType.forValue(input.readUnsignedByte()));
input.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
groupDescBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
int actualLength = GROUP_DESC_HEADER_LENGTH;
List<BucketsList> bucketsList = new ArrayList<>();
while (actualLength < bodyLength) {
BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
final int bucketsLength = input.readUnsignedShort();
bucketsBuilder.setWeight(input.readUnsignedShort());
bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
bucketsBuilder.setWatchGroup(input.readUnsignedInt());
input.skipBytes(PADDING_IN_BUCKETS_HEADER);
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, bucketsLength - BUCKETS_HEADER_LENGTH, input, keyMaker, registry);
bucketsBuilder.setAction(actions);
bucketsList.add(bucketsBuilder.build());
actualLength += bucketsLength;
}
groupDescBuilder.setBucketsList(bucketsList);
groupDescsList.add(groupDescBuilder.build());
}
builder.setGroupDesc(groupDescsList);
caseBuilder.setMultipartReplyGroupDesc(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method createRequestGroup.
private static MultipartRequestGroupCase createRequestGroup() {
MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder();
builder.setGroupId(new GroupId(2258L));
caseBuilder.setMultipartRequestGroup(builder.build());
return caseBuilder.build();
}
Aggregations