use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMocks.
private MultipartReplyMessage prepareMocks(DeviceContext mockedDeviceContext, MultipartReplyBody multipartReplyBody, final MultipartType multipartType) {
ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
when(mockedFeaturesReply.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(mockedFeaturesReply.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
DeviceInfo deviceInfo = mock(DeviceInfo.class);
when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(deviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
when(mockedDeviceContext.getDeviceInfo()).thenReturn(deviceInfo);
when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
MultipartReplyMessage multipartReplyMessage = mock(MultipartReplyMessage.class);
when(multipartReplyMessage.getType()).thenReturn(multipartType);
when(multipartReplyMessage.getFlags()).thenReturn(new MultipartRequestFlags(true));
when(multipartReplyMessage.getXid()).thenReturn(DUMMY_XID);
when(multipartReplyMessage.getMultipartReplyBody()).thenReturn(multipartReplyBody);
return multipartReplyMessage;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyPortStats.
private MultipartReplyBody prepareMultipartReplyPortStats() {
PortStatsBuilder dummyPortStatBuilder = new PortStatsBuilder();
dummyPortStatBuilder.setPortNo(DUMMY_PORT_NO);
dummyPortStatBuilder.setRxBytes(DUMMY_RX_BYTES);
dummyPortStatBuilder.setTxBytes(DUMMY_TX_BYTES);
dummyPortStatBuilder.setRxPackets(DUMMY_RX_PACKETS);
dummyPortStatBuilder.setTxPackets(DUMMY_TX_PACKETS);
dummyPortStatBuilder.setCollisions(DUMMY_COLLISIONS);
dummyPortStatBuilder.setRxCrcErr(DUMMY_RX_CRC_ERR);
dummyPortStatBuilder.setRxDropped(DUMMY_RX_DROPPED);
dummyPortStatBuilder.setRxErrors(DUMMY_RX_ERRORS);
dummyPortStatBuilder.setRxFrameErr(DUMMY_RX_FRAME_ERR);
dummyPortStatBuilder.setRxOverErr(DUMMY_OVER_ERR);
dummyPortStatBuilder.setTxDropped(DUMMY_TX_DROPPED);
dummyPortStatBuilder.setTxErrors(DUMMY_TX_ERRORS);
MultipartReplyPortStatsBuilder multipartReplyPortStatsBuilder = new MultipartReplyPortStatsBuilder();
multipartReplyPortStatsBuilder.setPortStats(Lists.newArrayList(dummyPortStatBuilder.build()));
MultipartReplyPortStatsCaseBuilder multipartReplyPortStatsCaseBuilder = new MultipartReplyPortStatsCaseBuilder();
multipartReplyPortStatsCaseBuilder.setMultipartReplyPortStats(multipartReplyPortStatsBuilder.build());
return multipartReplyPortStatsCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyGroup.
private MultipartReplyBody prepareMultipartReplyGroup() {
GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
groupStatsBuilder.setByteCount(DUMMY_BYTE_COUNT);
groupStatsBuilder.setBucketStats(Collections.<BucketStats>emptyList());
groupStatsBuilder.setDurationSec(DUMMY_DURATION_SEC);
groupStatsBuilder.setDurationNsec(DUMMY_DURATION_NSEC);
groupStatsBuilder.setGroupId(DUMMY_GROUP_ID);
groupStatsBuilder.setPacketCount(DUMMY_PACKET_COUNT);
groupStatsBuilder.setRefCount(DUMMY_REF_COUNT);
MultipartReplyGroupBuilder multipartReplyGroupBuilder = new MultipartReplyGroupBuilder();
multipartReplyGroupBuilder.setGroupStats(Lists.newArrayList(groupStatsBuilder.build()));
MultipartReplyGroupCaseBuilder multipartReplyGroupCaseBuilder = new MultipartReplyGroupCaseBuilder();
multipartReplyGroupCaseBuilder.setMultipartReplyGroup(multipartReplyGroupBuilder.build());
return multipartReplyGroupCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeQueueBody.
private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) {
MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
for (QueueStats queueStats : queue.getQueueStats()) {
ByteBuf queueStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
queueStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
queueStatsBuff.writeZero(QUEUE_PADDING);
queueStatsBuff.writeInt(queueStats.getQueueId().intValue());
queueStatsBuff.writeLong(queueStats.getTxBytes().longValue());
queueStatsBuff.writeLong(queueStats.getTxPackets().longValue());
queueStatsBuff.writeLong(queueStats.getTxErrors().longValue());
queueStatsBuff.setShort(QUEUE_STATS_LENGTH_INDEX, queueStatsBuff.readableBytes());
outBuffer.writeBytes(queueStatsBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeAggregateBody.
private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) {
MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body;
MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate();
outBuffer.writeLong(aggregate.getPacketCount().longValue());
outBuffer.writeLong(aggregate.getByteCount().longValue());
outBuffer.writeInt(aggregate.getFlowCount().intValue());
outBuffer.writeZero(AGGREGATE_PADDING);
}
Aggregations