use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method detachSingleVolumeMirror.
/**
* 1. Delete ShadowImage Pair
* 2. Delete DummyLunPath from secondary volume
*/
@Override
public void detachSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
NamedURI sourceVolumeURI = null;
try {
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
// TODO needs to sync pair and wait for synchronization here
Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
sourceVolumeURI = mirrorObj.getSource();
boolean status = hdsProtectionOperations.modifyShadowImagePair(storage, source.getNativeId(), mirrorObj.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
if (status) {
String taskId = UUID.randomUUID().toString();
TaskCompleter completer = new SimpleTaskCompleter(BlockMirror.class, mirror, taskId);
HDSJob syncjob = new HDSReplicationSyncJob(storage.getId(), source.getNativeId(), mirrorObj.getNativeId(), ReplicationStatus.SPLIT, completer);
hdsCommandHelper.waitForAsyncHDSJob(syncjob);
} else {
log.info("Replication info is not available on pair management server");
}
hdsProtectionOperations.deleteShadowImagePair(storage, source, mirrorObj);
hdsProtectionOperations.removeDummyLunPath(storage, mirror);
taskCompleter.ready(dbClient);
} catch (Exception e) {
String errorMsg = String.format(DETACH_ERROR_MSG_FORMAT, mirror, sourceVolumeURI != null ? sourceVolumeURI.toString() : HDSConstants.SPACE_STR);
log.error(errorMsg, e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("detachSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob in project coprhd-controller by CoprHD.
the class HDSMetaVolumeOperations method waitForAsyncHDSJob.
/**
* Waits the thread to till the operation completes.
*
* @param storageDeviceURI
* @param messageId
* @param job
* @param hdsApiFactory
* @return
* @throws HDSException
*/
private JobStatus waitForAsyncHDSJob(URI storageDeviceURI, String messageId, HDSJob job, HDSApiFactory hdsApiFactory) throws HDSException {
JobStatus status = JobStatus.IN_PROGRESS;
if (job == null) {
TaskCompleter taskCompleter = new TaskCompleter() {
@Override
public void ready(DbClient dbClient) throws DeviceControllerException {
}
@Override
public void error(DbClient dbClient, ServiceCoded serviceCoded) throws DeviceControllerException {
}
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
}
};
job = new HDSJob(messageId, storageDeviceURI, taskCompleter, "");
} else {
job.setHDSJob(messageId);
}
JobContext jobContext = new JobContext(dbClient, null, null, hdsApiFactory, null, null, null, null);
long startTime = System.currentTimeMillis();
while (true) {
JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
if (result.getJobStatus().equals(JobStatus.IN_PROGRESS) || result.getJobStatus().equals(JobStatus.ERROR)) {
if (System.currentTimeMillis() - startTime > SYNC_WRAPPER_TIME_OUT) {
HDSException.exceptions.asyncTaskFailedTimeout(System.currentTimeMillis() - startTime);
} else {
try {
Thread.sleep(SYNC_WRAPPER_WAIT);
} catch (InterruptedException e) {
log.error("Thread waiting for hds job to complete was interrupted and " + "will be resumed");
}
}
} else {
status = result.getJobStatus();
if (!status.equals(JobStatus.SUCCESS)) {
HDSException.exceptions.asyncTaskFailedWithErrorResponseWithoutErrorCode(messageId, result.getErrorDescription());
}
break;
}
}
return status;
}
use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method createSecondaryVolumeForSnapshot.
/**
* Creates Snapshot Volume
*
* @param storageSystem
* @param sourceVolume
* @param snapshotObj
* @throws Exception
*/
public void createSecondaryVolumeForSnapshot(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshotObj) throws Exception {
log.info("SecondaryVolume for snapshot creation operation started");
String taskId = UUID.randomUUID().toString();
TaskCompleter taskCompleter = new BlockSnapshotCreateCompleter(Arrays.asList(snapshotObj.getId()), taskId);
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
asyncTaskMessageId = hdsApiClient.createSnapshotVolume(systemObjectID, sourceVolume.getCapacity(), storageSystem.getModel());
if (asyncTaskMessageId != null) {
HDSJob createHDSJob = new HDSBlockCreateSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create snapshot volume call");
}
log.info("SecondaryVolume for snapshot creation operation completed successfully");
}
use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob 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.hds.prov.job.HDSJob in project coprhd-controller by CoprHD.
the class HDSMetaVolumeOperations method expandVolumeAsMetaVolume.
@Override
public void expandVolumeAsMetaVolume(StorageSystem storageSystem, StoragePool storagePool, Volume metaHead, List<String> newMetaMembers, String metaType, MetaVolumeTaskCompleter metaVolumeTaskCompleter) throws Exception {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
LogicalUnit metaHeadVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(metaHead.getNativeId(), storageSystem));
String metaHeadLdevId = null;
List<String> metaMembersLdevObjectIds = new ArrayList<String>();
// Step 1: Get LDEV id's of the meta members and format them
if (null != newMetaMembers && !newMetaMembers.isEmpty()) {
for (String metaMember : newMetaMembers) {
if (null != metaMember) {
String asyncTaskMessageId = hdsApiClient.formatLogicalUnit(systemObjectID, metaMember);
if (asyncTaskMessageId == null) {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
}
HDSJob formatLUJob = new HDSJob(asyncTaskMessageId, storageSystem.getId(), metaVolumeTaskCompleter.getVolumeTaskCompleter(), "formatLogicalUnit");
invokeMethodSynchronously(hdsApiFactory, asyncTaskMessageId, formatLUJob);
}
LogicalUnit metaMemberVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, metaMember);
if (null != metaMemberVolume && !metaMemberVolume.getLdevList().isEmpty()) {
for (LDEV ldev : metaMemberVolume.getLdevList()) {
// Format the logical unit. This is synchronous operation
// should wait it the operation completes.
metaMembersLdevObjectIds.add(ldev.getObjectID());
}
}
}
}
log.info("New Meta member LDEV ids: {}", metaMembersLdevObjectIds);
// Step 2: Get LDEV id of the meta volume head.
if (null != metaHeadVolume && null != metaHeadVolume.getLdevList()) {
for (LDEV ldev : metaHeadVolume.getLdevList()) {
// will be created during expansion of volume.
if (getLDEVID(ldev.getObjectID()).equalsIgnoreCase(metaHead.getNativeId())) {
metaHeadLdevId = ldev.getObjectID();
break;
}
}
}
// Step 3: Create LUSE Volume using metaHead LDEV & meta
// members LDEV Ids.
LogicalUnit logicalUnit = hdsApiClient.createLUSEVolume(systemObjectID, metaHeadLdevId, metaMembersLdevObjectIds);
if (null != logicalUnit) {
long capacityInBytes = Long.valueOf(logicalUnit.getCapacityInKB()) * 1024L;
metaHead.setProvisionedCapacity(capacityInBytes);
metaHead.setAllocatedCapacity(capacityInBytes);
dbClient.persistObject(metaHead);
}
}
Aggregations