use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupCreateCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createConsistencyGroup.
@Override
public void createConsistencyGroup(URI storage, URI consistencyGroup, String opId) throws ControllerException {
TaskCompleter completer = new BlockConsistencyGroupCreateCompleter(consistencyGroup, opId);
try {
WorkflowStepCompleter.stepExecuting(opId);
// Lock the CG for the step duration.
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, consistencyGroup, storage));
_workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
// Check if already created, if not create, if so just complete.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
String groupName = ControllerUtils.generateReplicationGroupName(storageObj, cg, null, _dbClient);
if (!cg.created(storage, groupName)) {
getDevice(storageObj.getSystemType()).doCreateConsistencyGroup(storageObj, consistencyGroup, groupName, completer);
} else {
_log.info(String.format("Consistency group %s (%s) already created", cg.getLabel(), cg.getId()));
completer.ready(_dbClient);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
throw DeviceControllerException.exceptions.createConsistencyGroupFailed(e);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupCreateCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createConsistencyGroupStep.
public boolean createConsistencyGroupStep(URI storage, URI consistencyGroup, String replicationGroupName, String opId) throws ControllerException {
TaskCompleter taskCompleter = null;
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
taskCompleter = new BlockConsistencyGroupCreateCompleter(consistencyGroup, opId);
String groupName = ControllerUtils.generateReplicationGroupName(storageSystem, consistencyGroup, replicationGroupName, _dbClient);
String lockKey = groupName;
boolean isVNX = storageSystem.deviceIsType(Type.vnxblock);
if (isVNX && lockKey == null) {
lockKey = replicationGroupName;
}
if (lockKey == null) {
BlockConsistencyGroup cgObj = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
lockKey = cgObj.getAlternateLabel() != null ? cgObj.getAlternateLabel() : cgObj.getLabel();
}
// Lock the CG for the step duration.
List<String> lockKeys = new ArrayList<>();
lockKeys.add(ControllerLockingUtil.getReplicationGroupStorageKey(_dbClient, lockKey, storage));
_workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
if (isVNX) {
// replication group may have been just created by another thread, in that case,
// group name for VNX will be array generated name (if arrayConsistency is true), or
// replicationGroupName if arrayConsistency is false
// so get the group name again here to be used in ControllerUtils.replicationGroupExists call
groupName = ControllerUtils.generateReplicationGroupName(storageSystem, consistencyGroup, replicationGroupName, _dbClient);
}
// make sure this array consistency group was not just created by another thread that held the lock
if (groupName != null && ControllerUtils.replicationGroupExists(storage, groupName, _dbClient)) {
taskCompleter.ready(_dbClient);
return true;
}
getDevice(storageSystem.getSystemType()).doCreateConsistencyGroup(storageSystem, consistencyGroup, groupName, taskCompleter);
} catch (Exception e) {
_log.error("create consistency group job failed:", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
return false;
}
return true;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupCreateCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testCreateConsistencyGroup.
@Test
public void testCreateConsistencyGroup() {
URI consistencyGroup = createConsistencyGroup().getId();
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
BlockConsistencyGroupCreateCompleter taskCompleter = new BlockConsistencyGroupCreateCompleter(consistencyGroup, token);
_deviceController.doCreateConsistencyGroup(_storageSystem, consistencyGroup, null, taskCompleter);
}
Aggregations