Search in sources :

Example 6 with StreamlineProcessor

use of com.hortonworks.streamline.streams.layout.component.StreamlineProcessor in project streamline by hortonworks.

the class StormTopologyTimeSeriesMetricsImplTest method getProcessorLayoutForTest.

private Component getProcessorLayoutForTest() {
    StreamlineProcessor processor = new StreamlineProcessor() {

        @Override
        public void accept(TopologyDagVisitor visitor) {
        }
    };
    processor.setId("12");
    processor.setName("rule");
    return processor;
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) TopologyDagVisitor(com.hortonworks.streamline.streams.layout.component.TopologyDagVisitor)

Example 7 with StreamlineProcessor

use of com.hortonworks.streamline.streams.layout.component.StreamlineProcessor in project streamline by hortonworks.

the class TestRunProcessorBoltFluxComponent method addUnderlyingBoltComponent.

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);
    }
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with StreamlineProcessor

use of com.hortonworks.streamline.streams.layout.component.StreamlineProcessor in project streamline by hortonworks.

the class TestTopologyDagCreatingVisitor method copyEdges.

private void copyEdges(InputComponent inputComponent) {
    List<Edge> edgesTo = originTopologyDag.getEdgesTo(inputComponent);
    edgesTo.forEach(e -> {
        OutputComponent from = e.getFrom();
        InputComponent to = e.getTo();
        Edge newEdge = new Edge(e.getId(), e.getFrom(), e.getTo(), e.getStreamGroupings());
        StreamlineSource replacedSource = sourceToReplacedTestSourceMap.get(from.getName());
        StreamlineProcessor replacedProcessorSource = processorToReplacedTestProcessorMap.get(from.getName());
        StreamlineSink replacedSink = sinkToReplacedTestSinkMap.get(to.getName());
        StreamlineProcessor replacedProcessorSink = processorToReplacedTestProcessorMap.get(to.getName());
        if (replacedSource != null) {
            newEdge.setFrom(replacedSource);
        } else if (replacedProcessorSource != null) {
            newEdge.setFrom(replacedProcessorSource);
        }
        if (replacedSink != null) {
            newEdge.setTo(replacedSink);
        } else if (replacedProcessorSink != null) {
            newEdge.setTo(replacedProcessorSink);
        }
        testTopologyDag.addEdge(newEdge);
    });
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) InputComponent(com.hortonworks.streamline.streams.layout.component.InputComponent) OutputComponent(com.hortonworks.streamline.streams.layout.component.OutputComponent) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink) Edge(com.hortonworks.streamline.streams.layout.component.Edge)

Example 9 with StreamlineProcessor

use of com.hortonworks.streamline.streams.layout.component.StreamlineProcessor in project streamline by hortonworks.

the class TopologyTestRunnerTest method injectTestTopology.

private void injectTestTopology(Topology topology) {
    StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
    StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("2");
    StreamlineSink originSink = TopologyTestHelper.createStreamlineSink("3");
    TopologyDag topologyDag = new TopologyDag();
    topologyDag.add(originSource);
    topologyDag.add(originProcessor);
    topologyDag.add(originSink);
    topologyDag.addEdge(new Edge("e1", originSource, originProcessor, "default", Stream.Grouping.SHUFFLE));
    topologyDag.addEdge(new Edge("e2", originProcessor, originSink, "default", Stream.Grouping.SHUFFLE));
    topology.setTopologyDag(topologyDag);
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink) Edge(com.hortonworks.streamline.streams.layout.component.Edge) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag)

Example 10 with StreamlineProcessor

use of com.hortonworks.streamline.streams.layout.component.StreamlineProcessor in project streamline by hortonworks.

the class TestRunRulesProcessorBoltFluxComponent method addUnderlyingBoltComponent.

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);
    }
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)16 StreamlineSink (com.hortonworks.streamline.streams.layout.component.StreamlineSink)8 StreamlineSource (com.hortonworks.streamline.streams.layout.component.StreamlineSource)8 Edge (com.hortonworks.streamline.streams.layout.component.Edge)6 Stream (com.hortonworks.streamline.streams.layout.component.Stream)6 Map (java.util.Map)6 InputComponent (com.hortonworks.streamline.streams.layout.component.InputComponent)5 OutputComponent (com.hortonworks.streamline.streams.layout.component.OutputComponent)5 TopologyDag (com.hortonworks.streamline.streams.layout.component.TopologyDag)5 RulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor)5 TestRunProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor)5 TestRunRulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor)5 TestRunSink (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink)5 TestRunSource (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Optional (java.util.Optional)5 Collectors.toList (java.util.stream.Collectors.toList)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 TopologyTestHelper (com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper)4