Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 82B6610971 for ; Sat, 20 Jul 2013 19:17:08 +0000 (UTC) Received: (qmail 53752 invoked by uid 500); 20 Jul 2013 19:17:08 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 53734 invoked by uid 500); 20 Jul 2013 19:17:08 -0000 Mailing-List: contact commits-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 commits@cloudstack.apache.org Received: (qmail 53727 invoked by uid 99); 20 Jul 2013 19:17:08 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Jul 2013 19:17:08 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C25F28AFC16; Sat, 20 Jul 2013 19:17:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mchen@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to f8b5a41 Date: Sat, 20 Jul 2013 19:17:07 +0000 (UTC) Updated Branches: refs/heads/master 78f1092df -> f8b5a4159 CLOUDSTACK-3419: [Object_Store_Refactor] Uploaded volume is being deleted while attaching it to guest VM. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f8b5a415 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f8b5a415 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f8b5a415 Branch: refs/heads/master Commit: f8b5a4159bc51c6f5ca40374c145dceb4dcbf246 Parents: 78f1092 Author: Min Chen Authored: Sat Jul 20 11:42:20 2013 -0700 Committer: Min Chen Committed: Sat Jul 20 12:16:55 2013 -0700 ---------------------------------------------------------------------- .../storage/volume/VolumeServiceImpl.java | 2 +- .../resource/NfsSecondaryStorageResource.java | 158 ++++++++++--------- 2 files changed, 87 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8b5a415/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java ---------------------------------------------------------------------- diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 89313e4..9338d38 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -639,7 +639,7 @@ public class VolumeServiceImpl implements VolumeService { srcVolume.processEvent(Event.OperationSuccessed); destVolume.processEvent(Event.OperationSuccessed, result.getAnswer()); - srcVolume.getDataStore().delete(srcVolume); + // srcVolume.getDataStore().delete(srcVolume); future.complete(res); } catch (Exception e) { res.setResult(e.toString()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8b5a415/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java index 054edd9..003c87a 100755 --- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java +++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java @@ -273,7 +273,11 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S newTemplTO.setSize(size); newDestTO = newTemplTO; } else { - return new CopyCmdAnswer("not implemented yet"); + VolumeObjectTO newVolTO = new VolumeObjectTO(); + newVolTO.setPath(finalDownloadPath); + newVolTO.setName(finalFileName); + newVolTO.setSize(size); + newDestTO = newVolTO; } return new CopyCmdAnswer(newDestTO); @@ -313,11 +317,11 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S File destFile = S3Utils.getFile(s3, s3.getBucketName(), srcData.getPath(), downloadDirectory, new FileNamingStrategy() { - @Override - public String determineFileName(final String key) { - return substringAfterLast(key, S3Utils.SEPARATOR); - } - }); + @Override + public String determineFileName(final String key) { + return substringAfterLast(key, S3Utils.SEPARATOR); + } + }); if (destFile == null) { return new CopyCmdAnswer("Can't find template"); @@ -589,10 +593,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S DownloadAnswer answer = new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED, swiftPath, swiftPath, file.length(), file.length(), md5sum - ); + ); return answer; } catch (Exception e) { - s_logger.debug("Failed to register template into swift", e); + s_logger.debug("Failed to register template into swift", e); return new DownloadAnswer(e.toString(), VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR); } finally { if (file != null) { @@ -650,16 +654,17 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S ext = filePath.substring(i + 1); } if (ext != null) { - if (ext.equalsIgnoreCase("vhd")) + if (ext.equalsIgnoreCase("vhd")) { return ImageFormat.VHD; - else if (ext.equalsIgnoreCase("qcow2")) + } else if (ext.equalsIgnoreCase("qcow2")) { return ImageFormat.QCOW2; - else if (ext.equalsIgnoreCase("ova")) + } else if (ext.equalsIgnoreCase("ova")) { return ImageFormat.OVA; - else if (ext.equalsIgnoreCase("tar")) + } else if (ext.equalsIgnoreCase("tar")) { return ImageFormat.TAR; - else if (ext.equalsIgnoreCase("img")) + } else if (ext.equalsIgnoreCase("img")) { return ImageFormat.RAW; + } } return null; @@ -921,16 +926,16 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } else if (dstore instanceof SwiftTO) { String path = cmd.getDirectory(); String volumeId = StringUtils.substringAfterLast(path, "/"); // assuming - // that - // the - // filename - // is - // the - // last - // section - // in - // the - // path + // that + // the + // filename + // is + // the + // last + // section + // in + // the + // path String result = swiftDelete((SwiftTO) dstore, "V-" + volumeId.toString(), ""); if (result != null) { String errMsg = "failed to delete snapshot for volume " + volumeId + " , err=" + result; @@ -971,12 +976,12 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S final File targetFile = S3Utils.getFile(s3, s3.getBucketName(), key, _storage.getFile(directoryName), new FileNamingStrategy() { - @Override - public String determineFileName(String key) { - return snapshotFileName; - } + @Override + public String determineFileName(String key) { + return snapshotFileName; + } - }); + }); if (cmd.getParent() != null) { @@ -1125,8 +1130,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S return new Answer(cmd, false, checksum); } finally { try { - if (is != null) + if (is != null) { is.close(); + } } catch (IOException e) { if (s_logger.isDebugEnabled()) { s_logger.debug("Could not close the file " + absoluteTemplatePath); @@ -1239,24 +1245,24 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S final String result = executeWithNoWaitLock(determineSnapshotLockId(accountId, volumeId), new Callable() { - @Override - public String call() throws Exception { - - if (deleteAllFlag) { - S3Utils.deleteDirectory(s3, bucket, determineSnapshotS3Directory(accountId, volumeId)); - } else { - S3Utils.deleteObject( - s3, - bucket, - determineSnapshotS3Key(accountId, volumeId, - determineSnapshotBackupFilename(name))); - } + @Override + public String call() throws Exception { + + if (deleteAllFlag) { + S3Utils.deleteDirectory(s3, bucket, determineSnapshotS3Directory(accountId, volumeId)); + } else { + S3Utils.deleteObject( + s3, + bucket, + determineSnapshotS3Key(accountId, volumeId, + determineSnapshotBackupFilename(name))); + } - return null; + return null; - } + } - }); + }); return result; @@ -1330,16 +1336,16 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } else if (dstore instanceof SwiftTO) { String path = obj.getPath(); String filename = StringUtils.substringAfterLast(path, "/"); // assuming - // that - // the - // filename - // is - // the - // last - // section - // in - // the - // path + // that + // the + // filename + // is + // the + // last + // section + // in + // the + // path String volumeId = StringUtils.substringAfterLast(StringUtils.substringBeforeLast(path, "/"), "/"); String result = swiftDelete((SwiftTO) dstore, "V-" + volumeId, filename); if (result != null) { @@ -1391,8 +1397,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S String bucket = s3.getBucketName(); // List the objects in the source directory on S3 final List objectSummaries = S3Utils.getDirectory(s3, bucket, this.TEMPLATE_ROOT_DIR); - if (objectSummaries == null) + if (objectSummaries == null) { return null; + } Map tmpltInfos = new HashMap(); for (S3ObjectSummary objectSummary : objectSummaries) { String key = objectSummary.getKey(); @@ -1412,8 +1419,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S String bucket = s3.getBucketName(); // List the objects in the source directory on S3 final List objectSummaries = S3Utils.getDirectory(s3, bucket, this.VOLUME_ROOT_DIR); - if (objectSummaries == null) + if (objectSummaries == null) { return null; + } Map tmpltInfos = new HashMap(); for (S3ObjectSummary objectSummary : objectSummaries) { String key = objectSummary.getKey(); @@ -1596,8 +1604,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S boolean success = true; String result; result = configureIpFirewall(ipList, cmd.getIsAppendAIp()); - if (result != null) + if (result != null) { success = false; + } return new Answer(cmd, success, result); } @@ -1807,16 +1816,16 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S Long volumeId = obj.getId(); String path = obj.getPath(); String filename = StringUtils.substringAfterLast(path, "/"); // assuming - // that - // the - // filename - // is - // the - // last - // section - // in - // the - // path + // that + // the + // filename + // is + // the + // last + // section + // in + // the + // path String result = swiftDelete((SwiftTO) dstore, "V-" + volumeId.toString(), filename); if (result != null) { String errMsg = "failed to delete volume " + filename + " , err=" + result; @@ -1882,8 +1891,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S @Override public Type getType() { - if (SecondaryStorageVm.Role.templateProcessor.toString().equals(_role)) + if (SecondaryStorageVm.Role.templateProcessor.toString().equals(_role)) { return Host.Type.SecondaryStorage; + } return Host.Type.SecondaryStorageCmdExecutor; } @@ -1946,8 +1956,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } } - if (_inSystemVM) + if (_inSystemVM) { _storage.mkdirs(_parent); + } _configSslScr = Script.findScript(getDefaultScriptsDir(), "config_ssl.sh"); if (_configSslScr != null) { @@ -1972,8 +1983,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } _role = (String) params.get("role"); - if (_role == null) + if (_role == null) { _role = SecondaryStorageVm.Role.templateProcessor.toString(); + } s_logger.info("Secondary storage runs in role " + _role); _guid = (String) params.get("guid"); @@ -2189,8 +2201,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S if (result != null) { s_logger.warn("Unable to mount " + nfsPath + " due to " + result); file = new File(root); - if (file.exists()) + if (file.exists()) { file.delete(); + } return null; } @@ -2223,8 +2236,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S final StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand(); fillNetworkInformation(cmd); - if (_publicIp != null) + if (_publicIp != null) { cmd.setPublicIpAddress(_publicIp); + } if (_inSystemVM) { Script command = new Script("/bin/bash", s_logger);