File tree Expand file tree Collapse file tree
api/src/main/java/org/apache/cloudstack/api/response
server/src/main/java/com/cloud/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,10 @@ public void setCancellable(Boolean cancellable) {
211211 this .cancellable = cancellable ;
212212 }
213213
214+ public boolean getCancellable () {
215+ return Boolean .TRUE .equals (cancellable );
216+ }
217+
214218 public void setJobInstanceName (String jobInstanceName ) {
215219 this .jobInstanceName = jobInstanceName ;
216220 }
Original file line number Diff line number Diff line change 9090import org .apache .cloudstack .framework .config .dao .ConfigurationDao ;
9191import org .apache .cloudstack .framework .jobs .AsyncJob ;
9292import org .apache .cloudstack .framework .jobs .AsyncJobManager ;
93+ import org .apache .cloudstack .jobs .JobInfo ;
9394import org .apache .cloudstack .framework .jobs .dao .AsyncJobDao ;
9495import org .apache .cloudstack .resourcedetail .SnapshotPolicyDetailVO ;
9596import org .apache .cloudstack .resourcedetail .dao .DiskOfferingDetailsDao ;
@@ -2187,7 +2188,11 @@ public static AccountJoinVO findAccountViewById(Long accountId) {
21872188 }
21882189
21892190 public static AsyncJobResponse newAsyncJobResponse (AsyncJobJoinVO ve ) {
2190- return s_jobJoinDao .newAsyncJobResponse (ve );
2191+ final AsyncJobResponse response = s_jobJoinDao .newAsyncJobResponse (ve );
2192+ if (!response .getCancellable () && ve .getStatus () == JobInfo .Status .IN_PROGRESS .value () && s_asyncMgr .hasOnlyQueuedWork (ve .getId ())) {
2193+ response .setCancellable (true );
2194+ }
2195+ return response ;
21912196 }
21922197
21932198 public static AsyncJobJoinVO newAsyncJobView (AsyncJob e ) {
Original file line number Diff line number Diff line change 3030import org .apache .cloudstack .api .response .ExceptionResponse ;
3131import org .apache .cloudstack .jobs .JobInfo ;
3232import org .apache .cloudstack .framework .jobs .AsyncJob ;
33- import org .apache .cloudstack .framework .jobs .AsyncJobManager ;
3433import org .apache .commons .collections .CollectionUtils ;
3534import org .springframework .stereotype .Component ;
3635
@@ -69,9 +68,6 @@ private String managementServerName(final Long msid) {
6968 return managementServer != null ? managementServer .getName () : null ;
7069 }
7170
72- @ Inject
73- private AsyncJobManager asyncJobManager ;
74-
7571 private static final Map <String , Boolean > cancellableCommands = new ConcurrentHashMap <>();
7672
7773 /** The same annotation cancelAsyncJob checks; a command class that cannot be loaded is reported as not cancellable. */
@@ -99,8 +95,7 @@ public AsyncJobResponse newAsyncJobResponse(final AsyncJobJoinVO job) {
9995 jobResponse .setDomainPath (ApiResponseHelper .getPrettyDomainPath (job .getDomainPath ()));
10096 jobResponse .setUserId (job .getUserUuid ());
10197 jobResponse .setCmd (job .getCmd ());
102- jobResponse .setCancellable (isCancellableCommand (job .getCmd ())
103- || (job .getStatus () == JobInfo .Status .IN_PROGRESS .value () && asyncJobManager .hasOnlyQueuedWork (job .getId ())));
98+ jobResponse .setCancellable (isCancellableCommand (job .getCmd ()));
10499 jobResponse .setCreated (job .getCreated ());
105100 jobResponse .setRemoved (job .getRemoved ());
106101 jobResponse .setId (job .getUuid ());
You can’t perform that action at this time.
0 commit comments