Gilad Chaplik has uploaded a new change for review.

Change subject: common: introduce qos package, and storage qos
......................................................................

common: introduce qos package, and storage qos

- Base Qos abstract class, in the future all QoS will inherit it.
- QosType (version >= 3.3  network, version >= 3.5 disk, cpu), to distinguish
between the types.
- StorageQos object as the first implementation.
- Handle field validation propeties.

For more information see http://www.ovirt.org/Features/aggregate_QoS,
http://www.ovirt.org/Features/blkio-support

Change-Id: I1a9af59277b5055453159f002f19046c0051d8ff
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosBase.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/StorageQos.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
9 files changed, 377 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/31803/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosBase.java
new file mode 100644
index 0000000..b9159e9
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosBase.java
@@ -0,0 +1,151 @@
+package org.ovirt.engine.core.common.businessentities.qos;
+
+import java.io.Serializable;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import 
org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions;
+import org.ovirt.engine.core.common.businessentities.BusinessEntity;
+import org.ovirt.engine.core.common.businessentities.IVdcQueryable;
+import org.ovirt.engine.core.common.validation.annotation.ValidI18NName;
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Base abstract class for QoS objects
+ * derived class will hold qos limit according to type.
+ */
+public abstract class QosBase extends IVdcQueryable implements 
BusinessEntity<Guid>, Serializable {
+    private static final long serialVersionUID = 1122772549710787678L;
+    private Guid id = Guid.Empty;
+    private QosType qosType;
+
+    @NotNull(message = "ACTION_TYPE_FAILED_QOS_STORAGE_POOL_NOT_EXIST")
+    private Guid storagePoolId;
+
+    @NotNull(message = "QOS_NAME_NOT_NULL")
+    @Size(min = 1, max = BusinessEntitiesDefinitions.GENERAL_NAME_SIZE, 
message = "QOS_NAME_TOO_LONG")
+    @ValidI18NName(message = "QOS_NAME_INVALID")
+    private String name;
+
+    @Size(max = BusinessEntitiesDefinitions.GENERAL_MAX_SIZE)
+    private String description;
+
+    @SuppressWarnings("unused")
+    private QosBase() {
+    }
+
+    public QosBase(QosType qosType) {
+        if (qosType == null) {
+            throw new IllegalArgumentException("Quality of Service element 
type cannot be null");
+        }
+        this.qosType = qosType;
+    }
+    /**
+     * @return object's type
+     */
+    public QosType getQosType() {
+        return qosType;
+    }
+
+    /**
+     * Extended of toString(), should include more inputs, and be called 
explicitly.
+     *
+     * @return object summary
+     */
+    public abstract String getString();
+
+    /**
+     * Check whether specific derived QoS values are equal.
+     *
+     * @param other
+     * @return are equals
+     */
+    public abstract boolean equalValues(QosBase other);
+
+    @Override
+    public Guid getId() {
+        return id;
+    }
+
+    @Override
+    public void setId(Guid id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Guid getStoragePoolId() {
+        return storagePoolId;
+    }
+
+    public void setStoragePoolId(Guid storagePoolId) {
+        this.storagePoolId = storagePoolId;
+    }
+
+    @Override
+    public Object getQueryableId() {
+        return getId();
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((description == null) ? 0 : 
description.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((qosType == null) ? 0 : qosType.hashCode());
+        result = prime * result + ((storagePoolId == null) ? 0 : 
storagePoolId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        QosBase other = (QosBase) obj;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (qosType != other.qosType)
+            return false;
+        if (storagePoolId == null) {
+            if (other.storagePoolId != null)
+                return false;
+        } else if (!storagePoolId.equals(other.storagePoolId))
+            return false;
+        return true;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosType.java
new file mode 100644
index 0000000..dd08f5a
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/QosType.java
@@ -0,0 +1,32 @@
+package org.ovirt.engine.core.common.businessentities.qos;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ovirt.engine.core.common.businessentities.Identifiable;
+
+public enum QosType implements Identifiable {
+    STORAGE(1);
+
+    private int value;
+    private static final Map<Integer, QosType> valueToStatus = new 
HashMap<Integer, QosType>();
+
+    static {
+        for (QosType status : values()) {
+            valueToStatus.put(status.getValue(), status);
+        }
+    }
+
+    private QosType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static QosType forValue(int value) {
+        return valueToStatus.get(value);
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/StorageQos.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/StorageQos.java
new file mode 100644
index 0000000..99d7ba6
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/qos/StorageQos.java
@@ -0,0 +1,148 @@
+package org.ovirt.engine.core.common.businessentities.qos;
+
+import java.io.Serializable;
+
+import org.ovirt.engine.core.common.config.ConfigValues;
+import org.ovirt.engine.core.common.utils.ObjectUtils;
+import org.ovirt.engine.core.common.validation.annotation.ConfiguredRange;
+
+public class StorageQos extends QosBase implements Serializable {
+
+    public StorageQos() {
+        super(QosType.STORAGE);
+    }
+
+    private static final long serialVersionUID = 1122123549710787758L;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxThroughputUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxThroughput;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxReadThroughputUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxReadThroughput;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxWriteThroughputUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxWriteThroughput;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxIopsUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxIops;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxReadIopsUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxReadIops;
+
+    @ConfiguredRange(min = 0, maxConfigValue = 
ConfigValues.MaxWriteIopsUpperBoundQosValue,
+            message = "ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES")
+    private Integer maxWriteIops;
+
+    public Integer getMaxThroughput() {
+        return maxThroughput;
+    }
+
+    public void setMaxThroughput(Integer maxThroughput) {
+        this.maxThroughput = maxThroughput;
+    }
+
+    public Integer getMaxReadThroughput() {
+        return maxReadThroughput;
+    }
+
+    public void setMaxReadThroughput(Integer maxReadThroughput) {
+        this.maxReadThroughput = maxReadThroughput;
+    }
+
+    public Integer getMaxWriteThroughput() {
+        return maxWriteThroughput;
+    }
+
+    public void setMaxWriteThroughput(Integer maxWriteThroughput) {
+        this.maxWriteThroughput = maxWriteThroughput;
+    }
+
+    public Integer getMaxIops() {
+        return maxIops;
+    }
+
+    public void setMaxIops(Integer maxIops) {
+        this.maxIops = maxIops;
+    }
+
+    public Integer getMaxReadIops() {
+        return maxReadIops;
+    }
+
+    public void setMaxReadIops(Integer maxReadIops) {
+        this.maxReadIops = maxReadIops;
+    }
+
+    public Integer getMaxWriteIops() {
+        return maxWriteIops;
+    }
+
+    public void setMaxWriteIops(Integer maxWriteIops) {
+        this.maxWriteIops = maxWriteIops;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return super.equals(obj)
+                && equalValues((QosBase) obj);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((maxIops == null) ? 0 : maxIops.hashCode());
+        result = prime * result + ((maxReadIops == null) ? 0 : 
maxReadIops.hashCode());
+        result = prime * result + ((maxReadThroughput == null) ? 0 : 
maxReadThroughput.hashCode());
+        result = prime * result + ((maxThroughput == null) ? 0 : 
maxThroughput.hashCode());
+        result = prime * result + ((maxWriteIops == null) ? 0 : 
maxWriteIops.hashCode());
+        result = prime * result + ((maxWriteThroughput == null) ? 0 : 
maxWriteThroughput.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equalValues(QosBase obj) {
+        if (!(obj instanceof StorageQos)) {
+            return false;
+        }
+        StorageQos other = (StorageQos) obj;
+        return ObjectUtils.objectsEqual(maxThroughput, 
other.getMaxThroughput())
+                && ObjectUtils.objectsEqual(maxReadThroughput, 
other.getMaxReadThroughput())
+                && ObjectUtils.objectsEqual(maxWriteThroughput, 
other.getMaxWriteThroughput())
+                && ObjectUtils.objectsEqual(maxIops, other.getMaxIops())
+                && ObjectUtils.objectsEqual(maxReadIops, 
other.getMaxReadIops())
+                && ObjectUtils.objectsEqual(maxWriteIops, 
other.getMaxWriteIops());
+    }
+
+    @Override
+    public String getString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("[")
+                .append("Throughput")
+                .append("{")
+                .append("max=")
+                .append(maxThroughput)
+                .append("max read=")
+                .append(maxReadThroughput)
+                .append("max write=")
+                .append(maxWriteThroughput)
+                .append("}")
+                .append("IOPS")
+                .append("{")
+                .append("max=")
+                .append(maxIops)
+                .append("max read=")
+                .append(maxReadIops)
+                .append("max write=")
+                .append(maxWriteIops)
+                .append("}")
+                .append("]");
+        return builder.toString();
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
index 9f154bb..1c0c5a6 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java
@@ -1890,5 +1890,29 @@
     @DefaultValueAttribute("false")
     JsonProtocolSupported,
 
-    Invalid
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxThroughputUpperBoundQosValue,
+
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxReadThroughputUpperBoundQosValue,
+
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxWriteThroughputUpperBoundQosValue,
+
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxIopsUpperBoundQosValue,
+
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxReadIopsUpperBoundQosValue,
+
+    @TypeConverterAttribute(Integer.class)
+    @DefaultValueAttribute("1000000")
+    MaxWriteIopsUpperBoundQosValue,
+
+    Invalid;
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 4dc8112..cd55a46 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -954,6 +954,13 @@
     ACTION_TYPE_FAILED_RNG_SOURCE_NOT_SUPPORTED(ErrorType.CONFLICT),
     ACTION_TYPE_RNG_MUST_BE_SPECIFIED(ErrorType.BAD_PARAMETERS),
 
+    // QoS
+    ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_QOS_STORAGE_POOL_NOT_EXIST(ErrorType.BAD_PARAMETERS),
+    QOS_NAME_NOT_NULL(ErrorType.BAD_PARAMETERS),
+    QOS_NAME_TOO_LONG(ErrorType.BAD_PARAMETERS),
+    QOS_NAME_INVALID(ErrorType.BAD_PARAMETERS),
+
     // network QoS
     ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES(ErrorType.BAD_PARAMETERS),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 5f48dfc..cd64d03 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1111,6 +1111,9 @@
 ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS=Cannot ${action} ${type}. 
Gluster operation is in progress in cluster. Please try again.
 ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is 
required.
 
+ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.
+ACTION_TYPE_FAILED_QOS_STORAGE_POOL_NOT_EXIST=Cannot ${action} ${type}. 
Invalid data center.
+
 ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. All 
three values are needed in order to define QoS on each network directions.
 ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES=Cannot ${action} ${type}. 
Negative values are not allowed.
 ACTION_TYPE_FAILED_NETWORK_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. 
Values are out of range.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index cc39bab..a25b257 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -3048,6 +3048,12 @@
     @DefaultStringValue("Cannot ${action} ${type}. QoS cannot be configured 
such that Peak is set lower than Average, but it was configured so on the 
following network(s): 
${ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE_LIST}.")
     String ACTION_TYPE_FAILED_HOST_NETWORK_QOS_PEAK_LOWER_THAN_AVERAGE();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Values are out of range.")
+    String ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Invalid data center")
+    String ACTION_TYPE_FAILED_QOS_STORAGE_POOL_NOT_EXIST();
+
     @DefaultStringValue("QoS name cannot be empty.")
     String QOS_NAME_NOT_NULL();
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
index 469625a..3f176fd 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
@@ -206,6 +206,9 @@
 
                <!--QoS-->
                <include 
name="common/businessentities/network/NetworkQoS.java"/>
+               <include name="common/businessentities/qos/QosBase.java"/>
+               <include name="common/businessentities/qos/QosType.java"/>
+               <include name="common/businessentities/qos/StorageQos.java"/>
 
                <!-- Misc -->
                <include name="common/AuditLogType.java" />
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 7f8fc91..e6dc7ce 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -1086,6 +1086,8 @@
 ACTION_TYPE_FAILED_GLUSTER_OPERATION_INPROGRESS=Cannot ${action} ${type}. 
Gluster operation is in progress in cluster. Please try again.
 ACTION_TYPE_FAILED_TAG_ID_REQUIRED=Cannot ${action} ${type}. Tag ID is 
required.
 
+ACTION_TYPE_FAILED_QOS_OUT_OF_RANGE_VALUES=Cannot ${action} ${type}. Values 
are out of range.
+ACTION_TYPE_FAILED_QOS_STORAGE_POOL_NOT_EXIST=Cannot ${action} ${type}. 
Invalid data center.
 
 ACTION_TYPE_FAILED_NETWORK_QOS_MISSING_VALUES=Cannot ${action} ${type}. All 
three values are needed in order to define QoS on each network directions.
 ACTION_TYPE_FAILED_NETWORK_QOS_NEGATIVE_VALUES=Cannot ${action} ${type}. 
Negative values are not allowed.


-- 
To view, visit http://gerrit.ovirt.org/31803
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a9af59277b5055453159f002f19046c0051d8ff
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to