Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1403#discussion_r59078742
  
    --- Diff: 
engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java
 ---
    @@ -361,59 +608,225 @@ private String getProperty(long snapshotId, String 
property) {
         }
     
         private Map<String, String> getVolumeDetails(VolumeInfo volumeInfo) {
    -        Map<String, String> sourceDetails = new HashMap<String, String>();
    +        Map<String, String> volumeDetails = new HashMap<String, String>();
     
             VolumeVO volumeVO = _volumeDao.findById(volumeInfo.getId());
     
             long storagePoolId = volumeVO.getPoolId();
             StoragePoolVO storagePoolVO = 
_storagePoolDao.findById(storagePoolId);
     
    -        sourceDetails.put(DiskTO.STORAGE_HOST, 
storagePoolVO.getHostAddress());
    -        sourceDetails.put(DiskTO.STORAGE_PORT, 
String.valueOf(storagePoolVO.getPort()));
    -        sourceDetails.put(DiskTO.IQN, volumeVO.get_iScsiName());
    +        volumeDetails.put(DiskTO.STORAGE_HOST, 
storagePoolVO.getHostAddress());
    +        volumeDetails.put(DiskTO.STORAGE_PORT, 
String.valueOf(storagePoolVO.getPort()));
    +        volumeDetails.put(DiskTO.IQN, volumeVO.get_iScsiName());
     
             ChapInfo chapInfo = _volumeService.getChapInfo(volumeInfo, 
volumeInfo.getDataStore());
     
             if (chapInfo != null) {
    -            sourceDetails.put(DiskTO.CHAP_INITIATOR_USERNAME, 
chapInfo.getInitiatorUsername());
    -            sourceDetails.put(DiskTO.CHAP_INITIATOR_SECRET, 
chapInfo.getInitiatorSecret());
    -            sourceDetails.put(DiskTO.CHAP_TARGET_USERNAME, 
chapInfo.getTargetUsername());
    -            sourceDetails.put(DiskTO.CHAP_TARGET_SECRET, 
chapInfo.getTargetSecret());
    +            volumeDetails.put(DiskTO.CHAP_INITIATOR_USERNAME, 
chapInfo.getInitiatorUsername());
    +            volumeDetails.put(DiskTO.CHAP_INITIATOR_SECRET, 
chapInfo.getInitiatorSecret());
    +            volumeDetails.put(DiskTO.CHAP_TARGET_USERNAME, 
chapInfo.getTargetUsername());
    +            volumeDetails.put(DiskTO.CHAP_TARGET_SECRET, 
chapInfo.getTargetSecret());
    +        }
    +
    +        return volumeDetails;
    +    }
    +
    +    private Map<String, String> getSnapshotDetails(SnapshotInfo 
snapshotInfo) {
    +        Map<String, String> snapshotDetails = new HashMap<String, 
String>();
    +
    +        long storagePoolId = snapshotInfo.getDataStore().getId();
    +        StoragePoolVO storagePoolVO = 
_storagePoolDao.findById(storagePoolId);
    +
    +        snapshotDetails.put(DiskTO.STORAGE_HOST, 
storagePoolVO.getHostAddress());
    +        snapshotDetails.put(DiskTO.STORAGE_PORT, 
String.valueOf(storagePoolVO.getPort()));
    +
    +        long snapshotId = snapshotInfo.getId();
    +
    +        snapshotDetails.put(DiskTO.IQN, getProperty(snapshotId, 
DiskTO.IQN));
    +
    +        snapshotDetails.put(DiskTO.CHAP_INITIATOR_USERNAME, 
getProperty(snapshotId, DiskTO.CHAP_INITIATOR_USERNAME));
    +        snapshotDetails.put(DiskTO.CHAP_INITIATOR_SECRET, 
getProperty(snapshotId, DiskTO.CHAP_INITIATOR_SECRET));
    +        snapshotDetails.put(DiskTO.CHAP_TARGET_USERNAME, 
getProperty(snapshotId, DiskTO.CHAP_TARGET_USERNAME));
    +        snapshotDetails.put(DiskTO.CHAP_TARGET_SECRET, 
getProperty(snapshotId, DiskTO.CHAP_TARGET_SECRET));
    +
    +        return snapshotDetails;
    +    }
    +
    +    private HostVO getHost(SnapshotInfo snapshotInfo) {
    +        HostVO hostVO = getHost(snapshotInfo.getDataCenterId(), true);
    +
    +        if (hostVO == null) {
    +            hostVO = getHost(snapshotInfo.getDataCenterId(), false);
    +
    +            if (hostVO == null) {
    +                throw new CloudRuntimeException("Unable to locate an 
applicable host");
    +            }
             }
     
    -        return sourceDetails;
    +        return hostVO;
         }
     
    -    public HostVO getHost(long dataStoreId) {
    -        StoragePoolVO storagePoolVO = 
_storagePoolDao.findById(dataStoreId);
    +    private HostVO getHost(Long zoneId, boolean 
computeClusterMustSupportResign) {
    +        if (zoneId == null) {
    +            throw new CloudRuntimeException("Zone ID cannot be null.");
    +        }
     
    -        List<? extends Cluster> clusters = 
_mgr.searchForClusters(storagePoolVO.getDataCenterId(), new Long(0), 
Long.MAX_VALUE, HypervisorType.XenServer.toString());
    +        List<? extends Cluster> clusters = _mgr.searchForClusters(zoneId, 
new Long(0), Long.MAX_VALUE, HypervisorType.XenServer.toString());
    --- End diff --
    
    ``new Long(0)`` avoids the constant pool -- placing unnecessary pressure on 
the garbage collector.  With autoboxing, ``0L`` will accomplish the same thing 
without skipping the constant pool.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to