mirror of https://github.com/apache/cloudstack.git
Let reset job description to be in API standard
This commit is contained in:
parent
3f752bf1df
commit
1d8eab2a11
|
|
@ -663,7 +663,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||
List<SyncQueueItemVO> items = _queueMgr.getActiveQueueItems(msHost.getId(), true);
|
||||
cleanupPendingJobs(items);
|
||||
_queueMgr.resetQueueProcess(msHost.getId());
|
||||
_jobDao.resetJobProcess(msHost.getId());
|
||||
_jobDao.resetJobProcess(msHost.getId(), BaseCmd.INTERNAL_ERROR, getResetResultMessage());
|
||||
txn.commit();
|
||||
} catch(Throwable e) {
|
||||
s_logger.warn("Unexpected exception ", e);
|
||||
|
|
@ -680,7 +680,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||
List<SyncQueueItemVO> l = _queueMgr.getActiveQueueItems(getMsid(), false);
|
||||
cleanupPendingJobs(l);
|
||||
_queueMgr.resetQueueProcess(getMsid());
|
||||
_jobDao.resetJobProcess(getMsid());
|
||||
_jobDao.resetJobProcess(getMsid(), BaseCmd.INTERNAL_ERROR, getResetResultMessage());
|
||||
} catch(Throwable e) {
|
||||
s_logger.error("Unexpected exception " + e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -691,6 +691,13 @@ public class AsyncJobManagerImpl implements AsyncJobManager, ClusterManagerListe
|
|||
GC_INTERVAL, TimeUnit.MILLISECONDS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String getResetResultMessage() {
|
||||
ExceptionResponse resultObject = new ExceptionResponse();
|
||||
resultObject.setErrorCode(BaseCmd.INTERNAL_ERROR);
|
||||
resultObject.setErrorText("job cancelled because of management server restart");
|
||||
return ApiSerializerHelper.toSerializedStringOld(resultObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,5 +29,5 @@ public interface AsyncJobDao extends GenericDao<AsyncJobVO, Long> {
|
|||
AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId);
|
||||
List<AsyncJobVO> findInstancePendingAsyncJobs(AsyncJob.Type instanceType, Long accountId);
|
||||
List<AsyncJobVO> getExpiredJobs(Date cutTime, int limit);
|
||||
void resetJobProcess(long msid);
|
||||
void resetJobProcess(long msid, int jobResultCode, String jobResultMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,8 +107,9 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long> implements
|
|||
}
|
||||
|
||||
@DB
|
||||
public void resetJobProcess(long msid) {
|
||||
String sql = "UPDATE async_job SET job_status=2, job_result='job cancelled because of management server restart' where job_status=0 AND (job_complete_msid=? OR (job_complete_msid IS NULL AND job_init_msid=?))";
|
||||
public void resetJobProcess(long msid, int jobResultCode, String jobResultMessage) {
|
||||
String sql = "UPDATE async_job SET job_status=" + AsyncJobResult.STATUS_FAILED + ", job_result_code=" + jobResultCode
|
||||
+ ", job_result='" + jobResultMessage + "' where job_status=0 AND (job_complete_msid=? OR (job_complete_msid IS NULL AND job_init_msid=?))";
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue