You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/06/15 04:52:48 UTC

[48/50] [abbrv] merge to master

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f41c800d/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java
index a6355ad,6d0cde1..5ebfa7d
--- a/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/StoragePoolJoinDaoImpl.java
@@@ -28,27 -30,27 +28,27 @@@ import org.springframework.stereotype.C
  
  import com.cloud.api.ApiDBUtils;
  import com.cloud.api.query.vo.StoragePoolJoinVO;
++import com.cloud.capacity.Capacity;
  import com.cloud.configuration.dao.ConfigurationDao;
++import com.cloud.storage.ScopeType;
  import com.cloud.storage.StoragePool;
  import com.cloud.storage.StorageStats;
  import com.cloud.utils.db.GenericDaoBase;
  import com.cloud.utils.db.SearchBuilder;
  import com.cloud.utils.db.SearchCriteria;
  
--
  @Component
--@Local(value={StoragePoolJoinDao.class})
++@Local(value = { StoragePoolJoinDao.class })
  public class StoragePoolJoinDaoImpl extends GenericDaoBase<StoragePoolJoinVO, Long> implements StoragePoolJoinDao {
      public static final Logger s_logger = Logger.getLogger(StoragePoolJoinDaoImpl.class);
  
      @Inject
--    private ConfigurationDao  _configDao;
++    private ConfigurationDao _configDao;
  
      private final SearchBuilder<StoragePoolJoinVO> spSearch;
  
      private final SearchBuilder<StoragePoolJoinVO> spIdSearch;
  
--
      protected StoragePoolJoinDaoImpl() {
  
          spSearch = createSearchBuilder();
@@@ -62,10 -64,10 +62,6 @@@
          this._count = "select count(distinct id) from storage_pool_view WHERE ";
      }
  
--
--
--
--
      @Override
      public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool) {
          StoragePoolResponse poolResponse = new StoragePoolResponse();
@@@ -88,12 -90,12 +84,11 @@@
              poolResponse.setHypervisor(pool.getHypervisor().toString());
          }
  
--
--        long allocatedSize = pool.getUsedCapacity() +  pool.getReservedCapacity();
++        long allocatedSize = pool.getUsedCapacity() + pool.getReservedCapacity();
          poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
          poolResponse.setDiskSizeAllocated(allocatedSize);
  
--        //TODO: StatsCollector does not persist data
++        // TODO: StatsCollector does not persist data
          StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
          if (stats != null) {
              Long used = stats.getByteUsed();
@@@ -118,10 -120,10 +113,9 @@@
      public StoragePoolResponse setStoragePoolResponse(StoragePoolResponse response, StoragePoolJoinVO sp) {
          String tag = sp.getTag();
          if (tag != null) {
--            if ( response.getTags() != null && response.getTags().length() > 0){
++            if (response.getTags() != null && response.getTags().length() > 0) {
                  response.setTags(response.getTags() + "," + tag);
--            }
--            else{
++            } else {
                  response.setTags(tag);
              }
          }
@@@ -149,12 -151,13 +143,13 @@@
              poolResponse.setHypervisor(pool.getHypervisor().toString());
          }
  
--
-         long allocatedSize = pool.getUsedCapacity() +  pool.getReservedCapacity();
 -        short capacityType = pool.getScope() == ScopeType.HOST ? Capacity.CAPACITY_TYPE_LOCAL_STORAGE : Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED;
++        short capacityType = pool.getScope() == ScopeType.HOST ? Capacity.CAPACITY_TYPE_LOCAL_STORAGE
++                : Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED;
+         long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(), capacityType);
          poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
          poolResponse.setDiskSizeAllocated(allocatedSize);
  
--        //TODO: StatsCollector does not persist data
++        // TODO: StatsCollector does not persist data
          StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
          if (stats != null) {
              Long used = stats.getByteUsed();
@@@ -174,11 -177,11 +169,10 @@@
      }
  
      @Override
--    public StoragePoolResponse setStoragePoolForMigrationResponse(StoragePoolResponse response,
--            StoragePoolJoinVO sp) {
++    public StoragePoolResponse setStoragePoolForMigrationResponse(StoragePoolResponse response, StoragePoolJoinVO sp) {
          String tag = sp.getTag();
          if (tag != null) {
--            if ( response.getTags() != null && response.getTags().length() > 0){
++            if (response.getTags() != null && response.getTags().length() > 0) {
                  response.setTags(response.getTags() + "," + tag);
              } else {
                  response.setTags(tag);
@@@ -195,22 -198,22 +189,20 @@@
  
      }
  
--
--
      @Override
      public List<StoragePoolJoinVO> searchByIds(Long... spIds) {
          // set detail batch query size
          int DETAILS_BATCH_SIZE = 2000;
          String batchCfg = _configDao.getValue("detail.batch.query.size");
--        if ( batchCfg != null ){
++        if (batchCfg != null) {
              DETAILS_BATCH_SIZE = Integer.parseInt(batchCfg);
          }
          // query details by batches
          List<StoragePoolJoinVO> uvList = new ArrayList<StoragePoolJoinVO>();
          // query details by batches
          int curr_index = 0;
--        if ( spIds.length > DETAILS_BATCH_SIZE ){
--            while ( (curr_index + DETAILS_BATCH_SIZE ) <= spIds.length ) {
++        if (spIds.length > DETAILS_BATCH_SIZE) {
++            while ((curr_index + DETAILS_BATCH_SIZE) <= spIds.length) {
                  Long[] ids = new Long[DETAILS_BATCH_SIZE];
                  for (int k = 0, j = curr_index; j < curr_index + DETAILS_BATCH_SIZE; j++, k++) {
                      ids[k] = spIds[j];
@@@ -241,7 -244,7 +233,4 @@@
          return uvList;
      }
  
--
--
--
  }