cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [2/2] git commit: updated refs/heads/4.4 to c476312
Date Fri, 30 May 2014 17:08:29 GMT
FIXED CLOUDSTACK-6669 Support volume resize in usage server


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

Branch: refs/heads/4.4
Commit: c476312a10073240c1436664477c10219141ac6e
Parents: fab339e
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Fri May 30 11:47:56 2014 +0530
Committer: Daan Hoogland <daan@onecht.net>
Committed: Fri May 30 19:07:25 2014 +0200

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c476312a/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 4ceecbb..159380b 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -961,9 +961,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) {
@@ -1366,20 +1365,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 = _usageVolumeDao.createSearchCriteria();
             sc.addAnd("accountId", SearchCriteria.Op.EQ, event.getAccountId());
             sc.addAnd("id", SearchCriteria.Op.EQ, volId);
@@ -1389,6 +1377,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());
@@ -1400,7 +1389,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                 s_logger.debug("create volume with id : " + volId + " for account: " + event.getAccountId());
             }
             Account acct = _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);
             _usageVolumeDao.persist(volumeVO);
         } else if (EventTypes.EVENT_VOLUME_DELETE.equals(event.getType())) {
             SearchCriteria<UsageVolumeVO> sc = _usageVolumeDao.createSearchCriteria();


Mime
View raw message