Search in sources :

Example 6 with JobPollResult

use of com.emc.storageos.volumecontroller.impl.JobPollResult in project coprhd-controller by CoprHD.

the class HDSCommandHelper method waitForAsyncHDSJob.

/**
 * wait for hds async job.
 *
 * @param job {@link HDSJob}
 */
public void waitForAsyncHDSJob(HDSJob job) throws HDSException {
    JobContext jobContext = new JobContext(dbClient, null, null, hdsApiFactory, null, null, null);
    long startTime = System.currentTimeMillis();
    while (true) {
        JobPollResult result = job.poll(jobContext, trackingPeriodInMillis);
        if (!job.isJobInTerminalState()) {
            if (System.currentTimeMillis() - startTime > HDSJob.ERROR_TRACKING_LIMIT) {
                log.error("Timed out waiting on hds job to complete after {} milliseconds", System.currentTimeMillis() - startTime);
                throw HDSException.exceptions.asyncTaskFailedTimeout(HDSJob.ERROR_TRACKING_LIMIT);
            } else {
                try {
                    Thread.sleep(trackingPeriodInMillis);
                } catch (InterruptedException e) {
                    log.error("Thread waiting for hds job to complete was interrupted and " + "will be resumed");
                }
            }
        } else {
            if (job.isJobInTerminalFailedState()) {
                throw HDSException.exceptions.asyncTaskFailed(result.getErrorDescription());
            }
            break;
        }
    }
}
Also used : JobContext(com.emc.storageos.volumecontroller.JobContext) JobPollResult(com.emc.storageos.volumecontroller.impl.JobPollResult)

Example 7 with JobPollResult

use of com.emc.storageos.volumecontroller.impl.JobPollResult in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method waitForSmisJob.

private JobStatus waitForSmisJob(StorageSystem storageDevice, SmisJob job, int pollCycleLimit) throws SmisException {
    JobStatus status = JobStatus.IN_PROGRESS;
    JobContext jobContext = new JobContext(_dbClient, _cimConnection, null, null, null, null, null, this);
    long startTime = System.currentTimeMillis();
    int pollCycleCount = 0;
    while (true) {
        JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
        pollCycleCount++;
        if (result.getJobStatus().equals(JobStatus.IN_PROGRESS)) {
            if (pollCycleCount > pollCycleLimit) {
                throw new SmisException("Reached maximum number of poll " + pollCycleLimit);
            } else if (System.currentTimeMillis() - startTime > SYNC_WRAPPER_TIME_OUT) {
                throw new SmisException("Timed out waiting on smis job to complete after " + (System.currentTimeMillis() - startTime) + " milliseconds");
            } else {
                try {
                    Thread.sleep(SYNC_WRAPPER_WAIT);
                } catch (InterruptedException e) {
                    _log.error("Thread waiting for smis job to complete was interrupted and will be resumed");
                }
            }
        } else {
            status = result.getJobStatus();
            if (!status.equals(JobStatus.SUCCESS)) {
                throw new SmisException("Smis job failed: " + result.getErrorDescription());
            }
            break;
        }
    }
    return status;
}
Also used : JobStatus(com.emc.storageos.volumecontroller.Job.JobStatus) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) JobContext(com.emc.storageos.volumecontroller.JobContext) JobPollResult(com.emc.storageos.volumecontroller.impl.JobPollResult)

Aggregations

JobPollResult (com.emc.storageos.volumecontroller.impl.JobPollResult)7 DbClient (com.emc.storageos.db.client.DbClient)4 JobContext (com.emc.storageos.volumecontroller.JobContext)4 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)2 JobStatus (com.emc.storageos.volumecontroller.Job.JobStatus)2 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)2 CIMInstance (javax.cim.CIMInstance)2 CIMObjectPath (javax.cim.CIMObjectPath)2 WBEMClient (javax.wbem.client.WBEMClient)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 Volume (com.emc.storageos.db.client.model.Volume)1 LinkStatus (com.emc.storageos.db.client.model.Volume.LinkStatus)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 Job (com.emc.storageos.volumecontroller.Job)1 MetaVolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.MetaVolumeTaskCompleter)1 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)1 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)1