Search in sources :

Example 66 with StreamlineEvent

use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.

the class StreamlineEventImplTest method testPut.

@Test(expected = UnsupportedOperationException.class)
public void testPut() throws Exception {
    Map<String, Object> map = new HashMap<>();
    map.put("foo", "bar");
    StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(map).build();
    event.put("key", "val");
}
Also used : HashMap(java.util.HashMap) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Test(org.junit.Test)

Example 67 with StreamlineEvent

use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.

the class StreamlineEventImplTest method testClear.

@Test(expected = UnsupportedOperationException.class)
public void testClear() throws Exception {
    Map<String, Object> map = new HashMap<>();
    map.put("foo", "bar");
    StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(map).build();
    event.clear();
}
Also used : HashMap(java.util.HashMap) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Test(org.junit.Test)

Example 68 with StreamlineEvent

use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.

the class WindowRulesBolt method execute.

/**
 * Process the tuple window and optionally emit new tuples based on the tuples in the input window.
 *
 * @param inputWindow
 */
@Override
public void execute(TupleWindow inputWindow) {
    ++windowId;
    LOG.debug("Window activated, window id {}, number of tuples in window {}", windowId, inputWindow.get().size());
    Map<String, Tuple> eventIdToTupleMap = new HashMap<>();
    try {
        StreamlineEvent event;
        for (Tuple input : inputWindow.get()) {
            if ((event = getStreamlineEventFromTuple(input)) != null) {
                LOG.debug("++++++++ Executing tuple [{}] which contains StreamlineEvent [{}]", input, event);
                eventIdToTupleMap.put(event.getId(), input);
                processAndEmit(event, eventIdToTupleMap);
            }
        }
        // force evaluation of the last group by
        processAndEmit(GROUP_BY_TRIGGER_EVENT, eventIdToTupleMap);
        // current group is processed and result emitted
        eventIdToTupleMap.clear();
    } catch (Exception e) {
        collector.reportError(e);
        LOG.error("", e);
    }
}
Also used : HashMap(java.util.HashMap) IdPreservedStreamlineEvent(com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Tuple(org.apache.storm.tuple.Tuple) ProcessingException(com.hortonworks.streamline.streams.exception.ProcessingException)

Example 69 with StreamlineEvent

use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.

the class WindowRulesBolt method getDataSourceIds.

private List<String> getDataSourceIds(Collection<Tuple> tuples) {
    Set<String> res = new HashSet<>();
    StreamlineEvent event;
    for (Tuple tuple : tuples) {
        if ((event = getStreamlineEventFromTuple(tuple)) != null) {
            res.add(event.getDataSourceId());
        }
    }
    return new ArrayList<>(res);
}
Also used : IdPreservedStreamlineEvent(com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) ArrayList(java.util.ArrayList) Tuple(org.apache.storm.tuple.Tuple) HashSet(java.util.HashSet)

Example 70 with StreamlineEvent

use of com.hortonworks.streamline.streams.StreamlineEvent in project streamline by hortonworks.

the class WindowRulesBolt method getEventIds.

private List<String> getEventIds(Collection<Tuple> tuples) {
    Set<String> res = new HashSet<>();
    StreamlineEvent event;
    for (Tuple tuple : tuples) {
        if ((event = getStreamlineEventFromTuple(tuple)) != null) {
            res.add(event.getId());
        }
    }
    return new ArrayList<>(res);
}
Also used : IdPreservedStreamlineEvent(com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) ArrayList(java.util.ArrayList) Tuple(org.apache.storm.tuple.Tuple) HashSet(java.util.HashSet)

Aggregations

StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)97 Test (org.junit.Test)47 HashMap (java.util.HashMap)41 Values (org.apache.storm.tuple.Values)25 ArrayList (java.util.ArrayList)19 Tuple (org.apache.storm.tuple.Tuple)14 Result (com.hortonworks.streamline.streams.Result)13 Expectations (mockit.Expectations)9 TupleImpl (org.apache.storm.tuple.TupleImpl)9 Map (java.util.Map)8 Verifications (mockit.Verifications)8 TransformRuntime (com.hortonworks.streamline.streams.runtime.TransformRuntime)7 ProcessingException (com.hortonworks.streamline.streams.exception.ProcessingException)6 StormSqlExpression (com.hortonworks.streamline.streams.runtime.rule.condition.expression.StormSqlExpression)6 List (java.util.List)5 IdPreservedStreamlineEvent (com.hortonworks.streamline.streams.common.IdPreservedStreamlineEvent)4 StreamlineEventImpl (com.hortonworks.streamline.streams.common.StreamlineEventImpl)4 Fields (org.apache.storm.tuple.Fields)4 EventCorrelationInjector (com.hortonworks.streamline.streams.common.event.correlation.EventCorrelationInjector)3 MergeTransform (com.hortonworks.streamline.streams.layout.component.rule.action.transform.MergeTransform)3