Search in sources :

Example 81 with StringMap

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;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 82 with StringMap

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;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort)

Example 83 with StringMap

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);
    }
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringMap(com.emc.storageos.db.client.model.StringMap) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 84 with StringMap

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;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) PhysicalNAS(com.emc.storageos.db.client.model.PhysicalNAS)

Example 85 with StringMap

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);
                }
            }
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)257 URI (java.net.URI)108 ArrayList (java.util.ArrayList)90 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)59 StringSet (com.emc.storageos.db.client.model.StringSet)57 HashMap (java.util.HashMap)57 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)48 ExportMask (com.emc.storageos.db.client.model.ExportMask)43 Volume (com.emc.storageos.db.client.model.Volume)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)41 StoragePool (com.emc.storageos.db.client.model.StoragePool)39 Initiator (com.emc.storageos.db.client.model.Initiator)38 List (java.util.List)34 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)33 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)31 HashSet (java.util.HashSet)30 Project (com.emc.storageos.db.client.model.Project)24 StoragePort (com.emc.storageos.db.client.model.StoragePort)23 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Network (com.emc.storageos.db.client.model.Network)21