Search in sources :

Example 1 with ThroughputTracker

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

the class StreamJunction method sendData.

private void sendData(long timeStamp, Object[] data) {
    // Set timestamp to system if Siddhi is in playback mode
    if (siddhiAppContext.isPlayback()) {
        ((EventTimeBasedMillisTimestampGenerator) this.siddhiAppContext.getTimestampGenerator()).setCurrentTimestamp(timeStamp);
    }
    if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
        throughputTracker.eventIn();
    }
    if (disruptor != null) {
        long sequenceNo = ringBuffer.next();
        try {
            Event existingEvent = ringBuffer.get(sequenceNo);
            existingEvent.setTimestamp(timeStamp);
            existingEvent.setIsExpired(false);
            System.arraycopy(data, 0, existingEvent.getData(), 0, data.length);
        } finally {
            ringBuffer.publish(sequenceNo);
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(timeStamp, data);
        }
    }
}
Also used : EventTimeBasedMillisTimestampGenerator(org.wso2.siddhi.core.util.timestamp.EventTimeBasedMillisTimestampGenerator) Event(org.wso2.siddhi.core.event.Event) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent)

Example 2 with ThroughputTracker

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

the class StreamJunction method sendEvent.

public void sendEvent(ComplexEvent complexEvent) {
    if (isTraceEnabled) {
        log.trace("Event is received by streamJunction " + this);
    }
    ComplexEvent complexEventList = complexEvent;
    if (disruptor != null) {
        while (complexEventList != null) {
            if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
                throughputTracker.eventIn();
            }
            long sequenceNo = ringBuffer.next();
            try {
                Event existingEvent = ringBuffer.get(sequenceNo);
                existingEvent.copyFrom(complexEventList);
            } finally {
                ringBuffer.publish(sequenceNo);
            }
            complexEventList = complexEventList.getNext();
        }
    } else {
        if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
            int messageCount = 0;
            while (complexEventList != null) {
                messageCount++;
                complexEventList = complexEventList.getNext();
            }
            throughputTracker.eventsIn(messageCount);
        }
        for (Receiver receiver : receivers) {
            receiver.receive(complexEvent);
        }
    }
}
Also used : ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent) Event(org.wso2.siddhi.core.event.Event) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent)

Example 3 with ThroughputTracker

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

the class StreamJunction method sendEvent.

public void sendEvent(Event event) {
    if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
        throughputTracker.eventIn();
    }
    if (isTraceEnabled) {
        log.trace(event + " event is received by streamJunction " + this);
    }
    if (disruptor != null) {
        long sequenceNo = ringBuffer.next();
        try {
            Event existingEvent = ringBuffer.get(sequenceNo);
            existingEvent.copyFrom(event);
        } finally {
            ringBuffer.publish(sequenceNo);
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(event);
        }
    }
}
Also used : Event(org.wso2.siddhi.core.event.Event) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent)

Example 4 with ThroughputTracker

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

the class StreamJunction method sendEvent.

private void sendEvent(Event[] events) {
    if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
        throughputTracker.eventsIn(events.length);
    }
    if (isTraceEnabled) {
        log.trace("Event is received by streamJunction " + this);
    }
    if (disruptor != null) {
        for (Event event : events) {
            // Todo : optimize for arrays
            long sequenceNo = ringBuffer.next();
            try {
                Event existingEvent = ringBuffer.get(sequenceNo);
                existingEvent.copyFrom(event);
            } finally {
                ringBuffer.publish(sequenceNo);
            }
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(events);
        }
    }
}
Also used : Event(org.wso2.siddhi.core.event.Event) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent)

Example 5 with ThroughputTracker

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

the class CronTrigger method sendEvent.

private void sendEvent() {
    long currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
    if (throughputTracker != null && siddhiAppContext.isStatsEnabled()) {
        throughputTracker.eventIn();
    }
    streamJunction.sendEvent(new Event(currentTime, new Object[] { currentTime }));
}
Also used : Event(org.wso2.siddhi.core.event.Event)

Aggregations

Event (org.wso2.siddhi.core.event.Event)7 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)4 ThroughputTracker (org.wso2.siddhi.core.util.statistics.ThroughputTracker)2 ArrayList (java.util.ArrayList)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 AggregationRuntime (org.wso2.siddhi.core.aggregation.AggregationRuntime)1 IncrementalAggregationProcessor (org.wso2.siddhi.core.aggregation.IncrementalAggregationProcessor)1 IncrementalExecutor (org.wso2.siddhi.core.aggregation.IncrementalExecutor)1 RecreateInMemoryData (org.wso2.siddhi.core.aggregation.RecreateInMemoryData)1 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)1 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)1 ConnectionUnavailableException (org.wso2.siddhi.core.exception.ConnectionUnavailableException)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)1 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)1 StreamRuntime (org.wso2.siddhi.core.query.input.stream.StreamRuntime)1 EntryValveExecutor (org.wso2.siddhi.core.query.input.stream.single.EntryValveExecutor)1 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 GroupByKeyGenerator (org.wso2.siddhi.core.query.selector.GroupByKeyGenerator)1 IncrementalAttributeAggregator (org.wso2.siddhi.core.query.selector.attribute.aggregator.incremental.IncrementalAttributeAggregator)1