1 | /* |
2 | * Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. |
3 | * |
4 | * WSO2 Inc. licenses this file to you under the Apache License, |
5 | * Version 2.0 (the "License"); you may not use this file except |
6 | * in compliance with the License. |
7 | * You may obtain a copy of the License at |
8 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, |
12 | * software distributed under the License is distributed on an |
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | * KIND, either express or implied. See the License for the |
15 | * specific language governing permissions and limitations |
16 | * under the License. |
17 | */ |
18 | package org.wso2.siddhi.core.stream.handler.window; |
19 | |
20 | import org.wso2.siddhi.core.event.StreamEvent; |
21 | import org.wso2.siddhi.core.util.SchedulerQueue; |
22 | import org.wso2.siddhi.core.stream.StreamElement; |
23 | import org.wso2.siddhi.core.stream.StreamProcessor; |
24 | import org.wso2.siddhi.core.stream.handler.StreamHandler; |
25 | import org.wso2.siddhi.query.api.query.QueryEventStream; |
26 | |
27 | import java.util.List; |
28 | import java.util.concurrent.Executors; |
29 | import java.util.concurrent.ScheduledExecutorService; |
30 | |
31 | public abstract class WindowHandler implements StreamHandler{ |
32 | private List<QueryEventStream> queryEventStreamList; |
33 | private StreamProcessor nextPreStreamFlowProcessor; |
34 | private ScheduledExecutorService eventRemoverScheduler = Executors.newScheduledThreadPool(1); |
35 | private SchedulerQueue<StreamEvent> window = new SchedulerQueue<StreamEvent>(); |
36 | private StreamElement prevStreamElement; |
37 | |
38 | @Override |
39 | public void setNext(StreamProcessor nextPreStreamFlowProcessor) { |
40 | this.nextPreStreamFlowProcessor = nextPreStreamFlowProcessor; |
41 | } |
42 | |
43 | |
44 | protected List<QueryEventStream> getQueryEventStreamList() { |
45 | return queryEventStreamList; |
46 | } |
47 | |
48 | // protected StreamHandler getNextStreamHandler() { |
49 | // return nextStreamHandler; |
50 | // } |
51 | |
52 | |
53 | protected StreamProcessor getNextPreStreamFlowProcessor() { |
54 | return nextPreStreamFlowProcessor; |
55 | } |
56 | |
57 | protected ScheduledExecutorService getEventRemoverScheduler() { |
58 | return eventRemoverScheduler; |
59 | } |
60 | |
61 | public SchedulerQueue<StreamEvent> getWindow() { |
62 | return window; |
63 | } |
64 | |
65 | @Override |
66 | public void setPrevious(StreamElement streamElement) { |
67 | this.prevStreamElement = streamElement; |
68 | } |
69 | |
70 | @Override |
71 | public String getStreamId() { |
72 | return prevStreamElement.getStreamId(); |
73 | } |
74 | |
75 | public abstract void setParameters(Object[] parameters); |
76 | } |