|
| 1 | +package com.cloud.storage; |
| 2 | + |
| 3 | +import java.util.Date; |
| 4 | + |
| 5 | +import javax.persistence.Column; |
| 6 | +import javax.persistence.Entity; |
| 7 | +import javax.persistence.EnumType; |
| 8 | +import javax.persistence.Enumerated; |
| 9 | +import javax.persistence.GeneratedValue; |
| 10 | +import javax.persistence.GenerationType; |
| 11 | +import javax.persistence.Id; |
| 12 | +import javax.persistence.Table; |
| 13 | +import javax.persistence.Temporal; |
| 14 | +import javax.persistence.TemporalType; |
| 15 | + |
| 16 | +//import com.cloud.storage.VMVolumeStorageResourceAssoc.Status; |
| 17 | +import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; |
| 18 | +import com.cloud.utils.db.GenericDaoBase; |
| 19 | + |
| 20 | +/** |
| 21 | + * Join table for storage hosts and volumes |
| 22 | + * @author Nitin |
| 23 | + * |
| 24 | + */ |
| 25 | +@Entity |
| 26 | +@Table(name="volume_host_ref") |
| 27 | +public class VolumeHostVO { |
| 28 | + @Id |
| 29 | + @GeneratedValue(strategy=GenerationType.IDENTITY) |
| 30 | + Long id; |
| 31 | + |
| 32 | + @Column(name="host_id") |
| 33 | + private long hostId; |
| 34 | + |
| 35 | + @Column(name="volume_id") |
| 36 | + private long volumeId; |
| 37 | + |
| 38 | + @Column(name=GenericDaoBase.CREATED_COLUMN) |
| 39 | + private Date created = null; |
| 40 | + |
| 41 | + @Column(name="last_updated") |
| 42 | + @Temporal(value=TemporalType.TIMESTAMP) |
| 43 | + private Date lastUpdated = null; |
| 44 | + |
| 45 | + @Column (name="download_pct") |
| 46 | + private int downloadPercent; |
| 47 | + |
| 48 | + @Column (name="size") |
| 49 | + private long size; |
| 50 | + |
| 51 | + @Column (name="physical_size") |
| 52 | + private long physicalSize; |
| 53 | + |
| 54 | + @Column (name="download_state") |
| 55 | + @Enumerated(EnumType.STRING) |
| 56 | + private Status downloadState; |
| 57 | + |
| 58 | + @Column(name="checksum") |
| 59 | + private String checksum; |
| 60 | + |
| 61 | + @Column (name="local_path") |
| 62 | + private String localDownloadPath; |
| 63 | + |
| 64 | + @Column (name="error_str") |
| 65 | + private String errorString; |
| 66 | + |
| 67 | + @Column (name="job_id") |
| 68 | + private String jobId; |
| 69 | + |
| 70 | + @Column (name="install_path") |
| 71 | + private String installPath; |
| 72 | + |
| 73 | + @Column (name="url") |
| 74 | + private String downloadUrl; |
| 75 | + |
| 76 | + @Column(name="is_copy") |
| 77 | + private boolean isCopy = false; |
| 78 | + |
| 79 | + @Column(name="destroyed") |
| 80 | + boolean destroyed = false; |
| 81 | + |
| 82 | + |
| 83 | + public String getInstallPath() { |
| 84 | + return installPath; |
| 85 | + } |
| 86 | + |
| 87 | + public long getHostId() { |
| 88 | + return hostId; |
| 89 | + } |
| 90 | + |
| 91 | + public void setHostId(long hostId) { |
| 92 | + this.hostId = hostId; |
| 93 | + } |
| 94 | + |
| 95 | + |
| 96 | + public long getVolumeId() { |
| 97 | + return volumeId; |
| 98 | + } |
| 99 | + |
| 100 | + |
| 101 | + public void setVolumeId(long volumeId) { |
| 102 | + this.volumeId = volumeId; |
| 103 | + } |
| 104 | + |
| 105 | + |
| 106 | + public int getDownloadPercent() { |
| 107 | + return downloadPercent; |
| 108 | + } |
| 109 | + |
| 110 | + |
| 111 | + public void setDownloadPercent(int downloadPercent) { |
| 112 | + this.downloadPercent = downloadPercent; |
| 113 | + } |
| 114 | + |
| 115 | + |
| 116 | + public void setDownloadState(Status downloadState) { |
| 117 | + this.downloadState = downloadState; |
| 118 | + } |
| 119 | + |
| 120 | + |
| 121 | + public long getId() { |
| 122 | + return id; |
| 123 | + } |
| 124 | + |
| 125 | + |
| 126 | + public Date getCreated() { |
| 127 | + return created; |
| 128 | + } |
| 129 | + |
| 130 | + |
| 131 | + public Date getLastUpdated() { |
| 132 | + return lastUpdated; |
| 133 | + } |
| 134 | + |
| 135 | + |
| 136 | + public void setLastUpdated(Date date) { |
| 137 | + lastUpdated = date; |
| 138 | + } |
| 139 | + |
| 140 | + |
| 141 | + public void setInstallPath(String installPath) { |
| 142 | + this.installPath = installPath; |
| 143 | + } |
| 144 | + |
| 145 | + |
| 146 | + public Status getDownloadState() { |
| 147 | + return downloadState; |
| 148 | + } |
| 149 | + |
| 150 | + public String getChecksum() { |
| 151 | + return checksum; |
| 152 | + } |
| 153 | + |
| 154 | + public void setChecksum(String checksum) { |
| 155 | + this.checksum = checksum; |
| 156 | + } |
| 157 | + |
| 158 | + public VolumeHostVO(long hostId, long volumeId) { |
| 159 | + super(); |
| 160 | + this.hostId = hostId; |
| 161 | + this.volumeId = volumeId; |
| 162 | + } |
| 163 | + |
| 164 | + public VolumeHostVO(long hostId, long volumeId, Date lastUpdated, |
| 165 | + int downloadPercent, Status downloadState, |
| 166 | + String localDownloadPath, String errorString, String jobId, |
| 167 | + String installPath, String downloadUrl, String checksum) { |
| 168 | + //super(); |
| 169 | + this.hostId = hostId; |
| 170 | + this.volumeId = volumeId; |
| 171 | + this.lastUpdated = lastUpdated; |
| 172 | + this.downloadPercent = downloadPercent; |
| 173 | + this.downloadState = downloadState; |
| 174 | + this.localDownloadPath = localDownloadPath; |
| 175 | + this.errorString = errorString; |
| 176 | + this.jobId = jobId; |
| 177 | + this.installPath = installPath; |
| 178 | + this.setDownloadUrl(downloadUrl); |
| 179 | + this.checksum = checksum; |
| 180 | + } |
| 181 | + |
| 182 | + protected VolumeHostVO() { |
| 183 | + |
| 184 | + } |
| 185 | + |
| 186 | + |
| 187 | + public void setLocalDownloadPath(String localPath) { |
| 188 | + this.localDownloadPath = localPath; |
| 189 | + } |
| 190 | + |
| 191 | + |
| 192 | + public String getLocalDownloadPath() { |
| 193 | + return localDownloadPath; |
| 194 | + } |
| 195 | + |
| 196 | + |
| 197 | + public void setErrorString(String errorString) { |
| 198 | + this.errorString = errorString; |
| 199 | + } |
| 200 | + |
| 201 | + |
| 202 | + public String getErrorString() { |
| 203 | + return errorString; |
| 204 | + } |
| 205 | + |
| 206 | + |
| 207 | + public void setJobId(String jobId) { |
| 208 | + this.jobId = jobId; |
| 209 | + } |
| 210 | + |
| 211 | + |
| 212 | + public String getJobId() { |
| 213 | + return jobId; |
| 214 | + } |
| 215 | + |
| 216 | + |
| 217 | + public boolean equals(Object obj) { |
| 218 | + if (obj instanceof VolumeHostVO) { |
| 219 | + VolumeHostVO other = (VolumeHostVO)obj; |
| 220 | + return (this.volumeId==other.getVolumeId() && this.hostId==other.getHostId()); |
| 221 | + } |
| 222 | + return false; |
| 223 | + } |
| 224 | + |
| 225 | + |
| 226 | + public int hashCode() { |
| 227 | + Long tid = new Long(volumeId); |
| 228 | + Long hid = new Long(hostId); |
| 229 | + return tid.hashCode()+hid.hashCode(); |
| 230 | + } |
| 231 | + |
| 232 | + public void setSize(long size) { |
| 233 | + this.size = size; |
| 234 | + } |
| 235 | + |
| 236 | + public long getSize() { |
| 237 | + return size; |
| 238 | + } |
| 239 | + |
| 240 | + |
| 241 | + public void setPhysicalSize(long physicalSize) { |
| 242 | + this.physicalSize = physicalSize; |
| 243 | + } |
| 244 | + |
| 245 | + public long getPhysicalSize() { |
| 246 | + return physicalSize; |
| 247 | + } |
| 248 | + |
| 249 | + public void setDestroyed(boolean destroyed) { |
| 250 | + this.destroyed = destroyed; |
| 251 | + } |
| 252 | + |
| 253 | + public boolean getDestroyed() { |
| 254 | + return destroyed; |
| 255 | + } |
| 256 | + |
| 257 | + public void setDownloadUrl(String downloadUrl) { |
| 258 | + this.downloadUrl = downloadUrl; |
| 259 | + } |
| 260 | + |
| 261 | + public String getDownloadUrl() { |
| 262 | + return downloadUrl; |
| 263 | + } |
| 264 | + |
| 265 | + public void setCopy(boolean isCopy) { |
| 266 | + this.isCopy = isCopy; |
| 267 | + } |
| 268 | + |
| 269 | + public boolean isCopy() { |
| 270 | + return isCopy; |
| 271 | + } |
| 272 | + |
| 273 | + |
| 274 | + public long getVolumeSize() { |
| 275 | + return -1; |
| 276 | + } |
| 277 | + |
| 278 | + |
| 279 | + public String toString() { |
| 280 | + return new StringBuilder("VolumeHost[").append(id).append("-").append(volumeId).append("-").append(hostId).append(installPath).append("]").toString(); |
| 281 | + } |
| 282 | + |
| 283 | +} |
0 commit comments