Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 03D6F2004CA for ; Wed, 11 May 2016 18:02:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0266C160A09; Wed, 11 May 2016 16:02:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 24837160A14 for ; Wed, 11 May 2016 18:02:07 +0200 (CEST) Received: (qmail 16448 invoked by uid 500); 11 May 2016 16:02:07 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 16428 invoked by uid 99); 11 May 2016 16:02:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 May 2016 16:02:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CF686DFC55; Wed, 11 May 2016 16:02:06 +0000 (UTC) From: DaanHoogland To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: Taking fast and efficient volume snapshot... Content-Type: text/plain Message-Id: <20160511160206.CF686DFC55@git1-us-west.apache.org> Date: Wed, 11 May 2016 16:02:06 +0000 (UTC) archived-at: Wed, 11 May 2016 16:02:09 -0000 Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1403#discussion_r62876182 --- Diff: engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java --- @@ -361,59 +603,221 @@ private String getProperty(long snapshotId, String property) { } private Map getVolumeDetails(VolumeInfo volumeInfo) { - Map sourceDetails = new HashMap(); + Map volumeDetails = new HashMap(); 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 sourceDetails; + return volumeDetails; + } + + private Map getSnapshotDetails(SnapshotInfo snapshotInfo) { + Map snapshotDetails = new HashMap(); + + 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; } - public HostVO getHost(long dataStoreId) { - StoragePoolVO storagePoolVO = _storagePoolDao.findById(dataStoreId); + private HostVO getHost(SnapshotInfo snapshotInfo) { + HostVO hostVO = getHost(snapshotInfo.getDataCenterId(), true); - List clusters = _mgr.searchForClusters(storagePoolVO.getDataCenterId(), new Long(0), Long.MAX_VALUE, HypervisorType.XenServer.toString()); + if (hostVO == null) { + hostVO = getHost(snapshotInfo.getDataCenterId(), false); - if (clusters == null) { - throw new CloudRuntimeException("Unable to locate an applicable cluster"); + if (hostVO == null) { + throw new CloudRuntimeException("Unable to locate an applicable host in data center with ID = " + snapshotInfo.getDataCenterId()); + } } - for (Cluster cluster : clusters) { - if (cluster.getAllocationState() == AllocationState.Enabled) { - List hosts = _hostDao.findByClusterId(cluster.getId()); + return hostVO; + } - if (hosts != null) { - for (HostVO host : hosts) { - if (host.getResourceState() == ResourceState.Enabled) { - return host; - } - } + private HostVO getHost(Long zoneId, boolean computeClusterMustSupportResign) { + Preconditions.checkArgument(zoneId != null, "Zone ID cannot be null."); + + List hosts = _hostDao.listByDataCenterIdAndHypervisorType(zoneId, HypervisorType.XenServer); + + if (hosts == null) { + return null; + } + + List clustersToSkip = new ArrayList<>(); + + Collections.shuffle(hosts, random); + + for (HostVO host : hosts) { + if (computeClusterMustSupportResign) { + long clusterId = host.getClusterId(); + + if (clustersToSkip.contains(clusterId)) { + continue; + } + + if (_clusterDao.computeClusterSupportsResign(clusterId)) { + return host; + } + else { + clustersToSkip.add(clusterId); } } + else { + return host; + } } - throw new CloudRuntimeException("Unable to locate an applicable cluster"); + return null; } @Override public void copyAsync(Map volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback callback) { CopyCommandResult result = new CopyCommandResult(null, null); + result.setResult("Unsupported operation requested for copying data."); + callback.complete(result); } + + private Map getDetails(DataObject dataObj) { + if (dataObj instanceof VolumeInfo) { + return getVolumeDetails((VolumeInfo)dataObj); + } + else if (dataObj instanceof SnapshotInfo) { + return getSnapshotDetails((SnapshotInfo)dataObj); + } + + throw new CloudRuntimeException("'dataObj' must be of type 'VolumeInfo' or 'SnapshotInfo'."); + } + + private CopyCmdAnswer performResignature(DataObject dataObj, HostVO hostVO) { --- End diff -- performResigning seems a better name, @mike-tutkowski ??? --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---