use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class ZoneReferencesRemoveCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
if (removeZoneReferences || status == Status.error) {
String refKey = null;
try {
for (URI fcZoneReferenceId : getIds()) {
if (NullColumnValueGetter.isNullURI(fcZoneReferenceId)) {
_log.info("fcZoneReferenceId is null. Nothing to remove.");
continue;
}
FCZoneReference ref = dbClient.queryObject(FCZoneReference.class, fcZoneReferenceId);
if (ref != null) {
refKey = ref.getPwwnKey();
_log.info(String.format("Remove FCZoneReference key: %s volume %s id %s", ref.getPwwnKey(), ref.getVolumeUri(), ref.getId().toString()));
dbClient.removeObject(ref);
}
}
} catch (DatabaseException ex) {
_log.error("Could not persist FCZoneReference: " + refKey);
}
}
updateWorkflowStatus(status, coded);
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class XIVCommunicationInterface method scan.
/**
* {@inheritDoc}
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
// Call scan method of SMICommunication interface to validate SMIS connectivity
super.scan(accessProfile);
URI providerURI = null;
StorageProvider providerObj = null;
String detailedStatusMessage = "Unknown Status";
try {
providerURI = accessProfile.getSystemId();
providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
// Validate Secondary URL for its availability
validateManagementURL(providerObj.getSecondaryURL(), providerObj.getSecondaryUsername(), providerObj.getSecondaryPassword());
// scan succeeds
detailedStatusMessage = String.format("Scan job completed successfully for REST API: %s", providerObj.getSecondaryURL());
} catch (Exception e) {
detailedStatusMessage = String.format("Scan job failed for REST API: %s because %s", providerObj.getSecondaryURL(), e.getMessage());
throw new SMIPluginException(detailedStatusMessage);
} finally {
if (providerObj != null) {
try {
// set detailed message
providerObj.setLastScanStatusMessage(detailedStatusMessage);
_dbClient.updateObject(providerObj);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class DataCollectionJobUtil method updateActiveProviderDetailsInDbSystem.
/**
* Finds & update the storage systems in the following scenarios.
*
* 1. Query all systems from db.
* 2. If the system is not vnxblock or vmaxblock, then continue.
* 3. Verify each system whether it is in the scanned list or not.
* 4. If it is in the scannedList then update the activeprovider details.
* 5. If it is not in the scannedList then
* 6 .Check whether the system's active Provider is part of the InitialScanList
* (both Providers which tookj part for Scanning + providers which had dropped due
* to connection issues found in refreshConnections)
* 7. If yes, then set check whether the system is registered or not.
* If it is registered, then set the reachableStatus to false
* else delete all its components.
* 8. If NO, then don't disturb.
*
* @param scannedSystemsNativeGuidsMap
* : List of scanned Systems NativeGuids.
* @param systemsToPersist : List of systems to persist.
* @param initialScanList : intialScanned List of providers.
* @param providersToUpdate : Providers to update holds provider => List of managed systems
*/
public void updateActiveProviderDetailsInDbSystem(Map<String, StorageSystemViewObject> scannedSystemsNativeGuidsMap, List<StorageSystem> systemsToPersist, Set<URI> initialScanList, Map<URI, List<String>> providersToUpdate) {
Iterator<URI> storageSystemUrisInDb;
StorageSystem storageSystemInDb = null;
try {
storageSystemUrisInDb = _dbClient.queryByType(StorageSystem.class, true).iterator();
} catch (DatabaseException e) {
_logger.error("Exception occurred while querying db to get StorageSystems due to ", e);
return;
}
while (storageSystemUrisInDb.hasNext()) {
URI dbSystemUri = storageSystemUrisInDb.next();
try {
storageSystemInDb = _dbClient.queryObject(StorageSystem.class, dbSystemUri);
if (null == storageSystemInDb || !storageSystemInDb.isStorageSystemManagedByProvider()) {
_logger.info("Either storageSystem object is null or system not managed by provider : {}", dbSystemUri);
continue;
}
// By this time, DB has true reflection of physical Environment
// Case 1: registered and managed by provider. mark it visible
// Case 2: not registered still managed by provider. mark it
// visible.
String dbSystemNativeGuid = storageSystemInDb.getNativeGuid();
if (scannedSystemsNativeGuidsMap.containsKey(dbSystemNativeGuid)) {
_logger.info("Detected a existing storage system {} via scan process again.", dbSystemNativeGuid);
StorageSystemViewObject systemDetails = scannedSystemsNativeGuidsMap.get(dbSystemNativeGuid);
updateActiveProviders(systemDetails, storageSystemInDb, providersToUpdate);
} else {
_logger.info("Existing discovered storage system {} is not part of available new scan list.", dbSystemNativeGuid);
if (initialScanList.contains(storageSystemInDb.getActiveProviderURI())) {
// Invisible.
if (RegistrationStatus.REGISTERED.toString().equalsIgnoreCase(storageSystemInDb.getRegistrationStatus())) {
injectReachableStatusInSystem(storageSystemInDb, null, NullColumnValueGetter.getNullURI(), false);
}
}
}
} catch (Exception e) {
_logger.error("Exception while updating visible status for id: {} due to", storageSystemInDb.getId(), e);
}
systemsToPersist.add(storageSystemInDb);
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class BlockMonitoringImpl method stopMonitoringStaleSystem.
/**
* 1.Find stale SMIS Provider from DB
* 2. Un-subscribe cimconnection to avoid indications.
* 3. Remove stale smisprovider URI from local CACHE
*/
@Override
public void stopMonitoringStaleSystem() {
_logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
Iterator<Map.Entry<String, DistributedQueueItemProcessedCallback>> iter = SMIS_PROVIDERS_CACHE.entrySet().iterator();
StorageProvider smisprovider = null;
while (iter.hasNext()) {
Map.Entry<String, DistributedQueueItemProcessedCallback> entry = iter.next();
String smisProvoiderURI = entry.getKey();
_logger.debug("smisProvoiderURI :{}", smisProvoiderURI);
try {
smisprovider = _dbClient.queryObject(StorageProvider.class, URI.create(smisProvoiderURI));
} catch (final DatabaseException e) {
_logger.error(e.getMessage(), e);
}
if (null == smisprovider || smisprovider.getInactive()) {
_logger.info("Stale SMIS Provider {} has been removed from monitoring", smisProvoiderURI);
_connectionFactory.unsubscribeSMIProviderConnection(smisProvoiderURI);
try {
// Removes monitorinJob token from queue
entry.getValue().itemProcessed();
} catch (Exception e) {
_logger.error("Exception occurred while removing monitoringJob token from ZooKeeper queue", e);
} finally {
// Removes from CACHE
iter.remove();
ACTIVE_SMIS_PROVIDERS_CACHE.remove(smisProvoiderURI);
}
}
}
_logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class IsilonMonitoringImpl method stopMonitoringStaleSystem.
@Override
public void stopMonitoringStaleSystem() {
_logger.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
Iterator<Map.Entry<MonitoredDevice, DistributedQueueItemProcessedCallback>> iter = ISILON_CACHE.entrySet().iterator();
StorageSystem storageDeviceFromDB = null;
while (iter.hasNext()) {
Map.Entry<MonitoredDevice, DistributedQueueItemProcessedCallback> entry = iter.next();
MonitoredDevice monitoredDevice = entry.getKey();
URI isilonDeviceURI = monitoredDevice._storageSystemURI;
_logger.debug("storageDeviceURI :{}", isilonDeviceURI);
try {
storageDeviceFromDB = _dbClient.queryObject(StorageSystem.class, isilonDeviceURI);
} catch (DatabaseException e) {
_logger.error(e.getMessage(), e);
}
if (null == storageDeviceFromDB || storageDeviceFromDB.getInactive()) {
_logger.info("Stale isilon {} has been removed from monitoring", isilonDeviceURI);
try {
// Removes monitorinJob token from queue
entry.getValue().itemProcessed();
} catch (Exception e) {
_logger.error("Exception occurred while removing monitoringJob token from ZooKeeper queue", e);
} finally {
// Removes item from CACHE
iter.remove();
}
}
}
_logger.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
}
Aggregations