@Override protected StorageQos createQosEntity(ResultSet rs) throws SQLException { StorageQos entity = new StorageQos(); entity.setMaxThroughput(getInteger(rs, "max_throughput")); entity.setMaxReadThroughput(getInteger(rs, "max_read_throughput")); entity.setMaxWriteThroughput(getInteger(rs, "max_write_throughput")); entity.setMaxIops(getInteger(rs, "max_iops")); entity.setMaxReadIops(getInteger(rs, "max_read_iops")); entity.setMaxWriteIops(getInteger(rs, "max_write_iops")); return entity; } }
@Override public void init(StorageQos qos) { initStorageParameterModel(qos.getMaxThroughput(), qos.getMaxReadThroughput(), qos.getMaxWriteThroughput(), getThroughput()); initStorageParameterModel(qos.getMaxIops(), qos.getMaxReadIops(), qos.getMaxWriteIops(), getIops()); }
@Override protected void updateExistingEntity() { existingEntity.setName("newB"); existingEntity.setDescription("If I owned a company, my employees would love me. They’d have huge pictures of me up the walls and in their home, like Lenin."); existingEntity.setMaxThroughput(30); existingEntity.setMaxReadThroughput(30); existingEntity.setMaxWriteThroughput(30); existingEntity.setMaxIops(30); existingEntity.setMaxReadIops(30); existingEntity.setMaxWriteIops(30); }
@Override protected StorageQos generateNewEntity() { StorageQos storageQos = new StorageQos(); storageQos.setId(Guid.newGuid()); storageQos.setName("qos_d"); storageQos.setDescription("bla bla"); storageQos.setStoragePoolId(FixturesTool.STORAGE_POOL_MIXED_TYPES); storageQos.setMaxThroughput(200); storageQos.setMaxReadThroughput(200); storageQos.setMaxWriteThroughput(200); storageQos.setMaxIops(200); storageQos.setMaxReadIops(200); storageQos.setMaxWriteIops(200); return storageQos; }
public NewStorageQosModel(Model sourceModel, StoragePool dataCenter) { super(new StorageQos(), new StorageQosParametersModel(), sourceModel, dataCenter); }
@Override protected QosParametersBase<StorageQos> getParameters() { QosParametersBase<StorageQos> qosParametersBase = new QosParametersBase<>(); qosParametersBase.setQos(getQos()); qosParametersBase.setQosId(getQos().getId()); return qosParametersBase; }
/** * used to set qos's href (requires dc id). */ private void handleQosDataCenterLinks(Map<Guid, List<Qos>> qosMap) { if (!qosMap.isEmpty()) { List<StorageQos> list = getBackendCollection( StorageQos.class, QueryType.GetAllQosByType, new QosQueryParameterBase(null, QosType.STORAGE)); for (StorageQos storageQos : list) { List<Qos> qosList = qosMap.get(storageQos.getId()); if (qosList != null) { DataCenter dc = new DataCenter(); dc.setId(storageQos.getStoragePoolId().toString()); for (Qos qos : qosList) { qos.setDataCenter(dc); } } } } }
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 + "\""); } }
@Override protected void postInitQosList(List<StorageQos> qosList) { qosList.add(0, EMPTY_QOS); getQos().setItems(qosList); if (getDefaultQosId() != null) { for (StorageQos storageQos : qosList) { if (getDefaultQosId().equals(storageQos.getId())) { getQos().setSelectedItem(storageQos); break; } } } }
private static void mapStorageQosToEntity(Qos model, StorageQos entity) { if (model.isSetMaxThroughput()) { entity.setMaxThroughput(IntegerMapper.mapMinusOneToNull(model.getMaxThroughput())); } if (model.isSetMaxReadThroughput()) { entity.setMaxReadThroughput(IntegerMapper.mapMinusOneToNull(model.getMaxReadThroughput())); } if (model.isSetMaxWriteThroughput()) { entity.setMaxWriteThroughput(IntegerMapper.mapMinusOneToNull(model.getMaxWriteThroughput())); } if (model.isSetMaxIops()) { entity.setMaxIops(IntegerMapper.mapMinusOneToNull(model.getMaxIops())); } if (model.isSetMaxReadIops()) { entity.setMaxReadIops(IntegerMapper.mapMinusOneToNull(model.getMaxReadIops())); } if (model.isSetMaxWriteIops()) { entity.setMaxWriteIops(IntegerMapper.mapMinusOneToNull(model.getMaxWriteIops())); } }
private static void mapStorageQosToModel(QosBase entity, Qos model) { StorageQos storageQos = verifyAndCast(entity, StorageQos.class); if (storageQos != null) { model.setMaxThroughput(storageQos.getMaxThroughput()); model.setMaxReadThroughput(storageQos.getMaxReadThroughput()); model.setMaxWriteThroughput(storageQos.getMaxWriteThroughput()); model.setMaxIops(storageQos.getMaxIops()); model.setMaxReadIops(storageQos.getMaxReadIops()); model.setMaxWriteIops(storageQos.getMaxWriteIops()); } }
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 public void getQosByDiskProfileIds() { Map<Guid, StorageQos> qosMap = dao.getQosByDiskProfileIds(Collections.singleton(FixturesTool.DISK_PROFILE_1)); assertNotNull(qosMap); assertEquals(FixturesTool.QOS_ID_1, qosMap.get(FixturesTool.DISK_PROFILE_1).getId()); } }
@Override public void flush(StorageQos storageQos) { storageQos.setMaxThroughput(null); storageQos.setMaxReadThroughput(null); storageQos.setMaxWriteThroughput(null); if (getThroughput().getChoiceGroupTotal().getEntity() && getThroughput().getTotal().getEntity() != null) { storageQos.setMaxThroughput(Integer.parseInt(getThroughput().getTotal().getEntity())); } else if (getThroughput().getChoiceGroupReadWrite().getEntity()) { storageQos.setMaxReadThroughput(Integer.parseInt(getThroughput().getRead().getEntity())); storageQos.setMaxWriteThroughput(Integer.parseInt(getThroughput().getWrite().getEntity())); storageQos.setMaxIops(null); storageQos.setMaxReadIops(null); storageQos.setMaxWriteIops(null); if (getIops().getChoiceGroupTotal().getEntity() && getIops().getTotal().getEntity() != null) { storageQos.setMaxIops(Integer.parseInt(getIops().getTotal().getEntity())); } else if (getIops().getChoiceGroupReadWrite().getEntity()) { storageQos.setMaxReadIops(Integer.parseInt(getIops().getRead().getEntity())); storageQos.setMaxWriteIops(Integer.parseInt(getIops().getWrite().getEntity()));
@Override protected MapSqlParameterSource createFullParametersMapper(StorageQos obj) { MapSqlParameterSource map = super.createFullParametersMapper(obj); map.addValue("max_throughput", obj.getMaxThroughput()); map.addValue("max_read_throughput", obj.getMaxReadThroughput()); map.addValue("max_write_throughput", obj.getMaxWriteThroughput()); map.addValue("max_iops", obj.getMaxIops()); map.addValue("max_read_iops", obj.getMaxReadIops()); map.addValue("max_write_iops", obj.getMaxWriteIops()); return map; }
@Override public void flush() { if (getProfile() == null) { setProfile(new DiskProfile()); } DiskProfile diskProfile = getProfile(); diskProfile.setName(getName().getEntity()); diskProfile.setDescription(getDescription().getEntity()); StorageDomain storageDomain = getParentListModel().getSelectedItem(); diskProfile.setStorageDomainId(storageDomain != null ? storageDomain.getId() : null); StorageQos storageQos = getQos().getSelectedItem(); diskProfile.setQosId(storageQos != null && storageQos.getId() != null && !storageQos.getId().equals(Guid.Empty) ? storageQos.getId() : null); }
@Test public void getQosByDiskProfileId() { StorageQos qos = dao.getQosByDiskProfileId(FixturesTool.DISK_PROFILE_1); assertNotNull(qos); assertEquals(FixturesTool.QOS_ID_1, qos.getId()); }