use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method setAggregate.
private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
final MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(packetCount);
builder.setPacketCount(new BigInteger(1, packetCount));
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(byteCount);
builder.setByteCount(new BigInteger(1, byteCount));
builder.setFlowCount(input.readUnsignedInt());
input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
caseBuilder.setMultipartReplyAggregate(builder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testAggregateSerialize.
@Test
public void testAggregateSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(2));
final MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder();
MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder();
aggregate.setPacketCount(BigInteger.valueOf(1L));
aggregate.setByteCount(BigInteger.valueOf(1L));
aggregate.setFlowCount(1L);
aggregateCase.setMultipartReplyAggregate(aggregate.build());
builder.setMultipartReplyBody(aggregateCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyAggregateCase body = (MultipartReplyAggregateCase) message.getMultipartReplyBody();
MultipartReplyAggregate messageOutput = body.getMultipartReplyAggregate();
Assert.assertEquals("Wrong Packet count", messageOutput.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", messageOutput.getByteCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Flow count", messageOutput.getFlowCount().longValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyAggregate.
private MultipartReplyBody prepareMultipartReplyAggregate() {
MultipartReplyAggregateBuilder multipartReplyAggregateBuilder = new MultipartReplyAggregateBuilder();
multipartReplyAggregateBuilder.setByteCount(DUMMY_BYTE_COUNT);
multipartReplyAggregateBuilder.setPacketCount(DUMMY_PACKET_COUNT);
multipartReplyAggregateBuilder.setFlowCount(DUMMY_FLOW_COUNT);
MultipartReplyAggregateCaseBuilder multipartReplyAggregateCaseBuilder = new MultipartReplyAggregateCaseBuilder();
multipartReplyAggregateCaseBuilder.setMultipartReplyAggregate(multipartReplyAggregateBuilder.build());
return multipartReplyAggregateCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder in project openflowplugin by opendaylight.
the class AbstractCompatibleStatServiceTest method testHandleAndNotify.
@Test
public void testHandleAndNotify() throws Exception {
GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1)).build();
rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(11L)).setFlowCount(12L).setPacketCount(BigInteger.valueOf(13L)).build()).build()).build())).build();
AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(11L))).setFlowCount(new Counter32(12L)).setPacketCount(new Counter64(BigInteger.valueOf(13L))).build();
Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(aggregatedStats);
ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = service.handleAndNotify(input, notificationPublishService);
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> result = resultFuture.get();
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class));
}
Aggregations