use of com.hortonworks.streamline.streams.layout.component.TopologyDag in project streamline by hortonworks.
the class TopologyActionsService method testRunTopology.
public TopologyTestRunHistory testRunTopology(Topology topology, TopologyTestRunCase testCase, Long durationSecs) throws Exception {
TopologyDag dag = topologyDagBuilder.getDag(topology);
topology.setTopologyDag(dag);
ensureValid(dag);
TopologyActions topologyActions = getTopologyActionsInstance(topology);
LOG.debug("Running topology {} in test mode", topology);
return topologyTestRunner.runTest(topologyActions, topology, testCase, durationSecs);
}
use of com.hortonworks.streamline.streams.layout.component.TopologyDag in project streamline by hortonworks.
the class TestTopologyDagCreatingVisitorTest method visitSink_noMatchingTestRunSink.
@Test
public void visitSink_noMatchingTestRunSink() throws Exception {
TopologyDag originTopologyDag = new TopologyDag();
StreamlineSink originSink = TopologyTestHelper.createStreamlineSink("1");
originTopologyDag.add(originSink);
TestTopologyDagCreatingVisitor visitor = new TestTopologyDagCreatingVisitor(originTopologyDag, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
try {
visitor.visit(originSink);
fail("IllegalStateException should be thrown.");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(originSink.getName()));
}
}
use of com.hortonworks.streamline.streams.layout.component.TopologyDag 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));
}
use of com.hortonworks.streamline.streams.layout.component.TopologyDag 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()));
}
}
use of com.hortonworks.streamline.streams.layout.component.TopologyDag in project streamline by hortonworks.
the class StreamCatalogService method doExportTopology.
private TopologyData doExportTopology(Topology topology) throws Exception {
TopologyDag dag = topologyDagBuilder.getDag(topology);
topology.setTopologyDag(dag);
TopologyData topologyData = new TopologyData();
TopologyExportVisitor exportVisitor = new TopologyExportVisitor(topology.getId(), topologyData, this);
topologyData.setTopologyName(topology.getName());
topologyData.setConfig(topology.getConfig());
TopologyDag topologyDag = topology.getTopologyDag();
if (topologyDag != null) {
topologyDag.traverse(exportVisitor);
}
topologyData.setMetadata(getTopologyEditorMetadata(topology.getId()));
return topologyData;
}
Aggregations