cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/4.2 to 08e722d
Date Sat, 20 Jul 2013 19:11:45 GMT
Updated Branches:
  refs/heads/4.2 f604e3d9c -> 08e722dda


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/08e722dd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/08e722dd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/08e722dd

Branch: refs/heads/4.2
Commit: 08e722ddaee292ff387dca7833a8e0049568a134
Parents: f604e3d
Author: Min Chen <min.chen@citrix.com>
Authored: Sat Jul 20 11:42:20 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Sat Jul 20 11:43:11 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/08e722dd/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 54506c5..cded500 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
@@ -653,7 +653,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/08e722dd/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 5048f2a..a82714b 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
@@ -284,7 +284,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);
@@ -324,11 +328,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");
@@ -684,10 +688,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) {
@@ -745,16 +749,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;
@@ -1016,16 +1021,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;
@@ -1066,12 +1071,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) {
 
@@ -1220,8 +1225,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);
@@ -1334,24 +1340,24 @@ public class NfsSecondaryStorageResource extends ServerResourceBase
implements S
             final String result = executeWithNoWaitLock(determineSnapshotLockId(accountId,
volumeId),
                     new Callable<String>() {
 
-                        @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;
 
@@ -1425,16 +1431,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) {
@@ -1506,8 +1512,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase
implements S
         String bucket = s3.getBucketName();
         // List the objects in the source directory on S3
         final List<S3ObjectSummary> objectSummaries = S3Utils.getDirectory(s3, bucket,
this.TEMPLATE_ROOT_DIR);
-        if (objectSummaries == null)
+        if (objectSummaries == null) {
             return null;
+        }
         Map<String, TemplateProp> tmpltInfos = new HashMap<String, TemplateProp>();
         for (S3ObjectSummary objectSummary : objectSummaries) {
             String key = objectSummary.getKey();
@@ -1527,8 +1534,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase
implements S
         String bucket = s3.getBucketName();
         // List the objects in the source directory on S3
         final List<S3ObjectSummary> objectSummaries = S3Utils.getDirectory(s3, bucket,
this.VOLUME_ROOT_DIR);
-        if (objectSummaries == null)
+        if (objectSummaries == null) {
             return null;
+        }
         Map<Long, TemplateProp> tmpltInfos = new HashMap<Long, TemplateProp>();
         for (S3ObjectSummary objectSummary : objectSummaries) {
             String key = objectSummary.getKey();
@@ -1711,8 +1719,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);
     }
@@ -1928,16 +1937,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;
@@ -2003,8 +2012,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;
     }
@@ -2067,8 +2077,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) {
@@ -2093,8 +2104,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");
@@ -2310,8 +2322,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;
         }
 
@@ -2344,8 +2357,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);


Mime
View raw message