Search in sources :

Example 6 with ComponentConfigException

use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.

the class CustomProcessorUploadHandler method created.

@Override
public void created(Path path) {
    File createdFile = path.toFile();
    LOG.info("Created called with " + createdFile);
    boolean succeeded = false;
    try {
        if (createdFile.getName().endsWith(".tar")) {
            LOG.info("Processing file at " + path);
            CustomProcessorInfo customProcessorInfo = this.getCustomProcessorInfo(createdFile);
            if (customProcessorInfo == null) {
                LOG.warn("No information found for CustomProcessorRuntime in " + createdFile);
                return;
            }
            InputStream jarFile = this.getJarFile(createdFile);
            if (jarFile == null) {
                LOG.warn("No jar file found for CustomProcessorRuntime in " + createdFile);
                return;
            }
            this.catalogService.addCustomProcessorInfoAsBundle(customProcessorInfo, jarFile);
            succeeded = true;
        } else {
            LOG.info("Failing unsupported file that was received: " + path);
        }
    } catch (IOException e) {
        LOG.warn("Exception occured while processing tar file: " + createdFile, e);
    } catch (ComponentConfigException e) {
        LOG.warn("UI specification for custom processor incorrect for custom processor file: " + createdFile, e);
    } catch (NoSuchAlgorithmException e) {
        LOG.warn("Got NoSuchAlgorithmException while calculating digest for jar: " + createdFile, e);
    } finally {
        try {
            if (succeeded) {
                LOG.info("CustomProcessorRuntime uploaded successfully from  " + createdFile + " Moving file to " + uploadSuccessPath);
                moveFileToSuccessDirectory(createdFile);
            } else {
                LOG.warn("CustomProcessorRuntime failed to upload from " + createdFile + " Moving file to " + uploadFailPath);
                moveFileToFailDirectory(createdFile);
            }
        } catch (IOException e1) {
            LOG.warn("Error moving " + createdFile.getAbsolutePath() + " to " + (succeeded ? uploadSuccessPath : uploadFailPath), e1);
        }
    }
}
Also used : ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) BufferedInputStream(java.io.BufferedInputStream) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) File(java.io.File) CustomProcessorInfo(com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo)

Example 7 with ComponentConfigException

use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.

the class RuleBoltFluxComponent method validateConfig.

@Override
public void validateConfig() throws ComponentConfigException {
    super.validateConfig();
    String fieldName = TopologyLayoutConstants.JSON_KEY_RULES_PROCESSOR_CONFIG;
    Map rulesProcessorConfig = (Map) conf.get(fieldName);
    if (rulesProcessorConfig == null) {
        throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_MISSING_INVALID_CONFIG, fieldName));
    }
/*
        Commenting the below code because of cyclic dependency between layout
        module and core module
        ObjectMapper mapper = new ObjectMapper();
        try {
            mapper.readValue(mapper.writeValueAsString(rulesProcessorConfig), RulesProcessor.class);
            //TODO: may be add further validation here for the RulesProcessor
            // object successfully created?
        } catch (IOException e) {
            throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_MISSING_INVALID_CONFIG, fieldName));
        }*/
}
Also used : ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) Map(java.util.Map)

Example 8 with ComponentConfigException

use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.

the class TopologyLayoutValidator method validateProcessors.

private void validateProcessors() throws ComponentConfigException {
    List<Map> processors = (List<Map>) jsonMap.get(TopologyLayoutConstants.JSON_KEY_PROCESSORS);
    for (Map processor : processors) {
        // processor name given by the user in UI
        String processorName = (String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME);
        if (componentKeys.contains(processorName)) {
            throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_UINAME_DUP, processorName));
        }
        processorComponentKeys.add(processorName);
        componentKeys.add(processorName);
    }
}
Also used : ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) List(java.util.List) Map(java.util.Map)

Example 9 with ComponentConfigException

use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.

the class TopologyLayoutValidator method validate.

/**
 * @throws ComponentConfigException
 */
public void validate() throws ComponentConfigException {
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        jsonMap = objectMapper.readValue(json, Map.class);
        validateDataSources();
        validateDataSinks();
        validateProcessors();
        validateLinks();
        checkDisconnectedDataSources();
        checkDisconnectedDataSinks();
        checkDisconnectedProcessors();
    } catch (IOException ex) {
        throw new ComponentConfigException(ex);
    }
}
Also used : ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) IOException(java.io.IOException) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with ComponentConfigException

use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.

the class StormTopologyValidator method validateParserProcessorLinks.

// if there is a link from a parser processor then the stream id has to
// be present and it has to be one of the two streams - parsed or failed
private void validateParserProcessorLinks() throws ComponentConfigException {
    List<Map> dataSources = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_DATA_SOURCES);
    Set<String> dataSourceNames = new HashSet<>();
    for (Map dataSource : dataSources) {
        dataSourceNames.add((String) dataSource.get(TopologyLayoutConstants.JSON_KEY_UINAME));
    }
    List<Map> processors = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_PROCESSORS);
    Map<String, Map> parserProcessors = new LinkedHashMap<>();
    for (Map processor : processors) {
        String type = (String) processor.get(TopologyLayoutConstants.JSON_KEY_TYPE);
        if ("PARSER".equals(type)) {
            parserProcessors.put((String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME), (Map) processor.get(TopologyLayoutConstants.JSON_KEY_CONFIG));
        }
    }
    Set<String> parserProcessorKeys = parserProcessors.keySet();
    if (parserProcessorKeys.size() == 0) {
        throw new ComponentConfigException(TopologyLayoutConstants.ERR_MSG_NO_PARSER_PROCESSOR);
    }
    List<Map> links = (List) this.topologyConfig.get(TopologyLayoutConstants.JSON_KEY_LINKS);
    for (Map link : links) {
        Map linkConfig = (Map) link.get(TopologyLayoutConstants.JSON_KEY_CONFIG);
        String from = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_FROM);
        String to = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_TO);
        if (parserProcessorKeys.contains(from)) {
            Map processor = parserProcessors.get(from);
            List<String> processorStreams = new ArrayList<>();
            String parsedTuplesStream = (String) processor.get(TopologyLayoutConstants.JSON_KEY_PARSED_TUPLES_STREAM);
            processorStreams.add(parsedTuplesStream);
            String failedTuplesStream = (String) processor.get(TopologyLayoutConstants.JSON_KEY_FAILED_TUPLES_STREAM);
            if (failedTuplesStream != null) {
                processorStreams.add(failedTuplesStream);
            }
            String streamId = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_STREAM_ID);
            if (StringUtils.isEmpty(streamId) || !processorStreams.contains(streamId)) {
                throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
            }
        }
        if (parserProcessorKeys.contains(to)) {
            // link to a parser processor can only go from a data source
            if (!dataSourceNames.contains(from)) {
                throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_LINK_TO_PARSER, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
            }
        }
    }
}
Also used : ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ComponentConfigException (com.hortonworks.streamline.common.exception.ComponentConfigException)11 Map (java.util.Map)10 List (java.util.List)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Schema (com.hortonworks.registries.common.Schema)1 CustomProcessorInfo (com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashMap (java.util.HashMap)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1