Search in sources :

Example 16 with DatabaseException

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);
}
Also used : URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 17 with DatabaseException

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);
            }
        }
    }
}
Also used : SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) XIVRestException(com.emc.storageos.xiv.api.XIVRestException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 18 with DatabaseException

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);
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with DatabaseException

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());
}
Also used : DistributedQueueItemProcessedCallback(com.emc.storageos.coordinator.client.service.DistributedQueueItemProcessedCallback) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 20 with DatabaseException

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());
}
Also used : DistributedQueueItemProcessedCallback(com.emc.storageos.coordinator.client.service.DistributedQueueItemProcessedCallback) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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