mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Change Upload table to store dataStoreId instead of hostId.
This commit is contained in:
parent
f16f92dd1d
commit
0a976d5fd5
@ -35,7 +35,7 @@ public interface Upload extends InternalIdentity, Identity {
|
||||
FTP_UPLOAD, HTTP_DOWNLOAD
|
||||
}
|
||||
|
||||
long getHostId();
|
||||
long getDataStoreId();
|
||||
|
||||
Date getCreated();
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ import javax.persistence.TemporalType;
|
||||
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
@Entity
|
||||
@Table(name="upload")
|
||||
@ -45,7 +44,7 @@ public class UploadVO implements Upload {
|
||||
private String uuid;
|
||||
|
||||
@Column(name="host_id")
|
||||
private long hostId;
|
||||
private long storeId;
|
||||
|
||||
@Column(name="type_id")
|
||||
private long typeId;
|
||||
@ -85,12 +84,12 @@ public class UploadVO implements Upload {
|
||||
private String installPath;
|
||||
|
||||
@Override
|
||||
public long getHostId() {
|
||||
return hostId;
|
||||
public long getDataStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setHostId(long hostId) {
|
||||
this.hostId = hostId;
|
||||
public void setDataStoreId(long hostId) {
|
||||
this.storeId = hostId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,7 +98,8 @@ public class UploadVO implements Upload {
|
||||
}
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ public class UploadVO implements Upload {
|
||||
|
||||
public UploadVO(long hostId, long templateId) {
|
||||
super();
|
||||
this.hostId = hostId;
|
||||
this.storeId = hostId;
|
||||
this.typeId = templateId;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class UploadVO implements Upload {
|
||||
Status uploadState, Type type,
|
||||
String uploadUrl, Mode mode) {
|
||||
super();
|
||||
this.hostId = hostId;
|
||||
this.storeId = hostId;
|
||||
this.typeId = typeId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.uploadState = uploadState;
|
||||
@ -142,7 +142,7 @@ public class UploadVO implements Upload {
|
||||
Status uploadState, int uploadPercent, Type type,
|
||||
Mode mode) {
|
||||
super();
|
||||
this.hostId = hostId;
|
||||
this.storeId = hostId;
|
||||
this.typeId = typeId;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.uploadState = uploadState;
|
||||
@ -182,7 +182,7 @@ public class UploadVO implements Upload {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof UploadVO) {
|
||||
UploadVO other = (UploadVO)obj;
|
||||
return (this.typeId==other.getTypeId() && this.hostId==other.getHostId() && this.type == other.getType());
|
||||
return (this.typeId==other.getTypeId() && this.storeId==other.getDataStoreId() && this.type == other.getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class UploadDaoImpl extends GenericDaoBase<UploadVO, Long> implements Upl
|
||||
typeUploadStatusSearch.done();
|
||||
|
||||
typeHostAndUploadStatusSearch = createSearchBuilder();
|
||||
typeHostAndUploadStatusSearch.and("host_id", typeHostAndUploadStatusSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
typeHostAndUploadStatusSearch.and("host_id", typeHostAndUploadStatusSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
typeHostAndUploadStatusSearch.and("upload_state", typeHostAndUploadStatusSearch.entity().getUploadState(), SearchCriteria.Op.EQ);
|
||||
typeHostAndUploadStatusSearch.done();
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
|
||||
|
||||
// Create Symlink at ssvm
|
||||
String uuid = UUID.randomUUID().toString() + path.substring(path.length() - 4) ; // last 4 characters of the path specify the format like .vhd
|
||||
DataStore secStore = this.storeMgr.getDataStore(ApiDBUtils.findUploadById(uploadId).getHostId(), DataStoreRole.Image);
|
||||
DataStore secStore = this.storeMgr.getDataStore(ApiDBUtils.findUploadById(uploadId).getDataStoreId(), DataStoreRole.Image);
|
||||
EndPoint ep = _epSelector.select(secStore);
|
||||
if( ep == null ) {
|
||||
errorString = "There is no secondary storage VM for secondary storage host " + secStore.getName();
|
||||
@ -459,14 +459,14 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
|
||||
for (UploadVO extractJob : extractJobs){
|
||||
if( getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS ){
|
||||
String path = extractJob.getInstallPath();
|
||||
DataStore secStore = this.storeMgr.getDataStore(extractJob.getHostId(), DataStoreRole.Image);
|
||||
DataStore secStore = this.storeMgr.getDataStore(extractJob.getDataStoreId(), DataStoreRole.Image);
|
||||
|
||||
|
||||
// Would delete the symlink for the Type and if Type == VOLUME then also the volume
|
||||
DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(),extractJob.getUploadUrl(), ((ImageStoreVO)secStore).getParent());
|
||||
EndPoint ep = _epSelector.select(secStore);
|
||||
if( ep == null ) {
|
||||
s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getHostId());
|
||||
s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getDataStoreId());
|
||||
continue; //TODO: why continue? why not break?
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -136,7 +136,7 @@ CREATE TABLE `cloud`.`template_store_ref` (
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the template_store entry was destroyed by the user or not',
|
||||
`is_copy` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'indicates whether this was copied ',
|
||||
PRIMARY KEY (`id`),
|
||||
-- CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_data_store` (`id`) ON DELETE CASCADE,
|
||||
-- CONSTRAINT `fk_template_store_ref__store_id` FOREIGN KEY `fk_template_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_template_store_ref__store_id`(`store_id`),
|
||||
CONSTRAINT `fk_template_store_ref__template_id` FOREIGN KEY `fk_template_store_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`),
|
||||
INDEX `i_template_store_ref__template_id`(`template_id`)
|
||||
@ -149,6 +149,10 @@ CREATE TABLE `cloud`.`template_store_ref` (
|
||||
-- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `s3_id`;
|
||||
-- ALTER TABLE `cloud`.`snapshots` DROP COLUMN `sechost_id`;
|
||||
|
||||
-- change upload host_id FK to point to image_store table
|
||||
ALTER TABLE `cloud`.`upload` DROP FOREIGN KEY `fk_upload__host_id`;
|
||||
ALTER TABLE `cloud`.`upload` ADD CONSTRAINT `fk_upload__store_id` FOREIGN KEY(`host_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE;
|
||||
|
||||
CREATE TABLE `cloud`.`snapshot_store_ref` (
|
||||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`store_id` bigint unsigned NOT NULL,
|
||||
@ -162,7 +166,7 @@ CREATE TABLE `cloud`.`snapshot_store_ref` (
|
||||
`state` varchar(255) NOT NULL,
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the snapshot_store entry was destroyed by the user or not',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_snapshot_store_ref__store_id` FOREIGN KEY `fk_snapshot_store_ref__store_id` (`store_id`) REFERENCES `image_data_store` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_snapshot_store_ref__store_id` FOREIGN KEY `fk_snapshot_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_snapshot_store_ref__store_id`(`store_id`),
|
||||
CONSTRAINT `fk_snapshot_store_ref__snapshot_id` FOREIGN KEY `fk_snapshot_store_ref__snapshot_id` (`snapshot_id`) REFERENCES `snapshots` (`id`),
|
||||
INDEX `i_snapshot_store_ref__snapshot_id`(`snapshot_id`)
|
||||
@ -189,7 +193,7 @@ CREATE TABLE `cloud`.`volume_store_ref` (
|
||||
`format` varchar(32) NOT NULL COMMENT 'format for the volume',
|
||||
`destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_data_store` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_volume_store_ref__store_id` FOREIGN KEY `fk_volume_store_ref__store_id` (`store_id`) REFERENCES `image_store` (`id`) ON DELETE CASCADE,
|
||||
INDEX `i_volume_store_ref__store_id`(`store_id`),
|
||||
CONSTRAINT `fk_volume_store_ref__volume_id` FOREIGN KEY `fk_volume_store_ref__volume_id` (`volume_id`) REFERENCES `volumes` (`id`),
|
||||
INDEX `i_volume_store_ref__volume_id`(`volume_id`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user