Search in sources :

Example 1 with Window

use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.

the class TestWindowedQueryBolt method testJsonWindowConfig_EventTimeWindow.

@Test
public void testJsonWindowConfig_EventTimeWindow() throws IOException {
    String windowConfigJson = "{\"windowLength\" : {\"class\":\".Window$Duration\", \"durationMs\":2000},\n" + " \"slidingInterval\":{\"class\":\".Window$Duration\", \"durationMs\":2000},\n" + " \"tsFields\": [\"s1:tsField1\" , \"s2:tsField2\", \"s3:field3.innerTsField\"],\n" + " \"lagMs\": 1000 ,\n" + " \"lateStream\": \"optionalLateStream\"}";
    WindowedQueryBolt bolt = new WindowedQueryBolt("users", "city").join("cities", "cityName", "users").selectStreamLine("name, users:city as city, cities:country");
    bolt.withWindowConfig(new Window(windowConfigJson));
}
Also used : TupleWindow(org.apache.storm.windowing.TupleWindow) Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Test(org.junit.Test)

Example 2 with Window

use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.

the class JoinBoltFluxComponentTest method testMakeWindowFromJson.

@Test
public void testMakeWindowFromJson() throws IOException {
    String wjson = "{\"windowLength\":{\"class\":\".Window$Count\",\"count\":100},\"slidingInterval\":{\"class\":\".Window$Count\",\"count\":100},\"tsField\":null,\"lagMs\":0}";
    // should not throw an exception
    Window w = new Window(wjson);
}
Also used : Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Test(org.junit.Test)

Example 3 with Window

use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.

the class JoinBoltFluxComponentTest method testMakeEventTimeWindowFromJson.

@Test
public void testMakeEventTimeWindowFromJson() throws IOException {
    String json = "{\"windowLength\" : {\"class\":\".Window$Count\", \"count\":100}, \"slidingInterval\":{\"class\":\".Window$Count\", \"count\":100}, " + // event time window related settings
    "\"tsFields\": [\"stream1:tsField1\" , \"stream2:tsField2\"], \"lagMs\":10 , \"lateStream\": \"optionalLateStream\"} }";
    // should not throw an exception
    Window w = new Window(json);
}
Also used : Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Test(org.junit.Test)

Example 4 with Window

use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.

the class TopologyWindow method fromMap.

@Override
public Storable fromMap(Map<String, Object> map) {
    super.fromMap(map);
    setId((Long) map.get(ID));
    setVersionId((Long) map.get(VERSIONID));
    setTopologyId((Long) map.get(TOPOLOGY_ID));
    setName((String) map.get(NAME));
    setDescription((String) map.get(DESCRIPTION));
    setCondition((String) map.get(CONDITION));
    setParsedRuleStr((String) map.get(PARSED_RULE_STR));
    try {
        ObjectMapper mapper = new ObjectMapper();
        String streamsStr = (String) map.get(STREAMS);
        if (!StringUtils.isEmpty(streamsStr)) {
            List<String> streams = mapper.readValue(streamsStr, new TypeReference<List<String>>() {
            });
            setStreams(streams);
        }
        String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
        if (!StringUtils.isEmpty(outputStreamsStr)) {
            List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
            });
            setOutputStreams(outputStreams);
        }
        String windowStr = (String) map.get(WINDOW);
        if (!StringUtils.isEmpty(windowStr)) {
            Window window = mapper.readValue(windowStr, Window.class);
            setWindow(window);
        }
        String actionsStr = (String) map.get(ACTIONS);
        if (!StringUtils.isEmpty(actionsStr)) {
            List<Action> actions = mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
            });
            setActions(actions);
        }
        String projectionsStr = (String) map.get(PROJECTIONS);
        if (!StringUtils.isEmpty(projectionsStr)) {
            List<Projection> projections = mapper.readValue(projectionsStr, new TypeReference<List<Projection>>() {
            });
            setProjections(projections);
        }
        String groupbykeysStr = (String) map.get(GROUPBYKEYS);
        if (!StringUtils.isEmpty(groupbykeysStr)) {
            List<String> groupbykeys = mapper.readValue(groupbykeysStr, new TypeReference<List<String>>() {
            });
            setGroupbykeys(groupbykeys);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return this;
}
Also used : Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Action(com.hortonworks.streamline.streams.layout.component.rule.action.Action) IOException(java.io.IOException) ArrayList(java.util.ArrayList) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with Window

use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.

the class TopologyRule method fromMap.

@Override
public Storable fromMap(Map<String, Object> map) {
    super.fromMap(map);
    setId((Long) map.get(ID));
    setVersionId((Long) map.get(VERSIONID));
    setTopologyId((Long) map.get(TOPOLOGY_ID));
    setName((String) map.get(NAME));
    setDescription((String) map.get(DESCRIPTION));
    setCondition((String) map.get(CONDITION));
    setSql((String) map.get(SQL));
    setParsedRuleStr((String) map.get(PARSED_RULE_STR));
    try {
        ObjectMapper mapper = new ObjectMapper();
        String streamsStr = (String) map.get(STREAMS);
        if (!StringUtils.isEmpty(streamsStr)) {
            List<String> streams = mapper.readValue(streamsStr, new TypeReference<List<String>>() {
            });
            setStreams(streams);
        }
        String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
        if (!StringUtils.isEmpty(outputStreamsStr)) {
            List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
            });
            setOutputStreams(outputStreams);
        }
        String windowStr = (String) map.get(WINDOW);
        if (!StringUtils.isEmpty(windowStr)) {
            Window window = mapper.readValue(windowStr, Window.class);
            setWindow(window);
        }
        String projectionsStr = (String) map.get(PROJECTIONS);
        if (!StringUtils.isEmpty(projectionsStr)) {
            setProjections(mapper.readValue(projectionsStr, new TypeReference<List<Projection>>() {
            }));
        }
        String actionsStr = (String) map.get(ACTIONS);
        if (!StringUtils.isEmpty(actionsStr)) {
            setActions(mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
            }));
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return this;
}
Also used : Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Action(com.hortonworks.streamline.streams.layout.component.rule.action.Action) ArrayList(java.util.ArrayList) List(java.util.List) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Window (com.hortonworks.streamline.streams.layout.component.rule.expression.Window)12 Test (org.junit.Test)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ArrayList (java.util.ArrayList)4 TupleWindow (org.apache.storm.windowing.TupleWindow)4 RulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor)3 List (java.util.List)3 Function (com.google.common.base.Function)2 Rule (com.hortonworks.streamline.streams.layout.component.rule.Rule)2 Action (com.hortonworks.streamline.streams.layout.component.rule.action.Action)2 IOException (java.io.IOException)2 WindowedBoltExecutor (org.apache.storm.topology.WindowedBoltExecutor)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)1 Edge (com.hortonworks.streamline.streams.layout.component.Edge)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Verifications (mockit.Verifications)1 Tuple (org.apache.storm.tuple.Tuple)1