Search in sources :

Example 16 with Stat

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

the class VPlexPerpetualCSVFileCollector method addPortMetric.

/**
 * Create a new metric for the VPlex FE port, which is held in 'stat' and add it to the metering data.
 *
 * @param context [IN/OUT] - Metering context structure. Will contain a value for filling in metering data.
 * @param stat [IN] - PortStat for a particular VPlex FE port
 */
private void addPortMetric(Map<String, Object> context, PortStat stat) {
    Stat fePortStat = new Stat();
    fePortStat.setServiceType(Constants._Block);
    fePortStat.setTimeCollected(stat.sampleTime);
    fePortStat.setTotalIOs(stat.iops);
    fePortStat.setKbytesTransferred(stat.kbytes);
    fePortStat.setNativeGuid(stat.port.getNativeGuid());
    fePortStat.setResourceId(stat.port.getId());
    @SuppressWarnings("unchecked") List<Stat> metrics = (List<Stat>) context.get(Constants._Stats);
    metrics.add(fePortStat);
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 17 with Stat

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

the class CommunicationInterfaceTest method testArrayWeight.

@Test
public void testArrayWeight() {
    // long s = UnsignedLongs.parseUnsignedLong("18446744073709551104");
    String s = "18446744073709551104";
    String s1 = s.substring(0, s.length() - 6);
    long l = Long.parseLong(s1);
    BigInteger t = new BigInteger("-1");
    UnsignedInteger64 ui = new UnsignedInteger64("18446744073709551104");
    String providerIPAddress = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.ipaddress");
    String providerNamespace = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.namespace");
    String providerPortNumber = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.port");
    String providerUser = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.username");
    String providerPwd = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.password");
    String providerUseSSL = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.usessl");
    String providerSystemSerialId = EnvConfig.get(UNIT_TEST_CONFIG_FILE, "smis.host.array.serial");
    BigInteger l1 = ui.bigIntegerValue();
    _logger.info("Test Started");
    WBEMClientCIMXML _wbemClient = null;
    try {
        final NamespaceList _nsList = (NamespaceList) _context.getBean("namespaces");
        _wbemClient = (WBEMClientCIMXML) _context.getBean("cimClient");
        AccessProfile _profile = new AccessProfile();
        _profile.setInteropNamespace(providerNamespace);
        _profile.setIpAddress(providerIPAddress);
        _profile.setPassword(providerPwd);
        _profile.setProviderPort(providerPortNumber);
        _profile.setnamespace("Performance");
        _profile.setelementType("Array");
        _profile.setUserName(providerUser);
        // need to set Array serial ID;
        _profile.setSslEnable(providerUseSSL);
        _profile.setserialID(providerSystemSerialId);
        getCIMClient(_profile, _wbemClient);
        Map<String, Object> _keyMap = new ConcurrentHashMap<String, Object>();
        _keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
        _keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
        _keyMap.put(Constants._cimClient, new WBEMClientCIMXML());
        _keyMap.put(Constants.ACCESSPROFILE, _profile);
        _profile.setSystemId(new URI("tag"));
        _profile.setSystemClazz(StorageSystem.class);
        _keyMap.put(Constants._serialID, _profile.getserialID());
        _keyMap.put(Constants._storagePool, CimObjectPathCreator.createInstance(Constants._cimPool, _profile.getInteropNamespace()));
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        _keyMap.put("storageProcessors", new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants._computerSystem, CimObjectPathCreator.createInstance(Constants._cimSystem, _profile.getInteropNamespace()));
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants._serialID, _profile.getserialID());
        // _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants._Volumes, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants._nativeGUIDs, Sets.newHashSet());
        _keyMap.put(Constants._Stats, new LinkedList<Stat>());
        _keyMap.put(Constants._InteropNamespace, _profile.getInteropNamespace());
        _keyMap.put(Constants._debug, true);
        // _keyMap.put(Constants._cache, _Cache);
        // _keyMap.put(Constants._globalCacheKey, cacheVolumes);
        // _keyMap.put(Constants._cachePools, cachePools);
        // _keyMap.put(Constants._cassandraInsertion, _dbUtil);
        // _keyMap.put(Constants.PROPS, accessProfile.getProps());
        // Add storagePool Object path & LinkedList<CIMObjectPath> to Map
        _keyMap.put(Constants._storagePool, CimObjectPathCreator.createInstance(Constants._cimPool, _profile.getInteropNamespace()));
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        Executor _executor = new Executor() {

            @Override
            protected void customizeException(Exception e, Operation operation) throws BaseCollectionException {
            // TODO Auto-generated method stub
            }
        };
        Util _util = new Util();
        CommandGenerator _gen = new CommandGenerator();
        _gen.setutil(_util);
        _executor.set_keyMap(_keyMap);
        _executor.set_generator(_gen);
        _executor.set_util(_util);
        _executor.execute((Namespace) _nsList.getNsList().get("metering"));
    } catch (Exception e) {
        _logger.error(e.getMessage(), e);
    } finally {
        _wbemClient.close();
    }
}
Also used : UnsignedInteger64(javax.cim.UnsignedInteger64) CIMObjectPath(javax.cim.CIMObjectPath) Util(com.emc.storageos.plugins.common.Util) AccessProfile(com.emc.storageos.plugins.AccessProfile) Operation(com.emc.storageos.plugins.common.domainmodel.Operation) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) WBEMClientCIMXML(org.sblim.cimclient.internal.wbem.WBEMClientCIMXML) CommandGenerator(com.emc.storageos.plugins.common.commandgenerator.CommandGenerator) Stat(com.emc.storageos.db.client.model.Stat) Executor(com.emc.storageos.plugins.common.Executor) BigInteger(java.math.BigInteger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.junit.Test)

