use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class HDSVolumeExpandJob method updateStatus.
/**
* Called to update the job status when the volume expand job completes.
*
* @param jobContext
* The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
LogicalUnit logicalUnit = null;
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
DbClient dbClient = jobContext.getDbClient();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
// from pool's reserved capacity map.
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
HDSUtils.updateStoragePoolCapacity(dbClient, hdsApiClient, storagePool);
StringMap reservationMap = storagePool.getReservedCapacityMap();
URI volumeId = getTaskCompleter().getId();
// remove from reservation map
reservationMap.remove(volumeId.toString());
dbClient.persistObject(storagePool);
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
if (_status == JobStatus.SUCCESS) {
VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
// set requested capacity
volume.setCapacity(taskCompleter.getSize());
// set meta related properties
volume.setIsComposite(taskCompleter.isComposite());
volume.setCompositionType(taskCompleter.getMetaVolumeType());
logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
if (null != logicalUnit) {
long capacityInBytes = (Long.valueOf(logicalUnit.getCapacityInKB())) * 1024L;
volume.setProvisionedCapacity(capacityInBytes);
volume.setAllocatedCapacity(capacityInBytes);
}
logMsgBuilder.append(String.format("%n Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
if (volume.getIsComposite()) {
logMsgBuilder.append(String.format("%n Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
}
_log.info(logMsgBuilder.toString());
dbClient.persistObject(volume);
// Reset list of meta members native ids in WF data (when meta
// is created meta members are removed from array)
WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
}
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for HDSVolumeExpandJob", e);
setErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method computeStaticLoadMetrics.
/**
* Compute static load metrics.
*
* @param accessProfile
* @return
*/
private void computeStaticLoadMetrics(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = accessProfile.getSystemId();
StorageSystem storageSystem = null;
try {
storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
_logger.info("started computeStaticLoadMetrics for storagesystem: {}", storageSystem.getLabel());
VNXeApiClient client = getVnxUnityClient(accessProfile);
List<VNXeNasServer> nasServers = client.getNasServers();
for (VNXeNasServer nasServer : nasServers) {
if ((nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) || nasServer.getIsReplicationDestination()) {
_logger.debug("Found a replication destination NasServer");
continue;
}
if (nasServer.getIsSystem()) {
// skip system nasServer
continue;
}
VirtualNAS virtualNAS = findvNasByNativeId(storageSystem, nasServer.getId());
if (virtualNAS != null) {
_logger.info("Process db metrics for nas server : {}", nasServer.getName());
StringMap dbMetrics = virtualNAS.getMetrics();
if (dbMetrics == null) {
dbMetrics = new StringMap();
}
// process db metrics
StringMap tmpDbMetrics = populateDbMetrics(nasServer, client);
dbMetrics.putAll(tmpDbMetrics);
// set dbMetrics in db
virtualNAS.setMetrics(dbMetrics);
_dbClient.updateObject(virtualNAS);
}
}
} catch (Exception e) {
_logger.error("CollectStatisticsInformation failed. Storage system: {}", storageSystemId, e);
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method populateDbMetrics.
/**
* Calculate nas server metrics
*
* @param nasServer
* @param apiClient
* @return StringMap containing calculated metrics
*/
private StringMap populateDbMetrics(final VNXeNasServer nasServer, VNXeApiClient client) {
StringMap dbMetrics = new StringMap();
long totalProvCap = 0L;
long totalFsCount = 0L;
// get total exports
int nfsSharesCount = 0;
int cifsSharesCount = 0;
List<VNXeFileSystem> fileSystemList = client.getFileSystemsForNasServer(nasServer.getId());
if (fileSystemList != null && !fileSystemList.isEmpty()) {
for (VNXeFileSystem fs : fileSystemList) {
totalProvCap = totalProvCap + fs.getSizeTotal();
totalFsCount++;
List<VNXeNfsShare> nfsShares = client.getNfsSharesForFileSystem(fs.getId());
if (nfsShares != null && !nfsShares.isEmpty()) {
nfsSharesCount = nfsSharesCount + nfsShares.size();
}
List<VNXeCifsShare> cifsShares = client.getCifsSharesForFileSystem(fs.getId());
if (cifsShares != null && !cifsShares.isEmpty()) {
cifsSharesCount = cifsSharesCount + cifsShares.size();
}
List<VNXeFileSystemSnap> snapshotsList = client.getFileSystemSnaps(fs.getId());
if (snapshotsList != null && !snapshotsList.isEmpty()) {
for (VNXeFileSystemSnap snap : snapshotsList) {
totalProvCap = totalProvCap + snap.getSize();
totalFsCount++;
List<VNXeNfsShare> snapNfsShares = client.getNfsSharesForSnap(snap.getId());
if (snapNfsShares != null && !snapNfsShares.isEmpty()) {
nfsSharesCount = nfsSharesCount + snapNfsShares.size();
}
List<VNXeCifsShare> snapCifsShares = client.getCifsSharesForSnap(snap.getId());
if (snapCifsShares != null && !snapCifsShares.isEmpty()) {
cifsSharesCount = cifsSharesCount + snapCifsShares.size();
}
}
}
}
}
if (totalProvCap > 0) {
totalProvCap = (totalProvCap / KB_IN_BYTES);
}
_logger.info("Total fs Count {} for nas server : {}", String.valueOf(totalFsCount), nasServer.getName());
_logger.info("Total fs Capacity {} for nas server : {}", String.valueOf(totalProvCap), nasServer.getName());
// Set max limits in dbMetrics
StringMap maxDbMetrics = getMaxDbMetrics(client);
dbMetrics.putAll(maxDbMetrics);
// set total nfs and cifs exports for this nas server
dbMetrics.put(MetricsKeys.totalNfsExports.name(), String.valueOf(nfsSharesCount));
dbMetrics.put(MetricsKeys.totalCifsShares.name(), String.valueOf(cifsSharesCount));
// set total fs objects and their sum of capacity for this nas server
dbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalFsCount));
dbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalProvCap));
Long maxExports = MetricsKeys.getLong(MetricsKeys.maxExports, dbMetrics);
Long maxStorObjs = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, dbMetrics);
Long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, dbMetrics);
Long totalExports = Long.valueOf(nfsSharesCount + cifsSharesCount);
// setting overLoad factor (true or false)
String overLoaded = FALSE;
if (totalExports >= maxExports || totalProvCap >= maxCapacity || totalFsCount >= maxStorObjs) {
overLoaded = TRUE;
}
double percentageLoadExports = 0.0;
// percentage calculator
if (totalExports > 0.0) {
percentageLoadExports = ((double) (totalExports) / maxExports) * 100;
}
double percentageLoadStorObj = ((double) (totalProvCap) / maxCapacity) * 100;
double percentageLoad = (percentageLoadExports + percentageLoadStorObj) / 2;
dbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
dbMetrics.put(MetricsKeys.overLoaded.name(), overLoaded);
return dbMetrics;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverClusterIdentification.
/**
* Implementation for discovering assembly ID (serial number) to cluster id (0 or 1)
* mapping used in placement algorithms such as RP and VPLEX.
*
* @param vplex VPLEX storage system to discovery cluster info for
* @param client a reference to the VPLEX API client
*/
private void discoverClusterIdentification(StorageSystem vplex, VPlexApiClient client) {
try {
if (vplex.getVplexAssemblyIdtoClusterId() != null && !vplex.getVplexAssemblyIdtoClusterId().isEmpty()) {
// to retrieve it again. (This information is not expected to change)
return;
}
// Get the cluster information
List<VPlexClusterInfo> clusterInfoList = client.getClusterInfoLite();
// Get the cluster assembly identifiers and form the
// system serial number based on these identifiers.
StringMap assemblyIdToClusterId = new StringMap();
for (VPlexClusterInfo clusterInfo : clusterInfoList) {
String assemblyId = clusterInfo.getTopLevelAssembly();
if (VPlexApiConstants.NULL_ATT_VAL.equals(assemblyId)) {
throw VPlexCollectionException.exceptions.failedScanningManagedSystemsNullAssemblyId(vplex.getIpAddress(), clusterInfo.getName());
}
assemblyIdToClusterId.put(assemblyId, clusterInfo.getClusterId());
}
// Store the vplex assembly ID -> cluster ID mapping
if (vplex.getVplexAssemblyIdtoClusterId() == null) {
vplex.setVplexAssemblyIdtoClusterId(assemblyIdToClusterId);
} else {
vplex.getVplexAssemblyIdtoClusterId().putAll(assemblyIdToClusterId);
}
} catch (Exception e) {
if (vplex != null) {
s_logger.error("Error discovering cluster identification for the VPLEX storage system {}:", vplex.getIpAddress(), e);
throw VPlexCollectionException.exceptions.failedPortsDiscovery(vplex.getId().toString(), e.getLocalizedMessage(), e);
}
s_logger.error("Error discovering cluster identification for the VPLEX storage system", e);
throw VPlexCollectionException.exceptions.failedPortsDiscovery("None", e.getLocalizedMessage(), e);
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method createUnManagedFileSystem.
/**
* create StorageFileSystem Info Object
*
* @param unManagedFileSystem
* @param unManagedFileSystemNativeGuid
* @param system
* @param pool
* @param storagePort
* @param fileSystem
* @return UnManagedFileSystem
* @throws IOException
* @throws VNXFileCollectionException
*/
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, String unManagedFileSystemNativeGuid, StorageSystem system, StoragePool pool, StoragePort storagePort, VNXFileSystem fileSystem) throws IOException, VNXFileCollectionException {
if (null == unManagedFileSystem) {
unManagedFileSystem = new UnManagedFileSystem();
unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
unManagedFileSystem.setStorageSystemUri(system.getId());
unManagedFileSystem.setStoragePoolUri(pool.getId());
unManagedFileSystem.setHasExports(false);
unManagedFileSystem.setHasShares(false);
}
Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
StringMap unManagedFileSystemCharacteristics = new StringMap();
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
if (fileSystem.getType().equals(UnManagedDiscoveredObject.SupportedProvisioningType.THICK.name())) {
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), FALSE);
} else {
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
}
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
if (null != system) {
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
}
if (null != pool) {
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
// We should check matched vpool based on storagepool of type for given fs.
// In vipr, storagepool of thin is taken as THICK
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
_logger.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
if (null == matchedVPools || matchedVPools.isEmpty()) {
// clear all existing supported vpools.
unManagedFileSystem.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
_logger.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
}
}
if (null != storagePort) {
StringSet storagePorts = new StringSet();
storagePorts.add(storagePort.getId().toString());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
}
unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
// Set attributes of FileSystem
StringSet fsPath = new StringSet();
fsPath.add("/" + fileSystem.getFsName());
StringSet fsMountPath = new StringSet();
fsMountPath.add("/" + fileSystem.getFsName());
StringSet fsName = new StringSet();
fsName.add(fileSystem.getFsName());
StringSet fsId = new StringSet();
fsId.add(fileSystem.getFsId() + "");
unManagedFileSystem.setLabel(fileSystem.getFsName());
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAME.toString(), fsName);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NATIVE_ID.toString(), fsId);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PATH.toString(), fsPath);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
StringSet allocatedCapacity = new StringSet();
String usedCapacity = "0";
if (fileSystem.getUsedCapacity() != null) {
usedCapacity = fileSystem.getUsedCapacity();
}
allocatedCapacity.add(usedCapacity);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
StringSet provisionedCapacity = new StringSet();
String capacity = "0";
if (fileSystem.getTotalCapacity() != null) {
capacity = fileSystem.getTotalCapacity();
}
provisionedCapacity.add(capacity);
unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
// Add fileSystemInformation and Characteristics.
unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
unManagedFileSystem.setFileSystemCharacterstics(unManagedFileSystemCharacteristics);
return unManagedFileSystem;
}
Aggregations