Search in sources :

Example 96 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class SMICommunicationInterfaceTest method scanTest.

private void scanTest(final SMICommunicationInterface smi) {
    ExecutorService service = Executors.newFixedThreadPool(2);
    service.submit(new Runnable() {

        @Override
        public void run() {
            try {
                smi.scan(createXIVAccessProfile());
            } catch (BaseCollectionException e) {
                _LOGGER.error(e.getMessage(), e);
            }
        }
    });
    service.submit(new Runnable() {

        @Override
        public void run() {
            try {
                Thread.sleep(300000);
            } catch (InterruptedException e) {
                _LOGGER.error(e.getMessage(), e);
            }
            _LOGGER.info("Started Querying");
            long latchcount = Cassandraforplugin.query(_dbClient);
            Assert.assertTrue("Processed 1 record", latchcount == 1);
            smi.cleanup();
        }
    });
    service.shutdown();
    try {
        service.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
    } catch (InterruptedException e) {
        _LOGGER.error(e.getMessage(), e);
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 97 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class Executor method executeOperation.

/**
 * Execute the Operation defined in Domain Logic XML. Use Generator to
 * return Command Objects for an Operation. Then execute them either in a
 * multi-threaded fashion or singleThreaded.
 *
 * @param operation
 * @throws BaseCollectionException
 */
private void executeOperation(Operation operation) throws BaseCollectionException {
    try {
        if (!isSupportedOperation(operation)) {
            _LOGGER.info("Filtered the operation {} as per instructions", operation.getMessage());
            return;
        }
        _LOGGER.info(null == operation.getMessage() ? "START Executing operation" : "START :" + operation.getMessage());
        _commandObjects = _generator.returnCommandObjects(operation, _keyMap);
        // the same time.
        for (Command commandObj : _commandObjects) {
            printArgs(commandObj);
            Object resultObj = null;
            try {
                resultObj = commandObj.execute();
                processResult(operation, resultObj, commandObj);
            } catch (Exception e) {
                _LOGGER.error("Execution failed for :", e);
                // We do not want 'Provider/Firmware Not Supported Error' to get suppressed. check and throw again.
                if (e instanceof SMIPluginException) {
                    int errorCode = ((SMIPluginException) e).getErrorCode();
                    if (errorCode == SMIPluginException.ERRORCODE_PROVIDER_NOT_SUPPORTED || errorCode == SMIPluginException.ERRORCODE_FIRMWARE_NOT_SUPPORTED || errorCode == SMIPluginException.ERRORCODE_OPERATIONFAILED) {
                        throw e;
                    }
                }
            }
        }
    } catch (final Exception e) {
        _LOGGER.error("Operation Execution failed : ", e);
        customizeException(e, operation);
    }
    _LOGGER.debug(null == operation.getMessage() ? "END Executing operation" : "END :" + operation.getMessage());
}
Also used : Command(com.emc.storageos.plugins.common.commandgenerator.Command) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 98 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class Processor method addPath.

/**
 * Add CIMObject Paths to Map.
 *
 * @param keyMap
 * @param operation
 * @param path
 * @throws SMIPluginException
 */
@SuppressWarnings("serial")
protected void addPath(Map<String, Object> keyMap, String key, CIMObjectPath path) throws BaseCollectionException {
    try {
        Object result = keyMap.get(key);
        if (keyMap.containsKey(key) && result instanceof List<?>) {
            @SuppressWarnings("unchecked") List<CIMObjectPath> cimPathList = (List<CIMObjectPath>) keyMap.get(key);
            cimPathList.add(path);
            keyMap.put(key, cimPathList);
        } else {
            keyMap.put(key, path);
        }
    } catch (Exception ex) {
        throw new BaseCollectionException("Error while adding CIMObject Path to Map : " + path, ex) {

            @Override
            public int getErrorCode() {
                // To-Do errorCode
                return -1;
            }
        };
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) List(java.util.List) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 99 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class CIMPathProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    String serialID = null;
    _logger.debug("ID :" + (String) keyMap.get(Constants._serialID));
    try {
        final Iterator<?> it = (Iterator<?>) resultObj;
        while (it.hasNext()) {
            final CIMObjectPath path = (CIMObjectPath) it.next();
            if (operation.getMethod().contains(Constants._enum)) {
                CIMProperty<?> ccprop = path.getKey(Constants._CreationClassName);
                String ccName = (String) ccprop.getValue();
                _logger.debug("CCName :" + ccName);
                if (ccName.contains(Constants._StorageSystem)) {
                    // Filter out the ObjectPath based on Array Serial ID
                    CIMProperty<?> prop = path.getKey(Constants._Name);
                    serialID = (String) prop.getValue();
                    _logger.info("serial ID Found:" + serialID);
                    if (serialID != null && serialID.toLowerCase().contains(((String) keyMap.get(Constants._serialID)).toLowerCase())) {
                        addPath(keyMap, operation.getResult(), path);
                        break;
                    }
                }
            } else {
                addPath(keyMap, operation.getResult(), path);
            }
        }
    } catch (Exception e) {
        _logger.error("Failed while processing Result with serialID : {}", serialID, e.fillInStackTrace());
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 100 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException 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)

Aggregations

BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)185 Iterator (java.util.Iterator)66 CIMInstance (javax.cim.CIMInstance)66 CIMObjectPath (javax.cim.CIMObjectPath)59 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)55 IOException (java.io.IOException)47 URI (java.net.URI)47 ArrayList (java.util.ArrayList)47 PostMethod (org.apache.commons.httpclient.methods.PostMethod)36 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)35 Status (com.emc.nas.vnxfile.xmlapi.Status)33 AccessProfile (com.emc.storageos.plugins.AccessProfile)30 List (java.util.List)30 Map (java.util.Map)30 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 StoragePool (com.emc.storageos.db.client.model.StoragePool)27 Header (org.apache.commons.httpclient.Header)27 StoragePort (com.emc.storageos.db.client.model.StoragePort)22 HashSet (java.util.HashSet)18 URISyntaxException (java.net.URISyntaxException)17