Search in sources :

Example 1 with AsyncJobVO

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RebootRouterCmd(org.apache.cloudstack.api.command.admin.router.RebootRouterCmd) DomainRouterVO(com.cloud.vm.DomainRouterVO) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Example 2 with AsyncJobVO

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);
        }
    }
}
Also used : VmWorkTakeVolumeSnapshot(com.cloud.vm.VmWorkTakeVolumeSnapshot) VmWorkAttachVolume(com.cloud.vm.VmWorkAttachVolume) VmWorkMigrateVolume(com.cloud.vm.VmWorkMigrateVolume) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) InsufficientStorageCapacityException(com.cloud.exception.InsufficientStorageCapacityException) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StorageAccessException(com.cloud.exception.StorageAccessException) ExecutionException(java.util.concurrent.ExecutionException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Example 3 with AsyncJobVO

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);
}
Also used : Filter(com.cloud.utils.db.Filter) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Example 4 with AsyncJobVO

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);
}
Also used : Filter(com.cloud.utils.db.Filter) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Example 5 with AsyncJobVO

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);
}
Also used : Filter(com.cloud.utils.db.Filter) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Aggregations

AsyncJobVO (org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)13 Account (com.cloud.user.Account)5 Filter (com.cloud.utils.db.Filter)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 ConfigurationException (javax.naming.ConfigurationException)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 SnapshotScheduleVO (com.cloud.storage.SnapshotScheduleVO)2 DB (com.cloud.utils.db.DB)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 VMInstanceVO (com.cloud.vm.VMInstanceVO)2 VmWorkAttachVolume (com.cloud.vm.VmWorkAttachVolume)2 VMSnapshotVO (com.cloud.vm.snapshot.VMSnapshotVO)2 ArrayList (java.util.ArrayList)2 CallContext (org.apache.cloudstack.context.CallContext)2 DispatchTask (com.cloud.api.dispatch.DispatchTask)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientStorageCapacityException (com.cloud.exception.InsufficientStorageCapacityException)1 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1