Skip to content

Commit ff047e7

Browse files
Edison Susudison
authored andcommitted
refactor snapshot, move existing snapshot code into its own snapshotstrategy
1 parent 020be66 commit ff047e7

47 files changed

Lines changed: 1632 additions & 1206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ public enum State {
6161
BackedUp,
6262
Error;
6363

64-
private final static StateMachine2<State, Event, Snapshot> s_fsm = new StateMachine2<State, Event, Snapshot>();
65-
66-
public static StateMachine2<State, Event, Snapshot> getStateMachine() {
67-
return s_fsm;
68-
}
69-
70-
static {
71-
s_fsm.addTransition(null, Event.CreateRequested, Creating);
72-
s_fsm.addTransition(Creating, Event.OperationSucceeded, CreatedOnPrimary);
73-
s_fsm.addTransition(Creating, Event.OperationNotPerformed, BackedUp);
74-
s_fsm.addTransition(Creating, Event.OperationFailed, Error);
75-
s_fsm.addTransition(CreatedOnPrimary, Event.BackupToSecondary, BackingUp);
76-
s_fsm.addTransition(BackingUp, Event.OperationSucceeded, BackedUp);
77-
s_fsm.addTransition(BackingUp, Event.OperationFailed, Error);
78-
}
79-
8064
public String toString() {
8165
return this.name();
8266
}
@@ -107,7 +91,7 @@ enum Event {
10791

10892
Date getCreated();
10993

110-
Type getType();
94+
Type getRecurringType();
11195

11296
State getState();
11397

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public short getsnapshotType() {
175175
}
176176

177177
@Override
178-
public Type getType() {
178+
public Type getRecurringType() {
179179
if (snapshotType < 0 || snapshotType >= Type.values().length) {
180180
return null;
181181
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@
1818
*/
1919
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21+
import com.cloud.agent.api.Answer;
22+
2123
public class CopyCommandResult extends CommandResult {
2224
private final String path;
23-
public CopyCommandResult(String path) {
25+
private final Answer answer;
26+
public CopyCommandResult(String path, Answer answer) {
2427
super();
2528
this.path = path;
29+
this.answer = answer;
2630
}
2731

2832
public String getPath() {
2933
return this.path;
3034
}
35+
36+
public Answer getAnswer() {
37+
return this.answer;
38+
}
3139
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectInStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323

2424
public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> {
2525
public String getInstallPath();
26+
public void setInstallPath(String path);
2627
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreDriver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public interface DataStoreDriver {
3030
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
3131
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
3232
public boolean canCopy(DataObject srcData, DataObject destData);
33+
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
3334
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/ObjectInDataStoreStateMachine.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum Event {
4949
OperationSuccessed,
5050
OperationFailed,
5151
CopyingRequested,
52+
ResizeRequested,
5253
ExpungeRequested
5354

5455
}

engine/storage/src/org/apache/cloudstack/storage/volume/PrimaryDataStoreDriver.java renamed to engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.cloudstack.storage.volume;
19+
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21-
import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
22-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
23-
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
2421
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
2522

2623
public interface PrimaryDataStoreDriver extends DataStoreDriver {
27-
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
24+
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
2825
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
2926
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.engine.subsystem.api.storage;
1818

19+
import com.cloud.storage.Snapshot;
1920

20-
public interface SnapshotInfo extends DataObject {
21+
22+
public interface SnapshotInfo extends DataObject, Snapshot {
2123
public SnapshotInfo getParent();
2224
public SnapshotInfo getChild();
2325
public VolumeInfo getBaseVolume();
26+
Long getDataCenterId();
27+
public Long getPrevSnapshotId();
2428
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.apache.cloudstack.engine.subsystem.api.storage;
2+
3+
4+
public interface SnapshotStrategy {
5+
public boolean canHandle(SnapshotInfo snapshot);
6+
public SnapshotInfo takeSnapshot(VolumeInfo volume, Long snapshotId);
7+
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
8+
public boolean deleteSnapshot(SnapshotInfo snapshot);
9+
public boolean revertSnapshot(SnapshotInfo snapshot);
10+
}

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
*/
1919
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2122
import com.cloud.storage.Volume;
2223

2324
public interface VolumeInfo extends DataObject, Volume {
2425
public boolean isAttachedVM();
2526
public void addPayload(Object data);
2627
public Object getpayload();
28+
public HypervisorType getHypervisorType();
29+
public Long getLastPoolId();
2730
}

0 commit comments

Comments
 (0)