Search in sources :

Example 1 with Stream

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

the class TestTopologyDagCreatingVisitorTest method createTestRunSource.

private TestRunSource createTestRunSource(StreamlineSource originSource) {
    Map<String, List<Map<String, Object>>> testRecordsMap = new HashMap<>();
    for (Stream stream : originSource.getOutputStreams()) {
        testRecordsMap.put(stream.getId(), TopologyTestHelper.createTestRecords());
    }
    TestRunSource testRunSource = new TestRunSource(originSource.getOutputStreams(), testRecordsMap, 1, 0L, "");
    testRunSource.setName(originSource.getName());
    return testRunSource;
}
Also used : HashMap(java.util.HashMap) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(com.hortonworks.streamline.streams.layout.component.Stream) TestRunSource(com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource)

Example 2 with Stream

use of com.hortonworks.streamline.streams.layout.component.Stream 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 Stream

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

the class TopologyTestHelper method createStreamlineProcessor.

public static StreamlineProcessor createStreamlineProcessor(String id) {
    Stream stream = createDefaultStream();
    StreamlineProcessor processor = new StreamlineProcessor(Sets.newHashSet(stream));
    processor.setId(id);
    processor.setName("testProcessor_" + id);
    processor.setConfig(new Config());
    processor.setTransformationClass("dummyTransformation");
    return processor;
}
Also used : StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) Config(com.hortonworks.streamline.common.Config) Stream(com.hortonworks.streamline.streams.layout.component.Stream)

Example 4 with Stream

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

the class NormalizationBoltTest method createBulkNormalizationProcessor.

public static NormalizationProcessor createBulkNormalizationProcessor(String outputStreamId) throws NormalizationException, IOException {
    Map<String, NormalizationConfig> inputStreamsWithConfig = new HashMap<>();
    Schema inputSchema = Schema.of(Schema.Field.of("temp", Schema.Type.INTEGER), Schema.Field.of("foo", Schema.Type.STRING));
    String bulkScriptText = getBulkScriptText();
    BulkNormalizationConfig bulkNormalizationConfig = new BulkNormalizationConfig(inputSchema, bulkScriptText);
    inputStreamsWithConfig.put(INPUT_STREAM_ID, bulkNormalizationConfig);
    Stream declaredOutputStream = new Stream(outputStreamId, OUTPUT_SCHEMA_FIELDS);
    NormalizationProcessor normalizationProcessor = new NormalizationProcessor(inputStreamsWithConfig, declaredOutputStream, NormalizationProcessor.Type.bulk);
    normalizationProcessor.addOutputStream(declaredOutputStream);
    return normalizationProcessor;
}
Also used : BulkNormalizationConfig(com.hortonworks.streamline.streams.layout.component.impl.normalization.BulkNormalizationConfig) NormalizationConfig(com.hortonworks.streamline.streams.layout.component.impl.normalization.NormalizationConfig) FieldBasedNormalizationConfig(com.hortonworks.streamline.streams.layout.component.impl.normalization.FieldBasedNormalizationConfig) BulkNormalizationConfig(com.hortonworks.streamline.streams.layout.component.impl.normalization.BulkNormalizationConfig) HashMap(java.util.HashMap) Schema(com.hortonworks.registries.common.Schema) NormalizationProcessor(com.hortonworks.streamline.streams.layout.component.impl.normalization.NormalizationProcessor) Stream(com.hortonworks.streamline.streams.layout.component.Stream) InputStream(java.io.InputStream)

Example 5 with Stream

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

the class StreamCatalogService method setReconfigureTarget.

