cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/5] git commit: updated refs/heads/master to 3b511a1
Date Thu, 03 Dec 2015 18:54:59 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 186e0257c -> 3b511a139


CLOUDSTACK-9022: keep Destroyed volumes for sometime


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

Branch: refs/heads/master
Commit: 9077c9a5b47224b2d00978ff67e9af6957ec589b
Parents: e675250
Author: Wei Zhou <w.zhou@tech.leaseweb.com>
Authored: Tue Nov 3 17:04:55 2015 +0100
Committer: Wei Zhou <w.zhou@tech.leaseweb.com>
Committed: Mon Nov 30 20:43:13 2015 +0100

----------------------------------------------------------------------
 engine/schema/src/com/cloud/storage/dao/VolumeDao.java    |  3 +++
 .../schema/src/com/cloud/storage/dao/VolumeDaoImpl.java   | 10 ++++++++++
 server/src/com/cloud/configuration/Config.java            |  1 +
 server/src/com/cloud/storage/StorageManagerImpl.java      |  9 ++++++---
 4 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index 4959ce4..a05dc1f 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.storage.dao;
 
+import java.util.Date;
 import java.util.List;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -79,6 +80,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
 
     List<VolumeVO> listVolumesToBeDestroyed();
 
+    List<VolumeVO> listVolumesToBeDestroyed(Date date);
+
     ImageFormat getImageFormat(Long volumeId);
 
     List<VolumeVO> findReadyRootVolumesByInstance(long instanceId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index f573847..d53471f 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -331,6 +331,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
         AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
         AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getState(), Op.EQ);
         AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), Op.NEQ);
+        AllFieldsSearch.and("updateTime", AllFieldsSearch.entity().getUpdated(), SearchCriteria.Op.LT);
         AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), Op.EQ);
         AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), Op.EQ);
         AllFieldsSearch.done();
@@ -483,6 +484,15 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
     }
 
     @Override
+    public List<VolumeVO> listVolumesToBeDestroyed(Date date) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("state", Volume.State.Destroy);
+        sc.setParameters("updateTime", date);
+
+        return listBy(sc);
+    }
+
+    @Override
     public boolean updateState(com.cloud.storage.Volume.State currentState, Event event,
com.cloud.storage.Volume.State nextState, Volume vo, Object data) {
 
         Long oldUpdated = vo.getUpdatedCount();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 182ec50..d9abecd 100644
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -672,6 +672,7 @@ public enum Config {
             "86400",
             "The interval (in seconds) to wait before running the storage cleanup thread.",
             null),
+    StorageCleanupDelay("Advanced", StorageManager.class, Integer.class, "storage.cleanup.delay",
"86400", "Determines how long (in seconds) to wait before actually expunging destroyed volumes.
The default value = the default value of storage.cleanup.interval.", null),
     StorageCleanupEnabled("Advanced", StorageManager.class, Boolean.class, "storage.cleanup.enabled",
"true", "Enables/disables the storage cleanup thread.", null),
     UpdateWait("Advanced", AgentManager.class, Integer.class, "update.wait", "600", "Time
to wait (in seconds) before alerting on a updating agent", null),
     XapiWait("Advanced", AgentManager.class, Integer.class, "xapiwait", "60", "Time (in seconds)
to wait for XAPI to return", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9077c9a5/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index ba39e1f..595cf14 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -301,6 +301,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     boolean _templateCleanupEnabled = true;
     int _storageCleanupInterval;
     int _storagePoolAcquisitionWaitSeconds = 1800; // 30 minutes
+    int _storageCleanupDelay;
     int _downloadUrlCleanupInterval;
     int _downloadUrlExpirationInterval;
     // protected BigDecimal _overProvisioningFactor = new BigDecimal(1);
@@ -470,9 +471,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
 
         String time = configs.get("storage.cleanup.interval");
         _storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
+        time = configs.get("storage.cleanup.delay");
+        _storageCleanupDelay = NumbersUtil.parseInt(time, _storageCleanupInterval);
 
-        s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval:
" + _storageCleanupInterval + ", template cleanup enabled: " +
-                _templateCleanupEnabled);
+        s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval:
" + _storageCleanupInterval + ", delay: " + _storageCleanupDelay  +
+                ", template cleanup enabled: " + _templateCleanupEnabled);
 
         String cleanupInterval = configs.get("extract.url.cleanup.interval");
         _downloadUrlCleanupInterval = NumbersUtil.parseInt(cleanupInterval, 7200);
@@ -1111,7 +1114,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
 
                     cleanupSecondaryStorage(recurring);
 
-                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed();
+                    List<VolumeVO> vols = _volsDao.listVolumesToBeDestroyed(new Date(System.currentTimeMillis()
- ((long) _storageCleanupDelay << 10)));
                     for (VolumeVO vol : vols) {
                         try {
                             volService.expungeVolumeAsync(volFactory.getVolume(vol.getId()));


Mime
View raw message