cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/master to 37d5831
Date Wed, 14 Aug 2013 22:53:12 GMT
Updated Branches:
  refs/heads/master ae617b6a3 -> 37d58313c


CLOUDSTACK-4325: if userdispersing algorithm is used, then zone wide storages never been picked
up


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

Branch: refs/heads/master
Commit: 37d58313c9c90c2b3191b55b0cc6927d9f3d2077
Parents: ae617b6
Author: Edison Su <sudison@gmail.com>
Authored: Wed Aug 14 15:51:32 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Aug 14 15:52:55 2013 -0700

----------------------------------------------------------------------
 client/tomcatconf/componentContext.xml.in       |  1 -
 client/tomcatconf/nonossComponentContext.xml.in |  1 -
 .../src/com/cloud/storage/dao/VolumeDao.java    |  2 +-
 .../com/cloud/storage/dao/VolumeDaoImpl.java    | 27 +++++++++++++++-
 .../allocator/ZoneWideStoragePoolAllocator.java | 34 ++++++++++++++++++++
 5 files changed, 61 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37d58313/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index e0552aa..f36d0ee 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -223,7 +223,6 @@
           <ref bean="LocalStoragePoolAllocator"/>
           <ref bean="clusterScopeStoragePoolAllocator"/>
           <ref bean="zoneWideStoragePoolAllocator"/>
-          <ref bean="garbageCollectingStoragePoolAllocator"/>
       </list>
     </property>
   </bean>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37d58313/client/tomcatconf/nonossComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in
index 2be071e..90fd4b0 100644
--- a/client/tomcatconf/nonossComponentContext.xml.in
+++ b/client/tomcatconf/nonossComponentContext.xml.in
@@ -322,7 +322,6 @@
           <ref bean="LocalStoragePoolAllocator"/>
           <ref bean="clusterScopeStoragePoolAllocator"/>
           <ref bean="zoneWideStoragePoolAllocator"/>
-          <ref bean="garbageCollectingStoragePoolAllocator"/>
       </list>
     </property>
   </bean>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37d58313/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 0ba80a9..1f5083a 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -76,7 +76,7 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
     List<VolumeVO> findReadyRootVolumesByInstance(long instanceId);
 
     List<Long> listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long
accountId);
-
+    List<Long> listZoneWidePoolIdsByVolumeCount(long dcId, long accountId);
     /**
      * Gets the Total Primary Storage space allocated for an account
      * 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37d58313/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 efe41c9..bf28410 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -78,7 +78,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
 
     private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT pool.id,
SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT
JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? "
             + " AND pool.pod_id = ? AND pool.cluster_id = ? " + " GROUP BY pool.id ORDER
BY 2 ASC ";
-
+    private static final String ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT
pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool`
pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id =
? "
+            + " AND pool.scope = 'ZONE' AND pool.status='Up' " + " GROUP BY pool.id ORDER
BY 2 ASC ";
     @Override
     public List<VolumeVO> findDetachedByAccount(long accountId) {
         SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
@@ -481,6 +482,30 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
     }
 
     @Override
+    public List<Long> listZoneWidePoolIdsByVolumeCount(long dcId, long accountId) {
+
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        List<Long> result = new ArrayList<Long>();
+        try {
+            String sql = ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT;
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, accountId);
+            pstmt.setLong(2, dcId);
+
+            ResultSet rs = pstmt.executeQuery();
+            while (rs.next()) {
+                result.add(rs.getLong(1));
+            }
+            return result;
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("DB Exception on: " + ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT,
e);
+        } catch (Throwable e) {
+            throw new CloudRuntimeException("Caught: " + ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT,
e);
+        }
+    }
+
+    @Override
     @DB(txn = false)
     public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
         SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/37d58313/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
index 0288b17..38724fa 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ZoneWideStoragePoolAllocator.java
@@ -17,10 +17,13 @@
 package org.apache.cloudstack.storage.allocator;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.inject.Inject;
 
+import com.cloud.user.Account;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -101,4 +104,35 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator
{
         }
         return suitablePools;
     }
+    @Override
+    protected List<StoragePool> reorderPoolsByNumberOfVolumes(DeploymentPlan plan,
List<StoragePool> pools,
+                                                              Account account) {
+        if (account == null) {
+            return pools;
+        }
+        long dcId = plan.getDataCenterId();
+
+        List<Long> poolIdsByVolCount = _volumeDao.listZoneWidePoolIdsByVolumeCount(dcId,
+                account.getAccountId());
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("List of pools in ascending order of number of volumes for account
id: "
+                    + account.getAccountId() + " is: " + poolIdsByVolCount);
+        }
+
+        // now filter the given list of Pools by this ordered list
+        Map<Long, StoragePool> poolMap = new HashMap<Long, StoragePool>();
+        for (StoragePool pool : pools) {
+            poolMap.put(pool.getId(), pool);
+        }
+        List<Long> matchingPoolIds = new ArrayList<Long>(poolMap.keySet());
+
+        poolIdsByVolCount.retainAll(matchingPoolIds);
+
+        List<StoragePool> reorderedPools = new ArrayList<StoragePool>();
+        for (Long id : poolIdsByVolCount) {
+            reorderedPools.add(poolMap.get(id));
+        }
+
+        return reorderedPools;
+    }
 }


Mime
View raw message