Search in sources :

Example 1 with NodeConnectorStatisticsUpdate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate in project openflowplugin by opendaylight.

the class NodeConnectorStatNotificationSupplierImplTest method testCreate.

@Test
public void testCreate() {
    final NodeConnectorStatisticsUpdate notification = notifSupplierImpl.createNotification(createTestConnectorStat(), createTestConnectorStatPath());
    assertNotNull(notification);
    assertEquals(FLOW_NODE_ID, notification.getId().getValue());
    assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnector().get(0).getId().getValue());
}
Also used : NodeConnectorStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate) Test(org.junit.Test)

Example 2 with NodeConnectorStatisticsUpdate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate in project openflowplugin by opendaylight.

the class NodeConnectorStatNotificationSupplierImpl method createNotification.

@Override
public NodeConnectorStatisticsUpdate createNotification(final FlowCapableNodeConnectorStatistics flowCapableNodeConnectorStatistics, final InstanceIdentifier<FlowCapableNodeConnectorStatistics> path) {
    Preconditions.checkArgument(flowCapableNodeConnectorStatistics != null);
    Preconditions.checkArgument(path != null);
    final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
    final NodeConnectorKey ncKey = path.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
    ncBuilder.setId(ncKey.getId());
    ncBuilder.setKey(ncKey);
    final NodeConnectorStatisticsUpdateBuilder builder = new NodeConnectorStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    builder.setNodeConnector(Collections.singletonList(ncBuilder.build()));
    builder.setNodeConnectorStatisticsAndPortNumberMap(Collections.singletonList(new NodeConnectorStatisticsAndPortNumberMapBuilder(flowCapableNodeConnectorStatistics).build()));
    return builder.build();
}
Also used : NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) NodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) NodeConnectorStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder)

Example 3 with NodeConnectorStatisticsUpdate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate 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();
}
Also used : NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) PortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats) NodeConnectorStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder)

Example 4 with NodeConnectorStatisticsUpdate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate 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());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) DataContainer(org.opendaylight.yangtools.yang.binding.DataContainer) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 NodeConnectorStatisticsUpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder)2 NodeConnectorStatisticsAndPortNumberMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder)2 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)1 NodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)1 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)1 MultipartReplyPortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats)1 PortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats)1 NodeConnectorStatisticsUpdate (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate)1 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)1 DataContainer (org.opendaylight.yangtools.yang.binding.DataContainer)1