Search in sources :

Example 26 with MigrationCallbackException

use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.

the class StorageSystemArrayAffinityDiscoveryMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Storage system Array affinity discovery migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> systemURIs = dbClient.queryByType(StorageSystem.class, true);
        Iterator<StorageSystem> systems = dbClient.queryIterativeObjects(StorageSystem.class, systemURIs, true);
        List<StorageSystem> modifiedSystems = new ArrayList<StorageSystem>();
        while (systems.hasNext()) {
            StorageSystem system = systems.next();
            system.setArrayAffinityStatus(DataCollectionJobStatus.CREATED.name());
            system.setLastArrayAffinityRunTime(0L);
            system.setNextArrayAffinityRunTime(0L);
            system.setSuccessArrayAffinityTime(0L);
            modifiedSystems.add(system);
            logger.info("Updating StorageSystem (id={}) with default values for array affinity discovery statuses", system.getId().toString());
        }
        if (!modifiedSystems.isEmpty()) {
            dbClient.updateObject(modifiedSystems);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating array affinity discovery default values for Storage systems");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Storage system Array affinity discovery migration END");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 27 with MigrationCallbackException

use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.

the class TimeSeriesIndexMigration method process.

@Override
public void process() throws MigrationCallbackException {
    log.info("Adding new index records for class: {} field: {} annotation: {}", new Object[] { Order.class.getName(), Order.SUBMITTED, TimeSeriesAlternateId.class.getName() });
    ColumnFamily<String, IndexColumnName> tenantToOrder = new ColumnFamily<>(SOURCE_INDEX_CF_NAME, StringSerializer.get(), IndexColumnNameSerializer.get());
    ColumnFamily<String, IndexColumnName> timeseriesIndex = new ColumnFamily<>(SOURCE_INDEX_CF_NAME2, StringSerializer.get(), IndexColumnNameSerializer.get());
    DataObjectType doType = TypeMap.getDoType(Order.class);
    ColumnField field = doType.getColumnField(Order.SUBMITTED);
    ColumnFamily<String, TimeSeriesIndexColumnName> newIndexCF = field.getIndexCF();
    DbClientImpl client = (DbClientImpl) dbClient;
    Keyspace ks = client.getKeyspace(Order.class);
    List<CompletableFuture<Void>> tasks = new ArrayList(TASK_SIZE);
    try {
        OperationResult<Rows<String, IndexColumnName>> result = ks.prepareQuery(tenantToOrder).getAllRows().setRowLimit(1000).withColumnRange(new RangeBuilder().setLimit(0).build()).execute();
        for (Row<String, IndexColumnName> row : result.getResult()) {
            RowQuery<String, IndexColumnName> rowQuery = ks.prepareQuery(tenantToOrder).getKey(row.getKey()).autoPaginate(true).withColumnRange(new RangeBuilder().setLimit(5).build());
            ColumnList<IndexColumnName> cols = rowQuery.execute().getResult();
            while (!cols.isEmpty()) {
                if (tasks.size() < TASK_SIZE) {
                    CompletableFuture<Void> task = CompletableFuture.runAsync(new MigrationTask(ks, row.getKey(), cols, tenantToOrder, timeseriesIndex, newIndexCF));
                    tasks.add(task);
                } else {
                    CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])).join();
                    tasks = new ArrayList(TASK_SIZE);
                }
                cols = rowQuery.execute().getResult();
            }
        }
        if (!tasks.isEmpty()) {
            CompletableFuture.allOf(tasks.toArray(new CompletableFuture[0])).join();
        }
    } catch (Exception e) {
        log.error("Migration to {} failed e=", newIndexCF.getName(), e);
    }
}
Also used : RangeBuilder(com.netflix.astyanax.util.RangeBuilder) CompositeRangeBuilder(com.netflix.astyanax.serializers.CompositeRangeBuilder) ArrayList(java.util.ArrayList) CompletableFuture(java.util.concurrent.CompletableFuture) Order(com.emc.storageos.db.client.model.uimodels.Order) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) TimeSeriesAlternateId(com.emc.storageos.db.client.model.TimeSeriesAlternateId) Keyspace(com.netflix.astyanax.Keyspace)

