@Override public NetworkQoS createQosEntity(ResultSet rs) throws SQLException { NetworkQoS entity = new NetworkQoS(); entity.setInboundAverage(getInteger(rs, "inbound_average")); entity.setInboundPeak(getInteger(rs, "inbound_peak")); entity.setInboundBurst(getInteger(rs, "inbound_burst")); entity.setOutboundAverage(getInteger(rs, "outbound_average")); entity.setOutboundPeak(getInteger(rs, "outbound_peak")); entity.setOutboundBurst(getInteger(rs, "outbound_burst")); return entity; } }
@Override protected MapSqlParameterSource createFullParametersMapper(NetworkQoS networkQos) { MapSqlParameterSource map = super.createFullParametersMapper(networkQos); map.addValue("inbound_average", networkQos.getInboundAverage()); map.addValue("inbound_peak", networkQos.getInboundPeak()); map.addValue("inbound_burst", networkQos.getInboundBurst()); map.addValue("outbound_average", networkQos.getOutboundAverage()); map.addValue("outbound_peak", networkQos.getOutboundPeak()); map.addValue("outbound_burst", networkQos.getOutboundBurst()); return map; }
/** * Ensures that retrieving VDS by ID works as expected. */ @Test public void testGetNetworkQos() { NetworkQoS result = dao.get(qosAId); NetworkQoS trueA = new NetworkQoS(); trueA.setId(qosAId); trueA.setName("network_qos_a"); trueA.setStoragePoolId(FixturesTool.STORAGE_POOL_MIXED_TYPES); trueA.setInboundAverage(1000); trueA.setInboundPeak(2000); trueA.setInboundBurst(500); trueA.setOutboundAverage(1000); trueA.setOutboundPeak(2000); trueA.setOutboundBurst(500); assertNotNull(result); assertEquals(trueA, result); }
public void checkNameUniquness(String name) { NetworkQoS entity = new NetworkQoS(); entity.setId(Guid.newGuid()); entity.setName(name); entity.setStoragePoolId(FixturesTool.STORAGE_POOL_MIXED_TYPES); dao.save(entity); entity.setId(Guid.newGuid()); dao.save(entity); } }
private QosBase createNewQosEntityForQosType(QosType qosType) { switch (qosType) { case STORAGE: return new StorageQos(); case CPU: return new CpuQos(); case NETWORK: return new NetworkQoS(); case HOSTNETWORK: return new HostNetworkQos(); default: throw new IllegalArgumentException("Unsupported QoS type \"" + qosType + "\""); } }
/** * test update */ @Test public void testUpdateNetworkQos() { NetworkQoS newB = new NetworkQoS(); newB.setId(qosBId); newB.setName("newB"); newB.setStoragePoolId(FixturesTool.STORAGE_POOL_MIXED_TYPES); newB.setInboundAverage(30); newB.setInboundPeak(30); newB.setInboundBurst(30); newB.setOutboundAverage(30); newB.setOutboundPeak(30); newB.setOutboundBurst(30); dao.update(newB); NetworkQoS afterUpdate = dao.get(qosBId); assertEquals(newB, afterUpdate); }
private static QosBase createNewQosEntityForQosType(QosType qosType) { switch (qosType) { case STORAGE: return new StorageQos(); case CPU: return new CpuQos(); case NETWORK: return new NetworkQoS(); case HOSTNETWORK: return new HostNetworkQos(); default: throw new IllegalArgumentException("Unsupported QoS type"); } }
/** * test save */ @Test public void testSaveNetworkQos() { NetworkQoS qosD = new NetworkQoS(); qosD.setId(qosDId); qosD.setName("qos_d"); qosD.setStoragePoolId(FixturesTool.STORAGE_POOL_MIXED_TYPES); qosD.setInboundAverage(200); qosD.setInboundPeak(200); qosD.setInboundBurst(200); qosD.setOutboundAverage(200); qosD.setOutboundPeak(200); qosD.setOutboundBurst(200); dao.save(qosD); NetworkQoS returnedD = dao.get(qosDId); assertEquals(qosD, returnedD); }
private static void mapNetworkQosToModel(QosBase entity, Qos model) { NetworkQoS networkQos = verifyAndCast(entity, NetworkQoS.class); if (networkQos != null) { model.setInboundAverage(networkQos.getInboundAverage()); model.setInboundPeak(networkQos.getInboundPeak()); model.setInboundBurst(networkQos.getInboundBurst()); model.setOutboundAverage(networkQos.getOutboundAverage()); model.setOutboundPeak(networkQos.getOutboundPeak()); model.setOutboundBurst(networkQos.getOutboundBurst()); } }
public NetworkQoS flush() { if (getInbound().getEnabled().getEntity()) { networkQoS.setInboundAverage(getInbound().getAverage().getEntity()); networkQoS.setInboundPeak(getInbound().getPeak().getEntity()); networkQoS.setInboundBurst(getInbound().getBurst().getEntity()); } else { networkQoS.setInboundAverage(null); networkQoS.setInboundPeak(null); networkQoS.setInboundBurst(null); } if (getOutbound().getEnabled().getEntity()) { networkQoS.setOutboundAverage(getOutbound().getAverage().getEntity()); networkQoS.setOutboundPeak(getOutbound().getPeak().getEntity()); networkQoS.setOutboundBurst(getOutbound().getBurst().getEntity()); } else { networkQoS.setOutboundAverage(null); networkQoS.setOutboundPeak(null); networkQoS.setOutboundBurst(null); } return networkQoS; }
public NewNetworkQoSModel(Model sourceModel, StoragePool dataCenter) { super(sourceModel, dataCenter); setTitle(ConstantsManager.getInstance().getConstants().newNetworkQoSTitle()); setHelpTag(HelpTag.new_network_qos); setHashName("new_network_qos"); //$NON-NLS-1$ networkQoS = new NetworkQoS(); }
@Override public String getString() { StringBuilder builder = new StringBuilder(); builder.append("[") .append("inbound ") .append("{") .append("average=") .append(getInboundAverage()) .append(", peak=") .append(getInboundPeak()) .append(", burst=") .append(getInboundBurst()) .append("}, ") .append("outbound ") .append("{") .append("average=") .append(getOutboundAverage()) .append(", peak=") .append(getOutboundPeak()) .append(", burst=") .append(getOutboundBurst()) .append("}") .append("]"); return builder.toString(); }
private static QosBase mapNetworkQosToEntity(Qos model, NetworkQoS entity) { if (model.isSetInboundAverage()) { entity.setInboundAverage(IntegerMapper.mapMinusOneToNull(model.getInboundAverage())); } if (model.isSetInboundPeak()) { entity.setInboundPeak(IntegerMapper.mapMinusOneToNull(model.getInboundPeak())); } if (model.isSetInboundBurst()) { entity.setInboundBurst(IntegerMapper.mapMinusOneToNull(model.getInboundBurst())); } if (model.isSetOutboundAverage()) { entity.setOutboundAverage(IntegerMapper.mapMinusOneToNull(model.getOutboundAverage())); } if (model.isSetOutboundPeak()) { entity.setOutboundPeak(IntegerMapper.mapMinusOneToNull(model.getOutboundPeak())); } if (model.isSetOutboundBurst()) { entity.setOutboundBurst(IntegerMapper.mapMinusOneToNull(model.getOutboundBurst())); } return entity; }
public void init(NetworkQoS qos) { if (qos == null) { networkQoS = new NetworkQoS(); } else { networkQoS = qos; } if (networkQoS.getInboundAverage() == null || networkQoS.getInboundPeak() == null || networkQoS.getInboundBurst() == null) { getInbound().getEnabled().setEntity(false); } else { getInbound().getAverage().setEntity(networkQoS.getInboundAverage()); getInbound().getPeak().setEntity(networkQoS.getInboundPeak()); getInbound().getBurst().setEntity(networkQoS.getInboundBurst()); } if (networkQoS.getOutboundAverage() == null || networkQoS.getOutboundPeak() == null || networkQoS.getOutboundBurst() == null) { getOutbound().getEnabled().setEntity(false); } else { getOutbound().getAverage().setEntity(networkQoS.getOutboundAverage()); getOutbound().getPeak().setEntity(networkQoS.getOutboundPeak()); getOutbound().getBurst().setEntity(networkQoS.getOutboundBurst()); } }