cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [10/13] git commit: updated refs/heads/4.3 to 15ded4f
Date Mon, 24 Nov 2014 18:26:06 GMT
FIXED CLOUDSTACK-6669 Support volume resize in usage server

(cherry picked from commit bdde5335f9988e460a667da97ebe0cde2e74e7a1)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	usage/src/com/cloud/usage/UsageManagerImpl.java


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

Branch: refs/heads/4.3
Commit: 06a664b063d6e55fc969a016a6fc722e95d4bd23
Parents: 90c92ff
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Fri May 30 11:47:56 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Nov 24 23:47:04 2014 +0530

----------------------------------------------------------------------
 usage/src/com/cloud/usage/UsageManagerImpl.java | 22 +++++---------------
 1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06a664b0/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index f198fe0..ce7594f 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -924,9 +924,8 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
     }
     
     private boolean isVolumeEvent(String eventType) {
-        if (eventType == null) return false;
-        return (eventType.equals(EventTypes.EVENT_VOLUME_CREATE) ||
-                eventType.equals(EventTypes.EVENT_VOLUME_DELETE));
+        return eventType != null &&
+            (eventType.equals(EventTypes.EVENT_VOLUME_CREATE) || eventType.equals(EventTypes.EVENT_VOLUME_DELETE)
|| eventType.equals(EventTypes.EVENT_VOLUME_RESIZE));
     }
 
     private boolean isTemplateEvent(String eventType) {
@@ -1313,21 +1312,9 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
     }
 
     private void createVolumeHelperEvent(UsageEventVO event) {
-        
-        Long doId = -1L;
-        long zoneId = -1L;
-        Long templateId = -1L;
-        long size = -1L;
-        
         long volId = event.getResourceId();
-        if (EventTypes.EVENT_VOLUME_CREATE.equals(event.getType())) {
-            doId = event.getOfferingId();
-            zoneId = event.getZoneId();
-            templateId = event.getTemplateId();
-            size = event.getSize();
-        }
 
-        if (EventTypes.EVENT_VOLUME_CREATE.equals(event.getType())) {
+        if (EventTypes.EVENT_VOLUME_CREATE.equals(event.getType()) || EventTypes.EVENT_VOLUME_RESIZE.equals(event.getType()))
{
             SearchCriteria<UsageVolumeVO> sc = m_usageVolumeDao.createSearchCriteria();
             sc.addAnd("accountId", SearchCriteria.Op.EQ, event.getAccountId());
             sc.addAnd("id", SearchCriteria.Op.EQ, volId);
@@ -1337,6 +1324,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                 //This is a safeguard to avoid double counting of volumes.
                 s_logger.error("Found duplicate usage entry for volume: " + volId + " assigned
to account: " + event.getAccountId() + "; marking as deleted...");
             }
+            //an entry exists if it is a resize volume event. marking the existing deleted
and creating a new one in the case of resize.
             for (UsageVolumeVO volumesVO : volumesVOs) {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("deleting volume: " + volumesVO.getId() + " from account:
" + volumesVO.getAccountId());
@@ -1348,7 +1336,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                 s_logger.debug("create volume with id : " + volId + " for account: " + event.getAccountId());
             }
             Account acct = m_accountDao.findByIdIncludingRemoved(event.getAccountId());
-            UsageVolumeVO volumeVO = new UsageVolumeVO(volId, zoneId, event.getAccountId(),
acct.getDomainId(), doId, templateId, size, event.getCreateDate(), null);
+            UsageVolumeVO volumeVO = new UsageVolumeVO(volId, event.getZoneId(), event.getAccountId(),
acct.getDomainId(), event.getOfferingId(), event.getTemplateId(), event.getSize(), event.getCreateDate(),
null);
             m_usageVolumeDao.persist(volumeVO);
         } else if (EventTypes.EVENT_VOLUME_DELETE.equals(event.getType())) {
             SearchCriteria<UsageVolumeVO> sc = m_usageVolumeDao.createSearchCriteria();


Mime
View raw message