Skip to content

Commit b9ddcf8

Browse files
author
Alex Huang
committed
Started an object model for the orchestration platform
1 parent 49c9f1f commit b9ddcf8

4 files changed

Lines changed: 62 additions & 58 deletions

File tree

api/src/com/cloud/storage/Snapshot.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public int getMax() {
4040
return max;
4141
}
4242

43+
@Override
4344
public String toString() {
4445
return this.name();
4546
}
@@ -56,6 +57,7 @@ public enum Status {
5657
BackedUp,
5758
Error;
5859

60+
@Override
5961
public String toString() {
6062
return this.name();
6163
}
@@ -67,8 +69,9 @@ public boolean equals(String status) {
6769

6870
public static final long MANUAL_POLICY_ID = 0L;
6971

70-
Long getId();
72+
long getId();
7173

74+
@Override
7275
long getAccountId();
7376

7477
long getVolumeId();

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

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@
3636
@Entity
3737
@Table(name="snapshots")
3838
public class SnapshotVO implements Snapshot, Identity {
39-
39+
4040
@Id
4141
@GeneratedValue(strategy=GenerationType.IDENTITY)
4242
@Column(name="id")
43-
private long id = -1;
44-
43+
private final long id = -1;
44+
4545
@Column(name="data_center_id")
4646
long dataCenterId;
4747

4848
@Column(name="account_id")
4949
long accountId;
50-
50+
5151
@Column(name="domain_id")
5252
long domainId;
5353

5454
@Column(name="volume_id")
5555
Long volumeId;
56-
56+
5757
@Column(name="disk_offering_id")
5858
Long diskOfferingId;
5959

@@ -64,7 +64,7 @@ public class SnapshotVO implements Snapshot, Identity {
6464
@Expose
6565
@Column(name="name")
6666
String name;
67-
67+
6868
@Expose
6969
@Column(name="status", updatable = true, nullable=false)
7070
@Enumerated(value=EnumType.STRING)
@@ -75,10 +75,10 @@ public class SnapshotVO implements Snapshot, Identity {
7575

7676
@Column(name="type_description")
7777
String typeDescription;
78-
78+
7979
@Column(name="size")
8080
long size;
81-
81+
8282
@Column(name=GenericDao.CREATED_COLUMN)
8383
Date created;
8484

@@ -87,10 +87,10 @@ public class SnapshotVO implements Snapshot, Identity {
8787

8888
@Column(name="backup_snap_id")
8989
String backupSnapshotId;
90-
90+
9191
@Column(name="swift_id")
9292
Long swiftId;
93-
93+
9494
@Column(name="sechost_id")
9595
Long secHostId;
9696

@@ -100,16 +100,16 @@ public class SnapshotVO implements Snapshot, Identity {
100100
@Column(name="hypervisor_type")
101101
@Enumerated(value=EnumType.STRING)
102102
HypervisorType hypervisorType;
103-
103+
104104
@Expose
105105
@Column(name="version")
106106
String version;
107-
107+
108108
@Column(name="uuid")
109109
String uuid;
110-
110+
111111
public SnapshotVO() {
112-
this.uuid = UUID.randomUUID().toString();
112+
this.uuid = UUID.randomUUID().toString();
113113
}
114114

115115
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType ) {
@@ -127,11 +127,11 @@ public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long
127127
this.prevSnapshotId = 0;
128128
this.hypervisorType = hypervisorType;
129129
this.version = "2.2";
130-
this.uuid = UUID.randomUUID().toString();
130+
this.uuid = UUID.randomUUID().toString();
131131
}
132-
132+
133133
@Override
134-
public Long getId() {
134+
public long getId() {
135135
return id;
136136
}
137137

@@ -144,6 +144,7 @@ public long getAccountId() {
144144
return accountId;
145145
}
146146

147+
@Override
147148
public long getDomainId() {
148149
return domainId;
149150
}
@@ -165,9 +166,9 @@ public void setVolumeId(Long volumeId) {
165166
public String getPath() {
166167
return path;
167168
}
168-
169+
169170
public void setPath(String path) {
170-
this.path = path;
171+
this.path = path;
171172
}
172173

173174
@Override
@@ -178,15 +179,15 @@ public String getName() {
178179
public short getsnapshotType() {
179180
return snapshotType;
180181
}
181-
182+
182183
@Override
183184
public Type getType() {
184185
if (snapshotType < 0 || snapshotType >= Type.values().length) {
185186
return null;
186187
}
187188
return Type.values()[snapshotType];
188189
}
189-
190+
190191
public Long getSwiftId() {
191192
return swiftId;
192193
}
@@ -205,13 +206,13 @@ public void setSecHostId(Long secHostId) {
205206

206207
@Override
207208
public HypervisorType getHypervisorType() {
208-
return hypervisorType;
209+
return hypervisorType;
209210
}
210-
211+
211212
public void setSnapshotType(short snapshotType) {
212213
this.snapshotType = snapshotType;
213214
}
214-
215+
215216
@Override
216217
public boolean isRecursive(){
217218
if ( snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal() ) {
@@ -239,39 +240,40 @@ public void setVersion(String version) {
239240
this.version = version;
240241
}
241242

243+
@Override
242244
public Date getCreated() {
243245
return created;
244246
}
245247

246248
public Date getRemoved() {
247249
return removed;
248250
}
249-
250-
@Override
251+
252+
@Override
251253
public Status getStatus() {
252-
return status;
253-
}
254-
255-
public void setStatus(Status status) {
256-
this.status = status;
257-
}
258-
259-
public String getBackupSnapshotId(){
260-
return backupSnapshotId;
261-
}
262-
254+
return status;
255+
}
256+
257+
public void setStatus(Status status) {
258+
this.status = status;
259+
}
260+
261+
public String getBackupSnapshotId(){
262+
return backupSnapshotId;
263+
}
264+
263265
public long getPrevSnapshotId(){
264-
return prevSnapshotId;
265-
}
266-
267-
public void setBackupSnapshotId(String backUpSnapshotId){
268-
this.backupSnapshotId = backUpSnapshotId;
269-
}
270-
271-
public void setPrevSnapshotId(long prevSnapshotId){
272-
this.prevSnapshotId = prevSnapshotId;
273-
}
274-
266+
return prevSnapshotId;
267+
}
268+
269+
public void setBackupSnapshotId(String backUpSnapshotId){
270+
this.backupSnapshotId = backUpSnapshotId;
271+
}
272+
273+
public void setPrevSnapshotId(long prevSnapshotId){
274+
this.prevSnapshotId = prevSnapshotId;
275+
}
276+
275277
public static Type getSnapshotType(String snapshotType) {
276278
for ( Type type : Type.values()) {
277279
if ( type.equals(snapshotType)) {
@@ -280,13 +282,13 @@ public static Type getSnapshotType(String snapshotType) {
280282
}
281283
return null;
282284
}
283-
285+
284286
@Override
285287
public String getUuid() {
286-
return this.uuid;
288+
return this.uuid;
287289
}
288-
290+
289291
public void setUuid(String uuid) {
290-
this.uuid = uuid;
292+
this.uuid = uuid;
291293
}
292294
}

platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageSubSystem.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ public interface StorageSubSystem {
88
String getType();
99
Class<? extends Grouping> getScope();
1010

11-
create();
12-
1311
URI grantAccess(String vol, String reservationId);
1412
URI RemoveAccess(String vol, String reservationId);
1513
}

utils/src/com/cloud/utils/fsm/FiniteState.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,27 @@ public interface FiniteState<S, E> {
2929
* @return the state machine being used.
3030
*/
3131
StateMachine<S, E> getStateMachine();
32-
32+
3333
/**
3434
* get next state based on the event.
3535
* @param event
3636
* @return next State
3737
*/
3838
S getNextState(E event);
39-
39+
4040
/**
4141
* Get the states that could have traveled to the current state
4242
* via this event.
4343
* @param event
4444
* @return array of states
4545
*/
4646
List<S> getFromStates(E event);
47-
47+
4848
/**
4949
* Get the possible events that can happen from the current state.
5050
* @return array of events.
5151
*/
5252
Set<E> getPossibleEvents();
53+
5354
String getDescription();
5455
}

0 commit comments

Comments
 (0)