You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/10/21 17:18:18 UTC

git commit: Adding displayName,description elements to policy model

Updated Branches:
  refs/heads/master 3b89866a9 -> 4e8ee776a


Adding displayName,description elements to policy model

Signed-off-by: Lahiru Sandaruwan <la...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/4e8ee776
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/4e8ee776
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/4e8ee776

Branch: refs/heads/master
Commit: 4e8ee776abdc0ce3e7763b62a8586aa8010c7af4
Parents: 3b89866
Author: Melan Nimesh <me...@gmail.com>
Authored: Mon Oct 21 18:35:21 2013 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Mon Oct 21 20:53:01 2013 +0530

----------------------------------------------------------------------
 .../autoscaler/policy/PolicyManager.java        |  8 +--
 .../policy/deployers/PolicyReader.java          | 10 ++-
 .../policy/model/AutoscalePolicy.java           | 64 +++++++++++++++++---
 3 files changed, 70 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4e8ee776/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
index 1447554..6b1e043 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
@@ -52,13 +52,13 @@ public class PolicyManager {
     }
     
 	public void addPolicy(AutoscalePolicy policy) throws InvalidPolicyException {
-		if (!policyListMap.containsKey(policy.getName())) {
+		if (!policyListMap.containsKey(policy.getId())) {
 			if(log.isDebugEnabled()){
-				log.debug("Adding policy :" + policy.getName());
+				log.debug("Adding policy :" + policy.getId());
 			}
-			policyListMap.put(policy.getName(), policy);
+			policyListMap.put(policy.getId(), policy);
 		} else {
-			throw new InvalidPolicyException("Specified service [" + policy.getName()
+			throw new InvalidPolicyException("Specified service [" + policy.getId()
 					+ "] already exists");
 		}
 	}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4e8ee776/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/PolicyReader.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/PolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/PolicyReader.java
index a698fca..6d44af1 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/PolicyReader.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/PolicyReader.java
@@ -73,7 +73,15 @@ public class PolicyReader  {
 			StAXOMBuilder builder = new StAXOMBuilder(parser);
 			OMElement docEle = builder.getDocumentElement();
 			if("AutoscalePolicy".equalsIgnoreCase(docEle.getLocalName())){
-				policy.setName(docEle.getAttributeValue(new QName("name")));
+				policy.setId(docEle.getAttributeValue(new QName("id")));
+				OMElement displayNameEle = docEle.getFirstChildWithName(new QName("displayName"));
+				if(displayNameEle!=null){
+					policy.setDisplayName(displayNameEle.getText());
+				}
+				OMElement descriptionEle = docEle.getFirstChildWithName(new QName("description"));
+				if(descriptionEle!=null){
+					policy.setDescription(descriptionEle.getText());
+				}
 				
 				//LoadThresholds
 				OMElement loadThresholdsEle = docEle.getFirstChildWithName(new QName("LoadThresholds"));

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4e8ee776/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/AutoscalePolicy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/AutoscalePolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/AutoscalePolicy.java
index 34d166c..9bf4cf0 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/AutoscalePolicy.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/AutoscalePolicy.java
@@ -26,7 +26,9 @@ public class AutoscalePolicy {
 
 	private LoadThresholds loadThresholds;
 	private HAPolicy haPolicy;
-	private String name;
+	private String id;
+	private String displayName;
+	private String description;
 
     /**
      * Gets the value of the loadThresholds property.
@@ -77,27 +79,75 @@ public class AutoscalePolicy {
     }
 
     /**
-     * Gets the value of the name property.
+     * Gets the value of the id property.
      * 
      * @return
      *     possible object is
      *     {@link String }
      *     
      */
-    public String getName() {
-        return name;
+    public String getId() {
+        return id;
     }
 
     /**
-     * Sets the value of the name property.
+     * Sets the value of the id property.
      * 
      * @param value
      *     allowed object is
      *     {@link String }
      *     
      */
-    public void setName(String value) {
-        this.name = value;
+    public void setId(String value) {
+        this.id = value;
     }
 
+    /**
+     * Gets the value of the displayName property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+	public String getDisplayName() {
+		return displayName;
+	}
+
+	 /**
+     * Sets the value of the displayName property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+	public void setDisplayName(String displayName) {
+		this.displayName = displayName;
+	}
+
+	 /**
+     * Gets the value of the description property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+	public String getDescription() {
+		return description;
+	}
+
+	 /**
+     * Sets the value of the description property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
 }