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);
}
}
}
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);
}
}
Aggregations