You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2015/01/19 06:35:36 UTC
git commit: updated refs/heads/volume-upload to 7900ae5
Repository: cloudstack
Updated Branches:
refs/heads/volume-upload c5be9d0b9 -> 7900ae5d9
volume-upload: initializing state for volume and also setting the post url in volume_store_ref
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7900ae5d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7900ae5d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7900ae5d
Branch: refs/heads/volume-upload
Commit: 7900ae5d9f0f6be07745530e14fcd2ac18216c91
Parents: c5be9d0
Author: Koushik Das <ko...@apache.org>
Authored: Mon Jan 19 11:03:42 2015 +0530
Committer: Koushik Das <ko...@apache.org>
Committed: Mon Jan 19 11:03:42 2015 +0530
----------------------------------------------------------------------
.../com/cloud/storage/VolumeApiServiceImpl.java | 18 ++-
.../resource/NfsSecondaryStorageResource.java | 2 -
.../storage/template/UploadEntity.java | 114 +++++++++++++++++++
.../storage/template/uploadEntity.java | 113 ------------------
4 files changed, 127 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7900ae5d/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 3c22946..29ac7f1 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -31,13 +31,13 @@ import javax.inject.Inject;
import com.cloud.utils.EncryptionUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
import org.apache.cloudstack.api.command.user.volume.GetUploadParamsForVolumeCmd;
import org.apache.cloudstack.api.response.GetUploadParamsResponse;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand;
import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommandTypeAdapter;
import org.apache.log4j.Logger;
-
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
@@ -156,6 +156,7 @@ import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
@@ -262,7 +263,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
validateVolume(caller, ownerId, zoneId, volumeName, url, format, diskOfferingId);
- VolumeVO volume = persistVolume(owner, zoneId, volumeName, url, cmd.getFormat(), diskOfferingId);
+ VolumeVO volume = persistVolume(owner, zoneId, volumeName, url, cmd.getFormat(), diskOfferingId, Volume.State.Allocated);
VolumeInfo vol = volFactory.getVolume(volume.getId());
@@ -289,7 +290,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
validateVolume(caller, ownerId, zoneId, volumeName, null, format, diskOfferingId);
- VolumeVO volume = persistVolume(owner, zoneId, volumeName, null, cmd.getFormat(), diskOfferingId);
+ VolumeVO volume = persistVolume(owner, zoneId, volumeName, null, cmd.getFormat(), diskOfferingId, Volume.State.NotUploaded);
VolumeInfo vol = volFactory.getVolume(volume.getId());
@@ -304,6 +305,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
String url = "https://" + command.getEndPoint().getPublicAddr() + "/upload/" + command.getDataObject().getUuid();
response.setPostURL(new URL(url));
+ // set the post url, this is used in the monitoring thread to determine the SSVM
+ VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volume.getId());
+ if (volumeStore != null) {
+ volumeStore.setExtractUrl(url);
+ }
+
response.setId(UUID.fromString(command.getDataObject().getUuid()));
/*
@@ -395,7 +402,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
@DB
protected VolumeVO persistVolume(final Account owner, final Long zoneId, final String volumeName, final String url,
- final String format, final Long diskOfferingId) {
+ final String format, final Long diskOfferingId, final Volume.State state) {
return Transaction.execute(new TransactionCallback<VolumeVO>() {
@Override
public VolumeVO doInTransaction(TransactionStatus status) {
@@ -403,7 +410,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
volume.setPoolId(null);
volume.setDataCenterId(zoneId);
volume.setPodId(null);
- // to prevent a nullpointer deref I put the system account id here when no owner is given.
+ volume.setState(state); // initialize the state
+ // to prevent a null pointer deref I put the system account id here when no owner is given.
// TODO Decide if this is valid or whether throwing a CloudRuntimeException is more appropriate
volume.setAccountId((owner == null) ? Account.ACCOUNT_ID_SYSTEM : owner.getAccountId());
volume.setDomainId((owner == null) ? Domain.ROOT_DOMAIN : owner.getDomainId());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7900ae5d/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index d4edab3..ba51e3a 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -36,7 +36,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
-import java.io.PrintWriter;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -56,7 +55,6 @@ import org.apache.cloudstack.storage.template.UploadEntity;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7900ae5d/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/UploadEntity.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/UploadEntity.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/UploadEntity.java
new file mode 100644
index 0000000..7741ca5
--- /dev/null
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/UploadEntity.java
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.storage.template;
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+public class UploadEntity {
+ private long filesize;
+ private long downloadedsize;
+ private String filename;
+ private String absoluteFilePath;
+
+
+
+
+ public static enum Status {
+ UNKNOWN, IN_PROGRESS, COMPLETED, ERROR
+ }
+
+ private Status uploadState;
+ private FileOutputStream filewriter = null;
+ private String errorMessage=null;
+ private File file;
+
+ public UploadEntity(long filesize, Status status, String filename, String absoluteFilePath) {
+ this.filesize=filesize;
+ this.uploadState=status;
+ this.downloadedsize=0l;
+ this.filename=filename;
+ this.absoluteFilePath=absoluteFilePath;
+ }
+
+ public void setEntitysize(long filesize) {
+ this.filesize=filesize;
+ }
+
+ public void setStatus(Status status) {
+ this.uploadState = status;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage=errorMessage;
+ }
+
+ public FileOutputStream getFilewriter() {
+ return filewriter;
+ }
+
+ public long getEntitysize() {
+ return filesize;
+ }
+
+ public long getDownloadedsize() {
+ return downloadedsize;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public Status getUploadState() {
+ return uploadState;
+ }
+
+ public void setFilewriter(FileOutputStream filewriter) {
+ this.filewriter = filewriter;
+ }
+
+ public void incremetByteCount(long numberOfBytes) {
+ this.downloadedsize+= numberOfBytes;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+ public String getAbsoluteFilePath() {
+ return absoluteFilePath;
+ }
+
+ public void setAbsoluteFilePath(String absoluteFilePath) {
+ this.absoluteFilePath = absoluteFilePath;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7900ae5d/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/uploadEntity.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/uploadEntity.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/uploadEntity.java
deleted file mode 100644
index 6001bcb..0000000
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/uploadEntity.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.cloudstack.storage.template;
-
-
-import java.io.File;
-import java.io.FileOutputStream;
-
-public class UploadEntity {
- private long filesize;
- private long downloadedsize;
- private String filename;
- private String absoluteFilePath;
-
-
-
-
- public static enum Status {
- UNKNOWN, IN_PROGRESS, COMPLETED, ERROR
- }
-
- private Status uploadState;
- private FileOutputStream filewriter = null;
- private String errorMessage=null;
- private File file;
-
- public UploadEntity(long filesize, Status status, String filename, String absoluteFilePath){
- this.filesize=filesize;
- this.uploadState=status;
- this.downloadedsize=0l;
- this.filename=filename;
- this.absoluteFilePath=absoluteFilePath;
- }
-
- public void setEntitysize(long filesize){
- this.filesize=filesize;
- }
-
- public void setStatus(Status status) {
- this.uploadState = status;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage=errorMessage;
- }
-
- public FileOutputStream getFilewriter() {
- return filewriter;
- }
-
- public long getEntitysize() {
- return filesize;
- }
-
- public long getDownloadedsize() {
- return downloadedsize;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public Status getUploadState() {
- return uploadState;
- }
-
- public void setFilewriter(FileOutputStream filewriter) {
- this.filewriter = filewriter;
- }
-
- public void incremetByteCount(long numberOfBytes) {
- this.downloadedsize+= numberOfBytes;
- }
- public File getFile() {
- return file;
- }
-
- public void setFile(File file) {
- this.file = file;
- }
-
- public String getFilename() {
- return filename;
- }
-
- public void setFilename(String filename) {
- this.filename = filename;
- }
- public String getAbsoluteFilePath() {
- return absoluteFilePath;
- }
-
- public void setAbsoluteFilePath(String absoluteFilePath) {
- this.absoluteFilePath = absoluteFilePath;
- }
-
-
-}