private void setReconfigureTarget(TopologyEdge edge, TopologyStream stream) {
    TopologyComponent component = getTo(edge);
    component.setReconfigure(true);
    dao.addOrUpdate(component);
    // if component is a processor, update any rules in that processor that uses any of the streams
    if (component instanceof TopologyProcessor) {
        setReconfigureRules(Collections.singletonList((TopologyProcessor) component), edge.getStreamGroupings().stream().map(StreamGrouping::getStreamId).map(sid -> getStreamInfo(edge.getTopologyId(), sid, edge.getVersionId())).filter(curStream -> stream == null || curStream.getId().equals(stream.getId())).collect(Collectors.toList()));
    }
}
Also used : TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) Topology(com.hortonworks.streamline.streams.catalog.Topology) TopologyProcessorStreamMap(com.hortonworks.streamline.streams.catalog.TopologyProcessorStreamMap) Rule(com.hortonworks.streamline.streams.layout.component.rule.Rule) MLModelRegistryClient(com.hortonworks.streamline.registries.model.client.MLModelRegistryClient) UDAF(com.hortonworks.streamline.streams.rule.UDAF) Notifier(com.hortonworks.streamline.streams.catalog.Notifier) StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) Utils(com.hortonworks.streamline.common.util.Utils) QueryParam(com.hortonworks.registries.common.QueryParam) FileStorage(com.hortonworks.registries.common.util.FileStorage) UDAF2(com.hortonworks.streamline.streams.rule.UDAF2) Collections2(com.google.common.collect.Collections2) ComponentUISpecification(com.hortonworks.streamline.common.ComponentUISpecification) TopologyDag(com.hortonworks.streamline.streams.layout.component.TopologyDag) StreamGrouping(com.hortonworks.streamline.streams.catalog.TopologyEdge.StreamGrouping) ComponentConfigException(com.hortonworks.streamline.common.exception.ComponentConfigException) Matcher(java.util.regex.Matcher) TopologyEditorMetadata(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata) Map(java.util.Map) RuleParser(com.hortonworks.streamline.streams.catalog.rule.RuleParser) TopologyComponentBundle(com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) TopologyData(com.hortonworks.streamline.streams.catalog.topology.TopologyData) Set(java.util.Set) NOTIFICATION(com.hortonworks.streamline.common.ComponentTypes.NOTIFICATION) CURRENT_VERSION(com.hortonworks.streamline.common.util.WSUtils.CURRENT_VERSION) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CustomProcessorInfo(com.hortonworks.streamline.streams.catalog.processor.CustomProcessorInfo) StorableKey(com.hortonworks.registries.storage.StorableKey) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) Joiner(com.google.common.base.Joiner) TopologyState(com.hortonworks.streamline.streams.catalog.topology.state.TopologyState) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) TopologySourceStreamMap(com.hortonworks.streamline.streams.catalog.TopologySourceStreamMap) Projection(com.hortonworks.streamline.streams.catalog.Projection) TopologyOutputComponent(com.hortonworks.streamline.streams.catalog.TopologyOutputComponent) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) Nullable(javax.annotation.Nullable) TopologyVersion(com.hortonworks.streamline.streams.catalog.TopologyVersion) UDF(com.hortonworks.streamline.streams.catalog.UDF) IOException(java.io.IOException) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TreeMap(java.util.TreeMap) File(com.hortonworks.streamline.streams.catalog.File) DigestInputStream(java.security.DigestInputStream) Preconditions(com.google.common.base.Preconditions) TopologyDagBuilder(com.hortonworks.streamline.streams.catalog.topology.component.TopologyDagBuilder) BiFunction(java.util.function.BiFunction) UDF4(com.hortonworks.streamline.streams.rule.UDF4) LoggerFactory(org.slf4j.LoggerFactory) UDF3(com.hortonworks.streamline.streams.rule.UDF3) UDF2(com.hortonworks.streamline.streams.rule.UDF2) UDF7(com.hortonworks.streamline.streams.rule.UDF7) UDF6(com.hortonworks.streamline.streams.rule.UDF6) RulesProcessor(com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor) UDF5(com.hortonworks.streamline.streams.rule.UDF5) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) WSUtils(com.hortonworks.streamline.common.util.WSUtils) TypeReference(com.fasterxml.jackson.core.type.TypeReference) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) StorageUtils(com.hortonworks.registries.storage.util.StorageUtils) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) FileUtil(com.hortonworks.streamline.common.util.FileUtil) Collection(java.util.Collection) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) List(java.util.List) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) StorageManager(com.hortonworks.registries.storage.StorageManager) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) TopologyLayoutConstants(com.hortonworks.streamline.streams.layout.TopologyLayoutConstants) MessageDigest(java.security.MessageDigest) TopologyUIData(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata.TopologyUIData) TopologyEditorToolbar(com.hortonworks.streamline.streams.catalog.TopologyEditorToolbar) HashMap(java.util.HashMap) Hex(org.apache.commons.codec.binary.Hex) ComponentTypes(com.hortonworks.streamline.common.ComponentTypes) Schema(com.hortonworks.registries.common.Schema) HashSet(java.util.HashSet) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) ImmutableList(com.google.common.collect.ImmutableList) CustomProcessorRuntime(com.hortonworks.streamline.streams.runtime.CustomProcessorRuntime) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyExportVisitor(com.hortonworks.streamline.streams.catalog.topology.component.TopologyExportVisitor) Logger(org.slf4j.Logger) Stream(com.hortonworks.streamline.streams.layout.component.Stream) ProxyUtil(com.hortonworks.streamline.common.util.ProxyUtil) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) FileInputStream(java.io.FileInputStream) StorageException(com.hortonworks.registries.storage.exception.StorageException) TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) FluxComponent(com.hortonworks.streamline.streams.layout.storm.FluxComponent) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) InputStream(java.io.InputStream) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor) StreamGrouping(com.hortonworks.streamline.streams.catalog.TopologyEdge.StreamGrouping)

Aggregations

Stream (com.hortonworks.streamline.streams.layout.component.Stream)27 HashMap (java.util.HashMap)16 List (java.util.List)14 Map (java.util.Map)14 Test (org.junit.Test)13 StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)12 Collections (java.util.Collections)12 Edge (com.hortonworks.streamline.streams.layout.component.Edge)11 StreamlineSource (com.hortonworks.streamline.streams.layout.component.StreamlineSource)11 TopologyDag (com.hortonworks.streamline.streams.layout.component.TopologyDag)11 StreamlineSink (com.hortonworks.streamline.streams.layout.component.StreamlineSink)10 RulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor)10 TestRunSource (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunSource)10 Optional (java.util.Optional)10 TopologyTestHelper (com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper)9 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)9 InputComponent (com.hortonworks.streamline.streams.layout.component.InputComponent)8 OutputComponent (com.hortonworks.streamline.streams.layout.component.OutputComponent)8 ArrayList (java.util.ArrayList)8 TestRunProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor)7