use of org.apache.cloudstack.framework.jobs.impl.AsyncJobVO in project cloudstack by apache.
the class VirtualNetworkApplianceManagerImpl method rebootRouters.
private List<Long> rebootRouters(final List<DomainRouterVO> routers) {
final List<Long> jobIds = new ArrayList<Long>();
for (final DomainRouterVO router : routers) {
if (!_nwHelper.checkRouterVersion(router)) {
s_logger.debug("Upgrading template for router: " + router.getId());
final Map<String, String> params = new HashMap<String, String>();
params.put("ctxUserId", "1");
params.put("ctxAccountId", "" + router.getAccountId());
final RebootRouterCmd cmd = new RebootRouterCmd();
ComponentContext.inject(cmd);
params.put("id", "" + router.getId());
params.put("ctxStartEventId", "1");
final AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, router.getAccountId(), RebootRouterCmd.class.getName(), ApiGsonHelper.getBuilder().create().toJson(params), router.getId(), cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null, null);
job.setDispatcher(_asyncDispatcher.getName());
final long jobId = _asyncMgr.submitAsyncJob(job);
jobIds.add(jobId);
} else {
s_logger.debug("Router: " + router.getId() + " is already at the latest version. No upgrade required");
}
}
return jobIds;
}
use of org.apache.cloudstack.framework.jobs.impl.AsyncJobVO in project cloudstack by apache.
the class VolumeOrchestrator method cleanupStorageJobs.
@Override
public void cleanupStorageJobs() {
// clean up failure jobs related to volume
List<AsyncJobVO> jobs = _jobMgr.findFailureAsyncJobs(VmWorkAttachVolume.class.getName(), VmWorkMigrateVolume.class.getName(), VmWorkTakeVolumeSnapshot.class.getName());
for (AsyncJobVO job : jobs) {
try {
if (job.getCmd().equalsIgnoreCase(VmWorkAttachVolume.class.getName())) {
VmWorkAttachVolume work = VmWorkSerializer.deserialize(VmWorkAttachVolume.class, job.getCmdInfo());
cleanupVolumeDuringAttachFailure(work.getVolumeId(), work.getVmId());
} else if (job.getCmd().equalsIgnoreCase(VmWorkMigrateVolume.class.getName())) {
VmWorkMigrateVolume work = VmWorkSerializer.deserialize(VmWorkMigrateVolume.class, job.getCmdInfo());
cleanupVolumeDuringMigrationFailure(work.getVolumeId(), work.getDestPoolId());
} else if (job.getCmd().equalsIgnoreCase(VmWorkTakeVolumeSnapshot.class.getName())) {
VmWorkTakeVolumeSnapshot work = VmWorkSerializer.deserialize(VmWorkTakeVolumeSnapshot.class, job.getCmdInfo());
cleanupVolumeDuringSnapshotFailure(work.getVolumeId(), work.getSnapshotId());
}
} catch (Exception e) {
s_logger.debug("clean up job failure, will continue", e);
}
}
}
use of org.apache.cloudstack.framework.jobs.impl.AsyncJobVO in project cloudstack by apache.
the class AsyncJobDaoImpl method getExpiredCompletedJobs.
@Override
public List<AsyncJobVO> getExpiredCompletedJobs(final Date cutTime, final int limit) {
final SearchCriteria<AsyncJobVO> sc = expiringCompletedAsyncJobSearch.create();
sc.setParameters(ApiConstants.REMOVED, cutTime);
sc.setParameters("jobStatus", JobInfo.Status.IN_PROGRESS);
final Filter filter = new Filter(AsyncJobVO.class, ApiConstants.REMOVED, true, 0L, (long) limit);
return listIncludingRemovedBy(sc, filter);
}
use of org.apache.cloudstack.framework.jobs.impl.AsyncJobVO in project cloudstack by apache.
the class AsyncJobDaoImpl method getResetJobs.
@Override
public List<AsyncJobVO> getResetJobs(long msid) {
SearchCriteria<AsyncJobVO> sc = pendingAsyncJobSearch.create();
sc.setParameters("status", JobInfo.Status.IN_PROGRESS);
// construct query: (job_executing_msid=msid OR (job_executing_msid IS NULL AND job_init_msid=msid))
SearchCriteria<AsyncJobVO> msQuery = createSearchCriteria();
msQuery.addOr("executingMsid", SearchCriteria.Op.EQ, msid);
SearchCriteria<AsyncJobVO> initMsQuery = createSearchCriteria();
initMsQuery.addAnd("executingMsid", SearchCriteria.Op.NULL);
initMsQuery.addAnd("initMsid", SearchCriteria.Op.EQ, msid);
msQuery.addOr("initMsid", SearchCriteria.Op.SC, initMsQuery);
sc.addAnd("executingMsid", SearchCriteria.Op.SC, msQuery);
Filter filter = new Filter(AsyncJobVO.class, "created", true, null, null);
return listIncludingRemovedBy(sc, filter);
}
use of org.apache.cloudstack.framework.jobs.impl.AsyncJobVO in project cloudstack by apache.
the class AsyncJobDaoImpl method getExpiredUnfinishedJobs.
@Override
public List<AsyncJobVO> getExpiredUnfinishedJobs(Date cutTime, int limit) {
SearchCriteria<AsyncJobVO> sc = expiringUnfinishedAsyncJobSearch.create();
sc.setParameters("jobDispatcher", AsyncJobVO.JOB_DISPATCHER_PSEUDO);
sc.setParameters("created", cutTime);
sc.setParameters("jobStatus", JobInfo.Status.IN_PROGRESS);
Filter filter = new Filter(AsyncJobVO.class, "created", true, 0L, (long) limit);
return listIncludingRemovedBy(sc, filter);
}
Aggregations