@Override public InterfaceStatus getStatus() { return getOriginalIface().getStatistics().getStatus(); }
@Test public void testMasshUpdateStatisticsForVds() { List<VdsNetworkInterface> interfaces = dao.getAllInterfacesForVds(VDS_ID); List<VdsNetworkStatistics> statistics = new ArrayList<>(interfaces.size()); for (VdsNetworkInterface iface : interfaces) { VdsNetworkStatistics stats = iface.getStatistics(); stats.setReceiveDropRate(RandomUtils.instance().nextInt() * 1.0); stats.setStatus(RandomUtils.instance().nextEnum(InterfaceStatus.class)); statistics.add(stats); } dao.massUpdateStatisticsForVds(statistics); List<VdsNetworkInterface> after = dao.getAllInterfacesForVds(VDS_ID); for (VdsNetworkInterface iface : after) { boolean found = false; for (VdsNetworkStatistics stats : statistics) { if (iface.getId().equals(stats.getId())) { found = true; assertEquals(stats.getReceiveDropRate(), iface.getStatistics().getReceiveDropRate()); assertEquals(stats.getStatus(), iface.getStatistics().getStatus()); } } assertTrue(found); } }
private HostInterface hostInterfaceFromNic(VdsNetworkInterface nic) { HostInterface hi = new HostInterface(); hi.setInterface(nic); hi.setName(nic.getName()); hi.setIpv4Address(nic.getIpv4Address()); hi.setIpv6Address(nic.getIpv6Address()); hi.setMAC(nic.getMacAddress()); hi.setSpeed(nic.getSpeed()); hi.setRxRate(nic.getStatistics().getReceiveRate()); hi.setRxTotal(nic.getStatistics().getReceivedBytes()); hi.setRxDrop(nic.getStatistics().getReceiveDropRate()); hi.setTxRate(nic.getStatistics().getTransmitRate()); hi.setTxTotal(nic.getStatistics().getTransmittedBytes()); hi.setTxDrop(nic.getStatistics().getTransmitDropRate()); hi.setStatus(nic.getStatistics().getStatus()); hi.getPropertyChangedEvent().addListener(this); return hi; }