本文整理汇总了Java中org.wso2.siddhi.core.event.remove.RemoveEvent类的典型用法代码示例。如果您正苦于以下问题:Java RemoveEvent类的具体用法?Java RemoveEvent怎么用?Java RemoveEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoveEvent类属于org.wso2.siddhi.core.event.remove包,在下文中一共展示了RemoveEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
public void processEvent(InListEvent listEvent) {
acquireLock();
try {
if (!async && siddhiContext.isDistributedProcessingEnabled()) {
long expireTime = System.currentTimeMillis() + timeToKeep;
for (int i = 0, activeEvents = listEvent.getActiveEvents(); i < activeEvents; i++) {
window.put(new RemoveEvent(listEvent.getEvent(i), expireTime));
}
} else {
window.put(new RemoveListEvent(EventConverter.toRemoveEventArray(listEvent.getEvents(), listEvent.getActiveEvents(), System.currentTimeMillis() + timeToKeep)));
}
nextProcessor.process(listEvent);
} finally {
releaseLock();
}
}
示例2: init
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
if (parameters[0] instanceof IntConstant) {
timeToKeep = ((IntConstant) parameters[0]).getValue();
} else {
timeToKeep = ((LongConstant) parameters[0]).getValue();
}
oldEventList = new ArrayList<RemoveEvent>();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
newEventList = this.siddhiContext.getHazelcastInstance().getList(elementId + "-newEventList");
} else {
newEventList = new ArrayList<InEvent>();
}
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SchedulerSiddhiQueueGrid<StreamEvent>(elementId, this, this.siddhiContext, this.async);
} else {
window = new SchedulerSiddhiQueue<StreamEvent>(this);
}
//Ordinary scheduling
window.schedule();
}
示例3: init
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
lengthToKeep = ((IntConstant) parameters[0]).getValue();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SiddhiQueueGrid<StreamEvent>(elementId, this.siddhiContext, this.async);
} else {
window = new SiddhiQueue<StreamEvent>();
}
oldEventList = new ArrayList<RemoveEvent>();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
newEventList = this.siddhiContext.getHazelcastInstance().getList(elementId + "-newEventList");
} else {
newEventList = new ArrayList<InEvent>();
}
}
示例4: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
public void processEvent(InListEvent listEvent) {
acquireLock();
try {
long currentTime = (Long) listEvent.getEvent(listEvent.getActiveEvents() - 1).getData(timeStampAttributePosition);
removeExpiredEvent(currentTime);
long expireTime = currentTime + timeToKeep;
if (!async && siddhiContext.isDistributedProcessingEnabled()) {
for (int i = 0, activeEvents = listEvent.getActiveEvents(); i < activeEvents; i++) {
window.put(new RemoveEvent(listEvent.getEvent(i), expireTime));
}
} else {
window.put(new RemoveListEvent(EventConverter.toRemoveEventArray(listEvent.getEvents(), listEvent.getActiveEvents(), expireTime)));
}
nextProcessor.process(listEvent);
} finally {
releaseLock();
}
}
示例5: add
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
public void add(StreamEvent item) {
if (item instanceof AtomicEvent) {
if (cacheList.size() >= limit) {
cacheList.remove(0);
}
cacheList.add(new RemoveEvent((Event) item, Long.MAX_VALUE));
} else {
for (int i = 0, size = ((ListEvent) item).getActiveEvents(); i < size; i++) {
if (cacheList.size() >= limit) {
cacheList.remove(0);
}
cacheList.add(new RemoveEvent(((ListEvent) item).getEvent(i), Long.MAX_VALUE));
}
}
}
示例6: put
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
/**
* Every event that expires before next polling time will be put into a single group.
* If an event receives which expires after the next polling time, a new group will be
* created and subsequent messages will be put into that group and update next polling
* time. In this way separate groups will be created for messages which expires before
* a particular polling time. And since this is a FIFO queue the group that has to be
* pop-ed out in the next pol will always at the peek of the queue
* @param streamEvent
*/
@Override
public synchronized void put(T streamEvent) {
long expiryTime = ((RemoveEvent)streamEvent).getExpiryTime();
if (!pairQueue.isEmpty() && nextPollTime >= expiryTime) {
lastPair.getTwo().add(streamEvent);
} else {
LinkedBlockingQueue<T> eventsList = new LinkedBlockingQueue<T>();
eventsList.add(streamEvent);
Pair<Long, LinkedBlockingQueue<T>> eventPair = new Pair<Long, LinkedBlockingQueue<T>>(nextPollTime, eventsList);
pairQueue.add(eventPair);
lastPair = eventPair;
updateNextPollTime(nextPollTime);
}
}
示例7: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void processEvent(StreamEvent event) {
acquireLock();
try {
RemoveEvent removeEvent = new RemoveEvent(event,System.currentTimeMillis());
removeEvent.setOnAfterWindowData(((InnerStreamEvent)event).getOnAfterWindowData());
window.add(removeEvent);
if (window.size() > lengthToKeep) {
next.process(window.remove(0));
}
next.process(event);
} finally {
releaseLock();
}
}
示例8: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void processEvent(InEvent event) {
acquireLock();
try {
window.put(new RemoveEvent(event, Long.MAX_VALUE));
if (window.size() > lengthToKeep) {
nextProcessor.process((Event) window.poll());
}
nextProcessor.process(event);
} finally {
releaseLock();
}
}
示例9: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void processEvent(InEvent event) {
acquireLock();
try {
sortedWindow.add(new RemoveEvent(event, Long.MAX_VALUE));
if (sortedWindow.size() > lengthToKeep) {
Collections.sort(sortedWindow, eventComparator);
nextProcessor.process(new RemoveEvent(sortedWindow.remove(sortedWindow.size()-1), System.currentTimeMillis()));
}
nextProcessor.process(event);
} finally {
releaseLock();
}
}
示例10: restoreState
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void restoreState(Object[] data) {
window.restoreState((Object[]) data[0]);
oldEventList = ((ArrayList<RemoveEvent>) data[1]);
newEventList = ((ArrayList<InEvent>) data[2]);
window.reSchedule();
}
示例11: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void processEvent(InEvent event) {
acquireLock();
try {
StreamEvent oldEvent = map.put(generateKey(event), new RemoveEvent(event, Long.MAX_VALUE));
if (oldEvent != null) {
nextProcessor.process((AtomicEvent) oldEvent);
}
nextProcessor.process(event);
} finally {
releaseLock();
}
}
示例12: processLengthBatchWindow
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
private void processLengthBatchWindow(InEvent event) {
newEventList.add(event);
if (log.isDebugEnabled()) {
log.debug("newEventList size " + newEventList.size() + " with event " + event);
}
if (newEventList.size() == lengthToKeep) {
//sending old events
oldEventList.clear();
while (true) {
RemoveEvent oldEvent = (RemoveEvent) window.poll();
if (oldEvent == null) {
break;
} else {
oldEvent.setExpiryTime(System.currentTimeMillis());
oldEventList.add(oldEvent);
}
}
if (oldEventList.size() > 0) {
nextProcessor.process(new RemoveListEvent(oldEventList.toArray(new RemoveEvent[oldEventList.size()])));
oldEventList.clear();
}
InEvent[] inEvents = newEventList.toArray(new InEvent[newEventList.size()]);
for (InEvent inEvent : inEvents) {
window.put(new RemoveEvent(inEvent, -1));
}
nextProcessor.process(new InListEvent(inEvents));
newEventList.clear();
}
}
示例13: processEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
protected void processEvent(InEvent event) {
acquireLock();
try {
StreamEvent oldEvent = map.putIfAbsent(generateKey(event), new RemoveEvent(event, Long.MAX_VALUE));
if (oldEvent == null) {
nextProcessor.process(event);
}
} finally {
releaseLock();
}
}
示例14: removeExpiredEvent
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
private void removeExpiredEvent(long currentTime) {
while (true) {
RemoveEvent expiredEvent = (RemoveEvent) window.peek();
if (expiredEvent != null && expiredEvent.getExpiryTime() < currentTime) {
nextProcessor.process((AtomicEvent) window.poll());
} else {
break;
}
}
}
示例15: toString
import org.wso2.siddhi.core.event.remove.RemoveEvent; //导入依赖的package包/类
@Override
public String toString() {
return "Event{" +
"streamId='" + streamId + '\'' +
", timeStamp=" + timeStamp +
", data=" + (data == null ? null : Arrays.asList(data)) +
", type=" + ((this instanceof InStream) ? "new" : ((this instanceof RemoveEvent) ? "remove" : "other"))+
'}';
}