Search in sources :

Example 11 with MigrationCallbackException

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 12 with MigrationCallbackException

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;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 13 with MigrationCallbackException

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());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 14 with MigrationCallbackException

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();
    }
}
Also used : DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CheckResult(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.CheckResult) DbConsistencyCheckerHelper(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper) IndexAndCf(com.emc.storageos.db.client.impl.DbConsistencyCheckerHelper.IndexAndCf) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 15 with MigrationCallbackException

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);
    }
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ColumnField(com.emc.storageos.db.client.impl.ColumnField) RangeBuilder(com.netflix.astyanax.util.RangeBuilder) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ColumnFamily(com.netflix.astyanax.model.ColumnFamily) ClassNameTimeSeries(com.emc.storageos.db.client.model.ClassNameTimeSeries) ClassNameTimeSeriesIndexColumnName(com.emc.storageos.db.client.impl.ClassNameTimeSeriesIndexColumnName) IndexColumnName(com.emc.storageos.db.client.impl.IndexColumnName) MutationBatch(com.netflix.astyanax.MutationBatch) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType) Rows(com.netflix.astyanax.model.Rows)

Aggregations

MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)36 URI (java.net.URI)25 DbClient (com.emc.storageos.db.client.DbClient)24 ArrayList (java.util.ArrayList)18 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)9 StringSet (com.emc.storageos.db.client.model.StringSet)6 FileShare (com.emc.storageos.db.client.model.FileShare)4 HashMap (java.util.HashMap)4 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)3 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)3 Volume (com.emc.storageos.db.client.model.Volume)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 Configuration (com.emc.storageos.coordinator.common.Configuration)2 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 FileReplicationTopology (com.emc.storageos.db.client.model.FileReplicationTopology)2 Initiator (com.emc.storageos.db.client.model.Initiator)2