cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [1/2] git commit: updated refs/heads/planner_reserve to 1959377
Date Wed, 24 Apr 2013 22:42:51 GMT
Updated Branches:
  refs/heads/planner_reserve a3aa28929 -> 1959377d3


Changes to the op_host_planner_reservation schema - removed unnescessray columns


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/526c0cc6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/526c0cc6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/526c0cc6

Branch: refs/heads/planner_reserve
Commit: 526c0cc6d5e7c6a6e513f61595e00f884bfedc1d
Parents: a3aa289
Author: Prachi Damle <prachi@cloud.com>
Authored: Wed Apr 24 15:39:24 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Wed Apr 24 15:39:24 2013 -0700

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in        |    3 +
 .../com/cloud/deploy/PlannerHostReservationVO.java |   60 +++++----------
 .../deploy/dao/PlannerHostReservationDao.java      |    2 +
 .../deploy/dao/PlannerHostReservationDaoImpl.java  |   23 ++++++
 setup/db/db/schema-410to420.sql                    |    7 +--
 5 files changed, 50 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526c0cc6/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 48c1ba9..a341f33 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -844,4 +844,7 @@
   <bean id="AffinityGroupVMMapDaoImpl" class="org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDaoImpl">
   </bean>
   
+  <bean id="PlannerHostReservationDaoImpl" class="com.cloud.deploy.dao.PlannerHostReservationDaoImpl">
+  </bean>
+  
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526c0cc6/server/src/com/cloud/deploy/PlannerHostReservationVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/PlannerHostReservationVO.java b/server/src/com/cloud/deploy/PlannerHostReservationVO.java
index 47e1457..cf5f031 100644
--- a/server/src/com/cloud/deploy/PlannerHostReservationVO.java
+++ b/server/src/com/cloud/deploy/PlannerHostReservationVO.java
@@ -19,12 +19,16 @@ package com.cloud.deploy;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 import org.apache.cloudstack.api.InternalIdentity;
 
+import com.cloud.deploy.DeploymentPlanner.PlannerResourceUsage;
+
 @Entity
 @Table(name = "op_host_planner_reservation")
 public class PlannerHostReservationVO implements InternalIdentity {
@@ -45,29 +49,27 @@ public class PlannerHostReservationVO implements InternalIdentity {
     @Column(name="cluster_id")
     private Long clusterId;
 
-    @Column(name = "resource_type")
-    private short resourceType;
-
-    @Column(name = "domain_id")
-    private long domainId;
-
-    @Column(name = "account_id")
-    private long accountId;
-
-    @Column(name = "deployment_planner")
-    private String deploymentPlanner;
+    @Column(name = "resource_usage")
+    @Enumerated(EnumType.STRING)
+    private PlannerResourceUsage resourceUsage;
 
     public PlannerHostReservationVO() {
     }
 
-    public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId,
short resourceType,
-            String planner) {
+    public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId)
{
+        this.hostId = hostId;
+        this.dataCenterId = dataCenterId;
+        this.podId = podId;
+        this.clusterId = clusterId;
+    }
+
+    public PlannerHostReservationVO(Long hostId, Long dataCenterId, Long podId, Long clusterId,
+            PlannerResourceUsage resourceUsage) {
         this.hostId = hostId;
         this.dataCenterId = dataCenterId;
         this.podId = podId;
         this.clusterId = clusterId;
-        this.resourceType = resourceType;
-        this.deploymentPlanner = planner;
+        this.resourceUsage = resourceUsage;
     }
 
     @Override
@@ -104,32 +106,12 @@ public class PlannerHostReservationVO implements InternalIdentity {
         this.clusterId = new Long(clusterId);
     }
 
-    public short getResourceType() {
-        return resourceType;
-    }
-
-    public void setResourceType(short resourceType) {
-        this.resourceType = resourceType;
-    }
-
-    public String getDeploymentPlanner() {
-        return deploymentPlanner;
-    }
-
-    public long getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(long domainId) {
-        this.domainId = domainId;
-    }
-
-    public long getAccountId() {
-        return accountId;
+    public PlannerResourceUsage getResourceUsage() {
+        return resourceUsage;
     }
 
-    public void setAccountId(long accountId) {
-        this.accountId = accountId;
+    public void setResourceUsage(PlannerResourceUsage resourceType) {
+        this.resourceUsage = resourceType;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526c0cc6/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java b/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
index 112af95..71e235d 100644
--- a/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
+++ b/server/src/com/cloud/deploy/dao/PlannerHostReservationDao.java
@@ -21,4 +21,6 @@ import com.cloud.utils.db.GenericDao;
 
 public interface PlannerHostReservationDao extends GenericDao<PlannerHostReservationVO,
Long> {
 
+    PlannerHostReservationVO findByHostId(long hostId);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526c0cc6/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java b/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
index ccda44b..7b12067 100644
--- a/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
+++ b/server/src/com/cloud/deploy/dao/PlannerHostReservationDaoImpl.java
@@ -16,12 +16,35 @@
 // under the License.
 package com.cloud.deploy.dao;
 
+import javax.annotation.PostConstruct;
 import javax.ejb.Local;
 import com.cloud.deploy.PlannerHostReservationVO;
 import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
 
 @Local(value = { PlannerHostReservationDao.class })
 public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostReservationVO,
Long> implements
         PlannerHostReservationDao {
 
+    private SearchBuilder<PlannerHostReservationVO> _hostIdSearch;
+
+    public PlannerHostReservationDaoImpl() {
+
+    }
+
+    @PostConstruct
+    protected void init() {
+        _hostIdSearch = createSearchBuilder();
+        _hostIdSearch.and("hostId", _hostIdSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+        _hostIdSearch.done();
+    }
+
+    @Override
+    public PlannerHostReservationVO findByHostId(long hostId) {
+        SearchCriteria<PlannerHostReservationVO> sc = _hostIdSearch.create();
+        sc.setParameters("hostId", hostId);
+        return findOneBy(sc);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/526c0cc6/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index d63bdf1..4350b65 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -725,15 +725,10 @@ CREATE TABLE `cloud`.`op_host_planner_reservation` (
   `pod_id` bigint unsigned,
   `cluster_id` bigint unsigned,
   `host_id` bigint unsigned,
-  `account_id` bigint unsigned,
-  `domain_id` bigint unsigned,
-  `deployment_planner` varchar(255) COMMENT 'Name of the Planner',
-  `resource_type` int(1) unsigned NOT NULL COMMENT 'shared(0) Vs dedicated(1)',
+  `resource_usage` varchar(255) COMMENT 'Shared(between planners) Vs Dedicated (exclusive
usage to a planner)',
   PRIMARY KEY  (`id`),
   INDEX `i_op_host_planner_reservation__host_type`(`host_id`, `resource_type`),
   CONSTRAINT `fk_planner_reservation__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`)
ON DELETE CASCADE,
-  CONSTRAINT `fk_planner_reservation__account_id` FOREIGN KEY `fk_resource_count__account_id`(`account_id`)
REFERENCES `account`(`id`) ON DELETE CASCADE,
-  CONSTRAINT `fk_planner_reservation__domain_id` FOREIGN KEY `fk_resource_count__domain_id`(`domain_id`)
REFERENCES `domain`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_planner_reservation__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES
`cloud`.`data_center`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_planner_reservation__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`)
ON DELETE CASCADE,
   CONSTRAINT `fk_planner_reservation__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`)
ON DELETE CASCADE


Mime
View raw message