use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap 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.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method testTranslatePortStats.
@Test
public void testTranslatePortStats() {
DeviceContext mockedDeviceContext = mock(DeviceContext.class);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyPortStats(), MultipartType.OFPMPPORTSTATS);
DataContainer result = MultipartReplyTranslatorUtil.translate(multipartReplyMessage, mockedDeviceContext.getDeviceInfo(), CONVERTOR_MANAGER, mockedDeviceContext.oook()).get();
DataContainer dataObject = validateOutput(result);
assertTrue(dataObject instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap);
org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsUpdate = (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap) dataObject;
List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMaps = nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap();
assertEquals(1, nodeConnectorStatisticsAndPortNumberMaps.size());
NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsAndPortNumberMap = nodeConnectorStatisticsAndPortNumberMaps.get(0);
assertEquals("openflow:" + DUMMY_DATAPATH_ID + ":" + DUMMY_PORT_NO, nodeConnectorStatisticsAndPortNumberMap.getNodeConnectorId().getValue());
assertEquals(DUMMY_RX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getReceived());
assertEquals(DUMMY_TX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getTransmitted());
assertEquals(DUMMY_RX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getReceived());
assertEquals(DUMMY_TX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getTransmitted());
assertEquals(DUMMY_COLLISIONS, nodeConnectorStatisticsAndPortNumberMap.getCollisionCount());
assertEquals(DUMMY_RX_CRC_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveCrcError());
assertEquals(DUMMY_RX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getReceiveDrops());
assertEquals(DUMMY_RX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getReceiveErrors());
assertEquals(DUMMY_RX_FRAME_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveFrameError());
assertEquals(DUMMY_OVER_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveOverRunError());
assertEquals(DUMMY_TX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getTransmitDrops());
assertEquals(DUMMY_TX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getTransmitErrors());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.
the class MultipartReplyPortStatsDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeInt(PORT);
buffer.writeZero(PADDING_IN_PORT_STATS_HEADER);
buffer.writeLong(PACKETS_RECEIVED);
buffer.writeLong(PACKETS_TRANSMITTED);
buffer.writeLong(BYTES_RECEIVED);
buffer.writeLong(BYTES_TRANSMITTED);
buffer.writeLong(RECEIVE_DROPS);
buffer.writeLong(TRANSMIT_DROPS);
buffer.writeLong(RECEIVE_ERRORS);
buffer.writeLong(TRANSMIT_ERRORS);
buffer.writeLong(RECEIVE_FRAME_ERROR);
buffer.writeLong(RECEIVE_OVER_RUN_ERROR);
buffer.writeLong(RECEIVE_CRC_ERROR);
buffer.writeLong(COLLIESION_COUNT);
buffer.writeInt(SECOND);
buffer.writeInt(NANOSECOND);
final MultipartReplyPortStats reply = (MultipartReplyPortStats) deserializeMultipart(buffer);
final NodeConnectorStatisticsAndPortNumberMap portStats = reply.getNodeConnectorStatisticsAndPortNumberMap().get(0);
assertEquals(PACKETS_RECEIVED, portStats.getPackets().getReceived().longValue());
assertEquals(PACKETS_TRANSMITTED, portStats.getPackets().getTransmitted().longValue());
assertEquals(BYTES_RECEIVED, portStats.getBytes().getReceived().longValue());
assertEquals(BYTES_TRANSMITTED, portStats.getBytes().getTransmitted().longValue());
assertEquals(RECEIVE_DROPS, portStats.getReceiveDrops().longValue());
assertEquals(TRANSMIT_DROPS, portStats.getTransmitDrops().longValue());
assertEquals(RECEIVE_ERRORS, portStats.getReceiveErrors().longValue());
assertEquals(TRANSMIT_ERRORS, portStats.getTransmitErrors().longValue());
assertEquals(RECEIVE_FRAME_ERROR, portStats.getReceiveFrameError().longValue());
assertEquals(RECEIVE_OVER_RUN_ERROR, portStats.getReceiveOverRunError().longValue());
assertEquals(RECEIVE_CRC_ERROR, portStats.getReceiveCrcError().longValue());
assertEquals(COLLIESION_COUNT, portStats.getCollisionCount().longValue());
assertEquals(SECOND, portStats.getDuration().getSecond().getValue().intValue());
assertEquals(NANOSECOND, portStats.getDuration().getNanosecond().getValue().intValue());
assertEquals(0, buffer.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project genius by opendaylight.
the class NodeConnectorStatsImpl method processNodeConnectorStatistics.
/**
* This method processes NodeConnectorStatistics RPC result.
* It performs:
* - fetches various OF Port counters values
* - creates/updates new OF Port counters using Infrautils metrics API
* - set counter with values fetched from NodeConnectorStatistics
*/
private void processNodeConnectorStatistics(GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput, BigInteger dpid) {
String port = "";
String portUuid = "";
List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
// Parse NodeConnectorStatistics and create/update counters for them
for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
LOG.trace("Create/update metric counter for NodeConnector: {} of node: {}", nodeConnector, dpid.toString());
port = nodeConnector.getValue();
// update port name as per port name maintained in portNameCache
String portNameInCache = "openflow" + ":" + dpid.toString() + ":" + port;
java.util.Optional<String> portName = portNameCache.get(portNameInCache);
if (portName.isPresent()) {
Optional<List<InterfaceChildEntry>> interfaceChildEntries = interfaceChildCache.getInterfaceChildEntries(portName.get());
if (interfaceChildEntries.isPresent()) {
if (!interfaceChildEntries.get().isEmpty()) {
portUuid = interfaceChildEntries.get().get(0).getChildInterface();
LOG.trace("Retrieved portUuid {} for portname {}", portUuid, portName.get());
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
}
Counter counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_DURATION, dpid, port, portUuid, null);
long ofPortDuration = ncStatsAndPortMap.getDuration().getSecond().getValue();
updateCounter(counter, ofPortDuration);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVDROP, dpid, port, portUuid, null);
long packetsPerOFPortReceiveDrop = ncStatsAndPortMap.getReceiveDrops().longValue();
updateCounter(counter, packetsPerOFPortReceiveDrop);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVERROR, dpid, port, portUuid, null);
long packetsPerOFPortReceiveError = ncStatsAndPortMap.getReceiveErrors().longValue();
updateCounter(counter, packetsPerOFPortReceiveError);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_SENT, dpid, port, portUuid, null);
long packetsPerOFPortSent = ncStatsAndPortMap.getPackets().getTransmitted().longValue();
updateCounter(counter, packetsPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECV, dpid, port, portUuid, null);
long packetsPerOFPortReceive = ncStatsAndPortMap.getPackets().getReceived().longValue();
updateCounter(counter, packetsPerOFPortReceive);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_SENT, dpid, port, portUuid, null);
long bytesPerOFPortSent = ncStatsAndPortMap.getBytes().getTransmitted().longValue();
updateCounter(counter, bytesPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_RECV, dpid, port, portUuid, null);
long bytesPerOFPortReceive = ncStatsAndPortMap.getBytes().getReceived().longValue();
updateCounter(counter, bytesPerOFPortReceive);
}
}
Aggregations