Search in sources :

Example 1 with StreamlineSource

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

the class FileReaderSpoutFluxComponent method generateComponent.

@Override
protected void generateComponent() {
    StreamlineSource streamlineSource = (StreamlineSource) conf.get(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY);
    // add the output stream to conf so that the kafka spout declares output stream properly
    if (streamlineSource != null && streamlineSource.getOutputStreams().size() == 1) {
        conf.put(TopologyLayoutConstants.JSON_KEY_OUTPUT_STREAM_ID, streamlineSource.getOutputStreams().iterator().next().getId());
    } else {
        String msg = "FileReaderSpout source component [" + streamlineSource + "] should define exactly one output stream for Storm";
        LOG.error(msg, streamlineSource);
        throw new IllegalArgumentException(msg);
    }
    String spoutId = "fileReaderSpout" + UUID_FOR_COMPONENTS;
    String spoutClassName = "com.hortonworks.streamline.examples.sources.FileReaderSpout";
    String[] contructorArgNames = { "path" };
    List<Object> configMethods = new ArrayList<>();
    String[] configMethodNames = { "withOutputStream", "withDelimiter" };
    String[] configKeys = { TopologyLayoutConstants.JSON_KEY_OUTPUT_STREAM_ID, "delimiter" };
    configMethods.addAll(getConfigMethodsYaml(configMethodNames, configKeys));
    component = createComponent(spoutId, spoutClassName, null, getConstructorArgsYaml(contructorArgNames), configMethods);
    addParallelismToComponent();
}
Also used : ArrayList(java.util.ArrayList) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource)

Example 2 with StreamlineSource

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

the class TestTopologyDagCreatingVisitorTest method visitProcessor_connectedFromSource.

@Test
public void visitProcessor_connectedFromSource() throws Exception {
    StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
    StreamlineProcessor originProcessor = TopologyTestHelper.createStreamlineProcessor("2");
    TopologyDag originTopologyDag = new TopologyDag();
    originTopologyDag.add(originSource);
    originTopologyDag.add(originProcessor);
    originTopologyDag.addEdge(new Edge("e1", originSource, originProcessor, "default", Stream.Grouping.SHUFFLE));
    TestRunSource testSource = createTestRunSource(originSource);
    TestRunProcessor testProcessor = createTestRunProcessor(originProcessor);
    TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.singletonMap(originSource.getName(), testSource), Collections.singletonMap(originProcessor.getName(), testProcessor), Collections.emptyMap(), Collections.emptyMap());
    visitor.visit(originSource);
    visitor.visit(originProcessor);
    TopologyDag testTopologyDag = visitor.getTestTopologyDag();
    List<OutputComponent> testProcessors = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunProcessor && o.getName().equals(originProcessor.getName()))).collect(toList());
    List<OutputComponent> testSources = testTopologyDag.getOutputComponents().stream().filter(o -> (o instanceof TestRunSource && o.getName().equals(originSource.getName()))).collect(toList());
    TestRunProcessor testRunProcessor = (TestRunProcessor) testProcessors.get(0);
    TestRunSource testRunSource = (TestRunSource) testSources.get(0);
    assertEquals(1, testTopologyDag.getEdgesFrom(testRunSource).size());
    assertEquals(1, testTopologyDag.getEdgesTo(testRunProcessor).size());
    assertTrue(testTopologyDag.getEdgesFrom(testRunSource).get(0) == testTopologyDag.getEdgesTo(testRunProcessor).get(0));
}
Also used : OutputComponent(com.hortonworks.streamline.streams.layout.component.OutputComponent) Stream(com.hortonworks.streamline.streams.layout.component.Stream) TestRunProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) HashMap(java.util.HashMap) InputComponent(com.hortonworks.streamline.streams.layout.component.InputComponent) RulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor) Edge(com.hortonworks.streamline.streams.layout.component.Edge) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) TestRunSink(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TopologyTestHelper(com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper) TestRunSource(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource) Map(java.util.Map) TestRunRulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor) Optional(java.util.Optional) StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) Assert.fail(org.junit.Assert.fail) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) TestRunProcessor(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor) OutputComponent(com.hortonworks.streamline.streams.layout.component.OutputComponent) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) TestRunSource(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource) Edge(com.hortonworks.streamline.streams.layout.component.Edge) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) Test(org.junit.Test)

