Search in sources :

Example 11 with Stat

use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.

the class FEPortStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
    try {
        CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_FEPORT_MANIFEST);
        String[] feportsMetricValues = ((String[]) outputArguments[0].getValue())[0].split("\n");
        List<StoragePort> systemPorts = ControllerUtils.getSystemPortsOfSystem(dbClient, profile.getSystemId());
        _logger.debug("FEPort metricNames Sequence {}", metricSequence);
        // process the results.
        if (null != metricSequence && !metricSequence.isEmpty()) {
            // Step2: For each feport metric record
            for (String fePortMetricValue : feportsMetricValues) {
                if (fePortMetricValue.isEmpty()) {
                    _logger.debug("Empty FEPort stats returned as part of Statistics Response");
                    continue;
                }
                String[] metrics = fePortMetricValue.split(Constants.SEMI_COLON);
                // Step 3: For each port in db for a given system.
                for (StoragePort port : systemPorts) {
                    // Step 4: if port in db is null just continue.
                    if (null == port) {
                        continue;
                    } else if (!port.getInactive() && metrics[0].endsWith(port.getPortName())) {
                        // Step 5: Check whether provider returned port
                        // exists in db or not. if port exists in db,
                        // then create a PortStat object for it.
                        _logger.debug("found FEPort in db for {}", port.getPortName());
                        createPortStatMetric(metricSequence, port, keyMap, metricsObjList, metrics);
                    }
                }
            }
            // 
            // compute port metric to trigger if any port allocation qualification changed. If there is
            // changes, run vpool matcher
            // 
            portMetricsProcessor.triggerVpoolMatcherIfPortAllocationQualificationChanged(profile.getSystemId(), systemPorts);
            // 
            // compute storage system's average of port metrics. Then, persist it into storage system object.
            // 
            portMetricsProcessor.computeStorageSystemAvgPortMetrics(profile.getSystemId());
            // Compute port group's port metrics for vmax only
            portMetricsProcessor.computePortGroupMetrics(profile.getSystemId());
        } else {
            _logger.error("failed processing FEPOrt Metric values as metric sequence is null.");
        }
    } catch (Exception e) {
        _logger.error("Failed while extracting stats for FEPorts: ", e);
    }
    resultObj = null;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) Stat(com.emc.storageos.db.client.model.Stat) List(java.util.List) CIMArgument(javax.cim.CIMArgument)

Example 12 with Stat

use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.

the class SPProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<?> it = (Iterator<?>) resultObj;
    while (it.hasNext()) {
        try {
            final CIMInstance allocatedfrompool = (CIMInstance) it.next();
            CIMObjectPath path = (CIMObjectPath) allocatedfrompool.getProperty("Dependent").getValue();
            if (path.getObjectName().contains(_volume)) {
                String key = createKeyfromPath(path);
                // this check means, validating whether this Volume is
                // managed by Bourne
                Stat metrics = (Stat) getMetrics(keyMap, key);
                _logger.debug("Processing Volume to extract Allocated Capacity: {}", key);
                // Allocated Capacity =
                // CIM_AllocatedFromStoragePool.SpaceConsumed (in bytes)
                metrics.setAllocatedCapacity(Long.parseLong(allocatedfrompool.getProperty(_spaceConsumed).getValue().toString()));
            }
        } catch (Exception e) {
            if (!(e instanceof BaseCollectionException)) {
                _logger.error(" Allocated Capacity : ", e);
            }
        }
    }
    resultObj = null;
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 13 with Stat

use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.

the class VNXStoragePortStatsProcessor method preparePortStatInfo.

/**
 * Prepare the Port stat information
 *
 * @param nativeId
 * @param resourceId
 * @param iops
 * @param timeSample
 * @return ipPortStat
 */
