Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.request; | |
13 | ||
14 | import java.util.Vector; | |
15 | ||
16 | import org.eclipse.linuxtools.lttng.event.LttngSyntheticEvent; | |
17 | import org.eclipse.linuxtools.lttng.state.evProcessor.ITransEventProcessor; | |
18 | import org.eclipse.linuxtools.tmf.component.TmfEventProvider; | |
19 | import org.eclipse.linuxtools.tmf.event.TmfTimeRange; | |
20 | import org.eclipse.linuxtools.tmf.request.TmfEventRequest; | |
21 | ||
22 | /** | |
23 | * This class is an extension of Data Request which includes specific references | |
24 | * i.e. a status listener to indicate the start and end of the request | |
25 | * | |
26 | * @author alvaro | |
27 | * | |
28 | */ | |
29 | public class LttngSyntEventRequest extends TmfEventRequest<LttngSyntheticEvent> | |
30 | implements ILttngSyntEventRequest { | |
31 | ||
32 | // ======================================================================== | |
33 | // Data | |
34 | // ======================================================================= | |
35 | private Vector<IRequestStatusListener> listeners = new Vector<IRequestStatusListener>(); | |
36 | private Long feventCount = 0L; | |
37 | private boolean clearDataInd = false; | |
38 | private TmfTimeRange fExperimentTimeRange = null; | |
39 | private Object fsource = null; | |
40 | private final ITransEventProcessor fprocessor; | |
c1c69938 FC |
41 | private String fExperimentName = null; |
42 | ||
5d10d135 ASL |
43 | |
44 | // ======================================================================== | |
45 | // Constructors | |
46 | // ======================================================================= | |
c1c69938 FC |
47 | /** |
48 | * @param range | |
49 | * @param offset | |
50 | * @param nbEvents | |
51 | * @param maxBlockSize | |
52 | * @param listener | |
53 | * @param experimentTimeRange | |
54 | * @param processor | |
55 | */ | |
56 | public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents, | |
57 | int maxBlockSize, IRequestStatusListener listener, | |
58 | TmfTimeRange experimentTimeRange, ITransEventProcessor processor) { | |
59 | ||
60 | this(range, offset, nbEvents, maxBlockSize, listener, experimentTimeRange, processor, "", ExecutionType.FOREGROUND); | |
61 | } | |
5d10d135 ASL |
62 | /** |
63 | * @param range | |
64 | * @param offset | |
65 | * @param nbEvents | |
66 | * @param maxBlockSize | |
67 | * @param listener | |
c1c69938 FC |
68 | * @param experimentTimeRange |
69 | * @param processor | |
70 | * @param experimentName | |
5d10d135 ASL |
71 | */ |
72 | public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents, | |
73 | int maxBlockSize, IRequestStatusListener listener, | |
c1c69938 | 74 | TmfTimeRange experimentTimeRange, ITransEventProcessor processor, String experimentName) { |
5d10d135 | 75 | |
c1c69938 FC |
76 | this(range, offset, nbEvents, maxBlockSize, listener, experimentTimeRange, processor, experimentName, ExecutionType.FOREGROUND); |
77 | } | |
78 | ||
79 | /** | |
80 | * @param range | |
81 | * @param offset | |
82 | * @param nbEvents | |
83 | * @param maxBlockSize | |
84 | * @param listener | |
85 | * @param experimentTimeRange | |
86 | * @param processor | |
87 | * @param experimentName | |
88 | * @param execType | |
89 | */ | |
9b635e61 FC |
90 | public LttngSyntEventRequest(TmfTimeRange range, long offset, int nbEvents, |
91 | int maxBlockSize, IRequestStatusListener listener, | |
c1c69938 FC |
92 | TmfTimeRange experimentTimeRange, ITransEventProcessor processor, String experimentName, |
93 | ExecutionType execType) { | |
9b635e61 FC |
94 | |
95 | super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, execType); | |
5d10d135 | 96 | fExperimentTimeRange = experimentTimeRange; |
c1c69938 | 97 | fExperimentName = new String(experimentName); |
5d10d135 ASL |
98 | addListener(listener); |
99 | ||
100 | fprocessor = processor; | |
101 | } | |
102 | ||
103 | /** | |
104 | * @param listener | |
105 | */ | |
106 | public void addListener(IRequestStatusListener listener) { | |
107 | if (listener != null && !listeners.contains(listener)) { | |
108 | listeners.add(listener); | |
109 | } | |
110 | } | |
111 | ||
112 | /** | |
113 | * @param listener | |
114 | */ | |
c1c69938 | 115 | public void removeListener(IRequestStatusListener listener) { |
5d10d135 ASL |
116 | if (listener != null) { |
117 | listeners.remove(listener); | |
118 | } | |
119 | } | |
120 | ||
121 | // ======================================================================== | |
122 | // Methods | |
123 | // ======================================================================= | |
124 | /* (non-Javadoc) | |
125 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean) | |
126 | */ | |
d4011df2 | 127 | @Override |
5d10d135 ASL |
128 | public void startRequestInd(TmfEventProvider<LttngSyntheticEvent> provider) { |
129 | // trigger the start to process this request | |
130 | provider.sendRequest(this); | |
131 | } | |
132 | ||
133 | /* (non-Javadoc) | |
134 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion() | |
135 | */ | |
d4011df2 | 136 | @Override |
5d10d135 ASL |
137 | public void notifyCompletion() { |
138 | // Notify specific state views | |
139 | for (IRequestStatusListener listener : listeners) { | |
140 | listener.processingCompleted(new RequestCompletedSignal(this)); | |
141 | } | |
142 | } | |
143 | ||
144 | /* (non-Javadoc) | |
145 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting() | |
146 | */ | |
d4011df2 | 147 | @Override |
5d10d135 ASL |
148 | public void notifyStarting() { |
149 | for (IRequestStatusListener listener : listeners) { | |
150 | listener.processingStarted(new RequestStartedSignal(this)); | |
151 | } | |
152 | } | |
153 | ||
154 | /* (non-Javadoc) | |
155 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange() | |
156 | */ | |
d4011df2 | 157 | @Override |
5d10d135 ASL |
158 | public TmfTimeRange getExperimentTimeRange() { |
159 | return fExperimentTimeRange; | |
160 | } | |
161 | ||
162 | /* | |
163 | * (non-Javadoc) | |
164 | * | |
165 | * @see | |
166 | * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount | |
167 | * (java.lang.Long) | |
168 | */ | |
d4011df2 | 169 | @Override |
5d10d135 ASL |
170 | public synchronized void setSynEventCount(Long numOfEvents) { |
171 | this.feventCount = numOfEvents; | |
172 | } | |
173 | ||
174 | /* | |
175 | * (non-Javadoc) | |
176 | * | |
177 | * @see | |
178 | * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount | |
179 | * () | |
180 | */ | |
d4011df2 | 181 | @Override |
550d787e | 182 | public synchronized Long getSynEventCount() { |
5d10d135 ASL |
183 | return feventCount; |
184 | } | |
185 | ||
186 | /* (non-Javadoc) | |
187 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean) | |
188 | */ | |
d4011df2 | 189 | @Override |
5d10d135 ASL |
190 | public void setclearDataInd(boolean clearAllData) { |
191 | this.clearDataInd = clearAllData; | |
192 | } | |
193 | ||
194 | /* (non-Javadoc) | |
195 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd() | |
196 | */ | |
d4011df2 | 197 | @Override |
5d10d135 ASL |
198 | public boolean isclearDataInd() { |
199 | return clearDataInd; | |
200 | } | |
201 | ||
202 | /* (non-Javadoc) | |
203 | * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData() | |
204 | */ | |
205 | @Override | |
f9673903 FC |
206 | public void handleData(LttngSyntheticEvent event) { |
207 | super.handleData(event); | |
5d10d135 ASL |
208 | } |
209 | ||
210 | ||
211 | /* | |
212 | * (non-Javadoc) | |
213 | * | |
214 | * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted() | |
215 | */ | |
550d787e | 216 | @Override |
5d10d135 ASL |
217 | public void handleCompleted() { |
218 | // notify listeners | |
219 | notifyCompletion(); | |
220 | super.handleCompleted(); | |
221 | } | |
222 | ||
223 | /** | |
224 | * @return the source | |
225 | */ | |
d4011df2 | 226 | @Override |
5d10d135 ASL |
227 | public Object getSource() { |
228 | return fsource; | |
229 | } | |
230 | ||
231 | /** | |
232 | * @param source | |
233 | */ | |
d4011df2 | 234 | @Override |
5d10d135 ASL |
235 | public void setSource(Object source) { |
236 | this.fsource = source; | |
237 | } | |
238 | ||
239 | /** | |
240 | * @return the event processor associated to this request | |
241 | */ | |
242 | public ITransEventProcessor getProcessor() { | |
243 | return fprocessor; | |
244 | } | |
c1c69938 FC |
245 | |
246 | @Override | |
247 | public String getExperimentName() { | |
248 | return fExperimentName; | |
249 | } | |
250 | ||
5d10d135 | 251 | } |