Search in sources :

Example 1 with Command

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

Aggregations

BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 Command (com.emc.storageos.plugins.common.commandgenerator.Command)1 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)1