Skip to content

Commit fe3b01e

Browse files
committed
Update DataObjectInStore interface and unify implementation of
ImageDataFactory, VolumeDataFactory and SnapshotDataFactory implementations.
1 parent c74969f commit fe3b01e

17 files changed

Lines changed: 313 additions & 177 deletions

File tree

core/src/com/cloud/storage/VMTemplateHostVO.java

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,66 +44,66 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc, DataObj
4444
@Id
4545
@GeneratedValue(strategy=GenerationType.IDENTITY)
4646
Long id;
47-
47+
4848
@Column(name="host_id")
4949
private long hostId;
50-
50+
5151
@Column(name="template_id")
5252
private long templateId;
53-
53+
5454
@Column(name=GenericDaoBase.CREATED_COLUMN)
5555
private Date created = null;
56-
56+
5757
@Column(name="last_updated")
5858
@Temporal(value=TemporalType.TIMESTAMP)
5959
private Date lastUpdated = null;
60-
60+
6161
@Column (name="download_pct")
6262
private int downloadPercent;
63-
63+
6464
@Column (name="size")
6565
private long size;
66-
66+
6767
@Column (name="physical_size")
6868
private long physicalSize;
69-
69+
7070
@Column (name="download_state")
7171
@Enumerated(EnumType.STRING)
7272
private Status downloadState;
73-
73+
7474
@Column (name="local_path")
7575
private String localDownloadPath;
76-
76+
7777
@Column (name="error_str")
7878
private String errorString;
79-
79+
8080
@Column (name="job_id")
81-
private String jobId;
82-
81+
private String jobId;
82+
8383
@Column (name="install_path")
8484
private String installPath;
85-
85+
8686
@Column (name="url")
8787
private String downloadUrl;
8888

