CLOUDSTACK-3510

Persist the download url in the db for volume download.
Signed off by : nitin mehta<nitin.mehta@citrix.com>

Conflicts:

	server/src/com/cloud/storage/VolumeManagerImpl.java
This commit is contained in:
Edison Su 2013-07-29 11:47:43 -07:00
parent 7d342e695b
commit d64c318f57
3 changed files with 30 additions and 3 deletions

View File

@ -97,6 +97,9 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
@Column(name = "url")
private String downloadUrl;
@Column(name = "download_url")
private String extractUrl;
@Column(name = "destroyed")
boolean destroyed = false;
@ -345,4 +348,11 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
this.refCnt--;
}
public String getExtractUrl() {
return extractUrl;
}
public void setExtractUrl(String extractUrl) {
this.extractUrl = extractUrl;
}
}

View File

@ -31,6 +31,11 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
@ -40,6 +45,7 @@ import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@ -56,6 +62,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.command.AttachAnswer;
@ -71,8 +78,6 @@ import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
@ -2784,6 +2789,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
extractMode = mode.equals(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD;
}
// Check if the url already exists
VolumeDataStoreVO volumeStoreRef = _volumeStoreDao.findByVolume(volumeId);
if(volumeStoreRef != null && volumeStoreRef.getExtractUrl() != null){
return volumeStoreRef.getExtractUrl();
}
// Clean up code to remove all those previous uploadVO and uploadMonitor code. Previous code is trying to fake an async operation purely in
// db table with uploadVO and async_job entry, but internal implementation is actually synchronous.
StoragePool srcPool = (StoragePool) dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
@ -2828,7 +2839,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
s_logger.debug("Storage unavailable");
}
}
return secStore.createEntityExtractUrl(vol.getPath(), vol.getFormat());
String extractUrl = secStore.createEntityExtractUrl(vol.getPath(), vol.getFormat());
volumeStoreRef = _volumeStoreDao.findByVolume(volumeId);
volumeStoreRef.setExtractUrl(extractUrl);
_volumeStoreDao.update(volumeStoreRef.getId(), volumeStoreRef);
return extractUrl;
}
private String getFormatForPool(StoragePool pool) {

View File

@ -226,6 +226,7 @@ CREATE TABLE `cloud`.`volume_store_ref` (
`local_path` varchar(255),
`install_path` varchar(255),
`url` varchar(255),
`download_url` varchar(255),
`state` varchar(255) NOT NULL,
`destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
`update_count` bigint unsigned,