Search in sources :

Example 6 with SmisException

use of com.emc.storageos.volumecontroller.impl.smis.SmisException 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

SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 CIMObjectPath (javax.cim.CIMObjectPath)5 CIMArgument (javax.cim.CIMArgument)4 Volume (com.emc.storageos.db.client.model.Volume)3 URI (java.net.URI)3 WBEMException (javax.wbem.WBEMException)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ExportMask (com.emc.storageos.db.client.model.ExportMask)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1