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 //super(0, nbEvents, maxBlockSize);
72 fExperimentTimeRange
= experimentTimeRange
;
73 addListener(listener
);
75 fprocessor
= processor
;
81 public void addListener(IRequestStatusListener listener
) {
82 if (listener
!= null && !listeners
.contains(listener
)) {
83 listeners
.add(listener
);
90 public void removeListner(IRequestStatusListener listener
) {
91 if (listener
!= null) {
92 listeners
.remove(listener
);
96 // ========================================================================
98 // =======================================================================
100 * @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()
110 public void notifyCompletion() {
111 // Notify specific state views
112 for (IRequestStatusListener listener
: listeners
) {
113 listener
.processingCompleted(new RequestCompletedSignal(this));
118 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
120 public void notifyStarting() {
121 for (IRequestStatusListener listener
: listeners
) {
122 listener
.processingStarted(new RequestStartedSignal(this));
127 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
129 public TmfTimeRange
getExperimentTimeRange() {
130 return fExperimentTimeRange
;
137 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
140 public synchronized void setSynEventCount(Long numOfEvents
) {
141 this.feventCount
= numOfEvents
;
148 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
151 public synchronized Long
getSynEventCount() {
156 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
158 public void setclearDataInd(boolean clearAllData
) {
159 this.clearDataInd
= clearAllData
;
163 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
165 public boolean isclearDataInd() {
170 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
173 public void handleData() {
180 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
183 public void handleCompleted() {
186 super.handleCompleted();
192 public Object
getSource() {
199 public void setSource(Object source
) {
200 this.fsource
= source
;
204 * @return the event processor associated to this request
206 public ITransEventProcessor
getProcessor() {