1616// under the License.
1717package com .cloud .storage .snapshot ;
1818
19- import java .util .ArrayList ;
20- import java .util .Collections ;
21- import java .util .Date ;
22- import java .util .HashMap ;
23- import java .util .List ;
24- import java .util .Map ;
25- import java .util .TimeZone ;
26- import java .util .concurrent .ExecutionException ;
27- import java .util .concurrent .Executors ;
28- import java .util .concurrent .ScheduledExecutorService ;
29- import java .util .concurrent .TimeUnit ;
30- import java .util .stream .Collectors ;
31-
32- import javax .inject .Inject ;
33- import javax .naming .ConfigurationException ;
34-
35- import org .apache .cloudstack .acl .SecurityChecker ;
36- import com .cloud .api .ApiDBUtils ;
37- import org .apache .cloudstack .annotation .AnnotationService ;
38- import org .apache .cloudstack .annotation .dao .AnnotationDao ;
39- import org .apache .cloudstack .api .ApiCommandResourceType ;
40- import org .apache .cloudstack .api .ApiConstants ;
41- import org .apache .cloudstack .api .command .user .snapshot .CopySnapshotCmd ;
42- import org .apache .cloudstack .api .command .user .snapshot .CreateSnapshotPolicyCmd ;
43- import org .apache .cloudstack .api .command .user .snapshot .DeleteSnapshotPoliciesCmd ;
44- import org .apache .cloudstack .api .command .user .snapshot .ExtractSnapshotCmd ;
45- import org .apache .cloudstack .api .command .user .snapshot .ListSnapshotPoliciesCmd ;
46- import org .apache .cloudstack .api .command .user .snapshot .ListSnapshotsCmd ;
47- import org .apache .cloudstack .api .command .user .snapshot .UpdateSnapshotPolicyCmd ;
48- import org .apache .cloudstack .context .CallContext ;
49- import org .apache .cloudstack .engine .subsystem .api .storage .CreateCmdResult ;
50- import org .apache .cloudstack .engine .subsystem .api .storage .DataStore ;
51- import org .apache .cloudstack .engine .subsystem .api .storage .DataStoreManager ;
52- import org .apache .cloudstack .engine .subsystem .api .storage .EndPoint ;
53- import org .apache .cloudstack .engine .subsystem .api .storage .EndPointSelector ;
54- import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine ;
55- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotDataFactory ;
56- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotInfo ;
57- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotResult ;
58- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotService ;
59- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotStrategy ;
60- import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotStrategy .SnapshotOperation ;
61- import org .apache .cloudstack .engine .subsystem .api .storage .StorageStrategyFactory ;
62- import org .apache .cloudstack .engine .subsystem .api .storage .VolumeDataFactory ;
63- import org .apache .cloudstack .engine .subsystem .api .storage .VolumeInfo ;
64- import org .apache .cloudstack .engine .subsystem .api .storage .ZoneScope ;
65- import org .apache .cloudstack .framework .async .AsyncCallFuture ;
66- import org .apache .cloudstack .framework .config .ConfigKey ;
67- import org .apache .cloudstack .framework .config .Configurable ;
68- import org .apache .cloudstack .framework .config .dao .ConfigurationDao ;
69- import org .apache .cloudstack .managed .context .ManagedContextRunnable ;
70- import org .apache .cloudstack .resourcedetail .SnapshotPolicyDetailVO ;
71- import org .apache .cloudstack .resourcedetail .dao .SnapshotPolicyDetailsDao ;
72- import org .apache .cloudstack .snapshot .SnapshotHelper ;
73- import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
74- import org .apache .cloudstack .storage .datastore .db .SnapshotDataStoreDao ;
75- import org .apache .cloudstack .storage .datastore .db .SnapshotDataStoreVO ;
76- import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
77- import org .apache .cloudstack .storage .image .datastore .ImageStoreEntity ;
78- import org .apache .cloudstack .utils .reflectiontostringbuilderutils .ReflectionToStringBuilderUtils ;
79- import org .apache .commons .collections .CollectionUtils ;
80- import org .apache .commons .collections .MapUtils ;
81- import org .apache .commons .lang3 .StringUtils ;
82- import org .apache .commons .lang3 .ObjectUtils ;
83- import org .apache .commons .lang3 .builder .ReflectionToStringBuilder ;
84- import org .apache .commons .lang3 .builder .ToStringStyle ;
85- import org .springframework .stereotype .Component ;
86-
8719import com .cloud .agent .api .Answer ;
8820import com .cloud .agent .api .Command ;
8921import com .cloud .agent .api .DeleteSnapshotsDirCommand ;
9022import com .cloud .alert .AlertManager ;
23+ import com .cloud .api .ApiDBUtils ;
9124import com .cloud .api .commands .ListRecurringSnapshotScheduleCmd ;
9225import com .cloud .api .query .MutualExclusiveIdsManagerBase ;
9326import com .cloud .configuration .Config ;
175108import com .cloud .vm .snapshot .VMSnapshotVO ;
176109import com .cloud .vm .snapshot .dao .VMSnapshotDao ;
177110import com .cloud .vm .snapshot .dao .VMSnapshotDetailsDao ;
111+ import org .apache .cloudstack .acl .SecurityChecker ;
112+ import org .apache .cloudstack .annotation .AnnotationService ;
113+ import org .apache .cloudstack .annotation .dao .AnnotationDao ;
114+ import org .apache .cloudstack .api .ApiCommandResourceType ;
115+ import org .apache .cloudstack .api .ApiConstants ;
116+ import org .apache .cloudstack .api .command .user .snapshot .CopySnapshotCmd ;
117+ import org .apache .cloudstack .api .command .user .snapshot .CreateSnapshotPolicyCmd ;
118+ import org .apache .cloudstack .api .command .user .snapshot .DeleteSnapshotPoliciesCmd ;
119+ import org .apache .cloudstack .api .command .user .snapshot .ExtractSnapshotCmd ;
120+ import org .apache .cloudstack .api .command .user .snapshot .ListSnapshotPoliciesCmd ;
121+ import org .apache .cloudstack .api .command .user .snapshot .ListSnapshotsCmd ;
122+ import org .apache .cloudstack .api .command .user .snapshot .UpdateSnapshotPolicyCmd ;
123+ import org .apache .cloudstack .context .CallContext ;
124+ import org .apache .cloudstack .engine .subsystem .api .storage .CreateCmdResult ;
125+ import org .apache .cloudstack .engine .subsystem .api .storage .DataStore ;
178126import org .apache .cloudstack .engine .subsystem .api .storage .DataStoreCapabilities ;
127+ import org .apache .cloudstack .engine .subsystem .api .storage .DataStoreManager ;
128+ import org .apache .cloudstack .engine .subsystem .api .storage .EndPoint ;
129+ import org .apache .cloudstack .engine .subsystem .api .storage .EndPointSelector ;
130+ import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine ;
179131import org .apache .cloudstack .engine .subsystem .api .storage .PrimaryDataStore ;
132+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotDataFactory ;
133+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotInfo ;
134+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotResult ;
135+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotService ;
136+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotStrategy ;
137+ import org .apache .cloudstack .engine .subsystem .api .storage .SnapshotStrategy .SnapshotOperation ;
138+ import org .apache .cloudstack .engine .subsystem .api .storage .StorageStrategyFactory ;
139+ import org .apache .cloudstack .engine .subsystem .api .storage .VolumeDataFactory ;
140+ import org .apache .cloudstack .engine .subsystem .api .storage .VolumeInfo ;
141+ import org .apache .cloudstack .engine .subsystem .api .storage .ZoneScope ;
142+ import org .apache .cloudstack .framework .async .AsyncCallFuture ;
143+ import org .apache .cloudstack .framework .config .ConfigKey ;
144+ import org .apache .cloudstack .framework .config .Configurable ;
145+ import org .apache .cloudstack .framework .config .dao .ConfigurationDao ;
146+ import org .apache .cloudstack .managed .context .ManagedContextRunnable ;
147+ import org .apache .cloudstack .resourcedetail .SnapshotPolicyDetailVO ;
148+ import org .apache .cloudstack .resourcedetail .dao .SnapshotPolicyDetailsDao ;
149+ import org .apache .cloudstack .snapshot .SnapshotHelper ;
150+ import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
151+ import org .apache .cloudstack .storage .datastore .db .SnapshotDataStoreDao ;
152+ import org .apache .cloudstack .storage .datastore .db .SnapshotDataStoreVO ;
153+ import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
154+ import org .apache .cloudstack .storage .image .datastore .ImageStoreEntity ;
155+ import org .apache .cloudstack .utils .reflectiontostringbuilderutils .ReflectionToStringBuilderUtils ;
156+ import org .apache .commons .collections .CollectionUtils ;
157+ import org .apache .commons .collections .MapUtils ;
158+ import org .apache .commons .lang3 .ObjectUtils ;
159+ import org .apache .commons .lang3 .StringUtils ;
160+ import org .apache .commons .lang3 .builder .ReflectionToStringBuilder ;
161+ import org .apache .commons .lang3 .builder .ToStringStyle ;
162+ import org .springframework .stereotype .Component ;
163+
164+ import javax .inject .Inject ;
165+ import javax .naming .ConfigurationException ;
166+ import java .util .ArrayList ;
167+ import java .util .Collections ;
168+ import java .util .Date ;
169+ import java .util .HashMap ;
170+ import java .util .List ;
171+ import java .util .Map ;
172+ import java .util .TimeZone ;
173+ import java .util .concurrent .ExecutionException ;
174+ import java .util .concurrent .Executors ;
175+ import java .util .concurrent .ScheduledExecutorService ;
176+ import java .util .concurrent .TimeUnit ;
177+ import java .util .stream .Collectors ;
180178
181179@ Component
182180public class SnapshotManagerImpl extends MutualExclusiveIdsManagerBase implements SnapshotManager , SnapshotApiService , Configurable {
@@ -1561,14 +1559,6 @@ private void copyNewSnapshotToZonesOnPrimary(CreateSnapshotPayload payload, Snap
15611559 private boolean copySnapshotOnPool (SnapshotInfo snapshot , SnapshotStrategy snapshotStrategy , Long storagePoolId ) {
15621560 DataStore store = dataStoreMgr .getDataStore (storagePoolId , DataStoreRole .Primary );
15631561 SnapshotInfo snapshotOnStore = (SnapshotInfo ) store .create (snapshot );
1564- // if (snapshotOnStore.getStatus() == ObjectInDataStoreStateMachine.State.Allocated) {
1565- // snapshotOnStore.processEvent(Event.CreateOnlyRequested);
1566- // } else if (snapshotOnStore.getStatus() == ObjectInDataStoreStateMachine.State.Ready) {
1567- // snapshotOnStore.processEvent(Event.CopyRequested);
1568- // } else {
1569- // logger.info(String.format("Cannot copy snapshot to another storage in different zone. It's not in the right state %s", snapshotOnStore.getStatus()));
1570- // return false;
1571- // }
15721562
15731563 try {
15741564 AsyncCallFuture <SnapshotResult > future = snapshotSrv .copySnapshot (snapshot , snapshotOnStore , snapshotStrategy );
@@ -1589,10 +1579,6 @@ private boolean copySnapshotOnPool(SnapshotInfo snapshot, SnapshotStrategy snaps
15891579 } catch (ExecutionException e ) {
15901580 throw new RuntimeException (e );
15911581 }
1592- // boolean copySuccessful = snapshotStrategy.copySnapshot(snapshot, snapshotOnStore, null);
1593- // if (!copySuccessful) {
1594- // snapshotOnStore.processEvent(Event.OperationFailed);
1595- // }
15961582 return true ;
15971583 }
15981584
0 commit comments