use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class QualityOfServiceMigration method getDataFromVirtualPool.
/**
* Retrieves information from given Virtual Pool
*
* @param virtualPool Virtual Pool
* @return QosSpecification filled with information from Virtual Pool
*/
private QosSpecification getDataFromVirtualPool(VirtualPool virtualPool) throws MigrationCallbackException {
_log.debug("Fetching data from Virtual Pool, id: {}", virtualPool.getId());
QosSpecification qos = null;
try {
qos = new QosSpecification();
StringMap specs = new StringMap();
qos.setName(QOS_NAME + virtualPool.getLabel());
qos.setConsumer(QOS_CONSUMER);
qos.setLabel(virtualPool.getLabel());
qos.setId(URIUtil.createId(QosSpecification.class));
qos.setVirtualPoolId(virtualPool.getId());
String protocols = null;
if (virtualPool.getProtocols() != null) {
protocols = virtualPool.getProtocols().toString();
}
if (protocols != null) {
specs.put(SPEC_PROTOCOL, protocols.substring(1, protocols.length() - 1));
}
if (virtualPool.getSupportedProvisioningType() != null) {
specs.put(SPEC_PROVISIONING_TYPE, virtualPool.getSupportedProvisioningType());
}
if (virtualPool.getDriveType() != null) {
specs.put(SPEC_DRIVE_TYPE, virtualPool.getDriveType());
}
String systemType = getSystemType(virtualPool);
if (systemType != null) {
specs.put(SPEC_SYSTEM_TYPE, systemType);
}
if (virtualPool.getMultivolumeConsistency() != null) {
specs.put(SPEC_MULTI_VOL_CONSISTENCY, Boolean.toString(virtualPool.getMultivolumeConsistency()));
}
if (virtualPool.getArrayInfo() != null && virtualPool.getArrayInfo().get(RAID_LEVEL) != null) {
specs.put(SPEC_RAID_LEVEL, virtualPool.getArrayInfo().get(RAID_LEVEL).toString());
}
if (virtualPool.getExpandable() != null) {
specs.put(SPEC_EXPENDABLE, Boolean.toString(virtualPool.getExpandable()));
}
if (virtualPool.getNumPaths() != null) {
specs.put(SPEC_MAX_SAN_PATHS, Integer.toString(virtualPool.getNumPaths()));
}
if (virtualPool.getMinPaths() != null) {
specs.put(SPEC_MIN_SAN_PATHS, Integer.toString(virtualPool.getMinPaths()));
}
if (virtualPool.getMaxNativeContinuousCopies() != null) {
specs.put(SPEC_MAX_BLOCK_MIRRORS, Integer.toString(virtualPool.getMaxNativeContinuousCopies()));
}
if (virtualPool.getPathsPerInitiator() != null) {
specs.put(SPEC_PATHS_PER_INITIATOR, Integer.toString(virtualPool.getPathsPerInitiator()));
}
if (virtualPool.getHighAvailability() != null) {
specs.put(SPEC_HIGH_AVAILABILITY, virtualPool.getHighAvailability());
}
if (virtualPool.getMaxNativeSnapshots() != null) {
if (virtualPool.getMaxNativeSnapshots().equals(UNLIMITED_SNAPSHOTS)) {
specs.put(SPEC_MAX_SNAPSHOTS, LABEL_UNLIMITED_SNAPSHOTS);
} else if (virtualPool.getMaxNativeSnapshots().equals(DISABLED_SNAPSHOTS)) {
specs.put(SPEC_MAX_SNAPSHOTS, LABEL_DISABLED_SNAPSHOTS);
} else {
specs.put(SPEC_MAX_SNAPSHOTS, Integer.toString(virtualPool.getMaxNativeSnapshots()));
}
}
qos.setSpecs(specs);
} catch (Exception e) {
String errorMsg = String.format("%s encounter unexpected error %s", getName(), e.getMessage());
_log.error(errorMsg);
throw new MigrationCallbackException(errorMsg, e);
}
return qos;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class DbInitiatorHostMigrationTest method createExportMask.
private ExportMask createExportMask(List<Initiator> initiators) {
StringSet initiatorIds = new StringSet();
for (Initiator initiator : initiators) {
initiatorIds.add(initiator.getId().toString());
}
StringMap userAdded = new StringMap();
for (Initiator initiator : initiators) {
userAdded.put(initiator.getInitiatorPort().replaceAll(":", ""), initiator.getId().toString());
}
StringSetMap zoningMap = new StringSetMap();
StoragePort port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
StringSet portMap = new StringSet();
portMap.add(port.getId().toString());
zoningMap.put(initiators.get(0).getId().toString(), portMap);
ExportMask mask = new ExportMask();
mask.setId(URIUtil.createId(ExportMask.class));
mask.setInitiators(initiatorIds);
mask.setUserAddedInitiators(userAdded);
mask.setZoningMap(zoningMap);
_dbClient.createObject(mask);
return mask;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VirtualPoolMultiVolumeConsistencyMigrationTest method prepareVirtualPoolData.
/**
* Prepares the data for RP volume tests.
*
* @throws Exception When an error occurs preparing the RP volume data.
*/
private void prepareVirtualPoolData() throws Exception {
log.info("Preparing VirtualPool Data for VirtualPoolMultiVolumeConsistencyMigration.");
VirtualArray virtualArray = new VirtualArray();
URI virtualArrayURI = URIUtil.createId(VirtualArray.class);
virtualArray.setId(virtualArrayURI);
virtualArray.setLabel("virtualArray1");
_dbClient.createObject(virtualArray);
for (int i = 1; i <= 3; i++) {
VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
URI protectionSettingsURI = URIUtil.createId(VpoolProtectionVarraySettings.class);
protectionSettings.setId(protectionSettingsURI);
protectionSettings.setJournalSize("min");
_dbClient.createObject(protectionSettings);
VirtualPool virtualPool = new VirtualPool();
URI virtualPoolURI = URIUtil.createId(VirtualPool.class);
rpTestVirtualPoolURIs.add(virtualPoolURI);
virtualPool.setId(virtualPoolURI);
virtualPool.setLabel("rpVirtualPool" + i);
StringMap protectionVarraySettings = new StringMap();
protectionVarraySettings.put(virtualArrayURI.toString(), protectionSettingsURI.toString());
virtualPool.setProtectionVarraySettings(protectionVarraySettings);
_dbClient.createObject(virtualPool);
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VNXFileSystemStaticLoadProcessor method prepareDBMetrics.
/**
* get the DB metrics for each data mover or VDM
*
* @param storageSystem
* @param dbClient
* @param dmFsMountMap
* @param dmCapacityMap
* @param vdmFsMountMap
* @param vdmCapacityMap
*/
private void prepareDBMetrics(StorageSystem storageSystem, DbClient dbClient, final Map<String, List<String>> dmFsMountMap, final Map<String, Long> dmCapacityMap, final Map<String, List<String>> vdmFsMountMap, final Map<String, Long> vdmCapacityMap) {
List<VirtualNAS> modifiedVNas = new ArrayList<VirtualNAS>();
List<PhysicalNAS> modifiedPNas = new ArrayList<PhysicalNAS>();
for (Entry<String, List<String>> eachNas : dmFsMountMap.entrySet()) {
_logger.info(" Computing metrics for data mover {} ", eachNas.getKey());
// Get Physical NAS from db!!
PhysicalNAS pNAS = findPhysicalNasByNativeId(storageSystem, dbClient, eachNas.getKey());
List<VirtualNAS> vNasList = new ArrayList<VirtualNAS>();
if (null != pNAS) {
URIQueryResultList virtualNASUris = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualNASByParentConstraint(pNAS.getId()), virtualNASUris);
Long totalDmObjects = 0L;
Long totalDmCapacity = 0L;
Iterator<URI> virtualNASIter = virtualNASUris.iterator();
while (virtualNASIter.hasNext()) {
// Get Each vNAS on Physical NAS
VirtualNAS virtualNAS = dbClient.queryObject(VirtualNAS.class, virtualNASIter.next());
if (virtualNAS != null && !virtualNAS.getInactive()) {
vNasList.add(virtualNAS);
int vNasObjects = 0;
if (vdmFsMountMap.get(virtualNAS.getNativeId()) != null) {
vNasObjects = vdmFsMountMap.get(virtualNAS.getNativeId()).size();
totalDmObjects = totalDmObjects + vNasObjects;
}
Long vNasCapacity = 0L;
if (vdmCapacityMap.get(virtualNAS.getNativeId()) != null) {
vNasCapacity = vdmCapacityMap.get(virtualNAS.getNativeId());
totalDmCapacity = totalDmCapacity + vNasCapacity;
}
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = virtualNAS.getMetrics();
vNasDbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(vNasObjects));
vNasDbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(vNasCapacity));
modifiedVNas.add(virtualNAS);
}
}
if (dmFsMountMap.get(pNAS.getNativeId()) != null) {
totalDmObjects = totalDmObjects + dmFsMountMap.get(pNAS.getNativeId()).size();
}
if (dmCapacityMap.get(pNAS.getNativeId()) != null) {
totalDmCapacity = totalDmCapacity + dmCapacityMap.get(pNAS.getNativeId());
}
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
long StorageObj = MetricsKeys.getLong(MetricsKeys.storageObjects, vNas.getMetrics());
double percentageLoad = ((double) StorageObj / totalDmObjects) * 100;
vNasDbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
}
StringMap pNasDbMetrics = pNAS.getMetrics();
pNasDbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalDmObjects));
pNasDbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalDmCapacity));
long maxObjects = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, pNasDbMetrics);
long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, pNasDbMetrics);
double percentageLoad = ((double) totalDmObjects / maxObjects) * 100;
pNasDbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
if (totalDmObjects >= maxObjects || totalDmCapacity >= maxCapacity) {
pNasDbMetrics.put(MetricsKeys.overLoaded.name(), "true");
// All vNas under should be updated!!!
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
vNasDbMetrics.put(MetricsKeys.overLoaded.name(), "true");
}
} else {
pNasDbMetrics.put(MetricsKeys.overLoaded.name(), "false");
// All vNas under should be updated!!!
for (VirtualNAS vNas : vNasList) {
// Update dbMetrics for vNAS!!
StringMap vNasDbMetrics = vNas.getMetrics();
vNasDbMetrics.put(MetricsKeys.overLoaded.name(), "false");
}
}
modifiedPNas.add(pNAS);
}
// Update the db
if (!modifiedVNas.isEmpty()) {
dbClient.persistObject(modifiedVNas);
}
if (!modifiedPNas.isEmpty()) {
dbClient.persistObject(modifiedPNas);
}
}
return;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class PortMetricsProcessor method dataMoverAvgPortMetrics.
/**
* Compute DataMover or Virtual Data Mover average port metrics. The answer is in percent.
* This is averaged over all the usable port in a VirtualNAS .The Computed
* value get stored in DB.
*
* @param storageSystemURI -- URI for the storage system.
*/
public void dataMoverAvgPortMetrics(URI storageSystemURI) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
StringSet storagePorts = null;
Double portPercentBusy = 0.0;
Double avgPortPercentBusy = 0.0;
Double percentBusy = 0.0;
Double avgPercentBusy = 0.0;
int noOfInterface = 0;
if (storageSystem != null) {
URIQueryResultList vNASURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceVirtualNasConstraint(storageSystemURI), vNASURIs);
Iterator<VirtualNAS> virtualNASIterator = _dbClient.queryIterativeObjects(VirtualNAS.class, vNASURIs);
while (virtualNASIterator.hasNext()) {
VirtualNAS vNAS = virtualNASIterator.next();
if (vNAS != null && !vNAS.getInactive()) {
storagePorts = vNAS.getStoragePorts();
if (storagePorts != null && !storagePorts.isEmpty()) {
for (String sp : storagePorts) {
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, URI.create(sp));
portPercentBusy = portPercentBusy + MetricsKeys.getDouble(MetricsKeys.avgPortPercentBusy, storagePort.getMetrics());
percentBusy = percentBusy + MetricsKeys.getDouble(MetricsKeys.avgPercentBusy, storagePort.getMetrics());
}
noOfInterface = storagePorts.size();
if (noOfInterface != 0) {
avgPortPercentBusy = portPercentBusy / noOfInterface;
avgPercentBusy = percentBusy / noOfInterface;
}
StringMap dbMetrics = vNAS.getMetrics();
MetricsKeys.putDouble(MetricsKeys.avgPortPercentBusy, avgPortPercentBusy, dbMetrics);
MetricsKeys.putDouble(MetricsKeys.avgPercentBusy, avgPercentBusy, dbMetrics);
_dbClient.updateObject(vNAS);
}
}
}
}
}
Aggregations