cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [1/2] git commit: updated refs/heads/master to e86b612
Date Mon, 28 Oct 2013 20:02:38 GMT
Updated Branches:
  refs/heads/master 92f97248a -> e86b61275


ResourceDetails - added createDetail to ResourceDetailDao interface to provide generic way
of creating resourceDetail DB objects


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

Branch: refs/heads/master
Commit: e86b6127500d448ca72fa0dd6ffc76e42192632b
Parents: d0090a0
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Oct 28 12:53:00 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Oct 28 12:53:53 2013 -0700

----------------------------------------------------------------------
 .../cloud/dc/dao/DataCenterDetailsDaoImpl.java  |  8 ++--
 .../src/com/cloud/dc/dao/ResourceDetailDao.java |  2 +
 .../network/dao/NetworkDetailsDaoImpl.java      |  5 ++
 .../dao/ServiceOfferingDetailsDaoImpl.java      |  7 ++-
 .../storage/dao/StoragePoolDetailsDaoImpl.java  |  5 ++
 .../storage/dao/VMTemplateDetailsDaoImpl.java   |  7 +--
 .../cloud/storage/dao/VolumeDetailsDaoImpl.java |  7 ++-
 .../src/com/cloud/vm/dao/NicDetailDaoImpl.java  |  6 ++-
 .../com/cloud/vm/dao/UserVmDetailsDaoImpl.java  |  7 ++-
 .../db/PrimaryDataStoreDetailsDaoImpl.java      |  8 ++--
 .../metadata/ResourceMetaDataManagerImpl.java   | 50 ++++++--------------
 11 files changed, 59 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
index eb9176d..bc0621d 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
@@ -28,9 +28,6 @@ import com.cloud.dc.DataCenterDetailVO;
 @Local(value=DataCenterDetailsDao.class)
 public class DataCenterDetailsDaoImpl extends ResourceDetailDaoBase<DataCenterDetailVO>
