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);
}
}
}
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));
}*/
}
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);
}
}
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);
}
}
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)));
}
}
}
}
Aggregations