use of org.wso2.siddhi.core.stream.StreamJunction in project siddhi by wso2.
the class PartitionRuntime method addQuery.
public QueryRuntime addQuery(QueryRuntime metaQueryRuntime) {
Query query = metaQueryRuntime.getQuery();
if (query.getOutputStream() instanceof InsertIntoStream && metaQueryRuntime.getOutputCallback() instanceof InsertIntoStreamCallback) {
InsertIntoStreamCallback insertIntoStreamCallback = (InsertIntoStreamCallback) metaQueryRuntime.getOutputCallback();
StreamDefinition streamDefinition = insertIntoStreamCallback.getOutputStreamDefinition();
String id = streamDefinition.getId();
if (((InsertIntoStream) query.getOutputStream()).isInnerStream()) {
metaQueryRuntime.setToLocalStream(true);
localStreamDefinitionMap.putIfAbsent(id, streamDefinition);
DefinitionParserHelper.validateOutputStream(streamDefinition, localStreamDefinitionMap.get(id));
StreamJunction outputStreamJunction = localStreamJunctionMap.get(id);
if (outputStreamJunction == null) {
outputStreamJunction = new StreamJunction(streamDefinition, siddhiAppContext.getExecutorService(), siddhiAppContext.getBufferSize(), siddhiAppContext);
localStreamJunctionMap.putIfAbsent(id, outputStreamJunction);
}
insertIntoStreamCallback.init(localStreamJunctionMap.get(id));
} else {
streamDefinitionMap.putIfAbsent(id, streamDefinition);
DefinitionParserHelper.validateOutputStream(streamDefinition, streamDefinitionMap.get(id));
StreamJunction outputStreamJunction = streamJunctionMap.get(id);
if (outputStreamJunction == null) {
outputStreamJunction = new StreamJunction(streamDefinition, siddhiAppContext.getExecutorService(), siddhiAppContext.getBufferSize(), siddhiAppContext);
streamJunctionMap.putIfAbsent(id, outputStreamJunction);
}
insertIntoStreamCallback.init(streamJunctionMap.get(id));
}
}
metaQueryRuntimeMap.put(metaQueryRuntime.getQueryId(), metaQueryRuntime);
return metaQueryRuntime;
}
use of org.wso2.siddhi.core.stream.StreamJunction 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);
}
}
}
use of org.wso2.siddhi.core.stream.StreamJunction 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);
}
}
}
use of org.wso2.siddhi.core.stream.StreamJunction 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);
}
}
}
use of org.wso2.siddhi.core.stream.StreamJunction in project siddhi by wso2.
the class InputManager method constructInputHandler.
public InputHandler constructInputHandler(String streamId) {
InputHandler inputHandler = new InputHandler(streamId, inputHandlerMap.size(), inputEntryValve);
StreamJunction streamJunction = streamJunctionMap.get(streamId);
if (streamJunction == null) {
throw new DefinitionNotExistException("Stream with stream ID " + streamId + " has not been defined");
}
inputDistributor.addInputProcessor(streamJunctionMap.get(streamId).constructPublisher());
inputHandlerMap.put(streamId, inputHandler);
return inputHandler;
}
Aggregations