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 super(LttngSyntheticEvent
.class, range
, nbEvents
, maxBlockSize
);
57 //super(0, nbEvents, maxBlockSize);
58 fExperimentTimeRange
= experimentTimeRange
;
59 addListener(listener
);
61 fprocessor
= processor
;
67 public void addListener(IRequestStatusListener listener
) {
68 if (listener
!= null && !listeners
.contains(listener
)) {
69 listeners
.add(listener
);
76 public void removeListner(IRequestStatusListener listener
) {
77 if (listener
!= null) {
78 listeners
.remove(listener
);
82 // ========================================================================
84 // =======================================================================
86 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#startRequestInd(org.eclipse.linuxtools.tmf.experiment.TmfExperiment, boolean)
88 public void startRequestInd(TmfEventProvider
<LttngSyntheticEvent
> provider
) {
89 // trigger the start to process this request
90 provider
.sendRequest(this);
94 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyCompletion()
96 public void notifyCompletion() {
97 // Notify specific state views
98 for (IRequestStatusListener listener
: listeners
) {
99 listener
.processingCompleted(new RequestCompletedSignal(this));
104 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#notifyStarting()
106 public void notifyStarting() {
107 for (IRequestStatusListener listener
: listeners
) {
108 listener
.processingStarted(new RequestStartedSignal(this));
113 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#getExperimentTimeRange()
115 public TmfTimeRange
getExperimentTimeRange() {
116 return fExperimentTimeRange
;
123 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#setSynEventCount
126 public synchronized void setSynEventCount(Long numOfEvents
) {
127 this.feventCount
= numOfEvents
;
134 * org.eclipse.linuxtools.lttng.request.ILttngSyntEventRequest#getEventCount
137 public Long
getSynEventCount() {
142 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#setclearDataInd(boolean)
144 public void setclearDataInd(boolean clearAllData
) {
145 this.clearDataInd
= clearAllData
;
149 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#isclearDataInd()
151 public boolean isclearDataInd() {
156 * @see org.eclipse.linuxtools.lttng.request.ILttngEventRequest#handleData()
159 public void handleData() {
166 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
168 public void handleCompleted() {
171 super.handleCompleted();
177 public Object
getSource() {
184 public void setSource(Object source
) {
185 this.fsource
= source
;
189 * @return the event processor associated to this request
191 public ITransEventProcessor
getProcessor() {