use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.
the class FlowNodeReconciliationImpl method getDeleteAllGroup.
private Group getDeleteAllGroup() {
final GroupBuilder groupBuilder = new GroupBuilder();
groupBuilder.setGroupType(GroupTypes.GroupAll);
groupBuilder.setGroupId(new GroupId(OFConstants.OFPG_ALL));
return groupBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.
the class GroupMessageDeserializer method deserialize.
@Override
public GroupMessage deserialize(ByteBuf message) {
final GroupMessageBuilder builder = new GroupMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(GroupModCommand.forValue(message.readUnsignedShort()));
builder.setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
message.skipBytes(PADDING);
builder.setGroupId(new GroupId(message.readUnsignedInt()));
final List<Bucket> buckets = new ArrayList<>();
while (message.readableBytes() > 0) {
final int length = message.readUnsignedShort();
final BucketBuilder bucket = new BucketBuilder().setWeight(message.readUnsignedShort()).setWatchPort(message.readUnsignedInt()).setWatchGroup(message.readUnsignedInt());
message.skipBytes(PADDING_IN_BUCKETS_HEADER);
if (message.readableBytes() > 0) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
final int startIndex = message.readerIndex();
final int bucketLength = length - BUCKETS_HEADER_LENGTH;
int offset = 0;
while (message.readerIndex() - startIndex < bucketLength) {
actions.add(new ActionBuilder().setKey(new ActionKey(offset)).setOrder(offset).setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION)).build());
offset++;
}
bucket.setAction(actions);
}
buckets.add(bucket.build());
}
buckets.sort(COMPARATOR);
return builder.setBuckets(new BucketsBuilder().setBucket(buckets).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testBuildRequestBody.
@Override
public void testBuildRequestBody() throws Exception {
final GetGroupStatisticsInput input = mock(GetGroupStatisticsInput.class);
when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
when(input.getGroupId()).thenReturn(new GroupId(GROUP_NO));
final MultipartRequestGroupCase body = (MultipartRequestGroupCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
final MultipartRequestGroup group = body.getMultipartRequestGroup();
assertEquals(GROUP_NO, group.getGroupId().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.
the class DeviceGroupRegistryImplTest method setUp.
@Before
public void setUp() throws Exception {
deviceGroupRegistry = new DeviceGroupRegistryImpl();
groupId = new GroupId(42L);
groupId2 = new GroupId(84L);
Assert.assertEquals(0, deviceGroupRegistry.getAllGroupIds().size());
deviceGroupRegistry.store(groupId);
Assert.assertEquals(1, deviceGroupRegistry.getAllGroupIds().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupBody.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyGroupBody() {
ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 " + // length
"00 48 " + // pad1
"00 00 " + // groupId
"00 00 00 10 " + // refCount
"00 00 00 12 " + // pad2
"00 00 00 00 " + // packetCount
"FF 01 01 01 01 01 01 01 " + // byteCount
"FF 01 01 01 01 01 01 01 " + // durationSec
"00 00 00 08 " + // durationNsec
"00 00 00 09 " + // packetCountBucket
"FF 01 01 01 01 01 01 01 " + // byteCountBucket
"FF 01 01 01 01 01 01 01 " + // packetCountBucket_2
"FF 02 02 02 02 02 02 02 " + // byteCountBucket_2
"FF 02 02 02 02 02 02 02 " + // length_2
"00 48 " + // pad1.2
"00 00 " + // groupId_2
"00 00 00 10 " + // refCount_2
"00 00 00 12 " + // pad2.2
"00 00 00 00 " + // packetCount_2
"FF 01 01 01 01 01 01 01 " + // byteCount_2
"FF 01 01 01 01 01 01 01 " + // durationSec_2
"00 00 00 08 " + // durationNsec_2
"00 00 00 09 " + // packetCountBucket_1.2
"FF 01 01 01 01 01 01 01 " + // byteCountBucket_1.2
"FF 01 01 01 01 01 01 01 " + // packetCountBucket_2.2
"FF 02 02 02 02 02 02 02 " + // byteCountBucket_2.2
"FF 02 02 02 02 02 02 02");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getPacketCount());
Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getByteCount());
Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
Assert.assertEquals("Wrong packetCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
Assert.assertEquals("Wrong byteCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
Assert.assertEquals("Wrong packetCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
Assert.assertEquals("Wrong byteCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
Assert.assertEquals("Wrong packetCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getPacketCount());
Assert.assertEquals("Wrong byteCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getByteCount());
Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
Assert.assertEquals("Wrong packetCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
Assert.assertEquals("Wrong byteCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
Assert.assertEquals("Wrong packetCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
Assert.assertEquals("Wrong byteCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
}
Aggregations