Search in sources :

Example 1 with NetworkStatistics

use of org.ovirt.engine.core.common.businessentities.network.NetworkStatistics in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method extractInterfaceStatistics.

private static void extractInterfaceStatistics(Map<String, Object> dict, NetworkInterface<?> iface) {
    NetworkStatistics stats = iface.getStatistics();
    stats.setReceiveDropRate(assignDoubleValueWithNullProtection(dict, VdsProperties.rx_dropped));
    stats.setReceivedBytes(assignLongValue(dict, VdsProperties.rx_total));
    stats.setTransmitDropRate(assignDoubleValueWithNullProtection(dict, VdsProperties.tx_dropped));
    stats.setTransmittedBytes(assignLongValue(dict, VdsProperties.tx_total));
    stats.setSampleTime(assignDoubleValue(dict, VdsProperties.sample_time));
    iface.setSpeed(assignIntValue(dict, VdsProperties.INTERFACE_SPEED));
}
Also used : VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics)

Example 2 with NetworkStatistics

use of org.ovirt.engine.core.common.businessentities.network.NetworkStatistics in project ovirt-engine by oVirt.

the class NetworkStatisticsBuilder method updateExistingInterfaceStatistics.

/**
 * Updates an existing NetworkInterface entity with recent statistics stored in a new NetworkInterface entity.
 *
 * @param existingIface
 *            the existing NetworkInterface entity, whose Statistics and Speed members are to be modified.
 * @param reportedIface
 *            the NetworkInterface entity storing recently-reported values, which will not be modified.
 */
public void updateExistingInterfaceStatistics(NetworkInterface<?> existingIface, NetworkInterface<?> reportedIface) {
    NetworkStatistics existingStats = existingIface.getStatistics();
    NetworkStatistics reportedStats = reportedIface.getStatistics();
    speed = reportedIface.getSpeed();
    currentTime = reportedStats.getSampleTime();
    previousTime = existingStats.getSampleTime();
    existingIface.setSpeed(speed);
    existingStats.setReceiveDropRate(reportedStats.getReceiveDropRate());
    existingStats.setTransmitDropRate(reportedStats.getTransmitDropRate());
    EffectiveStats rxResult = computeEffectiveStats(reportedStats.getReceivedBytes(), existingStats.getReceivedBytes(), existingStats.getReceivedBytesOffset());
    EffectiveStats txResult = computeEffectiveStats(reportedStats.getTransmittedBytes(), existingStats.getTransmittedBytes(), existingStats.getTransmittedBytesOffset());
    existingStats.setReceivedBytes(rxResult.current);
    existingStats.setReceivedBytesOffset(rxResult.offset);
    existingStats.setReceiveRate(rxResult.rate);
    existingStats.setTransmittedBytes(txResult.current);
    existingStats.setTransmittedBytesOffset(txResult.offset);
    existingStats.setTransmitRate(txResult.rate);
    existingStats.setSampleTime(currentTime);
}
Also used : NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics)

Example 3 with NetworkStatistics

use of org.ovirt.engine.core.common.businessentities.network.NetworkStatistics in project ovirt-engine by oVirt.

the class NetworkStatisticsBuilderTest method verifyResult.

@Test
public void verifyResult() {
    statsBuilder.updateExistingInterfaceStatistics(existingIface, reportedIface);
    NetworkStatistics existingStats = existingIface.getStatistics();
    assertEquals(expectedRxDrops, existingStats.getReceiveDropRate());
    assertEquals(expectedRxRate, existingStats.getReceiveRate());
    assertEquals(expectedRxTotal, existingStats.getReceivedBytes());
    assertEquals(expectedRxOffset, existingStats.getReceivedBytesOffset());
    assertEquals(expectedTxDrops, existingStats.getTransmitDropRate());
    assertEquals(expectedTxRate, existingStats.getTransmitRate());
    assertEquals(expectedTxTotal, existingStats.getTransmittedBytes());
    assertEquals(expectedTxOffset, existingStats.getTransmittedBytesOffset());
    assertEquals(expectedTime, existingStats.getSampleTime());
    assertEquals(expectedSpeed, existingIface.getSpeed());
}
Also used : NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics) Test(org.junit.Test)

Example 4 with NetworkStatistics

use of org.ovirt.engine.core.common.businessentities.network.NetworkStatistics in project ovirt-engine by oVirt.

the class NetworkStatisticsBuilderTest method constructInterface.

private static NetworkInterface<NetworkStatistics> constructInterface(Double rxDrops, Double rxRate, Long rxTotal, Long rxOffset, Double txDrops, Double txRate, Long txTotal, Long txOffset, Double sampleTime, Integer speed) {
    NetworkInterface<NetworkStatistics> iface = new TestableNetworkInterface();
    NetworkStatistics stats = new TestableNetworkStatistics();
    iface.setStatistics(stats);
    stats.setReceiveDropRate(rxDrops);
    stats.setReceiveRate(rxRate);
    stats.setReceivedBytes(rxTotal);
    stats.setReceivedBytesOffset(rxOffset);
    stats.setTransmitDropRate(txDrops);
    stats.setTransmitRate(txRate);
    stats.setTransmittedBytes(txTotal);
    stats.setTransmittedBytesOffset(txOffset);
    stats.setSampleTime(sampleTime);
    iface.setSpeed(speed);
    return iface;
}
Also used : NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics)

Aggregations

NetworkStatistics (org.ovirt.engine.core.common.businessentities.network.NetworkStatistics)4 Test (org.junit.Test)1 VdsNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)1