CLOUDSTACK-6175:s3.singleupload.max.size option not applicable for

backup snapshot on KVM.
This commit is contained in:
Min Chen 2014-02-26 11:51:24 -08:00
parent 4c83f80c80
commit 94257c0fc8
1 changed files with 13 additions and 2 deletions

View File

@ -18,6 +18,7 @@
*/
package com.cloud.hypervisor.kvm.storage;
import static com.cloud.utils.S3Utils.mputFile;
import static com.cloud.utils.S3Utils.putFile;
import java.io.BufferedOutputStream;
@ -566,13 +567,20 @@ public class KVMStorageProcessor implements StorageProcessor {
public Answer createTemplateFromSnapshot(CopyCommand cmd) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
protected String copyToS3(File srcFile, S3TO destStore, String destPath) {
protected String copyToS3(File srcFile, S3TO destStore, String destPath) throws InterruptedException {
final String bucket = destStore.getBucketName();
long srcSize = srcFile.length();
String key = destPath + S3Utils.SEPARATOR + srcFile.getName();
putFile(destStore, srcFile, bucket, key);
if (!destStore.getSingleUpload(srcSize)) {
mputFile(destStore, srcFile, bucket, key);
} else {
putFile(destStore, srcFile, bucket, key);
}
return key;
}
protected Answer copyToObjectStore(CopyCommand cmd) {
DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO();
@ -603,6 +611,9 @@ public class KVMStorageProcessor implements StorageProcessor {
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
newSnapshot.setPath(destPath);
return new CopyCmdAnswer(newSnapshot);
} catch (Exception e) {
s_logger.error("failed to upload" + srcPath, e);
return new CopyCmdAnswer("failed to upload" + srcPath + e.toString());
} finally {
try {
if (srcFile != null) {