implements DataCenterDetailsDao, ScopedConfigStorage {
     
-    public DataCenterDetailsDaoImpl() {
-    }
-    
     @Override
     public Scope getScope() {
         return ConfigKey.Scope.Zone;
@@ -42,4 +39,9 @@ public class DataCenterDetailsDaoImpl extends ResourceDetailDaoBase<DataCenterDe
         return vo == null ? null : vo.getValue();
     }
 
+    @Override
+    public DataCenterDetailVO createDetail(long resourceId, String key, String value) {
+        return new DataCenterDetailVO(resourceId, key, value);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/dc/dao/ResourceDetailDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ResourceDetailDao.java b/engine/schema/src/com/cloud/dc/dao/ResourceDetailDao.java
index 85d2c78..e47e6f3 100644
--- a/engine/schema/src/com/cloud/dc/dao/ResourceDetailDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/ResourceDetailDao.java
@@ -37,4 +37,6 @@ public interface ResourceDetailDao<R extends ResourceDetail> extends
GenericDao<
     public void addDetails(List<R> details);
     
     public void addDetail(R detail);
+    
+    public R createDetail(long resourceId, String key, String value);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
index 915e184..7f43f44 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java
@@ -26,4 +26,9 @@ import com.cloud.dc.dao.ResourceDetailDaoBase;
 @Local(value=NetworkDetailsDao.class)
 public class NetworkDetailsDaoImpl extends ResourceDetailDaoBase<NetworkDetailVO> implements
NetworkDetailsDao {
 
+    @Override
+    public NetworkDetailVO createDetail(long resourceId, String key, String value) {
+        return new NetworkDetailVO(resourceId, key, value);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
index 6cac9da..96f1085 100644
--- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
@@ -27,7 +27,10 @@ import com.cloud.service.ServiceOfferingDetailsVO;
 @Local(value=ServiceOfferingDetailsDao.class)
 public class ServiceOfferingDetailsDaoImpl extends ResourceDetailDaoBase<ServiceOfferingDetailsVO>
         implements ServiceOfferingDetailsDao {
-    public ServiceOfferingDetailsDaoImpl() {
-        
+
+    @Override
+    public ServiceOfferingDetailsVO createDetail(long resourceId, String key, String value)
{
+        return new ServiceOfferingDetailsVO(resourceId, key, value);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
index 6d7991f..521f325 100644
--- a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
@@ -42,4 +42,9 @@ public class StoragePoolDetailsDaoImpl extends ResourceDetailDaoBase<StoragePool
         StoragePoolDetailVO vo = findDetail(id, key.key());
         return vo == null ? null : vo.getValue();
     }
+
+    @Override
+    public StoragePoolDetailVO createDetail(long resourceId, String key, String value) {
+        return new StoragePoolDetailVO(resourceId, key, value);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
index 384b2d6..ad3f1d5 100644
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
@@ -26,8 +26,9 @@ import com.cloud.storage.VMTemplateDetailVO;
 @Component
 @Local(value = VMTemplateDetailsDao.class)
 public class VMTemplateDetailsDaoImpl extends ResourceDetailDaoBase<VMTemplateDetailVO>
implements VMTemplateDetailsDao {
-    public VMTemplateDetailsDaoImpl(){
-        
+
+    @Override
+    public VMTemplateDetailVO createDetail(long resourceId, String key, String value) {
+        return new VMTemplateDetailVO(resourceId, key, value);
     }
-    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
index c62b66a..26fdd2f 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
@@ -26,7 +26,10 @@ import com.cloud.storage.VolumeDetailVO;
 @Component
 @Local(value=VolumeDetailsDao.class)
 public class VolumeDetailsDaoImpl extends ResourceDetailDaoBase<VolumeDetailVO> implements
VolumeDetailsDao {
-    public VolumeDetailsDaoImpl() {
-        
+
+    @Override
+    public VolumeDetailVO createDetail(long resourceId, String key, String value) {
+        return new VolumeDetailVO(resourceId, key, value);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
index a009025..afab4fd 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
@@ -26,7 +26,9 @@ import com.cloud.vm.NicDetailVO;
 @Component
 @Local (value={NicDetailDao.class})
 public class NicDetailDaoImpl extends ResourceDetailDaoBase<NicDetailVO> implements
NicDetailDao {
-    public NicDetailDaoImpl() {
-        
+
+    @Override
+    public NicDetailVO createDetail(long resourceId, String key, String value) {
+        return new NicDetailVO(resourceId, key, value);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
index ba72f25..2829192 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
@@ -26,7 +26,10 @@ import com.cloud.vm.UserVmDetailVO;
 @Component
 @Local(value=UserVmDetailsDao.class)
 public class UserVmDetailsDaoImpl extends ResourceDetailDaoBase<UserVmDetailVO> implements
UserVmDetailsDao {
-    public UserVmDetailsDaoImpl() {
-        
+
+    @Override
+    public UserVmDetailVO createDetail(long resourceId, String key, String value) {
+        return new UserVmDetailVO(resourceId, key, value);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
index 13b19d0..a1470a3 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
@@ -25,8 +25,10 @@ import com.cloud.dc.dao.ResourceDetailDaoBase;
 @Component
 public class PrimaryDataStoreDetailsDaoImpl extends ResourceDetailDaoBase<PrimaryDataStoreDetailVO>
implements
         PrimaryDataStoreDetailsDao {
-    
-    public PrimaryDataStoreDetailsDaoImpl() {
-        
+
+    @Override
+    public PrimaryDataStoreDetailVO createDetail(long resourceId, String key, String value)
{
+        return new PrimaryDataStoreDetailVO(resourceId, key, value);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e86b6127/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index c94f32f..9a61a67 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -26,26 +26,20 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.ResourceDetail;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
-import com.cloud.dc.DataCenterDetailVO;
 import com.cloud.dc.dao.DataCenterDetailsDao;
 import com.cloud.dc.dao.ResourceDetailDao;
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.dao.NetworkDetailVO;
 import com.cloud.network.dao.NetworkDetailsDao;
 import com.cloud.server.ResourceMetaDataService;
 import com.cloud.server.ResourceTag.ResourceObjectType;
 import com.cloud.server.TaggedResourceService;
-import com.cloud.service.ServiceOfferingDetailsVO;
 import com.cloud.service.dao.ServiceOfferingDetailsDao;
-import com.cloud.storage.VMTemplateDetailVO;
-import com.cloud.storage.VolumeDetailVO;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
 import com.cloud.storage.dao.VolumeDetailsDao;
 import com.cloud.utils.component.ManagerBase;
@@ -53,8 +47,6 @@ import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionStatus;
-import com.cloud.vm.NicDetailVO;
-import com.cloud.vm.UserVmDetailVO;
 import com.cloud.vm.dao.NicDetailDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
 
@@ -119,7 +111,6 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
             @Override
             public Boolean doInTransaction(TransactionStatus status) {
                 for (String key : details.keySet()) {
-                    long id = _taggedResourceMgr.getResourceId(resourceId, resourceType);
                     String value = details.get(key);
 
                     if (value == null || value.isEmpty()) {
@@ -127,33 +118,16 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
                     }
 
                     DetailDaoHelper newDetailDaoHelper = new DetailDaoHelper(resourceType);
-                    ResourceDetail detail = null;
+                    ResourceDetail detail = newDetailDaoHelper.createDetail( _taggedResourceMgr.getResourceId(resourceId,
resourceType), key, value);
                     
-                    // TODO - Have a better design here for getting the DAO.
-                    if(resourceType == ResourceObjectType.Volume){
-                        detail = new VolumeDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.Nic){
-                        detail = new NicDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.Zone){
-                        detail = new DataCenterDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.Network){
-                        detail = new NetworkDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.UserVm) {
-                        detail = new UserVmDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.Template) {
-                        detail = new VMTemplateDetailVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.ServiceOffering) {
-                        detail = new ServiceOfferingDetailsVO(id, key, value);
-                    } else if (resourceType == ResourceObjectType.Storage) {
-                        detail = new StoragePoolDetailVO(id, key, value);
-                    } else {
+                    if (detail == null) {
                         throw new UnsupportedOperationException("ResourceType " + resourceType
+ " doesn't support metadata");
+
                     }
                     newDetailDaoHelper.addDetail(detail);
                         
                 }
                 
-                
                 return true;
             }
         });
@@ -174,38 +148,42 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
 
     private class DetailDaoHelper {
         private ResourceObjectType resourceType;
+        private ResourceDetailDao<? super ResourceDetail> dao;
         
         private DetailDaoHelper(ResourceObjectType resourceType) {
             if (!resourceType.resourceMetadataSupport()) {
                 throw new UnsupportedOperationException("ResourceType " + resourceType +
" doesn't support metadata");
             }
             this.resourceType = resourceType;
-        }
-        
-        private void addDetail(ResourceDetail detail) {
-            ResourceDetailDao<ResourceDetail> dao = (ResourceDetailDao<ResourceDetail>)_daoMap.get(resourceType);
+            ResourceDetailDao<?> dao = _daoMap.get(resourceType);
             if (dao == null) {
                 throw new UnsupportedOperationException("ResourceType " + resourceType +
" doesn't support metadata");
             }
+            this.dao = (ResourceDetailDao)_daoMap.get(resourceType);
+        }
+        
+        private void addDetail(ResourceDetail detail) {
             dao.addDetail(detail);   
         }
         
         private void removeDetail(long resourceId, String key) {
-            ResourceDetailDao<? extends ResourceDetail> dao = _daoMap.get(resourceType);
             dao.removeDetail(resourceId, key);
         }
         
         private List<? extends ResourceDetail> getDetails(long resourceId) {
-            ResourceDetailDao<? extends ResourceDetail> dao = _daoMap.get(resourceType);
             List<? extends ResourceDetail> detailList = new ArrayList<ResourceDetail>();
       
             detailList = dao.findDetailsList(resourceId);
             return detailList;
         }
         
         private ResourceDetail getDetail(long resourceId, String key) {
-            ResourceDetailDao<? extends ResourceDetail> dao = _daoMap.get(resourceType);
             return dao.findDetail(resourceId, key);
         }
+        
+        private ResourceDetail createDetail(long resourceId, String key, String value) {
+            return dao.createDetail(resourceId, key, value);
+        }
+        
     }
     
     @Override


Mime
View raw message