use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class RecordableEventManager method recordEvents.
/**
* Called to record events in the database.
*
* @param events references to recordable events.
* @throws IOException thrown when insert events to database fails
*/
public void recordEvents(RecordableEvent... events) throws DatabaseException {
List<Event> dbEventsList = new ArrayList<Event>();
for (RecordableEvent event : events) {
Event dbEvent = ControllerUtils.convertToEvent(event);
// we need to drop the these indications
if (event.getResourceId() == null && !(event instanceof RecordableBourneEvent)) {
continue;
}
dbEventsList.add(dbEvent);
}
if (!dbEventsList.isEmpty()) {
Event[] dbEvents = new Event[dbEventsList.size()];
dbEventsList.toArray(dbEvents);
// Now insert the events into the database.
try {
String bucketId = _dbClient.insertTimeSeries(EventTimeSeries.class, dbEvents);
s_logger.debug("Event(s) persisted into Cassandra with bucketId/rowId : {}", bucketId);
} catch (DatabaseException e) {
s_logger.error("Error inserting events into the database", e);
throw e;
}
} else {
s_logger.info("Event list is empty");
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method discover.
/**
* {@inheritDoc}
*/
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemURI = null;
StorageSystem storageSystem = null;
String detailedStatusMessage = "Unknown Status";
long startTime = System.currentTimeMillis();
try {
_logger.info("Access Profile Details :" + accessProfile.toString());
storageSystemURI = accessProfile.getSystemId();
storageSystem = queryStorageSystem(accessProfile);
_keyMap = new ConcurrentHashMap<String, Object>();
_wbemClient = getCIMClient(accessProfile);
_logger.info("CIMClient initialized successfully");
_keyMap.put(Constants._cimClient, _wbemClient);
_keyMap.put(Constants.dbClient, _dbClient);
_keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
if (_networkDeviceController != null) {
_keyMap.put(Constants.networkDeviceController, _networkDeviceController);
}
_keyMap.put(Constants.PROPS, accessProfile.getProps());
_keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
_keyMap.put(Constants.ACCESSPROFILE, accessProfile);
_keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
_keyMap.put(Constants._serialID, accessProfile.getserialID());
_keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.PROTOCOLS, new HashSet<String>());
_keyMap.put(Constants.STORAGEETHERNETPORTS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.IPENDPOINTS, new LinkedList<CIMObjectPath>());
_keyMap.put(Constants.STORAGEVOLUMES, new LinkedList<CIMObjectPath>());
String providerVersion = getProviderVersionString(storageSystem);
if (null != providerVersion) {
_keyMap.put(Constants.VERSION, providerVersion);
_keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
}
Map<URI, StoragePool> poolsToMatchWithVpool = new HashMap<URI, StoragePool>();
_keyMap.put(Constants.MODIFIED_STORAGEPOOLS, poolsToMatchWithVpool);
// need this nested structure to be able to minimize the changes on existing code.
List<List<StoragePort>> portsToRunNetworkConnectivity = new ArrayList<List<StoragePort>>();
_keyMap.put(Constants.STORAGE_PORTS, portsToRunNetworkConnectivity);
List<StoragePort> discoveredPorts = new ArrayList<StoragePort>();
_keyMap.put(Constants.DISCOVERED_PORTS, discoveredPorts);
_keyMap.put(Constants.SLO_NAMES, new HashSet<String>());
if (Type.ibmxiv.name().equals(accessProfile.getSystemType())) {
initIBMDiscoveryKeyMap(accessProfile);
} else {
initEMCDiscoveryKeyMap(accessProfile);
if (Type.vmax.name().equals(accessProfile.getSystemType())) {
// discover port group
_keyMap.put(Constants.PORTGROUP, CimObjectPathCreator.createInstance(Constants.SE_TARGETMASKINGGROUP, accessProfile.getInteropNamespace()));
}
}
executor.setKeyMap(_keyMap);
executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemURI.toString(), e.getMessage());
_logger.error(detailedStatusMessage, e);
throw new SMIPluginException(detailedStatusMessage);
} finally {
if (storageSystem != null) {
try {
// set detailed message
storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(storageSystem);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
releaseResources();
long totalTime = System.currentTimeMillis() - startTime;
_logger.info(String.format("Discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method discoverArrayAffinity.
/**
* {@inheritDoc}
*/
@Override
public void discoverArrayAffinity(AccessProfile accessProfile) {
_logger.info("Calling discoverArrayAffinity");
URI storageSystemURI = accessProfile.getSystemId();
String detailedStatusMessage = "Array Affinity Discovery completed successfully for Storage System: %s";
long startTime = System.currentTimeMillis();
try {
_logger.info("Access Profile Details :" + accessProfile.toString());
_keyMap = new ConcurrentHashMap<String, Object>();
_wbemClient = getCIMClient(accessProfile);
_logger.info("CIMClient initialized successfully");
_keyMap.put(Constants._cimClient, _wbemClient);
_keyMap.put(Constants.dbClient, _dbClient);
_keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
_keyMap.put(Constants.PROPS, accessProfile.getProps());
_keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
_keyMap.put(Constants.ACCESSPROFILE, accessProfile);
_keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
_keyMap.put(Constants._serialID, accessProfile.getserialID());
_keyMap.put(Constants.MASKING_VIEWS, new LinkedList<CIMObjectPath>());
StorageSystem storageSystem = queryStorageSystem(accessProfile);
String providerVersion = getProviderVersionString(storageSystem);
if (null != providerVersion) {
_keyMap.put(Constants.VERSION, providerVersion);
_keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
}
executor.setKeyMap(_keyMap);
executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
} catch (Exception e) {
detailedStatusMessage = "Array Affinity Discovery failed for Storage System: %s because " + e.getMessage();
_logger.error(String.format(detailedStatusMessage, storageSystemURI.toString()), e);
throw new SMIPluginException(String.format(detailedStatusMessage, storageSystemURI.toString()));
} finally {
try {
String systemIdsStr = accessProfile.getProps().get(Constants.SYSTEM_IDS);
String[] systemIds = systemIdsStr.split(Constants.ID_DELIMITER);
List<StorageSystem> systemsToUpdate = new ArrayList<StorageSystem>();
for (String systemId : systemIds) {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, URI.create(systemId));
// set detailed message
system.setLastArrayAffinityStatusMessage(String.format(detailedStatusMessage, systemId));
systemsToUpdate.add(system);
}
_dbClient.updateObject(systemsToUpdate);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
releaseResources();
long totalTime = System.currentTimeMillis() - startTime;
_logger.info(String.format("Array Affinity discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discoverArrayAffinity.
/**
* {@inheritDoc}
*
* @param accessProfile
* @throws VNXeException
*/
@Override
public void discoverArrayAffinity(AccessProfile accessProfile) throws VNXeException {
_logger.info("Calling discoverArrayAffinity");
long startTime = System.currentTimeMillis();
URI systemURI = accessProfile.getSystemId();
StorageSystem system = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
// Get the VNX Unity storage system from the database.
system = _dbClient.queryObject(StorageSystem.class, systemURI);
if (system == null || system.getInactive()) {
_logger.warn("System {} is no longer active", systemURI);
return;
}
_logger.info(String.format("Array Affinity Discover on VNX Unity storage system %s at IP: %s, PORT: %s", systemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber()));
system.setArrayAffinityStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
_dbClient.updateObject(system);
unityArrayAffinityDiscoverer.discoverArrayAffinity(accessProfile, _dbClient, _partitionManager);
_logger.info("Finished array affinity discovery");
detailedStatusMessage = String.format("Array Affinity Discovery completed successfully for Storage System: %s", systemURI.toString());
} catch (Exception e) {
detailedStatusMessage = String.format("Array Affinity Discovery failed for VNX Unity %s: %s", systemURI.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw VNXeException.exceptions.discoveryError("Array Affinity Discovery error", e);
} finally {
if (system != null) {
try {
// set detailed message
system.setLastArrayAffinityStatusMessage(detailedStatusMessage);
_dbClient.updateObject(system);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
long totalTime = System.currentTimeMillis() - startTime;
_logger.info(String.format("Array Affinity discovery of Storage System %s took %f seconds", systemURI.toString(), (double) totalTime / (double) 1000));
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method discover.
/**
* Implementation for VNX Unity storage systems discovery, both of block and
* file
*
* @param accessProfile
*
* @throws VNXeException
*/
@Override
public void discover(AccessProfile accessProfile) throws VNXeException {
URI storageSystemURI = accessProfile.getSystemId();
StorageSystem viprStorageSystem = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
if (null != accessProfile.getnamespace() && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()) || accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_FILESYSTEMS.toString()))) {
discoverUnmanagedObjects(accessProfile);
} else {
// Get the VNX Unity storage system from the database.
viprStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
_logger.info(String.format("Discover VnxUnity storage system %s at IP:%s, PORT:%s", storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber()));
// Get the vnx unity service client for getting information
// about the Vnx Unity storage system.
VNXeApiClient client = getVnxUnityClient(accessProfile);
_logger.debug("Got handle to Vnx unity service client");
// Get the serial number and the native guid and set into the
// storage system.
_logger.info("Discovering storage system properties.");
VNXeStorageSystem system = client.getStorageSystem();
boolean isFASTVPEnabled = client.isFASTVPEnabled();
viprStorageSystem = discoverStorageSystemInfo(client, accessProfile, system, isFASTVPEnabled, viprStorageSystem);
StringSet arraySupportedProtocols = new StringSet();
// Discover the NasServers
Map<String, URI> nasServerIdMap = new HashMap<String, URI>();
Map<String, List<StorageHADomain>> nasServers = discoverNasServers(viprStorageSystem, client, nasServerIdMap, arraySupportedProtocols);
_logger.info("No of newly discovered NasServers {}", nasServers.get(NEW).size());
_logger.info("No of existing discovered NasServers {}", nasServers.get(EXISTING).size());
if (!nasServers.get(NEW).isEmpty()) {
_dbClient.createObject(nasServers.get(NEW));
}
if (!nasServers.get(EXISTING).isEmpty()) {
_dbClient.updateObject(nasServers.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed NAS Server discovery");
// Discover FileInterfaces
List<StoragePort> allExistingPorts = new ArrayList<StoragePort>();
List<StoragePort> allNewPorts = new ArrayList<StoragePort>();
Map<String, List<StoragePort>> ports = discoverFileStoragePorts(viprStorageSystem, client, nasServerIdMap);
if (ports.get(NEW) != null && !ports.get(NEW).isEmpty()) {
allNewPorts.addAll(ports.get(NEW));
_dbClient.createObject(ports.get(NEW));
}
if (ports.get(EXISTING) != null && !ports.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(ports.get(EXISTING));
_dbClient.updateObject(ports.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed file ports discovery");
// discover storage processors
Map<String, URI> spIdMap = new HashMap<String, URI>();
Map<String, List<StorageHADomain>> sps = discoverStorageProcessors(viprStorageSystem, client, spIdMap);
if (!sps.get(NEW).isEmpty()) {
_dbClient.createObject(sps.get(NEW));
}
if (!sps.get(EXISTING).isEmpty()) {
_dbClient.updateObject(sps.get(EXISTING));
}
_completer.statusPending(_dbClient, "Completed storage processor discovery");
// discover iscsi ports
Map<String, List<StoragePort>> iscsiPorts = discoverIscsiPorts(viprStorageSystem, client, spIdMap);
boolean hasIscsiPorts = false;
if (iscsiPorts.get(NEW) != null && !iscsiPorts.get(NEW).isEmpty()) {
allNewPorts.addAll(iscsiPorts.get(NEW));
hasIscsiPorts = true;
_dbClient.createObject(iscsiPorts.get(NEW));
}
if (iscsiPorts.get(EXISTING) != null && !iscsiPorts.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(iscsiPorts.get(EXISTING));
hasIscsiPorts = true;
_dbClient.updateObject(iscsiPorts.get(EXISTING));
}
if (hasIscsiPorts) {
arraySupportedProtocols.add(StorageProtocol.Block.iSCSI.name());
}
_completer.statusPending(_dbClient, "Completed iscsi ports discovery");
// discover fc ports
Map<String, List<StoragePort>> fcPorts = discoverFcPorts(viprStorageSystem, client, spIdMap);
boolean hasFcPorts = false;
if (fcPorts.get(NEW) != null && !fcPorts.get(NEW).isEmpty()) {
allNewPorts.addAll(fcPorts.get(NEW));
hasFcPorts = true;
_dbClient.createObject(fcPorts.get(NEW));
}
if (fcPorts.get(EXISTING) != null && !fcPorts.get(EXISTING).isEmpty()) {
allExistingPorts.addAll(fcPorts.get(EXISTING));
hasFcPorts = true;
_dbClient.updateObject(fcPorts.get(EXISTING));
}
if (hasFcPorts) {
arraySupportedProtocols.add(StorageProtocol.Block.FC.name());
}
_completer.statusPending(_dbClient, "Completed FC ports discovery");
List<StoragePort> allPorts = new ArrayList<StoragePort>(allNewPorts);
allPorts.addAll(allExistingPorts);
// check if any port not visible in this discovery
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, viprStorageSystem.getId());
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
allExistingPorts.addAll(notVisiblePorts);
}
/**
* Discover the VNX Unity pool information.
*/
_logger.info("Discovering storage pools.");
List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
Map<String, List<StoragePool>> pools = discoverStoragePools(viprStorageSystem, client, arraySupportedProtocols, poolsToMatchWithVpool);
_logger.info("No of newly discovered pools {}", pools.get(NEW).size());
_logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
if (!pools.get(NEW).isEmpty()) {
allPools.addAll(pools.get(NEW));
_dbClient.createObject(pools.get(NEW));
StoragePoolAssociationHelper.setStoragePoolVarrays(viprStorageSystem.getId(), pools.get(NEW), _dbClient);
}
if (!pools.get(EXISTING).isEmpty()) {
allPools.addAll(pools.get(EXISTING));
_dbClient.updateObject(pools.get(EXISTING));
}
List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, viprStorageSystem.getId());
if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
poolsToMatchWithVpool.addAll(notVisiblePools);
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allNewPorts, allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
_completer.statusPending(_dbClient, "Completed pool discovery");
// This associates the VNas with the virtual array
StoragePortAssociationHelper.runUpdateVirtualNasAssociationsProcess(allExistingPorts, null, _dbClient);
_logger.info("update virtual nas association for unity");
if (isFASTVPEnabled) {
_logger.info("FASTVP is enabled");
HashMap<String, List<AutoTieringPolicy>> policies = discoverAutoTierPolicies(viprStorageSystem, client);
if (!policies.get(NEW).isEmpty()) {
_dbClient.createObject(policies.get(NEW));
}
if (!policies.get(EXISTING).isEmpty()) {
_dbClient.updateObject(policies.get(EXISTING));
}
HashMap<String, List<StorageTier>> tiers = discoverStorageTier(viprStorageSystem, client);
if (!tiers.get(NEW).isEmpty()) {
_dbClient.createObject(tiers.get(NEW));
}
if (!tiers.get(EXISTING).isEmpty()) {
_dbClient.updateObject(tiers.get(EXISTING));
}
}
detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
}
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for VNX Unity %s: %s", storageSystemURI.toString(), e.getLocalizedMessage());
_logger.error(detailedStatusMessage, e);
throw VNXeException.exceptions.discoveryError("Discovery error", e);
} finally {
if (viprStorageSystem != null) {
try {
// set detailed message
viprStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(viprStorageSystem);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
}
}
Aggregations