Search in sources :

Example 11 with LatencyTracker

use of org.wso2.siddhi.core.util.statistics.LatencyTracker in project siddhi by wso2.

the class Scheduler method sendTimerEvents.

/**
 * Go through the timestamps stored in the {@link #toNotifyQueue} and send the TIMER events for the expired events.
 */
protected void sendTimerEvents() {
    Long toNotifyTime = toNotifyQueue.peek();
    long currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
    while (toNotifyTime != null && toNotifyTime - currentTime <= 0) {
        toNotifyQueue.poll();
        StreamEvent timerEvent = streamEventPool.borrowEvent();
        timerEvent.setType(StreamEvent.Type.TIMER);
        timerEvent.setTimestamp(toNotifyTime);
        streamEventChunk.add(timerEvent);
        if (lockWrapper != null) {
            lockWrapper.lock();
        }
        threadBarrier.pass();
        try {
            if (siddhiAppContext.isStatsEnabled() && latencyTracker != null) {
                try {
                    latencyTracker.markIn();
                    singleThreadEntryValve.process(streamEventChunk);
                } finally {
                    latencyTracker.markOut();
                }
            } else {
                singleThreadEntryValve.process(streamEventChunk);
            }
        } finally {
            if (lockWrapper != null) {
                lockWrapper.unlock();
            }
        }
        streamEventChunk.clear();
        toNotifyTime = toNotifyQueue.peek();
        currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
    }
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 12 with LatencyTracker

use of org.wso2.siddhi.core.util.statistics.LatencyTracker in project siddhi by wso2.

the class SinkMapper method init.

public final void init(StreamDefinition streamDefinition, String type, OptionHolder mapOptionHolder, List<Element> unmappedPayloadList, Sink sink, ConfigReader mapperConfigReader, LatencyTracker mapperLatencyTracker, SiddhiAppContext siddhiAppContext) {
    this.mapperLatencyTracker = mapperLatencyTracker;
    this.siddhiAppContext = siddhiAppContext;
    sink.setTrpDynamicOptions(trpDynamicOptions);
    this.sinkListener = sink;
    this.optionHolder = mapOptionHolder;
    this.type = type;
    if (unmappedPayloadList != null && !unmappedPayloadList.isEmpty()) {
        templateBuilderMap = new HashMap<>();
        for (Element e : unmappedPayloadList) {
            TemplateBuilder templateBuilder = new TemplateBuilder(streamDefinition, e.getValue());
            if (templateBuilderMap.containsKey(e.getKey())) {
                throw new SiddhiAppCreationException("Duplicate Keys, " + e.getKey() + ", in @payload() ");
            }
            templateBuilderMap.put(e.getKey(), templateBuilder);
        }
    }
    init(streamDefinition, mapOptionHolder, templateBuilderMap, mapperConfigReader, siddhiAppContext);
}
Also used : SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException) Element(org.wso2.siddhi.query.api.annotation.Element) TemplateBuilder(org.wso2.siddhi.core.util.transport.TemplateBuilder)

Aggregations

MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)4 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)4 LatencyTracker (org.wso2.siddhi.core.util.statistics.LatencyTracker)4 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)3 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)3 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)3 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)3 ArrayList (java.util.ArrayList)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)2 StreamRuntime (org.wso2.siddhi.core.query.input.stream.StreamRuntime)2 JoinStreamRuntime (org.wso2.siddhi.core.query.input.stream.join.JoinStreamRuntime)2 AbsentStreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)2 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)2 CountInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.CountInnerStateRuntime)2 EveryInnerStateRuntime (org.wso2.siddhi.core.query.input.stream.state.runtime.EveryInnerStateRuntime)2 Scheduler (org.wso2.siddhi.core.util.Scheduler)2 Window (org.wso2.siddhi.core.window.Window)2 Element (org.wso2.siddhi.query.api.annotation.Element)2 JoinInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.JoinInputStream)2