use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class NodeConnectorStatisticsToNotificationTransformer method transformToNotification.
/**
* Transform statistics to notification.
*
* @param mpReplyList raw multipart response from device
* @param deviceInfo device basic info
* @param ofVersion device version
* @param emulatedTxId emulated transaction Id
* @return notification containing flow stats
*/
public static NodeConnectorStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
NodeConnectorStatisticsUpdateBuilder notification = new NodeConnectorStatisticsUpdateBuilder();
notification.setId(deviceInfo.getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
notification.setNodeConnectorStatisticsAndPortNumberMap(new ArrayList<>());
for (MultipartReply mpReply : mpReplyList) {
MultipartReplyPortStatsCase caseBody = (MultipartReplyPortStatsCase) mpReply.getMultipartReplyBody();
MultipartReplyPortStats replyBody = caseBody.getMultipartReplyPortStats();
for (PortStats portStats : replyBody.getPortStats()) {
NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = processSingleNodeConnectorStats(deviceInfo, ofVersion, portStats);
notification.getNodeConnectorStatisticsAndPortNumberMap().add(statsBuilder.build());
}
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setBucketStats(Collections.emptyList()).setDurationSec(1L).setDurationNsec(1L).setRefCount(0L).build();
final List<GroupStats> groupStats = Collections.singletonList(groupStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(group.getGroupStats()).thenReturn(groupStats);
when(groupCase.getMultipartReplyGroup()).thenReturn(group);
when(reply.getMultipartReplyBody()).thenReturn(groupCase);
final GetGroupStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testStoreStatistics.
@Override
public void testStoreStatistics() throws Exception {
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = mock(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class);
when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO));
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> stats = Collections.singletonList(stat);
final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class);
when(output.getGroupStats()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class NodeConnectorDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyPortStatsCase nodeConnectorCase = mock(MultipartReplyPortStatsCase.class);
final MultipartReplyPortStats nodeConnector = mock(MultipartReplyPortStats.class);
final PortStats nodeConnectorStat = mock(PortStats.class);
final List<PortStats> nodeConnectorStats = Collections.singletonList(nodeConnectorStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(nodeConnector.getPortStats()).thenReturn(nodeConnectorStats);
when(nodeConnectorCase.getMultipartReplyPortStats()).thenReturn(nodeConnector);
when(reply.getMultipartReplyBody()).thenReturn(nodeConnectorCase);
when(nodeConnectorStat.getPortNo()).thenReturn(PORT_NO);
when(nodeConnectorStat.getTxBytes()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getCollisions()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxBytes()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxCrcErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxDropped()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxErrors()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxFrameErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxOverErr()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getRxPackets()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getTxDropped()).thenReturn(BigInteger.ONE);
when(nodeConnectorStat.getTxErrors()).thenReturn(BigInteger.ONE);
final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
final NodeConnectorStatisticsAndPortNumberMap stats = output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method testStoreStatistics.
@Override
public void testStoreStatistics() throws Exception {
final FlowAndStatisticsMapList stat = mock(FlowAndStatisticsMapList.class);
when(stat.getTableId()).thenReturn(TABLE_NO);
when(stat.getMatch()).thenReturn(new MatchBuilder().build());
final List<FlowAndStatisticsMapList> stats = Collections.singletonList(stat);
final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class);
when(output.getFlowAndStatisticsMapList()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPFLOW).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Aggregations