public void validate () throws Exception { String[] componentKeys = { TopologyLayoutConstants.JSON_KEY_DATA_SOURCES, TopologyLayoutConstants.JSON_KEY_DATA_SINKS, TopologyLayoutConstants.JSON_KEY_PROCESSORS, TopologyLayoutConstants.JSON_KEY_LINKS }; for (String componentKey: componentKeys) { List<Map> components = (List<Map>) this.topologyConfig.get(componentKey); for (Map component: components) { String transformationClass = (String) component.get(TopologyLayoutConstants.JSON_KEY_TRANSFORMATION_CLASS); Map<String, Object> config = (Map<String, Object>) component.get(TopologyLayoutConstants.JSON_KEY_CONFIG); FluxComponent fluxComponent = ReflectionHelper.newInstance(transformationClass); fluxComponent.withConfig(config); fluxComponent.withCatalogRootUrl(catalogRootUrl); fluxComponent.validateConfig(); } } validateParserProcessorLinks(); // Uncomment this with https://hwxiot.atlassian.net/browse/IOT-126 //validateRuleProcessorLinks(); validateCustomProcessorLinks(); }
private String addUnderlyingBoltComponent() { StreamlineProcessor underlyingProcessor = testRunProcessor.getUnderlyingProcessor(); String transformationClass = underlyingProcessor.getTransformationClass(); Map<String, Object> underlyingComponent; try { AbstractFluxComponent transformation = ReflectionHelper.newInstance(transformationClass); Map<String, Object> props = new LinkedHashMap<>(); props.putAll(underlyingProcessor.getConfig().getProperties()); props.put(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY, testRunProcessor.getUnderlyingProcessor()); // should get rid of below things which is only supported to spout and bolt in flux props.remove("parallelism"); transformation.withConfig(props); underlyingComponent = transformation.getComponent(); for (Map<String, Object> dependentComponents : transformation.getReferencedComponents()) { addToComponents(dependentComponents); } addToComponents(underlyingComponent); return (String) underlyingComponent.get(StormTopologyLayoutConstants.YAML_KEY_ID); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { log.error("Error creating underlying transformation instance", e); throw new RuntimeException(e); } } }
private String addUnderlyingBoltComponent() { StreamlineProcessor underlyingProcessor = testRunRulesProcessor.getUnderlyingProcessor(); String transformationClass = underlyingProcessor.getTransformationClass(); Map<String, Object> underlyingComponent; try { AbstractFluxComponent transformation = ReflectionHelper.newInstance(transformationClass); Map<String, Object> props = new LinkedHashMap<>(); props.putAll(underlyingProcessor.getConfig().getProperties()); props.put(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY, testRunRulesProcessor.getUnderlyingProcessor()); // should get rid of below things which is only supported to spout and bolt in flux props.remove("parallelism"); transformation.withConfig(props); underlyingComponent = transformation.getComponent(); for (Map<String, Object> dependentComponents : transformation.getReferencedComponents()) { addToComponents(dependentComponents); } addToComponents(underlyingComponent); return (String) underlyingComponent.get(StormTopologyLayoutConstants.YAML_KEY_ID); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { log.error("Error creating underlying transformation instance", e); throw new RuntimeException(e); } } }
private FileStorage getJarStorage (StreamlineConfiguration configuration, StorageManager storageManager) { FileStorage fileStorage = null; try { fileStorage = ReflectionHelper.newInstance(configuration.getFileStorageConfiguration().getClassName()); fileStorage.init(configuration.getFileStorageConfiguration().getProperties()); if (fileStorage instanceof StorageManagerAware) { ((StorageManagerAware) fileStorage).setStorageManager(storageManager); } } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { throw new RuntimeException(e); } return fileStorage; }