Example 3 with StreamlineSource

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

the class TestTopologyDagCreatingVisitorTest method visitSource_noMatchingTestRunSource.

@Test
public void visitSource_noMatchingTestRunSource() throws Exception {
    StreamlineSource originSource = TopologyTestHelper.createStreamlineSource("1");
    TopologyDag originTopologyDag = new TopologyDag();
    originTopologyDag.add(originSource);
    TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
    try {
        visitor.visit(originSource);
        fail("IllegalStateException should be thrown.");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(originSource.getName()));
    }
}
Also used : StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) Test(org.junit.Test)

Example 4 with StreamlineSource

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

the class CatalogToLayoutConverter method getComponentLayout.

public static com.hortonworks.streamline.streams.layout.component.Component getComponentLayout(TopologyComponent component) {
    StreamlineComponent componentLayout;
    if (component instanceof TopologySource) {
        componentLayout = new StreamlineSource() {

            @Override
            public void accept(TopologyDagVisitor visitor) {
                throw new UnsupportedOperationException("Not intended to be called here.");
            }
        };
    } else if (component instanceof TopologyProcessor) {
        componentLayout = new StreamlineProcessor() {

            @Override
            public void accept(TopologyDagVisitor visitor) {
                throw new UnsupportedOperationException("Not intended to be called here.");
            }
        };
    } else if (component instanceof TopologySink) {
        componentLayout = new StreamlineSink() {

            @Override
            public void accept(TopologyDagVisitor visitor) {
                throw new UnsupportedOperationException("Not intended to be called here.");
            }
        };
    } else {
        componentLayout = new StreamlineComponent() {

            @Override
            public void accept(TopologyDagVisitor visitor) {
                throw new UnsupportedOperationException("Not intended to be called here.");
            }
        };
    }
    componentLayout.setId(component.getId().toString());
    componentLayout.setName(component.getName());
    componentLayout.setConfig(component.getConfig());
    return componentLayout;
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) TopologyDagVisitor(com.hortonworks.streamline.streams.layout.component.TopologyDagVisitor) StreamlineComponent(com.hortonworks.streamline.streams.layout.component.StreamlineComponent) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource) StreamlineSink(com.hortonworks.streamline.streams.layout.component.StreamlineSink)

Example 5 with StreamlineSource

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

the class StormTopologyTimeSeriesMetricsImplTest method getSourceLayoutForTest.

private Component getSourceLayoutForTest() {
    StreamlineSource source = new StreamlineSource() {

        @Override
        public void accept(TopologyDagVisitor visitor) {
        }
    };
    source.setId("11");
    source.setName("device");
    Map<String, String> configurations = buildSourceConfigWithKafkaTopic(TOPIC_NAME);
    source.setConfig(new Config(configurations));
    return source;
}
Also used : TopologyDagVisitor(com.hortonworks.streamline.streams.layout.component.TopologyDagVisitor) Config(com.hortonworks.streamline.common.Config) StreamlineSource(com.hortonworks.streamline.streams.layout.component.StreamlineSource)

Aggregations

StreamlineSource (com.hortonworks.streamline.streams.layout.component.StreamlineSource)15 StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)10 StreamlineSink (com.hortonworks.streamline.streams.layout.component.StreamlineSink)10 Edge (com.hortonworks.streamline.streams.layout.component.Edge)8 TopologyDag (com.hortonworks.streamline.streams.layout.component.TopologyDag)8 Stream (com.hortonworks.streamline.streams.layout.component.Stream)7 TestRunProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor)7 TestRunRulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor)7 TestRunSink (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSink)7 TestRunSource (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource)7 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 Optional (java.util.Optional)7 Test (org.junit.Test)7 TopologyTestHelper (com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper)6 Collections (java.util.Collections)6 Assert.assertEquals (org.junit.Assert.assertEquals)6 Assert.assertTrue (org.junit.Assert.assertTrue)6 InputComponent (com.hortonworks.streamline.streams.layout.component.InputComponent)5