Search in sources :

Example 26 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class ExtendedCommunicationInterfaceImpl method injectStats.

/**
 * Inject Stats to Cassandra. To-Do: To verify, how fast batch insertion is
 * working for entries in 1000s. If its taking time, then will need to work
 * out, splitting again the batch into smaller batches.
 *
 * @throws BaseCollectionException
 */
protected void injectStats() throws BaseCollectionException {
    DbClient client = (DbClient) _keyMap.get(Constants.dbClient);
    @SuppressWarnings("unchecked") List<Stat> stats = (List<Stat>) _keyMap.get(Constants._Stats);
    @SuppressWarnings("unchecked") Map<String, String> props = (Map<String, String>) _keyMap.get(Constants.PROPS);
    String collectionType = props.get(Constants.METERING_COLLECTION_TYPE);
    if (collectionType != null && Constants.METERING_COLLECTION_TYPE_FULL.equalsIgnoreCase(collectionType)) {
        _logger.info("Started Injection of Stats to Cassandra");
        // insert in batches
        int size = Constants.DEFAULT_PARTITION_SIZE;
        if (null != props.get(Constants.METERING_RECORDS_PARTITION_SIZE)) {
            size = Integer.parseInt(props.get(Constants.METERING_RECORDS_PARTITION_SIZE));
        }
        if (null == _partitionManager) {
            Stat[] statBatch = new Stat[stats.size()];
            statBatch = stats.toArray(statBatch);
            try {
                client.insertTimeSeries(StatTimeSeries.class, statBatch);
                _logger.info("{} Stat records persisted to DB", statBatch.length);
            } catch (DatabaseException e) {
                _logger.error("Error inserting records into the database", e);
            }
        } else {
            _partitionManager.insertInBatches(stats, size, client);
        }
    } else {
        _logger.info("Stat records not persisted to DB");
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Stat(com.emc.storageos.db.client.model.Stat) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint)

Example 27 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class ScaleIOStorageDevice method doCreateSnapshot.

@Override
public void doCreateSnapshot(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, snapshotList);
        if (ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, dbClient, taskCompleter)) {
            snapshotOperations.createGroupSnapshots(storage, snapshotList, createInactive, readOnly, taskCompleter);
        } else {
            URI snapshot = snapshots.get(0).getId();
            snapshotOperations.createSingleVolumeSnapshot(storage, snapshot, createInactive, readOnly, taskCompleter);
        }
    } catch (DatabaseException e) {
        String message = String.format("IO exception when trying to create snapshot(s) on array %s", storage.getSerialNumber());
        log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doCreateSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 28 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class AbstractSnapshotOperations method setInactive.

/**
 * Wrapper for setting the BlockSnapshot.inactive value
 *
 * @param snapshotURI [in] - BlockSnapshot object to update
 * @param value [in] - Value to assign to inactive
 */
protected void setInactive(URI snapshotURI, boolean value) {
    try {
        if (snapshotURI != null) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
            snapshot.setInactive(value);
            _dbClient.persistObject(snapshot);
        }
    } catch (DatabaseException e) {
        _log.error("IOException when trying to update snapshot.inactive value", e);
    }
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 29 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class AbstractSnapshotOperations method setInactive.

/**
 * Wrapper for setting the BlockSnapshot.inactive value
 *
 * @param snapshotURIs [in] - List of BlockSnapshot objects to update
 * @param value [in] - Value to assign to inactive
 */
protected void setInactive(List<URI> snapshotURIs, boolean value) {
    try {
        if (snapshotURIs != null) {
            for (URI uri : snapshotURIs) {
                BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
                snapshot.setInactive(value);
                _dbClient.persistObject(snapshot);
            }
        }
    } catch (DatabaseException e) {
        _log.error("IOException when trying to update snapshot.inactive value", e);
    }
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 30 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method refreshConnections.

/**
 * Refresh the SMISProvider connections. This will be called after loading
 * the SMIS Provider information from DB.
 *
 * @param smisproviderList
 *            : List of SMISProvider.
 * @return List<URI> : returns the list of active provider URIs.
 */
public List<URI> refreshConnections(final List<StorageProvider> smisProviderList) {
    _log.debug("In refreshConnections()");
    List<URI> activeProviderURIList = new ArrayList<URI>();
    for (StorageProvider smisProvider : smisProviderList) {
        try {
            CimConnection connection = getConnection(smisProvider.getIPAddress(), smisProvider.getPortNumber().toString());
            if (null == connection) {
                _log.error("No CIMOM connection found for ip/port {}", ConnectionManager.generateConnectionCacheKey(smisProvider.getIPAddress(), smisProvider.getPortNumber()));
                // No need to add connection, as getConnection() called from any thread would create it.
                continue;
            }
            validateProviderConnection(smisProvider, connection, activeProviderURIList);
        } catch (final DatabaseException ex) {
            _log.error("DatabaseException occurred while fetching the storageDevice for {} due to ", smisProvider.getId(), ex);
        } catch (final ConnectionManagerException ex) {
            _log.error("No CIMOM Connection found for ipaddress due to ", ex);
        } catch (final Exception ex) {
            _log.error("Exception while refreshing connections due to ", ex);
        }
    }
    return activeProviderURIList;
}
Also used : ArrayList(java.util.ArrayList) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)109 URI (java.net.URI)70 ArrayList (java.util.ArrayList)29 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 IOException (java.io.IOException)21 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)20 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)19 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)18 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)12 HashSet (java.util.HashSet)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)11 Volume (com.emc.storageos.db.client.model.Volume)11 HashMap (java.util.HashMap)11 List (java.util.List)11 WBEMException (javax.wbem.WBEMException)11