Search in sources :

Example 26 with LogicalUnit

use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.

the class HDSCreateMetaVolumeMembersJob method updateStatus.

/**
 * Called to update the job status when the create meta members job completes.
 *
 * @param jobContext The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
        if (_status == JobStatus.SUCCESS) {
            List<LogicalUnit> luList = (List<LogicalUnit>) _javaResult.getBean(HDSConstants.LOGICALUNIT_LIST_BEAN_NAME);
            List<String> luObjectIdList = new ArrayList<String>();
            // verify that all meta members have been created
            if (null != luList && !luList.isEmpty()) {
                for (LogicalUnit lu : luList) {
                    luObjectIdList.add(lu.getObjectID());
                }
            }
            if (luObjectIdList.size() != count) {
                logMsgBuilder.append("\n");
                logMsgBuilder.append(String.format("   Failed to create required number %s of meta members for meta head %s, task: %s .", count, metaHead.getLabel(), opId));
                _log.error(logMsgBuilder.toString());
                setFailedStatus(logMsgBuilder.toString());
            } else {
                // Process meta members
                logMsgBuilder.append("\n");
                logMsgBuilder.append(String.format("   Created required number %s of meta members for meta head %s, task: %s .", count, metaHead.getLabel(), opId));
                metaMembers.addAll(luObjectIdList);
                logMsgBuilder.append(String.format("%n Meta member device ID's: %s", metaMembers));
                _log.info(logMsgBuilder.toString());
            }
        } else if (_status == JobStatus.FAILED) {
            logMsgBuilder.append("\n");
            logMsgBuilder.append(String.format("Task %s failed to create meta members for meta head volume: %s", opId, metaHead.getLabel()));
            _log.error(logMsgBuilder.toString());
            setFailedStatus(logMsgBuilder.toString());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for " + this.getJobName(), e);
        setErrorStatus("Encountered an internal error during " + this.getJobName() + " job status processing : " + e.getMessage());
    } finally {
        metaVolumeTaskCompleter.setLastStepStatus(_status);
        if (_status != JobStatus.IN_PROGRESS) {
            // set meta members native ids in step data in WF
            String opId = metaVolumeTaskCompleter.getVolumeTaskCompleter().getOpId();
            WorkflowService.getInstance().storeStepData(opId, metaMembers);
            _log.debug("Set meta members for meta volume in WF. Members: {}", metaMembers);
        }
        // operation.
        if (_status == Job.JobStatus.FAILED || _status == Job.JobStatus.ERROR) {
            super.updateStatus(jobContext);
        }
    }
}
Also used : LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 27 with LogicalUnit

use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.

the class HDSModifyVolumeJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext
 *            The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    LogicalUnit logicalUnit = null;
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
        if (_status == JobStatus.SUCCESS) {
            logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
            if (null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevListItr = logicalUnit.getLdevList().iterator();
                if (ldevListItr.hasNext()) {
                    LDEV ldev = ldevListItr.next();
                    if (null != ldev && -1 != ldev.getTierLevel()) {
                        logMsgBuilder.append(String.format("Task %s is successful to update volume %s tieringPolicy: %s", opId, logicalUnit.getObjectID(), ldev.getTierLevel()));
                    }
                }
            }
        } else if (_status == JobStatus.FAILED && VOLUME_MODIFY_JOB.equalsIgnoreCase(getJobName())) {
            URI id = getTaskCompleter().getId();
            logMsgBuilder.append(String.format("Task %s failed to update volume tieringPolicy: %s", opId, id.toString()));
            Volume volume = dbClient.queryObject(Volume.class, id);
            volume.setInactive(true);
            dbClient.persistObject(volume);
        }
        log.info(logMsgBuilder.toString());
    } catch (Exception e) {
        log.error("Caught an exception while trying to updating tieringPolicy of the volume", e);
        setErrorStatus("Encountered an internal error during tieringPolicy updation of volume: " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) URI(java.net.URI)

Aggregations

LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)27 URI (java.net.URI)18 ClientResponse (com.sun.jersey.api.client.ClientResponse)13 InputStream (java.io.InputStream)13 HashMap (java.util.HashMap)13 JavaResult (org.milyn.payload.JavaResult)13 StorageArray (com.emc.storageos.hds.model.StorageArray)12 IOException (java.io.IOException)12 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)10 EchoCommand (com.emc.storageos.hds.model.EchoCommand)9 Error (com.emc.storageos.hds.model.Error)9 LDEV (com.emc.storageos.hds.model.LDEV)7 ArrayList (java.util.ArrayList)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 Volume (com.emc.storageos.db.client.model.Volume)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 HDSException (com.emc.storageos.hds.HDSException)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)5