use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class NetworkConnectedVirtualArraysMigration method process.
/**
* Add assigned virtual arrays to connected virtual arrays.
* Starting 2.0, connected virtual arrays includes assigned,
* connected via port-virtualArray associations, and connected
* via routed networks
*/
@Override
public void process() throws MigrationCallbackException {
DbClient dbClient = getDbClient();
try {
List<URI> networkUris = dbClient.queryByType(Network.class, true);
Iterator<Network> networks = dbClient.queryIterativeObjects(Network.class, networkUris);
List<Network> updated = new ArrayList<Network>();
while (networks.hasNext()) {
Network network = networks.next();
log.info("Updating connected virtual arrays for network {}", network.getLabel());
if (network.getAssignedVirtualArrays() != null) {
if (network.getConnectedVirtualArrays() != null) {
for (String assignedVarrayUri : network.getAssignedVirtualArrays()) {
log.info("Adding virtual array {} to connected virtual arrays", assignedVarrayUri);
network.getConnectedVirtualArrays().add(assignedVarrayUri);
}
} else {
log.info("Setting connected virtual arrays to {}", network.getAssignedVirtualArrays());
network.setConnectedVirtualArrays(new StringSet(network.getAssignedVirtualArrays()));
}
updated.add(network);
}
}
dbClient.updateAndReindexObject(updated);
} catch (Exception e) {
log.error("Exception occured while updating Network connectedVirtualArrays");
log.error(e.getMessage(), e);
}
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class QualityOfServiceMigration method getDataFromVirtualPool.
/**
* Retrieves information from given Virtual Pool
*
* @param virtualPool Virtual Pool
* @return QosSpecification filled with information from Virtual Pool
*/
private QosSpecification getDataFromVirtualPool(VirtualPool virtualPool) throws MigrationCallbackException {
_log.debug("Fetching data from Virtual Pool, id: {}", virtualPool.getId());
QosSpecification qos = null;
try {
qos = new QosSpecification();
StringMap specs = new StringMap();
qos.setName(QOS_NAME + virtualPool.getLabel());
qos.setConsumer(QOS_CONSUMER);
qos.setLabel(virtualPool.getLabel());
qos.setId(URIUtil.createId(QosSpecification.class));
qos.setVirtualPoolId(virtualPool.getId());
String protocols = null;
if (virtualPool.getProtocols() != null) {
protocols = virtualPool.getProtocols().toString();
}
if (protocols != null) {
specs.put(SPEC_PROTOCOL, protocols.substring(1, protocols.length() - 1));
}
if (virtualPool.getSupportedProvisioningType() != null) {
specs.put(SPEC_PROVISIONING_TYPE, virtualPool.getSupportedProvisioningType());
}
if (virtualPool.getDriveType() != null) {
specs.put(SPEC_DRIVE_TYPE, virtualPool.getDriveType());
}
String systemType = getSystemType(virtualPool);
if (systemType != null) {
specs.put(SPEC_SYSTEM_TYPE, systemType);
}
if (virtualPool.getMultivolumeConsistency() != null) {
specs.put(SPEC_MULTI_VOL_CONSISTENCY, Boolean.toString(virtualPool.getMultivolumeConsistency()));
}
if (virtualPool.getArrayInfo() != null && virtualPool.getArrayInfo().get(RAID_LEVEL) != null) {
specs.put(SPEC_RAID_LEVEL, virtualPool.getArrayInfo().get(RAID_LEVEL).toString());
}
if (virtualPool.getExpandable() != null) {
specs.put(SPEC_EXPENDABLE, Boolean.toString(virtualPool.getExpandable()));
}
if (virtualPool.getNumPaths() != null) {
specs.put(SPEC_MAX_SAN_PATHS, Integer.toString(virtualPool.getNumPaths()));
}
if (virtualPool.getMinPaths() != null) {
specs.put(SPEC_MIN_SAN_PATHS, Integer.toString(virtualPool.getMinPaths()));
}
if (virtualPool.getMaxNativeContinuousCopies() != null) {
specs.put(SPEC_MAX_BLOCK_MIRRORS, Integer.toString(virtualPool.getMaxNativeContinuousCopies()));
}
if (virtualPool.getPathsPerInitiator() != null) {
specs.put(SPEC_PATHS_PER_INITIATOR, Integer.toString(virtualPool.getPathsPerInitiator()));
}
if (virtualPool.getHighAvailability() != null) {
specs.put(SPEC_HIGH_AVAILABILITY, virtualPool.getHighAvailability());
}
if (virtualPool.getMaxNativeSnapshots() != null) {
if (virtualPool.getMaxNativeSnapshots().equals(UNLIMITED_SNAPSHOTS)) {
specs.put(SPEC_MAX_SNAPSHOTS, LABEL_UNLIMITED_SNAPSHOTS);
} else if (virtualPool.getMaxNativeSnapshots().equals(DISABLED_SNAPSHOTS)) {
specs.put(SPEC_MAX_SNAPSHOTS, LABEL_DISABLED_SNAPSHOTS);
} else {
specs.put(SPEC_MAX_SNAPSHOTS, Integer.toString(virtualPool.getMaxNativeSnapshots()));
}
}
qos.setSpecs(specs);
} catch (Exception e) {
String errorMsg = String.format("%s encounter unexpected error %s", getName(), e.getMessage());
_log.error(errorMsg);
throw new MigrationCallbackException(errorMsg, e);
}
return qos;
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class SRDFTargetVolumeRDFGroupMigration method process.
@Override
public void process() throws MigrationCallbackException {
log.info("Updating SRDF Target volume rdfGroup information.");
DbClient dbClient = this.getDbClient();
List<URI> volumeURIs = dbClient.queryByType(Volume.class, true);
Map<URI, RemoteDirectorGroup> rdfGroupCache = new HashMap<URI, RemoteDirectorGroup>();
Map<URI, StorageSystem> systemCache = new HashMap<URI, StorageSystem>();
List<Volume> volumesToUpdate = new ArrayList<Volume>();
Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeURIs);
while (volumes.hasNext()) {
Volume volume = volumes.next();
try {
if (null != volume.getSrdfParent() && !NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent())) {
if (null != volume.getSrdfGroup() && !NullColumnValueGetter.isNullURI(volume.getSrdfGroup()) && !NullColumnValueGetter.isNullURI(volume.getStorageController())) {
log.info("Determining SRDF Target volume {} to update rdf group", volume.getLabel());
RemoteDirectorGroup volumeSrdfGroup = fetchRDFGroupFromCache(rdfGroupCache, volume.getSrdfGroup());
StorageSystem system = fetchSystemFromCache(systemCache, volume.getStorageController());
// Found a target volume with the target SRDFGroup uri
if (URIUtil.identical(volumeSrdfGroup.getSourceStorageSystemUri(), volume.getStorageController())) {
// Set the source SRDF Group URI
RemoteDirectorGroup sourceRDFGroup = getAssociatedTargetRemoteDirectorGroup(system.getUsingSmis80(), volumeSrdfGroup.getNativeGuid());
if (null == sourceRDFGroup) {
log.info("Source RDFGroup not found in DB. Hence skipping.");
continue;
}
volume.setSrdfGroup(sourceRDFGroup.getId());
volumesToUpdate.add(volume);
if (volumesToUpdate.size() > 100) {
this.dbClient.updateObject(volumesToUpdate);
log.info("Updated {} SRDF Target volumes in db", volumesToUpdate.size());
volumesToUpdate.clear();
}
} else {
log.info("No need to update the rdfgroup for volume {} as it has the right source RDFGroup {}", volume.getLabel(), volume.getSrdfGroup());
}
}
}
} catch (Exception ex) {
log.error("Exception occurred while updating the SRDFGroup for the target volume {}. proceeding next..", volume.getLabel());
}
}
// Update the remaining volumes
if (volumesToUpdate.size() > 0) {
this.dbClient.updateObject(volumesToUpdate);
log.info("Updated {} SRDF Target volumes in db", volumesToUpdate.size());
}
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class StaleIndexCleanerMigration method process.
@Override
public void process() throws MigrationCallbackException {
checkHelper = new DbConsistencyCheckerHelper((DbClientImpl) getDbClient());
checkHelper.setDoubleConfirmed(false);
Map<String, IndexAndCf> allIdxCfs = getAllIndexCFs();
CheckResult checkResult = new CheckResult();
try {
for (IndexAndCf indexAndCf : allIdxCfs.values()) {
try {
checkHelper.checkIndexingCF(indexAndCf, false, checkResult, true);
} catch (ConnectionException e) {
log.error("Failed to check stale index CF {}", indexAndCf, e);
}
}
ThreadPoolExecutor executor = checkHelper.getExecutor();
executor.shutdown();
try {
if (!executor.awaitTermination(120, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (Exception e) {
executor.shutdownNow();
}
log.info("Totally find {} stale index", checkResult.getTotal());
if (checkResult.getTotal() > 0) {
executeCleanupScripts();
}
} catch (Exception e) {
log.error("failed to cleanup stale/invalid index:", e);
} finally {
DbCheckerFileWriter.close();
}
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class UserToOrdersMigration method process.
@Override
public void process() throws MigrationCallbackException {
log.info("Adding new index records for class: {} field: {} annotation: {} name={}", new Object[] { Order.class, Order.SUBMITTED_BY_USER_ID, ClassNameTimeSeries.class.getName(), name });
DataObjectType doType = TypeMap.getDoType(Order.class);
ColumnField field = doType.getColumnField(Order.SUBMITTED_BY_USER_ID);
newIndexCF = field.getIndexCF();
ColumnFamily<String, IndexColumnName> userToOrders = new ColumnFamily<>(SOURCE_INDEX_CF_NAME, StringSerializer.get(), IndexColumnNameSerializer.get());
DbClientImpl client = (DbClientImpl) dbClient;
ks = client.getKeyspace(Order.class);
MutationBatch mutationBatch = ks.prepareMutationBatch();
long m = 0;
try {
OperationResult<Rows<String, IndexColumnName>> result = ks.prepareQuery(userToOrders).getAllRows().setRowLimit(1000).withColumnRange(new RangeBuilder().setLimit(0).build()).execute();
ColumnList<IndexColumnName> cols;
for (Row<String, IndexColumnName> row : result.getResult()) {
RowQuery<String, IndexColumnName> rowQuery = ks.prepareQuery(userToOrders).getKey(row.getKey()).autoPaginate(true).withColumnRange(new RangeBuilder().setLimit(5).build());
while (!(cols = rowQuery.execute().getResult()).isEmpty()) {
m++;
for (Column<IndexColumnName> col : cols) {
String indexKey = row.getKey();
String orderId = col.getName().getTwo();
ClassNameTimeSeriesIndexColumnName newCol = new ClassNameTimeSeriesIndexColumnName(col.getName().getOne(), orderId, col.getName().getTimeUUID());
mutationBatch.withRow(newIndexCF, indexKey).putEmptyColumn(newCol, null);
if (m % 10000 == 0) {
mutationBatch.execute();
}
}
}
}
mutationBatch.execute();
} catch (Exception e) {
log.error("Migration to {} failed e=", newIndexCF.getName(), e);
}
}
Aggregations