Example 28 with MigrationCallbackException

use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.

the class VirtualNASMultipleProjectsAssociationMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Migration started.");
    DbClient dbClient = getDbClient();
    List<VirtualNAS> vNASList = new ArrayList<VirtualNAS>();
    try {
        List<URI> virtualNASUris = dbClient.queryByType(VirtualNAS.class, true);
        Iterator<VirtualNAS> virtualNASIterator = dbClient.queryIterativeObjects(VirtualNAS.class, virtualNASUris, true);
        logger.info("Processing virtual NASs to set the associated project into a set.");
        while (virtualNASIterator.hasNext()) {
            VirtualNAS virtualNAS = virtualNASIterator.next();
            URI projectURI = virtualNAS.getProject();
            if (!NullColumnValueGetter.isNullURI(projectURI)) {
                virtualNAS.associateProject(projectURI.toString());
                vNASList.add(virtualNAS);
            }
        }
        if (!vNASList.isEmpty()) {
            logger.debug("Calling updateObject() to update virtual NAS is DB.");
            dbClient.updateObject(vNASList);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while associating project to virtual NAS.");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Migration completed successfully");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 29 with MigrationCallbackException

use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.

the class VirtualPoolAutoTieringPolicyMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Processing virtual pool auto tiering policy migration");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolUris = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolUris, true);
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            // If there is a FAST policy associated with the vpool, then mark the uniquePolicyNames to true
            if (virtualPool.getAutoTierPolicyName() != null && !virtualPool.getAutoTierPolicyName().isEmpty()) {
                // No way other than using contains to differentiate NativeGuid
                if (virtualPool.getAutoTierPolicyName().contains(NATIVE_GUID_DELIMITER)) {
                    virtualPool.setUniquePolicyNames(false);
                } else {
                    virtualPool.setUniquePolicyNames(true);
                }
                dbClient.persistObject(virtualPool);
                logger.info("Updating VirtualPool (id={}) with  unique policy names set to {}", virtualPool.getId().toString(), virtualPool.getUniquePolicyNames());
            }
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating auto tiering policy of vpool");
        logger.error(ex.getMessage(), ex);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 30 with MigrationCallbackException

use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.

the class VirtualPoolDefaultValuesForSystemTypeDriveTypeMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Migration started");
    DbClient dbClient = getDbClient();
    boolean changed = false;
    try {
        List<URI> virtualPoolUris = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolUris, true);
        logger.info("Processing virtual pool to set default values for drive type and system type as NONE");
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            changed = false;
            if (virtualPool.getDriveType() == null) {
                logger.info("Setting drive type to NONE for Virtual Pool {}", virtualPool.getId());
                virtualPool.setDriveType(SupportedDriveTypes.NONE.name());
                changed = true;
            }
            StringSetMap arrayInfo = virtualPool.getArrayInfo();
            if (arrayInfo != null) {
                if (arrayInfo.get(SYSTEM_TYPE_KEY) == null) {
                    logger.info("Setting array system type to NONE for Virtual Pool {}", virtualPool.getId());
                    arrayInfo.put(SYSTEM_TYPE_KEY, VirtualPool.SystemType.NONE.name());
                    changed = true;
                }
            } else {
                logger.info("No existing array info. Creating new array info and setting system type to NONE for Virtual Pool {}", virtualPool.getId());
                arrayInfo = new StringSetMap();
                arrayInfo.put(SYSTEM_TYPE_KEY, VirtualPool.SystemType.NONE.name());
                virtualPool.setArrayInfo(arrayInfo);
                changed = true;
            }
            if (changed) {
                logger.info("Persisting changes into DB for Virtual Pool {}", virtualPool.getId());
                dbClient.persistObject(virtualPool);
            }
        }
    } catch (Exception ex) {
        logger.error("Exception occured while setting default values to system type and drive type in virtual pool");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Migration completed successfully");
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

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