public class PriorityStreamProcessor
extends org.wso2.siddhi.core.query.processor.stream.StreamProcessor
implements org.wso2.siddhi.core.query.processor.SchedulingProcessor
PriorityStreamProcessor injects two new attributes into the stream which are
- priorityKey (see the constant ATTRIBUTE_PRIORITY_KEY
)
- currentPriority (see the constant ATTRIBUTE_CURRENT_PRIORITY
)
When an event with new unique key arrives, PriorityStreamProcessor checks the priority and if the priority is 0 the event will be sent out without being stored internally. If the event has a priority greater than 0, it will be stored in the stream processor and the current priority will be injected into that event.
When an event with existing priority key arrives, it will be stored as the recent event and the priority will be increased by the priority of the received event, and the priorityKey and currentPriority will be injected into the event.
After every given timeout, priority of every events will be reduced by 1 and the updated priority, will be sent out with the last known attributes of those events. It will continue until their priority reduced to 0.
When an event with existing id and a large negative priority, the output will be 0 not a negative priority.
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTE_CURRENT_PRIORITY
Second attribute name injected by PriorityStreamProcessor into the output stream event.
|
static String |
ATTRIBUTE_PRIORITY_KEY
First attribute name injected by PriorityStreamProcessor into the output stream event.
|
Constructor and Description |
---|
PriorityStreamProcessor() |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
currentState() |
org.wso2.siddhi.core.util.Scheduler |
getScheduler() |
protected List<org.wso2.siddhi.query.api.definition.Attribute> |
init(org.wso2.siddhi.query.api.definition.AbstractDefinition inputDefinition,
org.wso2.siddhi.core.executor.ExpressionExecutor[] attributeExpressionExecutors,
org.wso2.siddhi.core.util.config.ConfigReader configReader,
org.wso2.siddhi.core.config.SiddhiAppContext siddhiAppContext)
Initialize the PriorityStreamProcessor.
|
protected void |
process(org.wso2.siddhi.core.event.ComplexEventChunk<org.wso2.siddhi.core.event.stream.StreamEvent> streamEventChunk,
org.wso2.siddhi.core.query.processor.Processor nextProcessor,
org.wso2.siddhi.core.event.stream.StreamEventCloner streamEventCloner,
org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater complexEventPopulater)
Process events received by PriorityStreamProcessor.
|
void |
restoreState(Map<String,Object> map) |
void |
setScheduler(org.wso2.siddhi.core.util.Scheduler scheduler) |
void |
start() |
void |
stop() |
init, processEventChunk
cloneProcessor, constructStreamEventPopulater, getElementId, getNextProcessor, initProcessor, process, setNextProcessor, setStreamEventCloner, setToLast
public static final String ATTRIBUTE_PRIORITY_KEY
public static final String ATTRIBUTE_CURRENT_PRIORITY
protected List<org.wso2.siddhi.query.api.definition.Attribute> init(org.wso2.siddhi.query.api.definition.AbstractDefinition inputDefinition, org.wso2.siddhi.core.executor.ExpressionExecutor[] attributeExpressionExecutors, org.wso2.siddhi.core.util.config.ConfigReader configReader, org.wso2.siddhi.core.config.SiddhiAppContext siddhiAppContext)
init
in class org.wso2.siddhi.core.query.processor.stream.StreamProcessor
inputDefinition
- Input DefinitionattributeExpressionExecutors
- Array of AttributeExpressionExecutorsiddhiAppContext
- SiddhiAppContext of Siddhiprotected void process(org.wso2.siddhi.core.event.ComplexEventChunk<org.wso2.siddhi.core.event.stream.StreamEvent> streamEventChunk, org.wso2.siddhi.core.query.processor.Processor nextProcessor, org.wso2.siddhi.core.event.stream.StreamEventCloner streamEventCloner, org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater complexEventPopulater)
process
in class org.wso2.siddhi.core.query.processor.stream.StreamProcessor
streamEventChunk
- the event chunk that need to be processednextProcessor
- the next processor to which the success events need to be passedstreamEventCloner
- helps to clone the incoming event for local storage or modificationcomplexEventPopulater
- helps to populate the events with the resultant attributespublic void setScheduler(org.wso2.siddhi.core.util.Scheduler scheduler)
setScheduler
in interface org.wso2.siddhi.core.query.processor.SchedulingProcessor
public org.wso2.siddhi.core.util.Scheduler getScheduler()
getScheduler
in interface org.wso2.siddhi.core.query.processor.SchedulingProcessor
public void start()
start
in interface org.wso2.siddhi.core.util.extension.holder.EternalReferencedHolder
public void stop()
stop
in interface org.wso2.siddhi.core.util.extension.holder.EternalReferencedHolder
public Map<String,Object> currentState()
currentState
in interface org.wso2.siddhi.core.util.snapshot.Snapshotable
Copyright © 2019 WSO2. All rights reserved.