use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doRestoreFromGroupClone.
@Override
public void doRestoreFromGroupClone(StorageSystem storageSystem, List<URI> cloneVolumes, TaskCompleter taskCompleter) {
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = null;
List<Volume> clones = dbClient.queryObject(Volume.class, cloneVolumes);
_log.info("Restore from group clone on storage system {}, clones: {} .", storageSystem.getNativeId(), clones.toString());
try {
Map<VolumeClone, Volume> driverCloneToCloneMap = new HashMap<>();
List<VolumeClone> driverClones = new ArrayList<>();
for (Volume clone : clones) {
BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
VolumeClone driverClone = new VolumeClone();
driverClone.setStorageSystemId(storageSystem.getNativeId());
driverClone.setNativeId(clone.getNativeId());
driverClone.setParentId(sourceVolume.getNativeId());
driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
driverClones.add(driverClone);
driverCloneToCloneMap.put(driverClone, clone);
}
// Call driver
task = driver.restoreFromClone(Collections.unmodifiableList(driverClones));
if (!isTaskInTerminalState(task.getStatus())) {
// If the task is not in a terminal state and will be completed asynchronously
// create a job to monitor the progress of the request and update the clone
// volume replica state and call the completer as appropriate based on the result
// of the request.
RestoreFromGroupCloneExternalDeviceJob job = new RestoreFromGroupCloneExternalDeviceJob(storageSystem.getId(), cloneVolumes, task.getTaskId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(job));
} else if (task.getStatus() == DriverTask.TaskStatus.READY) {
for (Map.Entry<VolumeClone, Volume> entry : driverCloneToCloneMap.entrySet()) {
VolumeClone driverClone = entry.getKey();
Volume clone = entry.getValue();
ExternalDeviceUtils.updateRestoredClone(clone, driverClone, dbClient, false);
}
String msg = String.format("doRestoreFromGroupClone -- Restore from group clone: %s .", task.getMessage());
_log.info(msg);
dbClient.updateObject(clones);
taskCompleter.ready(dbClient);
} else {
String msg = String.format("Failed to restore from group clone on storage system %s, clones: %s .", storageSystem.getNativeId(), clones.toString());
_log.error(msg);
ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromGroupClone", msg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
String msg = String.format("Failed to restore from group clone on storage system %s, clones: %s .", storageSystem.getNativeId(), clones.toString());
_log.error(msg, e);
ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromGroupClone", msg);
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class HDSCloneOperations method restoreFromSingleClone.
@Override
public void restoreFromSingleClone(StorageSystem storageSystem, URI cloneURI, TaskCompleter taskCompleter) {
try {
Volume cloneVolume = dbClient.queryObject(Volume.class, cloneURI);
Volume sourceVolume = dbClient.queryObject(Volume.class, cloneVolume.getAssociatedSourceVolume());
hdsProtectionOperations.modifyShadowImagePair(storageSystem, sourceVolume.getNativeId(), cloneVolume.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.restore);
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageSystem.getId(), sourceVolume.getNativeId(), cloneVolume.getNativeId(), ReplicationStatus.PAIR, taskCompleter)));
log.info("FINISH restoreFromSingleClone for {}", cloneURI);
} catch (Exception e) {
String errorMsg = String.format(RESTORE_ERROR_MSG_FORMAT, cloneURI);
log.error(errorMsg, e);
taskCompleter.error(dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method deleteSingleVolumeMirror.
/**
* Deletes mirror instance from StorageSystem
*/
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
Set<String> thickLogicalUnitIdList = new HashSet<String>();
Set<String> thinLogicalUnitIdList = new HashSet<String>();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
if (logicalUnit == null) {
// related volume state (if any) has been deleted. skip
// processing, if already deleted from array.
log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
// HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
dbClient.markForDeletion(mirrorObj);
} else {
if (mirrorObj.getThinlyProvisioned()) {
thinLogicalUnitIdList.add(logicalUnitObjectId);
} else {
thickLogicalUnitIdList.add(logicalUnitObjectId);
}
log.info(logMsgBuilder.toString());
if (!thickLogicalUnitIdList.isEmpty()) {
String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThickLUsJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
if (!thinLogicalUnitIdList.isEmpty()) {
String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThinHDSJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
}
log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
} catch (Exception e) {
log.error("Problem in deleteSingleVolumeMirror: ", e);
ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doModifyVolumes.
@Override
public void doModifyVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Modify Volume Start - Array:%s, Pool:%s", storage.getSerialNumber(), storagePool.getNativeGuid()));
String systemObjectID = HDSUtils.getSystemObjectID(storage);
for (Volume volume : volumes) {
try {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s, tieringPolicy: %s", volume.getLabel(), volume.getThinlyProvisioned(), volume.getAutoTieringPolicyUri()));
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage));
String policyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
String autoTierPolicyName = null;
if (policyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
} else {
autoTierPolicyName = HitachiTieringPolicy.getPolicy(policyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
}
if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
if (ldevItr.hasNext()) {
LDEV ldev = ldevItr.next();
String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, logicalUnit.getObjectID(), ldev.getObjectID(), autoTierPolicyName, storage.getModel());
if (null != asyncMessageId) {
HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_MODIFY_JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
}
}
} else {
String errorMsg = String.format("No LDEV's found for volume: %s", volume.getId());
log.info(errorMsg);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (final Exception e) {
log.error("Problem in doModifyVolumes: ", e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
}
use of com.emc.storageos.volumecontroller.impl.job.QueueJob in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doDeleteVolumes.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes(com.emc.storageos.db.client.model.StorageSystem,
* java.lang.String, java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
Set<String> thickLogicalUnitIdList = new HashSet<String>();
Set<String> thinLogicalUnitIdList = new HashSet<String>();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
log.info("volumes size: {}", volumes.size());
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storageSystem);
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectId, logicalUnitObjectId);
if (logicalUnit == null) {
// related volume state (if any) has been deleted. skip
// processing, if already deleted from array.
log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
dbClient.persistObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(dbClient);
continue;
}
if (volume.getThinlyProvisioned()) {
thinLogicalUnitIdList.add(logicalUnitObjectId);
} else {
thickLogicalUnitIdList.add(logicalUnitObjectId);
}
}
log.info(logMsgBuilder.toString());
if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
if (null != thickLogicalUnitIdList && !thickLogicalUnitIdList.isEmpty()) {
String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectId, thickLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThickLUsJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThickLUsJobId, volumes.get(0).getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
}
}
if (null != thinLogicalUnitIdList && !thinLogicalUnitIdList.isEmpty()) {
String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectId, thinLogicalUnitIdList, storageSystem.getModel());
// in single operation.
if (null != asyncThinHDSJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThinHDSJobId, volumes.get(0).getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
}
}
} else {
// If we are here, there are no volumes to delete, we have
// invoked ready() for the VolumeDeleteCompleter, and told
// the multiVolumeTaskCompleter to skip these completers.
// In this case, the multiVolumeTaskCompleter complete()
// method will not be invoked and the result is that the
// workflow that initiated this delete request will never
// be updated. So, here we just call complete() on the
// multiVolumeTaskCompleter to ensure the workflow status is
// updated.
multiVolumeTaskCompleter.ready(dbClient);
}
} catch (Exception e) {
log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.hds.methodFailed("doDeleteVolume", e.getMessage());
taskCompleter.error(dbClient, error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
log.info(logMsgBuilder.toString());
}
Aggregations