Search in sources :

Example 1 with EventExchangeHolder

use of io.siddhi.core.util.event.handler.EventExchangeHolder in project siddhi by wso2.

the class StreamJunction method sendEvent.

private void sendEvent(Event[] events) {
    if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
        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 {
                EventExchangeHolder eventExchangeHolder = ringBuffer.get(sequenceNo);
                eventExchangeHolder.getEvent().copyFrom(event);
                eventExchangeHolder.getAndSetIsProcessed(false);
            } finally {
                ringBuffer.publish(sequenceNo);
            }
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(events);
        }
    }
}
Also used : EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder) StreamEvent(io.siddhi.core.event.stream.StreamEvent) ErroneousEvent(io.siddhi.core.util.error.handler.model.ErroneousEvent) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent)

Example 2 with EventExchangeHolder

use of io.siddhi.core.util.event.handler.EventExchangeHolder 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 && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
                throughputTracker.eventIn();
            }
            long sequenceNo = ringBuffer.next();
            try {
                EventExchangeHolder eventExchangeHolder = ringBuffer.get(sequenceNo);
                eventExchangeHolder.getEvent().copyFrom(complexEventList);
                eventExchangeHolder.getAndSetIsProcessed(false);
            } finally {
                ringBuffer.publish(sequenceNo);
            }
            complexEventList = complexEventList.getNext();
        }
    } else {
        if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            int messageCount = 0;
            while (complexEventList != null) {
                messageCount++;
                complexEventList = complexEventList.getNext();
            }
            throughputTracker.eventsIn(messageCount);
        }
        for (Receiver receiver : receivers) {
            receiver.receive(complexEvent);
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder)

Example 3 with EventExchangeHolder

use of io.siddhi.core.util.event.handler.EventExchangeHolder in project siddhi by wso2.

the class StreamJunction method sendEvent.

private void sendEvent(List<Event> events) {
    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 {
                EventExchangeHolder eventExchangeHolder = ringBuffer.get(sequenceNo);
                eventExchangeHolder.getEvent().copyFrom(event);
                eventExchangeHolder.getAndSetIsProcessed(false);
            } finally {
                ringBuffer.publish(sequenceNo);
            }
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(events.toArray(new Event[events.size()]));
        }
    }
}
Also used : EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder) StreamEvent(io.siddhi.core.event.stream.StreamEvent) ErroneousEvent(io.siddhi.core.util.error.handler.model.ErroneousEvent) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent)

Example 4 with EventExchangeHolder

use of io.siddhi.core.util.event.handler.EventExchangeHolder in project siddhi by wso2.

the class StreamJunction method sendEvent.

public void sendEvent(Event event) {
    if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
        throughputTracker.eventIn();
    }
    if (isTraceEnabled) {
        log.trace(event + " event is received by streamJunction " + this);
    }
    if (disruptor != null) {
        long sequenceNo = ringBuffer.next();
        try {
            EventExchangeHolder eventExchangeHolder = ringBuffer.get(sequenceNo);
            eventExchangeHolder.getEvent().copyFrom(event);
            eventExchangeHolder.getAndSetIsProcessed(false);
        } finally {
            ringBuffer.publish(sequenceNo);
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(event);
        }
    }
}
Also used : EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder)

Example 5 with EventExchangeHolder

use of io.siddhi.core.util.event.handler.EventExchangeHolder in project siddhi by wso2.

the class StreamJunction method sendData.

private void sendData(long timeStamp, Object[] data) {
    if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
        throughputTracker.eventIn();
    }
    if (disruptor != null) {
        long sequenceNo = ringBuffer.next();
        try {
            EventExchangeHolder eventExchangeHolder = ringBuffer.get(sequenceNo);
            eventExchangeHolder.getAndSetIsProcessed(false);
            eventExchangeHolder.getEvent().setTimestamp(timeStamp);
            eventExchangeHolder.getEvent().setIsExpired(false);
            System.arraycopy(data, 0, eventExchangeHolder.getEvent().getData(), 0, data.length);
        } finally {
            ringBuffer.publish(sequenceNo);
        }
    } else {
        for (Receiver receiver : receivers) {
            receiver.receive(timeStamp, data);
        }
    }
}
Also used : EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder)

Aggregations

EventExchangeHolder (io.siddhi.core.util.event.handler.EventExchangeHolder)6 ComplexEvent (io.siddhi.core.event.ComplexEvent)3 Event (io.siddhi.core.event.Event)2 StreamEvent (io.siddhi.core.event.stream.StreamEvent)2 ErroneousEvent (io.siddhi.core.util.error.handler.model.ErroneousEvent)2 BlockingWaitStrategy (com.lmax.disruptor.BlockingWaitStrategy)1 ProducerType (com.lmax.disruptor.dsl.ProducerType)1 StreamCallback (io.siddhi.core.stream.output.StreamCallback)1 EventExchangeHolderFactory (io.siddhi.core.util.event.handler.EventExchangeHolderFactory)1 StreamHandler (io.siddhi.core.util.event.handler.StreamHandler)1 Constructor (java.lang.reflect.Constructor)1