Example 18 with Stat

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

the class StorageSystemStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    Iterator<CIMInstance> systemStatsResponseItr = (Iterator<CIMInstance>) resultObj;
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
    logger.info("Processing storagesystem {} stats response", profile.getSystemId());
    try {
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        if (systemStatsResponseItr != null) {
            while (systemStatsResponseItr.hasNext()) {
                CIMInstance systemStatInstance = (CIMInstance) systemStatsResponseItr.next();
                Stat systemStat = new Stat();
                // HUS VM.211643
                systemStat.setNativeGuid(getSystemNativeGuid(systemStatInstance, dbClient));
                systemStat.setResourceId(profile.getSystemId());
                systemStat.setServiceType(Constants._Block);
                systemStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
                Long providerCollectionTime = convertCIMStatisticTime(getCIMPropertyValue(systemStatInstance, STATISTICTIME));
                if (0 != providerCollectionTime) {
                    systemStat.setTimeInMillis(providerCollectionTime);
                } else {
                    systemStat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
                }
                systemStat.setTotalIOs(ControllerUtils.getLongValue(getCIMPropertyValue(systemStatInstance, TOTALIOS)));
                systemStat.setKbytesTransferred(ControllerUtils.getLongValue(getCIMPropertyValue(systemStatInstance, KBYTESTRANSFERRED)));
                metricsObjList.add(systemStat);
            }
        }
    } catch (Exception ex) {
        logger.error("Failed while extracting Stats for storage System: ", ex);
    } finally {
        resultObj = null;
    }
    logger.info("Processing storagesystem {} stats response completed", profile.getSystemId());
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 19 with Stat

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

the class StatsCleanupMigration method process.

@Override
public void process() throws MigrationCallbackException {
    log.info("begin to cleanup stats CF and change it compaction strategy");
    DbClientImpl dbClient = (DbClientImpl) getDbClient();
    TimeSeriesType<Stat> doType = TypeMap.getTimeSeriesType(StatTimeSeries.class);
    try {
        dbClient.getLocalContext().getKeyspace().prepareQuery(doType.getCf()).setConsistencyLevel(ConsistencyLevel.CL_ALL).withCql(String.format("TRUNCATE TABLE \"%s\"", doType.getCf().getName())).execute();
        dbClient.getLocalContext().getKeyspace().prepareQuery(doType.getCf()).withCql(String.format("ALTER TABLE \"%s\" WITH compaction = {'class': 'SizeTieredCompactionStrategy'}", doType.getCf().getName())).execute();
    } catch (Exception e) {
        log.error("Failed to cleanup stats CF {}", e);
        throw new MigrationCallbackException("Failed to cleanup stats CF", e);
    }
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 20 with Stat

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

the class XMLStatsDumpGenerator method dumpRecordstoXML.

/**
 * Dump Metering Records as XML to disk
 *
 * @param <T>
 * @param record
 */
@SuppressWarnings("unchecked")
public <T extends TimeSeriesSerializer.DataPoint> void dumpRecordstoXML(Map<String, Object> keyMap) {
    PrintWriter writer = null;
    try {
        List<Stat> records = (List<Stat>) keyMap.get(Constants._Stats);
        Map<String, String> meteringProps = (Map<String, String>) keyMap.get(Constants.PROPS);
        String location = constructFileName(meteringProps, keyMap);
        checkAndCreateDirectory(meteringProps.get(Constants.METERINGDUMPLOCATION));
        writer = new PrintWriter(new File(location));
        XMLMarshaller marshaller = new XMLMarshaller() {

            @Override
            public void tailer(PrintWriter writer) {
                delegatetailer(writer);
            }

            @Override
            public void header(PrintWriter writer) {
                delegateheader(writer);
            }
        };
        marshaller.dumpXML(writer, records);
    } catch (Exception ex) {
        _logger.error("Dump Failed : ", ex);
    } finally {
        writer.close();
    }
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) List(java.util.List) Map(java.util.Map) File(java.io.File) PrintWriter(java.io.PrintWriter)

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