From b9ddcf8cfe7effdac2a2e6c5d1d7f9c82961da65 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 30 Aug 2012 15:54:33 -0700 Subject: [PATCH] Started an object model for the orchestration platform --- api/src/com/cloud/storage/Snapshot.java | 5 +- core/src/com/cloud/storage/SnapshotVO.java | 106 +++++++++--------- .../api/storage/StorageSubSystem.java | 2 - .../src/com/cloud/utils/fsm/FiniteState.java | 7 +- 4 files changed, 62 insertions(+), 58 deletions(-) diff --git a/api/src/com/cloud/storage/Snapshot.java b/api/src/com/cloud/storage/Snapshot.java index a37cc94241f..d169e64f116 100644 --- a/api/src/com/cloud/storage/Snapshot.java +++ b/api/src/com/cloud/storage/Snapshot.java @@ -40,6 +40,7 @@ public interface Snapshot extends ControlledEntity { return max; } + @Override public String toString() { return this.name(); } @@ -56,6 +57,7 @@ public interface Snapshot extends ControlledEntity { BackedUp, Error; + @Override public String toString() { return this.name(); } @@ -67,8 +69,9 @@ public interface Snapshot extends ControlledEntity { public static final long MANUAL_POLICY_ID = 0L; - Long getId(); + long getId(); + @Override long getAccountId(); long getVolumeId(); diff --git a/core/src/com/cloud/storage/SnapshotVO.java b/core/src/com/cloud/storage/SnapshotVO.java index 08dfafa6bac..75f965745d1 100644 --- a/core/src/com/cloud/storage/SnapshotVO.java +++ b/core/src/com/cloud/storage/SnapshotVO.java @@ -36,24 +36,24 @@ import com.google.gson.annotations.Expose; @Entity @Table(name="snapshots") public class SnapshotVO implements Snapshot, Identity { - + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id") - private long id = -1; - + private final long id = -1; + @Column(name="data_center_id") long dataCenterId; @Column(name="account_id") long accountId; - + @Column(name="domain_id") long domainId; @Column(name="volume_id") Long volumeId; - + @Column(name="disk_offering_id") Long diskOfferingId; @@ -64,7 +64,7 @@ public class SnapshotVO implements Snapshot, Identity { @Expose @Column(name="name") String name; - + @Expose @Column(name="status", updatable = true, nullable=false) @Enumerated(value=EnumType.STRING) @@ -75,10 +75,10 @@ public class SnapshotVO implements Snapshot, Identity { @Column(name="type_description") String typeDescription; - + @Column(name="size") long size; - + @Column(name=GenericDao.CREATED_COLUMN) Date created; @@ -87,10 +87,10 @@ public class SnapshotVO implements Snapshot, Identity { @Column(name="backup_snap_id") String backupSnapshotId; - + @Column(name="swift_id") Long swiftId; - + @Column(name="sechost_id") Long secHostId; @@ -100,16 +100,16 @@ public class SnapshotVO implements Snapshot, Identity { @Column(name="hypervisor_type") @Enumerated(value=EnumType.STRING) HypervisorType hypervisorType; - + @Expose @Column(name="version") String version; - + @Column(name="uuid") String uuid; - + public SnapshotVO() { - this.uuid = UUID.randomUUID().toString(); + this.uuid = UUID.randomUUID().toString(); } 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 class SnapshotVO implements Snapshot, Identity { this.prevSnapshotId = 0; this.hypervisorType = hypervisorType; this.version = "2.2"; - this.uuid = UUID.randomUUID().toString(); + this.uuid = UUID.randomUUID().toString(); } - + @Override - public Long getId() { + public long getId() { return id; } @@ -144,6 +144,7 @@ public class SnapshotVO implements Snapshot, Identity { return accountId; } + @Override public long getDomainId() { return domainId; } @@ -165,9 +166,9 @@ public class SnapshotVO implements Snapshot, Identity { public String getPath() { return path; } - + public void setPath(String path) { - this.path = path; + this.path = path; } @Override @@ -178,7 +179,7 @@ public class SnapshotVO implements Snapshot, Identity { public short getsnapshotType() { return snapshotType; } - + @Override public Type getType() { if (snapshotType < 0 || snapshotType >= Type.values().length) { @@ -186,7 +187,7 @@ public class SnapshotVO implements Snapshot, Identity { } return Type.values()[snapshotType]; } - + public Long getSwiftId() { return swiftId; } @@ -205,13 +206,13 @@ public class SnapshotVO implements Snapshot, Identity { @Override public HypervisorType getHypervisorType() { - return hypervisorType; + return hypervisorType; } - + public void setSnapshotType(short snapshotType) { this.snapshotType = snapshotType; } - + @Override public boolean isRecursive(){ if ( snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal() ) { @@ -239,6 +240,7 @@ public class SnapshotVO implements Snapshot, Identity { this.version = version; } + @Override public Date getCreated() { return created; } @@ -246,32 +248,32 @@ public class SnapshotVO implements Snapshot, Identity { public Date getRemoved() { return removed; } - - @Override + + @Override public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getBackupSnapshotId(){ - return backupSnapshotId; - } - + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public String getBackupSnapshotId(){ + return backupSnapshotId; + } + public long getPrevSnapshotId(){ - return prevSnapshotId; - } - - public void setBackupSnapshotId(String backUpSnapshotId){ - this.backupSnapshotId = backUpSnapshotId; - } - - public void setPrevSnapshotId(long prevSnapshotId){ - this.prevSnapshotId = prevSnapshotId; - } - + return prevSnapshotId; + } + + public void setBackupSnapshotId(String backUpSnapshotId){ + this.backupSnapshotId = backUpSnapshotId; + } + + public void setPrevSnapshotId(long prevSnapshotId){ + this.prevSnapshotId = prevSnapshotId; + } + public static Type getSnapshotType(String snapshotType) { for ( Type type : Type.values()) { if ( type.equals(snapshotType)) { @@ -280,13 +282,13 @@ public class SnapshotVO implements Snapshot, Identity { } return null; } - + @Override public String getUuid() { - return this.uuid; + return this.uuid; } - + public void setUuid(String uuid) { - this.uuid = uuid; + this.uuid = uuid; } } diff --git a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageSubSystem.java b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageSubSystem.java index bef7586d9c2..e12ff797ad4 100755 --- a/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageSubSystem.java +++ b/platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/StorageSubSystem.java @@ -8,8 +8,6 @@ public interface StorageSubSystem { String getType(); Class getScope(); - create(); - URI grantAccess(String vol, String reservationId); URI RemoveAccess(String vol, String reservationId); } diff --git a/utils/src/com/cloud/utils/fsm/FiniteState.java b/utils/src/com/cloud/utils/fsm/FiniteState.java index 21ef71113e9..d501b431c7c 100644 --- a/utils/src/com/cloud/utils/fsm/FiniteState.java +++ b/utils/src/com/cloud/utils/fsm/FiniteState.java @@ -29,14 +29,14 @@ public interface FiniteState { * @return the state machine being used. */ StateMachine getStateMachine(); - + /** * get next state based on the event. * @param event * @return next State */ S getNextState(E event); - + /** * Get the states that could have traveled to the current state * via this event. @@ -44,11 +44,12 @@ public interface FiniteState { * @return array of states */ List getFromStates(E event); - + /** * Get the possible events that can happen from the current state. * @return array of events. */ Set getPossibleEvents(); + String getDescription(); }