8989
@Column(name="is_copy")
9090
private boolean isCopy = false;
91-
91+
9292
@Column(name="destroyed")
9393
boolean destroyed = false;
94-
94+
9595
@Column(name="update_count", updatable = true, nullable=false)
9696
protected long updatedCount;
97-
97+
9898
@Column(name = "updated")
9999
@Temporal(value = TemporalType.TIMESTAMP)
100100
Date updated;
101-
101+
102102
@Column(name = "state")
103103
@Enumerated(EnumType.STRING)
104104
ObjectInDataStoreStateMachine.State state;
105-
106-
105+
106+
107107
@Override
108108
public String getInstallPath() {
109109
return installPath;
@@ -156,12 +156,12 @@ public Date getCreated() {
156156
public Date getLastUpdated() {
157157
return lastUpdated;
158158
}
159-
159+
160160
@Override
161161
public void setLastUpdated(Date date) {
162162
lastUpdated = date;
163163
}
164-
164+
165165
@Override
166166
public void setInstallPath(String installPath) {
167167
this.installPath = installPath;
@@ -197,7 +197,7 @@ public VMTemplateHostVO(long hostId, long templateId, Date lastUpdated,
197197
}
198198

199199
protected VMTemplateHostVO() {
200-
200+
201201
}
202202

203203
@Override
@@ -234,7 +234,7 @@ public String getJobId() {
234234
public boolean equals(Object obj) {
235235
if (obj instanceof VMTemplateHostVO) {
236236
VMTemplateHostVO other = (VMTemplateHostVO)obj;
237-
return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
237+
return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
238238
}
239239
return false;
240240
}
@@ -253,8 +253,8 @@ public void setSize(long size) {
253253
public long getSize() {
254254
return size;
255255
}
256-
257-
256+
257+
258258
public void setPhysicalSize(long physicalSize) {
259259
this.physicalSize = physicalSize;
260260
}
@@ -286,12 +286,12 @@ public void setCopy(boolean isCopy) {
286286
public boolean isCopy() {
287287
return isCopy;
288288
}
289-
289+
290290
@Override
291291
public long getTemplateSize() {
292292
return -1;
293293
}
294-
294+
295295
@Override
296296
public String toString() {
297297
return new StringBuilder("TmplHost[").append(id).append("-").append(templateId).append("-").append(hostId).append(installPath).append("]").toString();
@@ -302,21 +302,32 @@ public ObjectInDataStoreStateMachine.State getState() {
302302
// TODO Auto-generated method stub
303303
return this.state;
304304
}
305-
305+
306306
public long getUpdatedCount() {
307307
return this.updatedCount;
308308
}
309-
309+
310310
public void incrUpdatedCount() {
311311
this.updatedCount++;
312312
}
313313

314314
public void decrUpdatedCount() {
315315
this.updatedCount--;
316316
}
317-
317+
318318
public Date getUpdated() {
319319
return updated;
320320
}
321321

322+
@Override
323+
public long getObjectId() {
324+
return this.getTemplateId();
325+
}
326+
327+
@Override
328+
public long getDataStoreId() {
329+
return this.getHostId();
330+
}
331+
332+
322333
}

core/src/com/cloud/storage/VMTemplateStoragePoolVO.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,32 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
4545
@Id
4646
@GeneratedValue(strategy=GenerationType.IDENTITY)
4747
long id;
48-
48+
4949
@Column(name="pool_id")
5050
private long poolId;
51-
51+
5252
@Column(name="template_id") long templateId;
53-
53+
5454
@Column(name=GenericDaoBase.CREATED_COLUMN) Date created = null;
55-
55+
5656
@Column(name="last_updated")
5757
@Temporal(value=TemporalType.TIMESTAMP) Date lastUpdated = null;
58-
58+
5959
@Column (name="download_pct") int downloadPercent;
60-
60+
6161
@Column (name="download_state")
6262
@Enumerated(EnumType.STRING) Status downloadState;
63-
63+
6464
@Column (name="local_path") String localDownloadPath;
65-
65+
6666
@Column (name="error_str") String errorString;
67-
67+
6868
@Column (name="job_id") String jobId;
69-
69+
7070
@Column (name="install_path") String installPath;
71-
71+
7272
@Column (name="template_size") long templateSize;
73-
73+
7474
@Column (name="marked_for_gc") boolean markedForGC;
7575

7676
@Column(name="update_count", updatable = true, nullable=false)
@@ -88,7 +88,7 @@ public class VMTemplateStoragePoolVO implements VMTemplateStorageResourceAssoc,
8888
public String getInstallPath() {
8989
return installPath;
9090
}
91-
91+
9292
@Override
9393
public long getTemplateSize() {
9494
return templateSize;
@@ -141,12 +141,12 @@ public Date getCreated() {
141141
public Date getLastUpdated() {
142142
return lastUpdated;
143143
}
144-
144+
145145
@Override
146146
public void setLastUpdated(Date date) {
147147
lastUpdated = date;
148148
}
149-
149+
150150
@Override
151151
public void setInstallPath(String installPath) {
152152
this.installPath = installPath;
@@ -184,7 +184,7 @@ public VMTemplateStoragePoolVO(long poolId, long templateId, Date lastUpdated,
184184
}
185185

186186
protected VMTemplateStoragePoolVO() {
187-
187+
188188
}
189189

190190
@Override
@@ -216,15 +216,15 @@ public void setJobId(String jobId) {
216216
public String getJobId() {
217217
return jobId;
218218
}
219-
219+
220220
public void setTemplateSize(long templateSize) {
221221
this.templateSize = templateSize;
222222
}
223-
223+
224224
public boolean getMarkedForGC() {
225225
return markedForGC;
226226
}
227-
227+
228228
public void setMarkedForGC(boolean markedForGC) {
229229
this.markedForGC = markedForGC;
230230
}
@@ -244,7 +244,7 @@ public int hashCode() {
244244
Long hid = new Long(poolId);
245245
return tid.hashCode()+hid.hashCode();
246246
}
247-
247+
248248
@Override
249249
public String toString() {
250250
return new StringBuilder("TmplPool[").append(id).append("-").append(templateId).append("-").append("poolId").append("-").append(installPath).append("]").toString();
@@ -254,22 +254,32 @@ public String toString() {
254254
public State getState() {
255255
return this.state;
256256
}
257-
257+
258258
public long getUpdatedCount() {
259259
return this.updatedCount;
260260
}
261-
261+
262262
public void incrUpdatedCount() {
263263
this.updatedCount++;
264264
}
265265

266266
public void decrUpdatedCount() {
267267
this.updatedCount--;
268268
}
269-
269+
270270
public Date getUpdated() {
271271
return updated;
272272
}
273-
273+
274+
@Override
275+
public long getObjectId() {
276+
return this.getTemplateId();
277+
}
278+
279+
@Override
280+
public long getDataStoreId() {
281+
return this.getPoolId();
282+
}
283+
274284

275285
}

0 commit comments

Comments
 (0)