use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.
the class NormalizationBoltFluxComponent method validateConfig.
@Override
public void validateConfig() throws ComponentConfigException {
super.validateConfig();
String fieldName = TopologyLayoutConstants.JSON_KEY_NORMALIZATION_PROCESSOR_CONFIG;
Map normalizationProcessorConfig = (Map) conf.get(fieldName);
if (normalizationProcessorConfig == null) {
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 validateDataSinks.
private void validateDataSinks() throws ComponentConfigException {
List<Map> dataSinks = (List<Map>) jsonMap.get(TopologyLayoutConstants.JSON_KEY_DATA_SINKS);
for (Map dataSink : dataSinks) {
// data sink name given by the user in UI
String dataSinkName = (String) dataSink.get(TopologyLayoutConstants.JSON_KEY_UINAME);
if (componentKeys.contains(dataSinkName)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_UINAME_DUP, dataSinkName));
}
dataSinkComponentKeys.add(dataSinkName);
componentKeys.add(dataSinkName);
}
}
use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.
the class TopologyLayoutValidator method validateDataSources.
private void validateDataSources() throws ComponentConfigException {
List<Map> dataSources = (List<Map>) jsonMap.get(TopologyLayoutConstants.JSON_KEY_DATA_SOURCES);
for (Map dataSource : dataSources) {
// data source name given by the user in UI
String dataSourceName = (String) dataSource.get(TopologyLayoutConstants.JSON_KEY_UINAME);
if (componentKeys.contains(dataSourceName)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_UINAME_DUP, dataSourceName));
}
dataSourceComponentKeys.add(dataSourceName);
componentKeys.add(dataSourceName);
}
}
use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.
the class TopologyLayoutValidator method validateLinks.
private void validateLinks() throws ComponentConfigException {
List<Map> links = (List<Map>) jsonMap.get(TopologyLayoutConstants.JSON_KEY_LINKS);
for (Map link : links) {
// link name given by the user in UI
String linkName = (String) link.get(TopologyLayoutConstants.JSON_KEY_UINAME);
if (componentKeys.contains(linkName)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_UINAME_DUP, linkName));
}
Map linkConfig = (Map) link.get(TopologyLayoutConstants.JSON_KEY_CONFIG);
String linkFrom = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_FROM);
String linkTo = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_TO);
if (linkFrom.equals(linkTo)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_LOOP, linkFrom, linkTo));
}
// linkFrom can only be a source or a processor
if ((!dataSourceComponentKeys.contains(linkFrom) && !processorComponentKeys.contains(linkFrom)) || dataSinkComponentKeys.contains(linkFrom)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_LINK_FROM, linkFrom));
}
// linkTo can only be a sink or a processor
if ((!dataSinkComponentKeys.contains(linkTo) && !processorComponentKeys.contains(linkTo)) || dataSourceComponentKeys.contains(linkTo)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_LINK_TO, linkTo));
}
linkFromComponentKeys.add(linkFrom);
linkToComponentKeys.add(linkTo);
}
}
use of com.hortonworks.streamline.common.exception.ComponentConfigException in project streamline by hortonworks.
the class StormTopologyValidator method validateCustomProcessorLinks.
private void validateCustomProcessorLinks() 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<String, Schema>> outputSchemas = new LinkedHashMap<>();
for (Map processor : processors) {
String type = (String) processor.get(TopologyLayoutConstants.JSON_KEY_TYPE);
if ("CUSTOM".equals(type)) {
Map config = (Map) processor.get(TopologyLayoutConstants.JSON_KEY_CONFIG);
try {
getCustomProcessorInputSchema(config);
outputSchemas.put((String) processor.get(TopologyLayoutConstants.JSON_KEY_UINAME), getCustomProcessorOutputSchema(config));
} catch (IOException e) {
String message = "Invalid custom processor input or output schema config.";
LOG.error(message);
throw new ComponentConfigException(message, e);
}
}
}
Set<String> customProcessorKeys = outputSchemas.keySet();
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 (customProcessorKeys.contains(from)) {
String streamId = (String) linkConfig.get(TopologyLayoutConstants.JSON_KEY_STREAM_ID);
if (StringUtils.isEmpty(streamId)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
}
Map<String, Schema> streamIdToOutput = outputSchemas.get(from);
Set<String> outputStreams = streamIdToOutput.keySet();
if (!outputStreams.contains(streamId)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_STREAM_ID, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
}
if ("FIELDS".equals(link.get(TopologyLayoutConstants.JSON_KEY_TYPE))) {
Set<String> outputFields = getTopLevelFieldNamesFromSchema(streamIdToOutput.get(streamId));
List<String> groupingFields = (List) linkConfig.get(TopologyLayoutConstants.JSON_KEY_GROUPING_FIELDS);
if (!outputFields.containsAll(groupingFields)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_GROUPING_FIELDS, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
}
}
}
if (customProcessorKeys.contains(to)) {
// link to a custom processor can not go from a data source
if (dataSourceNames.contains(from)) {
throw new ComponentConfigException(String.format(TopologyLayoutConstants.ERR_MSG_INVALID_LINK_TO_PROCESSOR, link.get(TopologyLayoutConstants.JSON_KEY_UINAME)));
}
}
}
}
Aggregations