private Stat preparePortStatInfo(String nativeId, URI resourceId, long iops, long timeSample) {
    Stat ipPortStat = new Stat();
    ipPortStat.setServiceType(Constants._File);
    ipPortStat.setTimeCollected(timeSample);
    ipPortStat.setResourceId(resourceId);
    ipPortStat.setNativeGuid(nativeId);
    ipPortStat.setTotalIOs(iops);
    return ipPortStat;
}
Also used : Stat(com.emc.storageos.db.client.model.Stat)

Example 14 with Stat

use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.

the class VNXStoragePortStatsProcessor method processPortStatsInfo.

/**
 * Process the Port metrics which are received from XMLAPI server.
 *
 * @param interPortMap
 * @param stringMapPortIOs
 * @param storageSystem
 * @param dbClient
 * @param sampleTime
 * @return list of Port stats
 */
private List<Stat> processPortStatsInfo(Map<String, List<String>> interPortMap, Map<String, BigInteger> stringMapPortIOs, StorageSystem storageSystem, DbClient dbClient, Long sampleTime) {
    // get the interfaces and corresponding port
    List<Stat> stat = new ArrayList<Stat>();
    Stat fePortStat = null;
    for (Entry<String, List<String>> entry : interPortMap.entrySet()) {
        String interfaceIP = entry.getKey();
        List<String> portList = entry.getValue();
        // get the port information
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, interfaceIP, NativeGUIDGenerator.PORT);
        StoragePort storagePort = findExistingPort(portNativeGuid, dbClient);
        _logger.info("interface {} and port details {}", interfaceIP, storagePort.getPortName());
        // calculate traffic per interface- total traffic all ports/no of ports
        BigInteger iovalue = new BigInteger("0");
        for (String physicalName : portList) {
            iovalue = iovalue.add(stringMapPortIOs.get(physicalName));
        }
        // get Average port IO by adding and dividing the number.
        Long iopes = iovalue.longValue() / portList.size();
        Long kbytes = iopes / 1024;
        _logger.info("processIPPortMetrics input data iops{} and time details {} iopes", iopes.toString(), sampleTime.toString());
        // set Ethernet port speed to 1Gbps
        storagePort.setPortSpeed(1L);
        // send port metrics processor to store the content
        portMetricsProcessor.processIPPortMetrics(kbytes, iopes, storagePort, sampleTime);
        // finally add above value to stat object
        fePortStat = preparePortStatInfo(portNativeGuid, storagePort.getId(), iopes, sampleTime);
        stat.add(fePortStat);
    }
    return stat;
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 15 with Stat

use of com.emc.storageos.db.client.model.Stat in project coprhd-controller by CoprHD.

the class VNXVolumeStatsProcessor method injectBWInOut.

/**
 * Inject bwIn & bwOut in stat object.
 *
 * @param fileShareId : FileshareId to update.
 * @param keyMap : KeyMap
 * @param volItem : VolItem contains the bytesRead/bytesWrite values.
 * @param statsList : Stat List to update.
 */
private void injectBWInOut(String fileShareId, Map<String, Object> keyMap, Item volItem, List<Stat> statsList) {
    Iterator<Stat> statsItr = statsList.iterator();
    while (statsItr.hasNext()) {
        Stat stat = statsItr.next();
        if (null != fileShareId && fetchNativeId(stat.getNativeGuid()).equals(fileShareId)) {
            stat.setBandwidthOut(volItem.getBytesRead().longValue());
            stat.setBandwidthIn(volItem.getBytesWritten().longValue());
            break;
        }
    }
}
Also used : Stat(com.emc.storageos.db.client.model.Stat)

Aggregations

Stat (com.emc.storageos.db.client.model.Stat)40 List (java.util.List)14 DbClient (com.emc.storageos.db.client.DbClient)13 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 URI (java.net.URI)12 AccessProfile (com.emc.storageos.plugins.AccessProfile)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)6 PrintWriter (java.io.PrintWriter)6 FileShare (com.emc.storageos.db.client.model.FileShare)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 IOException (java.io.IOException)5 OutputStream (java.io.OutputStream)5 CIMInstance (javax.cim.CIMInstance)5 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)4 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)4 File (java.io.File)4