@Override protected VmNetworkStatistics createEntity() { return new VmNetworkStatistics(); } }
@Override protected Double[] getRawValue(VmNetworkInterface object) { Double receiveDropRate = object != null ? object.getStatistics().getReceiveDropRate() : null; Double transmitDropRate = object != null ? object.getStatistics().getTransmitDropRate() : null; return new Double[] { receiveDropRate, transmitDropRate }; } };
@Override protected Double getRate(VmNetworkInterface object) { return object.getStatistics().getReceiveRate(); }
private VmNetworkInterface setUpStatisticalEntityExpectations(VmNetworkInterface entity, VmNetworkStatistics statistics) { when(entity.getStatistics()).thenReturn(statistics); when(statistics.getReceiveRate()).thenReturn(1D); when(statistics.getReceiveDropRate()).thenReturn(2D); when(statistics.getTransmitRate()).thenReturn(3D); when(statistics.getTransmitDropRate()).thenReturn(4D); when(statistics.getReceivedBytes()).thenReturn(5L); when(statistics.getTransmittedBytes()).thenReturn(6L); return entity; }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); newVmStatistics = new VmNetworkStatistics(); newVmStatistics.setId(NEW_INTERFACE_ID); newVmStatistics.setVmId(VM_ID); newVmStatistics.setStatus(InterfaceStatus.DOWN); newVmStatistics.setSampleTime(0.0); newVmStatistics.setReceiveDropRate(0.0); newVmStatistics.setReceiveRate(0.0); newVmStatistics.setReceivedBytes(0L); newVmStatistics.setReceivedBytesOffset(0L); newVmStatistics.setTransmitDropRate(0.0); newVmStatistics.setTransmitRate(0.0); newVmStatistics.setTransmittedBytes(0L); newVmStatistics.setTransmittedBytesOffset(0L); }
SafeHtmlUtils.fromString(nic.getMacAddress()), dl); addDetailItem(templates.sub(constants.rxRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { nic.getStatistics().getReceiveRate(), nic.hasSpeed() ? nic.getSpeed().doubleValue() : 0})), dl); addDetailItem(templates.sub(constants.txRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { nic.getStatistics().getTransmitRate(), nic.hasSpeed() ? nic.getSpeed().doubleValue() : 0})), dl); addDetailItem(templates.sub(constants.dropsInterface(), constants.pkts()), SafeHtmlUtils.fromString(String.valueOf(nic.getStatistics().getReceiveDropRate() != null ? nic.getStatistics().getReceiveDropRate() : "" + nic.getStatistics().getTransmitDropRate())), dl); column.getElement().appendChild(dl); i++;
@Test public void testUpdateAll() { VmNetworkStatistics existingStats = dao.get(FixturesTool.VM_NETWORK_INTERFACE); VmNetworkStatistics existingStats2 = dao.get(new Guid("e2817b12-f873-4046-b0da-0098293c0000")); existingStats.setReceiveDropRate(10.0); existingStats2.setStatus(InterfaceStatus.DOWN); dao.updateAll(Arrays.asList(existingStats, existingStats2)); assertEquals(existingStats.getReceiveDropRate(), dao.get(existingStats.getId()).getReceiveDropRate()); assertEquals(existingStats2.getStatus(), dao.get(existingStats2.getId()).getStatus()); } }
public void setVmId(Guid vmId) { this.vmId = vmId; this.statistics.setVmId(vmId); }
@Override protected Double getRate(VmNetworkInterface object) { return object.getStatistics().getTransmitRate(); }
@Override protected MapSqlParameterSource createFullParametersMapper(VmNetworkStatistics stats) { return super.createFullParametersMapper(stats) .addValue("vm_id", stats.getVmId()); }
static VmNetworkInterface setUpStatisticalEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics) { when(entity.getStatistics()).thenReturn(statistics); when(statistics.getReceiveRate()).thenReturn(1D); when(statistics.getReceiveDropRate()).thenReturn(2D); when(statistics.getTransmitRate()).thenReturn(3D); when(statistics.getTransmitDropRate()).thenReturn(4D); when(statistics.getReceivedBytes()).thenReturn(5L); when(statistics.getTransmittedBytes()).thenReturn(6L); return entity; }
static VmNetworkInterface setUpStatisticalEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics) { when(entity.getStatistics()).thenReturn(statistics); when(statistics.getReceiveRate()).thenReturn(1D); when(statistics.getReceiveDropRate()).thenReturn(2D); when(statistics.getTransmitRate()).thenReturn(3D); when(statistics.getTransmitDropRate()).thenReturn(4D); when(statistics.getReceivedBytes()).thenReturn(5L); when(statistics.getTransmittedBytes()).thenReturn(6L); return entity; }
public VmNic() { super(new VmNetworkStatistics(), VmInterfaceType.pv.getValue()); linked = true; }
static VmNetworkInterface setUpStatisticalEntityExpectations( VmNetworkInterface entity, VmNetworkStatistics statistics) { when(entity.getStatistics()).thenReturn(statistics); when(statistics.getReceiveRate()).thenReturn(1D); when(statistics.getReceiveDropRate()).thenReturn(2D); when(statistics.getTransmitRate()).thenReturn(3D); when(statistics.getTransmitDropRate()).thenReturn(4D); when(statistics.getReceivedBytes()).thenReturn(5L); when(statistics.getTransmittedBytes()).thenReturn(6L); return entity; }
public VmNetworkInterface(VmNetworkInterface iface) { setId(iface.getId()); setMacAddress(iface.getMacAddress()); setName(iface.getName()); setNetworkName(iface.getNetworkName()); setLinked(iface.isLinked()); setSpeed(iface.getSpeed()); setType(iface.getType()); setVmId(iface.getVmId()); setVmName(iface.getVmName()); setVmTemplateId(iface.getVmTemplateId()); setStatistics(new VmNetworkStatistics(iface.getStatistics())); }
protected VmNetworkInterface setUpStatisticalExpectations() { VmNetworkStatistics stats = mock(VmNetworkStatistics.class); VmNetworkInterface entity = mock(VmNetworkInterface.class); when(entity.getStatistics()).thenReturn(stats); when(entity.getSpeed()).thenReturn(50); when(entity.getId()).thenReturn(NIC_ID); when(stats.getReceiveRate()).thenReturn(10D); when(stats.getTransmitRate()).thenReturn(20D); when(stats.getReceiveDropRate()).thenReturn(30D); when(stats.getTransmitDropRate()).thenReturn(40D); when(stats.getReceivedBytes()).thenReturn(50L); when(stats.getTransmittedBytes()).thenReturn(60L); List<VmNetworkInterface> ifaces = new ArrayList<>(); ifaces.add(entity); setUpEntityQueryExpectations( QueryType.GetVmInterfacesByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { VM_ID }, ifaces ); return entity; }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingVmInterface = dao.get(FixturesTool.VM_NETWORK_INTERFACE); existingTemplateInterface = dao.get(FixturesTool.TEMPLATE_NETWORK_INTERFACE); newVmInterface = new VmNetworkInterface(); newVmInterface.setStatistics(new VmNetworkStatistics()); newVmInterface.setId(Guid.newGuid()); newVmInterface.setVnicProfileId(FixturesTool.VM_NETWORK_INTERFACE_PROFILE); newVmInterface.setName("eth77"); newVmInterface.setNetworkName("enginet"); newVmInterface.setLinked(true); newVmInterface.setSpeed(1000); newVmInterface.setType(3); newVmInterface.setMacAddress("01:C0:81:21:71:17"); newVmDevice.setType(VmDeviceGeneralType.INTERFACE); newVmDevice.setDevice("bridge"); newVmDevice.setAddress("sample"); newVmDevice.setManaged(true); newVmDevice.setPlugged(true); newVmDevice.setReadOnly(false); Map<String, String> customProp = new LinkedHashMap<>(); customProp.put("prop1", "val1"); newVmDevice.setCustomProperties(customProp); }
private void createStatisticsItemColumn(VmNetworkInterface networkInterface, Row content) { Column column = createInfoColumn(constants.statistics(), true); RxTxRateRenderer rateRenderer = new RxTxRateRenderer(); RxTxTotalRenderer totalRenderer = new RxTxTotalRenderer(); DListElement dl = Document.get().createDLElement(); dl.addClassName(DL_HORIZONTAL); addDetailItem(templates.sub(constants.rxRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { networkInterface.getStatistics().getReceiveRate(), networkInterface.hasSpeed() ? networkInterface.getSpeed().doubleValue() : 0})), dl); addDetailItem(templates.sub(constants.txRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { networkInterface.getStatistics().getTransmitRate(), networkInterface.hasSpeed() ? networkInterface.getSpeed().doubleValue() : 0})), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.rxTotal()), SafeHtmlUtils.fromString(totalRenderer.render(networkInterface.getStatistics().getReceivedBytes())), dl); addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.txTotal()), SafeHtmlUtils.fromString(totalRenderer.render(networkInterface.getStatistics().getTransmittedBytes())), dl); addDetailItem(templates.sub(constants.dropsInterface(), constants.pkts()), SafeHtmlUtils.fromString(String.valueOf(networkInterface.getStatistics().getReceiveDropRate() + networkInterface.getStatistics().getTransmitDropRate())), dl); column.getElement().appendChild(dl); content.add(column); }