use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder in project openflowplugin by opendaylight.
the class AggregatedFlowStatisticsTranslatorTest method testTranslate.
@Test
public void testTranslate() throws Exception {
MultipartReplyAggregateBuilder aggregateStatsValueBld = new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(1L)).setFlowCount(2L).setPacketCount(BigInteger.valueOf(3L));
MultipartReplyAggregateCaseBuilder inputBld = new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(aggregateStatsValueBld.build());
MultipartReplyMessageBuilder mpInputBld = new MultipartReplyMessageBuilder().setMultipartReplyBody(inputBld.build());
final AggregatedFlowStatistics statistics = translator.translate(mpInputBld.build(), deviceInfo, null);
Assert.assertEquals(aggregateStatsValueBld.getByteCount(), statistics.getByteCount().getValue());
Assert.assertEquals(aggregateStatsValueBld.getFlowCount(), statistics.getFlowCount().getValue());
Assert.assertEquals(aggregateStatsValueBld.getPacketCount(), statistics.getPacketCount().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder in project openflowplugin by opendaylight.
the class OpendaylightFlowStatisticsServiceDelegateImplTest method testGetAggregateFlowStatisticsFromFlowTableForAllFlows.
@Test
public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1));
Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(50L))).setPacketCount(new Counter64(BigInteger.valueOf(51L))).setFlowCount(new Counter32(52L)).build());
rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPAGGREGATE).setVersion(OFConstants.OFP_VERSION_1_3).setFlags(new MultipartRequestFlags(false)).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(50L)).setPacketCount(BigInteger.valueOf(51L)).setFlowCount(52L).build()).build()).build())).build();
final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
Assert.assertTrue(rpcResultCompatible.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setAggregate.
private static MultipartReplyAggregateCase setAggregate(final 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.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtilTest method translateAggregate.
@Test
public void translateAggregate() {
final MultipartReply multipartReply = buildReply(MultipartType.OFPMPAGGREGATE, new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.ONE).setFlowCount(10L).setPacketCount(BigInteger.ONE).build()).build());
dummyAssertReply(multipartReply);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testAggregateBodySerialize.
@Test
public void testAggregateBodySerialize() throws Exception {
MultipartReplyMessageBuilder builder;
builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_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(1234L));
aggregate.setByteCount(BigInteger.valueOf(1234L));
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.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 36);
Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
Assert.assertEquals("Wrong Packet count", 1234L, serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", 1234L, serializedBuffer.readLong());
Assert.assertEquals("Wrong flow count", 1L, serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
}
Aggregations