1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.request
;
14 import java
.util
.Vector
;
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
;
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
29 public class LttngSyntEventRequest
extends TmfEventRequest
<LttngSyntheticEvent
>
30 implements ILttngSyntEventRequest
{
32 // ========================================================================
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
;
42 // ========================================================================
44 // =======================================================================
52 public LttngSyntEventRequest(TmfTimeRange range
, long offset
, int nbEvents
,
53 int maxBlockSize
, IRequestStatusListener listener
,
54 TmfTimeRange experimentTimeRange
, ITransEventProcessor processor
) {
56 this(range
, offset
, nbEvents
, maxBlockSize
, listener
, experimentTimeRange
, processor
, ExecutionType
.FOREGROUND
);
66 public LttngSyntEventRequest(TmfTimeRange range
, long offset
, int nbEvents
,
67 int maxBlockSize
, IRequestStatusListener listener
,
68 TmfTimeRange experimentTimeRange
, ITransEventProcessor processor
, ExecutionType execType
) {
70 super(LttngSyntheticEvent
.class, range
, nbEvents
, maxBlockSize
, execType
);
71 fExperimentTimeRange
= experimentTimeRange
;
72 addListener(listener
);
74 fprocessor
= processor
;
80 public void addListener(IRequestStatusListener listener
) {
81 if (listener
!= null && !listeners
.contains(listener
)) {
82 listeners
.add(listener
);
89 public void removeListner(IRequestStatusListener listener
) {
90 if (listener
!= null) {
91 listeners
.remove(listener
);
95 // ========================================================================
97 // =======================================================================
99 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean)
102 public void startRequestInd(TmfEventProvider
<LttngSyntheticEvent
> provider
) {
103 // trigger the start to process this request
104 provider
.sendRequest(this);
108 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion()
111 public void notifyCompletion() {
112 // Notify specific state views
113 for (IRequestStatusListener listener
: listeners
) {
114 listener
.processingCompleted(new RequestCompletedSignal(this));
119 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
122 public void notifyStarting() {
123 for (IRequestStatusListener listener
: listeners
) {
124 listener
.processingStarted(new RequestStartedSignal(this));
129 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
132 public TmfTimeRange
getExperimentTimeRange() {
133 return fExperimentTimeRange
;
140 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
144 public synchronized void setSynEventCount(Long numOfEvents
) {
145 this.feventCount
= numOfEvents
;
152 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
156 public synchronized Long
getSynEventCount() {
161 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
164 public void setclearDataInd(boolean clearAllData
) {
165 this.clearDataInd
= clearAllData
;
169 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
172 public boolean isclearDataInd() {
177 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
180 public void handleData(LttngSyntheticEvent event
) {
181 super.handleData(event
);
188 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
191 public void handleCompleted() {
194 super.handleCompleted();
201 public Object
getSource() {
209 public void setSource(Object source
) {
210 this.fsource
= source
;
214 * @return the event processor associated to this request
216 public ITransEventProcessor
getProcessor() {