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");
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations