use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 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.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final FlowAndStatisticsMapList flowStat = new FlowAndStatisticsMapListBuilder().setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setTableId(TABLE_NO).setByteCount(new Counter64(BigInteger.ONE)).setPacketCount(new Counter64(BigInteger.ONE)).setFlags(new FlowModFlags(true, false, false, false, false)).setMatch(new MatchBuilder().build()).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyFlowStatsBuilder().setFlowAndStatisticsMapList(Collections.singletonList(flowStat)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetFlowStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
assertEquals(stats.getTableId(), TABLE_NO);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.
the class OpendaylightFlowTableStatisticsServiceImpl method transformToNotification.
@Override
public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
final List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
notification.setFlowTableAndStatisticsMap(salFlowStats);
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody();
MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
List<TableStats> swTablesStats = replyBody.getTableStats();
// TODO: Duplicate code: look at MultiReplyTranslatorUtil method translateTable
for (TableStats swTableStats : swTablesStats) {
FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
salFlowStats.add(statisticsBuilder.build());
}
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.
the class PortDirectStatisticsService method buildReply.
@Override
protected GetNodeConnectorStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMap = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) mpReply.getMultipartReplyBody();
final MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
for (final PortStats portStats : replyBody.getPortStats()) {
final NodeConnectorId nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(getDatapathId(), portStats.getPortNo(), getOfVersion());
final BytesBuilder bytesBuilder = new BytesBuilder().setReceived(portStats.getRxBytes()).setTransmitted(portStats.getTxBytes());
final PacketsBuilder packetsBuilder = new PacketsBuilder().setReceived(portStats.getRxPackets()).setTransmitted(portStats.getTxPackets());
final DurationBuilder durationBuilder = new DurationBuilder();
if (portStats.getDurationSec() != null) {
durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
}
if (portStats.getDurationNsec() != null) {
durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
}
final NodeConnectorStatisticsAndPortNumberMap stats = new NodeConnectorStatisticsAndPortNumberMapBuilder().setBytes(bytesBuilder.build()).setPackets(packetsBuilder.build()).setNodeConnectorId(nodeConnectorId).setDuration(durationBuilder.build()).setCollisionCount(portStats.getCollisions()).setKey(new NodeConnectorStatisticsAndPortNumberMapKey(nodeConnectorId)).setReceiveCrcError(portStats.getRxCrcErr()).setReceiveDrops(portStats.getRxDropped()).setReceiveErrors(portStats.getRxErrors()).setReceiveFrameError(portStats.getRxFrameErr()).setReceiveOverRunError(portStats.getRxOverErr()).setTransmitDrops(portStats.getTxDropped()).setTransmitErrors(portStats.getTxErrors()).build();
nodeConnectorStatisticsAndPortNumberMap.add(stats);
}
}
}
return new GetNodeConnectorStatisticsOutputBuilder().setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatisticsAndPortNumberMap).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32 in project openflowplugin by opendaylight.
the class AggregatedFlowStatisticsTranslator method translate.
@Override
public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase) input.getMultipartReplyBody();
MultipartReplyAggregate replyBody = caseBody.getMultipartReplyAggregate();
aggregatedFlowStatisticsBuilder.setByteCount(new Counter64(replyBody.getByteCount()));
aggregatedFlowStatisticsBuilder.setFlowCount(new Counter32(replyBody.getFlowCount()));
aggregatedFlowStatisticsBuilder.setPacketCount(new Counter64(replyBody.getPacketCount()));
return aggregatedFlowStatisticsBuilder.build();
}
Aggregations