Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Chouinard2011-07-25 19:07:41 +0000
committerFrancois Chouinard2011-07-26 15:51:52 +0000
commit3ef7a3795db44e44b324ae60e8e456653899cd03 (patch)
tree18910d087d7282132099093be622a350a059b5be /lttng/org.eclipse.linuxtools.lttng
parentbb5c792de94df7bc323842ed7159999c2f107b0b (diff)
downloadorg.eclipse.linuxtools-3ef7a3795db44e44b324ae60e8e456653899cd03.tar.gz
org.eclipse.linuxtools-3ef7a3795db44e44b324ae60e8e456653899cd03.tar.xz
org.eclipse.linuxtools-3ef7a3795db44e44b324ae60e8e456653899cd03.zip
Contribution for Bug353020
(https://bugs.eclipse.org/bugs/attachment.cgi?id=200291)
Diffstat (limited to 'lttng/org.eclipse.linuxtools.lttng')
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF3
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java46
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/ILttExperimentSelectedListener.java6
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/StateExperimentListener.java7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java179
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java16
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/StateTraceManager.java51
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java286
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/TraceResource.java205
-rw-r--r--lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/config/TraceConfig.java26
13 files changed, 643 insertions, 193 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF
index 7a23cb11b7..4c36afff14 100644
--- a/lttng/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.linuxtools.tmf;bundle-version="0.3.2",
org.eclipse.linuxtools.lttng.jni;bundle-version="0.3.0",
org.eclipse.rse.core;bundle-version="3.1.101",
- org.eclipse.tm.tcf.core;bundle-version="0.3.0"
+ org.eclipse.tm.tcf.core;bundle-version="0.3.0",
+ org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.linuxtools.lttng,
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
index 031d011797..704db6f6e6 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/control/LttngSyntheticEventProvider.java
@@ -38,11 +38,12 @@ import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.signal.TmfStartSynchSignal;
import org.eclipse.linuxtools.tmf.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint;
import org.eclipse.linuxtools.tmf.trace.TmfContext;
import org.eclipse.linuxtools.tmf.trace.TmfTrace;
@@ -55,7 +56,7 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
// ========================================================================
// Data
// ========================================================================
- public static final int BLOCK_SIZE = 1;
+ public static final int BLOCK_SIZE = 50000;
public static final int NB_EVENTS = 1;
public static final int QUEUE_SIZE = 1; // lttng specific, one event at a time
@@ -70,6 +71,8 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
private ITransEventProcessor fstateUpdateProcessor = StateEventToHandlerFactory.getInstance();
private boolean waitForRequest = false;
long dispatchTime = 0L;
+ long dispatchIndex = 0L;
+ long eventIndex;
private final Map<ITmfTrace, LttngTraceState> traceToTraceStateModel = new HashMap<ITmfTrace, LttngTraceState>();
private boolean fIsExperimentNotified = false;
@@ -140,6 +143,8 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
experiment.startSynch(new TmfStartSynchSignal(0));
TmfTimeRange adjustedRange = reqWindow;
+ long adjustedIndex = eventRequest.getIndex();
+ int nbRequested = eventRequest.getNbRequested();
// Figure-out if we need to increase the range of the request: if some
// checkpoints are before the beginning of the range, increase the
@@ -152,16 +157,20 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
while(iter.hasNext()) {
traceManager = iter.next();
// restore trace state system to nearest check point
- TmfTimestamp checkPoint = traceManager
- .restoreCheckPointByTimestamp(reqWindow.getStartTime());
+ TmfCheckpoint checkPoint = null;
+ if (eventRequest.getIndex() > 0) {
+ checkPoint = traceManager.restoreCheckPointByIndex(eventRequest.getIndex());
+ } else {
+ checkPoint = traceManager.restoreCheckPointByTimestamp(reqWindow.getStartTime());
+ }
// validate that the checkpoint restored is within requested bounds
// (not outside the current trace's range or after the end of requested range)
TmfTimeRange traceRange = traceManager.getTrace().getTimeRange();
- if ((checkPoint != null) && !(
- checkPoint.getValue() >= traceRange.getStartTime().getValue() &&
- checkPoint.getValue() <= traceRange.getEndTime().getValue() &&
- checkPoint.getValue() < reqWindow.getEndTime().getValue())
+ if ((checkPoint == null) ||
+ checkPoint.getTimestamp().getValue() < traceRange.getStartTime().getValue() ||
+ checkPoint.getTimestamp().getValue() > traceRange.getEndTime().getValue() ||
+ checkPoint.getTimestamp().getValue() >= reqWindow.getEndTime().getValue()
) {
// checkpoint is out of trace bounds; no need to adjust request for this
// trace
@@ -169,8 +178,12 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
else {
// use checkpoint time as new startTime for request if it's earlier than
// current startTime
- if (checkPoint != null && adjustedRange.getStartTime().getValue() > checkPoint.getValue()) {
- adjustedRange = new TmfTimeRange(checkPoint, reqWindow.getEndTime());
+ if (adjustedRange.getStartTime().getValue() > checkPoint.getTimestamp().getValue() || adjustedIndex > (Long) checkPoint.getLocation().getLocation()) {
+ adjustedRange = new TmfTimeRange(checkPoint.getTimestamp(), reqWindow.getEndTime());
+ adjustedIndex = (Long) checkPoint.getLocation().getLocation();
+ if (nbRequested < TmfDataRequest.ALL_DATA) {
+ nbRequested += (eventRequest.getIndex() - adjustedIndex);
+ }
}
}
// Save which trace state model corresponds to current trace
@@ -178,10 +191,12 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
}
dispatchTime = reqWindow.getStartTime().getValue();
+ dispatchIndex = eventRequest.getIndex();
+ eventIndex = adjustedIndex;
// Create a single request for all traces in the experiment, with coalesced time range.
fSubRequest = new LttngBaseEventRequest(adjustedRange, reqWindow.getStartTime(),
- 0, TmfEventRequest.ALL_DATA, BLOCK_SIZE, eventRequest.getExecType() /*ITmfDataRequest.ExecutionType.FOREGROUND*/) {
+ adjustedIndex, nbRequested, BLOCK_SIZE, eventRequest.getExecType() /*ITmfDataRequest.ExecutionType.FOREGROUND*/) {
private LttngSyntheticEvent syntheticEvent = null;
@@ -235,7 +250,7 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
updateSynEvent(e);
// If time at or above requested time, update application
- if (eventTime >= dispatchTime) {
+ if (eventTime >= dispatchTime && eventIndex >= dispatchIndex) {
// Before update
syntheticEvent.setSequenceInd(SequenceInd.BEFORE);
fmainRequest.handleData(syntheticEvent);
@@ -256,6 +271,7 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
syntheticEvent.setSequenceInd(SequenceInd.UPDATE);
fstateUpdateProcessor.process(syntheticEvent, traceModel);
}
+ eventIndex++;
}
/**
@@ -460,4 +476,10 @@ public class LttngSyntheticEventProvider extends TmfEventProvider<LttngSynthetic
fmainRequest = null;
}
}
+
+ @Override
+ protected void queueBackgroundRequest(ITmfDataRequest<LttngSyntheticEvent> request, int blockSize, boolean indexing) {
+ // do not split background synthetic requests
+ queueRequest(request);
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
index 4adbad013c..25913fcad1 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngLocation.java
@@ -3,7 +3,7 @@ package org.eclipse.linuxtools.lttng.event;
import org.eclipse.linuxtools.tmf.trace.ITmfLocation;
-public class LttngLocation implements ITmfLocation<LttngTimestamp> {
+public class LttngLocation implements ITmfLocation<LttngTimestamp>, Comparable<LttngLocation> {
private final static long DEFAULT_CURR_TIME = 0L;
@@ -152,5 +152,10 @@ public class LttngLocation implements ITmfLocation<LttngTimestamp> {
public LttngTimestamp getLocation() {
return new LttngTimestamp ( operationTime );
}
+
+ @Override
+ public int compareTo(LttngLocation o) {
+ return operationTime.compareTo(o.operationTime);
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
index 91622be46b..bdc3e98d61 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngBaseEventRequest.java
@@ -55,7 +55,7 @@ public abstract class LttngBaseEventRequest extends TmfEventRequest<LttngEvent>
*/
public LttngBaseEventRequest(TmfTimeRange range, TmfTimestamp dispatchTime, long offset, int nbEvents,
int maxBlockSize, ITmfDataRequest.ExecutionType execType) {
- super(LttngEvent.class, range, nbEvents, maxBlockSize, execType);
+ super(LttngEvent.class, range, (int) offset, nbEvents, maxBlockSize, execType);
fDispatchTime = dispatchTime;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
index 3c9179a7c6..96a0886a6b 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/request/LttngSyntEventRequest.java
@@ -92,7 +92,7 @@ public class LttngSyntEventRequest extends TmfEventRequest<LttngSyntheticEvent>
TmfTimeRange experimentTimeRange, ITransEventProcessor processor, String experimentName,
ExecutionType execType) {
- super(LttngSyntheticEvent.class, range, nbEvents, maxBlockSize, execType);
+ super(LttngSyntheticEvent.class, range, (int) offset, nbEvents, maxBlockSize, execType);
fExperimentTimeRange = experimentTimeRange;
fExperimentName = new String(experimentName);
addListener(listener);
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/ILttExperimentSelectedListener.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/ILttExperimentSelectedListener.java
index 06db70672d..dfd115f192 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/ILttExperimentSelectedListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/ILttExperimentSelectedListener.java
@@ -13,7 +13,7 @@ package org.eclipse.linuxtools.lttng.signal;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal;
/**
* @author alvaro
@@ -31,9 +31,7 @@ public interface ILttExperimentSelectedListener {
/**
* @param signal
- * @param waitForComplete
- * if true: wait for the request to complete before returning
*/
- public void experimentUpdated(TmfExperimentUpdatedSignal signal, boolean waitForComplete);
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal);
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/StateExperimentListener.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/StateExperimentListener.java
index 3ce9235655..e47fcc9de9 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/StateExperimentListener.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/signal/StateExperimentListener.java
@@ -15,6 +15,7 @@ import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.tmf.component.TmfComponent;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal;
import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
@@ -41,4 +42,10 @@ public class StateExperimentListener extends TmfComponent {
// notify handler
fhandler.experimentSelected(signal.getSource(), experiment);
}
+
+ @TmfSignalHandler
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) {
+ // notify handler
+ fhandler.experimentRangeUpdated(signal);
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
index a5ed41ab15..60f942f2d4 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/experiment/StateExperimentManager.java
@@ -30,9 +30,8 @@ import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
/**
@@ -56,7 +55,13 @@ public class StateExperimentManager extends LTTngTreeNode implements
private final Map<ITmfTrace, StateTraceHelper> ftraceToManagerMap = new HashMap<ITmfTrace, StateTraceHelper>();
private LttngSyntheticEvent syntheticEvent = null;
- private ITmfEventRequest<LttngEvent> fStateCheckPointRequest = null;
+ private ITmfDataRequest<LttngEvent> fStateCheckPointRequest = null;
+ private boolean fCheckPointUpdateBusy = false;
+ private boolean fCheckPointUpdatePending = false;
+ private int fCheckPointUpdateIndex = 0;
+ private TmfTimeRange fCheckPointUpdateRange = null;
+ private long fCheckPointNbEventsHandled = 0;
+ private final Object fCheckPointUpdateSyncObj = new Object();
// ========================================================================
@@ -220,7 +225,7 @@ public class StateExperimentManager extends LTTngTreeNode implements
TmfExperiment<LttngEvent> experiment) {
// validate
if (experiment == null) {
- TraceDebug.debug("Received expriment is null"); //$NON-NLS-1$
+ TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$
return;
}
@@ -230,8 +235,20 @@ public class StateExperimentManager extends LTTngTreeNode implements
fStateCheckPointRequest.cancel();
}
+ synchronized (fCheckPointUpdateSyncObj) {
+ fCheckPointUpdateBusy = true;
+ fCheckPointUpdatePending = false;
+ fCheckPointUpdateIndex = 0;
+ }
+
// trigger data request to build the state system check points
- fStateCheckPointRequest = buildCheckPoints(experiment);
+ fStateCheckPointRequest = buildCheckPoints(experiment, experiment.getTimeRange(), true);
+
+ if (fStateCheckPointRequest == null) {
+ synchronized (fCheckPointUpdateSyncObj) {
+ fCheckPointUpdateBusy = false;
+ }
+ }
}
/*
@@ -241,12 +258,39 @@ public class StateExperimentManager extends LTTngTreeNode implements
* experimentUpdated
* (org.eclipse.linuxtools.tmf.signal.TmfExperimentUpdatedSignal, boolean)
*/
+ @SuppressWarnings("unchecked")
@Override
- public void experimentUpdated(TmfExperimentUpdatedSignal signal, boolean wait) {
- // NOTE: This represents the end of TMF indexing for a trace, however
- // the node was already existing and the state system check points are
- // already requested and built upon selection.
- // No action for the time being
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) {
+ TmfExperiment<LttngEvent> experiment = (TmfExperiment<LttngEvent>) signal.getExperiment();
+ // validate
+ if (experiment != fSelectedExperiment.getValue()) {
+ return;
+ }
+
+ synchronized (fCheckPointUpdateSyncObj) {
+ if (fCheckPointUpdateBusy) {
+ fCheckPointUpdatePending = true;
+ fCheckPointUpdateRange = signal.getRange();
+ return;
+ } else {
+ fCheckPointUpdateBusy = true;
+ }
+ }
+
+ // If previous request is ongoing, cancel it before requesting a new
+ // one.
+ if (fStateCheckPointRequest != null && !fStateCheckPointRequest.isCompleted()) {
+ fStateCheckPointRequest.cancel();
+ }
+
+ // trigger data request to build the state system check points
+ fStateCheckPointRequest = buildCheckPoints(experiment, signal.getRange(), false);
+
+ if (fStateCheckPointRequest == null) {
+ synchronized (fCheckPointUpdateSyncObj) {
+ fCheckPointUpdateBusy = false;
+ }
+ }
}
@@ -295,43 +339,48 @@ public class StateExperimentManager extends LTTngTreeNode implements
fwaitForCompletion = wait;
}
- private ITmfEventRequest<LttngEvent> buildCheckPoints(TmfExperiment<LttngEvent> experiment) {
+ private ITmfDataRequest<LttngEvent> buildCheckPoints(final TmfExperiment<LttngEvent> experiment, final TmfTimeRange range, boolean initial) {
// validate
if (experiment == null) {
- TraceDebug.debug("Received expriment is null"); //$NON-NLS-1$
+ TraceDebug.debug("Received experiment is null"); //$NON-NLS-1$
return null;
}
LTTngTreeNode experimentNode = getChildByName(experiment.getName());
if (experimentNode == null) {
- TraceDebug.debug("Expriment Node " + experiment.getName() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
+ TraceDebug.debug("Experiment Node " + experiment.getName() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
return null;
}
+ final boolean waitForCompletion = fwaitForCompletion;
+
// get the trace manager nodes associated to the experiment
LTTngTreeNode[] traceNodes = experimentNode.getChildren();
- synchronized (this) {
- ftraceToManagerMap.clear();
- }
-
- ITmfTrace trace;
- for (LTTngTreeNode traceStateManagerNode : traceNodes) {
- IStateTraceManager traceManager;
- try {
- traceManager = (IStateTraceManager) traceStateManagerNode;
- } catch (ClassCastException e) {
- System.out.println(e.getStackTrace().toString());
- return null;
- }
-
- // Clear all previously created check points as preparation to
- // re-build
- traceManager.clearCheckPoints();
- // build the trace to manager mapping for event dispatching
- trace = traceManager.getTrace();
+ if (initial) {
synchronized (this) {
- ftraceToManagerMap.put(trace, new StateTraceHelper(traceManager));
+ ftraceToManagerMap.clear();
+ }
+
+ ITmfTrace trace;
+ for (LTTngTreeNode traceStateManagerNode : traceNodes) {
+ IStateTraceManager traceManager;
+ try {
+ traceManager = (IStateTraceManager) traceStateManagerNode;
+ } catch (ClassCastException e) {
+ System.out.println(e.getStackTrace().toString());
+ return null;
+ }
+
+ // Clear all previously created check points as preparation to
+ // re-build
+ traceManager.clearCheckPoints();
+
+ // build the trace to manager mapping for event dispatching
+ trace = traceManager.getTrace();
+ synchronized (this) {
+ ftraceToManagerMap.put(trace, new StateTraceHelper(traceManager));
+ }
}
}
@@ -341,13 +390,13 @@ public class StateExperimentManager extends LTTngTreeNode implements
return null;
}
+ fCheckPointNbEventsHandled = 0;
+
// Prepare event data request to build state model
ITmfEventRequest<LttngEvent> request = new TmfEventRequest<LttngEvent>(
- LttngEvent.class, TmfTimeRange.Eternity,
- TmfDataRequest.ALL_DATA, LttngConstants.DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
+ LttngEvent.class, range, fCheckPointUpdateIndex,
+ TmfEventRequest.ALL_DATA, LttngConstants.DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
- long nbEventsHandled = 0;
-
/*
* (non-Javadoc)
*
@@ -359,7 +408,7 @@ public class StateExperimentManager extends LTTngTreeNode implements
super.handleData(event);
if (event != null) {
// Tracer.trace("Chk: " + event.getTimestamp());
- nbEventsHandled++;
+ fCheckPointNbEventsHandled++;
ITmfTrace trace = event.getParentTrace();
StateTraceHelper helper = ftraceToManagerMap.get(trace);
@@ -383,44 +432,33 @@ public class StateExperimentManager extends LTTngTreeNode implements
* (non-Javadoc)
*
* @see
- * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleFailure()
- */
- @Override
- public void handleFailure() {
- printCompletedMessage();
- super.handleFailure();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCancel()
+ * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
*/
@Override
- public void handleCancel() {
+ public void handleCompleted() {
+ super.handleCompleted();
printCompletedMessage();
- super.handleCancel();
+
+ if (!waitForCompletion) {
+ synchronized (fCheckPointUpdateSyncObj) {
+ fCheckPointUpdateBusy = false;
+ fCheckPointUpdateIndex += fCheckPointNbEventsHandled;
+ if (fCheckPointUpdatePending) {
+ fCheckPointUpdatePending = false;
+ fCheckPointUpdateBusy = true;
+ buildCheckPoints(experiment, fCheckPointUpdateRange, false);
+ }
+ }
+ }
}
/*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleSuccess()
- */
- @Override
- public void handleSuccess() {
- printCompletedMessage();
- super.handleSuccess();
- }
-
/**
* @param header
*/
private void printCompletedMessage() {
if (TraceDebug.isDEBUG()) {
- TraceDebug.debug("Trace check point building completed, number of events handled: " + nbEventsHandled + "\n\t\t"); //$NON-NLS-1$ //$NON-NLS-2$
+ TraceDebug.debug("Trace check point building completed, number of events handled: " + fCheckPointNbEventsHandled + "\n\t\t"); //$NON-NLS-1$ //$NON-NLS-2$
for (StateTraceHelper helper : ftraceToManagerMap.values()) {
TraceDebug.debug(helper.getStateManager().toString() + "\n\t\t"); //$NON-NLS-1$
}
@@ -431,9 +469,18 @@ public class StateExperimentManager extends LTTngTreeNode implements
// Execute event data request
experiment.sendRequest(request);
- if (fwaitForCompletion) {
+ if (waitForCompletion) {
try {
request.waitForCompletion();
+ synchronized (fCheckPointUpdateSyncObj) {
+ fCheckPointUpdateBusy = false;
+ fCheckPointUpdateIndex += fCheckPointNbEventsHandled;
+ if (fCheckPointUpdatePending) {
+ fCheckPointUpdatePending = false;
+ fCheckPointUpdateBusy = true;
+ buildCheckPoints(experiment, fCheckPointUpdateRange, false);
+ }
+ }
} catch (InterruptedException e) {
e.printStackTrace();
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java
index d997e47810..65a7186dc2 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/IStateTraceManager.java
@@ -5,6 +5,7 @@ import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.trace.TmfCheckpoint;
public interface IStateTraceManager {
// /**
@@ -40,13 +41,24 @@ public interface IStateTraceManager {
* @param eventTime
* The timestamp of the event to restore to
*
- * @return TmfTimestamp indicates the nearest time used to restore the
+ * @return TmfCheckpoint indicates the nearest checkpoint used to restore the
* state, null sent if input is invalid
*/
- public abstract TmfTimestamp restoreCheckPointByTimestamp(
+ public abstract TmfCheckpoint restoreCheckPointByTimestamp(
TmfTimestamp eventTime);
/**
+ * Restore to the closest checkpoint from index
+ *
+ * @param eventIndex
+ * The index of the event to restore to
+ *
+ * @return TmfCheckpoint indicates the nearest checkpoint used to restore the
+ * state, null sent if input is invalid
+ */
+ public abstract TmfCheckpoint restoreCheckPointByIndex(long eventIndex);
+
+ /**
* @return
*/
public abstract TmfTimeRange getExperimentTimeWindow();
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/StateTraceManager.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/StateTraceManager.java
index 64cdddca53..9679f0c1f1 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/StateTraceManager.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/state/trace/StateTraceManager.java
@@ -194,9 +194,9 @@ public class StateTraceManager extends LTTngTreeNode implements IStateTraceManag
*/
@Override
@SuppressWarnings("unchecked")
- public TmfTimestamp restoreCheckPointByTimestamp(TmfTimestamp eventTime) {
+ public TmfCheckpoint restoreCheckPointByTimestamp(TmfTimestamp eventTime) {
TmfTimeRange experimentRange = fExperiment.getTimeRange();
- TmfTimestamp nearestTimeStamp = fTrace.getStartTime();
+ TmfCheckpoint checkpoint = new TmfCheckpoint(fTrace.getStartTime(), new TmfLocation<Long>(0L));
// The GUI can have time limits higher than this log, since GUI can
// handle multiple logs
@@ -229,8 +229,7 @@ public class StateTraceManager extends LTTngTreeNode implements IStateTraceManag
} else {
// Useful CheckPoint found
- TmfCheckpoint checkpoint = timestampCheckpointsList.get(index);
- nearestTimeStamp = checkpoint.getTimestamp();
+ checkpoint = timestampCheckpointsList.get(index);
// get the location associated with the checkpoint
TmfLocation<Long> location = (TmfLocation<Long>) checkpoint.getLocation();
// reference a new copy of the checkpoint template
@@ -244,7 +243,49 @@ public class StateTraceManager extends LTTngTreeNode implements IStateTraceManag
fStateModel = traceState;
}
- return nearestTimeStamp;
+ return checkpoint;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.state.trace.IStateTraceManager#restoreCheckPointByIndex(long)
+ */
+ @Override
+ public TmfCheckpoint restoreCheckPointByIndex(long eventIndex) {
+ TmfCheckpoint checkpoint = new TmfCheckpoint(fTrace.getStartTime(), new TmfLocation<Long>(0L));
+
+ LttngTraceState traceState;
+ synchronized (fCheckPointsLock) {
+ Collections.sort(timestampCheckpointsList);
+ // Initiate the compare with a checkpoint containing the target time
+ // stamp to find
+ int index = Collections.binarySearch(timestampCheckpointsList, new TmfCheckpoint(null,
+ new TmfLocation<Long>(eventIndex)));
+ // adjust index to round down to earlier checkpoint when exact match not found
+ index = getPrevIndex(index);
+
+ if (index == 0) {
+ // No checkpoint restore is needed, start with a brand new
+ // TraceState
+ traceState = StateModelFactory.getStateEntryInstance(this);
+ } else {
+
+ // Useful CheckPoint found
+ checkpoint = timestampCheckpointsList.get(index);
+ // get the location associated with the checkpoint
+ @SuppressWarnings("unchecked")
+ TmfLocation<Long> location = (TmfLocation<Long>) checkpoint.getLocation();
+ // reference a new copy of the checkpoint template
+ traceState = stateCheckpointsList.get(location.getLocation()).clone();
+ }
+
+ }
+
+ // Restore the stored traceState
+ synchronized (fStateModelLock) {
+ fStateModel = traceState;
+ }
+
+ return checkpoint;
}
/**
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java
index a2266e46cf..124139a67b 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngExperiment.java
@@ -12,11 +12,20 @@
package org.eclipse.linuxtools.lttng.trace;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.jni.JniTrace;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.experiment.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.experiment.TmfExperimentLocation;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfExperimentRangeUpdatedSignal;
+import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.trace.TmfContext;
@@ -29,9 +38,9 @@ import org.eclipse.linuxtools.tmf.trace.TmfContext;
*/
public class LTTngExperiment<T extends TmfEvent> extends TmfExperiment<T> implements ITmfTrace {
- private static final int DEFAULT_INDEX_PAGE_SIZE = 50000;
+ private static final int DEFAULT_INDEX_PAGE_SIZE = 50000;
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -44,11 +53,11 @@ public class LTTngExperiment<T extends TmfEvent> extends TmfExperiment<T> implem
*/
public LTTngExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) {
this(type, id, traces, TmfTimestamp.Zero, indexPageSize, false);
- }
+ }
public LTTngExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize, boolean preIndexExperiment) {
- super(type, id, traces, epoch, indexPageSize, preIndexExperiment);
- }
+ super(type, id, traces, epoch, indexPageSize, preIndexExperiment);
+ }
/**
* @param type
@@ -68,100 +77,100 @@ public class LTTngExperiment<T extends TmfEvent> extends TmfExperiment<T> implem
public LTTngExperiment(Class<T> type, String id, ITmfTrace[] traces, int indexPageSize) {
this(type, id, traces, TmfTimestamp.Zero, indexPageSize);
}
-
+
public LTTngExperiment(LTTngExperiment<T> other) {
- super(other.getName() + "(clone)", other.fType); //$NON-NLS-1$
-
- fEpoch = other.fEpoch;
- fIndexPageSize = other.fIndexPageSize;
-
- fTraces = new ITmfTrace[other.fTraces.length];
- for (int trace = 0; trace < other.fTraces.length; trace++) {
- fTraces[trace] = other.fTraces[trace].createTraceCopy();
- }
-
- fNbEvents = other.fNbEvents;
- fTimeRange = other.fTimeRange;
+ super(other.getName() + "(clone)", other.fType); //$NON-NLS-1$
+
+ fEpoch = other.fEpoch;
+ fIndexPageSize = other.fIndexPageSize;
+
+ fTraces = new ITmfTrace[other.fTraces.length];
+ for (int trace = 0; trace < other.fTraces.length; trace++) {
+ fTraces[trace] = other.fTraces[trace].createTraceCopy();
+ }
+
+ fNbEvents = other.fNbEvents;
+ fTimeRange = other.fTimeRange;
+ }
+
+ @Override
+ public LTTngExperiment<T> createTraceCopy() {
+ LTTngExperiment<T> experiment = new LTTngExperiment<T>(this);
+ TmfSignalManager.deregister(experiment);
+ return experiment;
}
-
- @Override
- public LTTngExperiment<T> createTraceCopy() {
- LTTngExperiment<T> experiment = new LTTngExperiment<T>(this);
- TmfSignalManager.deregister(experiment);
- return experiment;
- }
-
- // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
// ITmfTrace trace positioning
// ------------------------------------------------------------------------
- @Override
- public synchronized TmfEvent getNextEvent(TmfContext context) {
+ @Override
+ public synchronized TmfEvent getNextEvent(TmfContext context) {
- // Validate the context
- if (!(context instanceof TmfExperimentContext)) {
- return null; // Throw an exception?
- }
+ // Validate the context
+ if (!(context instanceof TmfExperimentContext)) {
+ return null; // Throw an exception?
+ }
- if (!context.equals(fExperimentContext)) {
+ if (!context.equals(fExperimentContext)) {
// Tracer.trace("Ctx: Restoring context");
- fExperimentContext = seekLocation(context.getLocation());
- }
-
- TmfExperimentContext expContext = (TmfExperimentContext) context;
+ fExperimentContext = seekLocation(context.getLocation());
+ }
+
+ TmfExperimentContext expContext = (TmfExperimentContext) context;
// dumpContext(expContext, true);
- // If an event was consumed previously, get the next one from that trace
- int lastTrace = expContext.getLastTrace();
- if (lastTrace != TmfExperimentContext.NO_TRACE) {
- TmfContext traceContext = expContext.getContexts()[lastTrace];
- expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
- expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
- }
-
- // Scan the candidate events and identify the "next" trace to read from
- TmfEvent eventArray[] = expContext.getEvents();
- if (eventArray == null) {
- return null;
- }
- int trace = TmfExperimentContext.NO_TRACE;
- TmfTimestamp timestamp = TmfTimestamp.BigCrunch;
- if (eventArray.length == 1) {
- if (eventArray[0] != null) {
- timestamp = eventArray[0].getTimestamp();
- trace = 0;
- }
- } else {
- for (int i = 0; i < eventArray.length; i++) {
- TmfEvent event = eventArray[i];
- if (event != null && event.getTimestamp() != null) {
- TmfTimestamp otherTS = event.getTimestamp();
- if (otherTS.compareTo(timestamp, true) < 0) {
- trace = i;
- timestamp = otherTS;
- }
- }
- }
- }
-
- // Update the experiment context and set the "next" event
- TmfEvent event = null;
- if (trace != TmfExperimentContext.NO_TRACE) {
+ // If an event was consumed previously, get the next one from that trace
+ int lastTrace = expContext.getLastTrace();
+ if (lastTrace != TmfExperimentContext.NO_TRACE) {
+ TmfContext traceContext = expContext.getContexts()[lastTrace];
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+ expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
+ }
+
+ // Scan the candidate events and identify the "next" trace to read from
+ TmfEvent eventArray[] = expContext.getEvents();
+ if (eventArray == null) {
+ return null;
+ }
+ int trace = TmfExperimentContext.NO_TRACE;
+ TmfTimestamp timestamp = TmfTimestamp.BigCrunch;
+ if (eventArray.length == 1) {
+ if (eventArray[0] != null) {
+ timestamp = eventArray[0].getTimestamp();
+ trace = 0;
+ }
+ } else {
+ for (int i = 0; i < eventArray.length; i++) {
+ TmfEvent event = eventArray[i];
+ if (event != null && event.getTimestamp() != null) {
+ TmfTimestamp otherTS = event.getTimestamp();
+ if (otherTS.compareTo(timestamp, true) < 0) {
+ trace = i;
+ timestamp = otherTS;
+ }
+ }
+ }
+ }
+
+ // Update the experiment context and set the "next" event
+ TmfEvent event = null;
+ if (trace != TmfExperimentContext.NO_TRACE) {
// updateIndex(expContext, timestamp);
- TmfContext traceContext = expContext.getContexts()[trace];
- TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
- expLocation.getLocation()[trace] = traceContext.getLocation();
+ TmfContext traceContext = expContext.getContexts()[trace];
+ TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
+ expLocation.getLocation().locations[trace] = traceContext.getLocation();
- updateIndex(expContext, timestamp);
+ updateIndex(expContext, timestamp);
- expLocation.getRanks()[trace] = traceContext.getRank();
- expContext.setLastTrace(trace);
- expContext.updateRank(1);
- event = expContext.getEvents()[trace];
- fExperimentContext = expContext;
- }
+ expLocation.getRanks()[trace] = traceContext.getRank();
+ expContext.setLastTrace(trace);
+ expContext.updateRank(1);
+ event = expContext.getEvents()[trace];
+ fExperimentContext = expContext;
+ }
// if (event != null) {
// Tracer.trace("Exp: " + (expContext.getRank() - 1) + ": " + event.getTimestamp().toString());
@@ -169,16 +178,107 @@ public class LTTngExperiment<T extends TmfEvent> extends TmfExperiment<T> implem
// Tracer.trace("Ctx: Event returned= " + event.getTimestamp().toString());
// }
- return event;
- }
+ return event;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void indexExperiment(final boolean waitForCompletion) {
+ if (waitForCompletion) {
+ TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(LTTngExperiment.this, LTTngExperiment.this,
+ TmfTimeRange.Eternity);
+ broadcast(signal);
+ while (isIndexingBusy()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ ;
+ return;
+ }
+ for (ITmfTrace trace : fTraces) {
+ if (trace instanceof LTTngTrace) {
+ JniTrace jniTrace = ((LTTngTrace) trace).getCurrentJniTrace();
+ if (jniTrace != null && !jniTrace.isLiveTraceSupported()) {
+ updateTimeRange();
+ TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(LTTngExperiment.this, LTTngExperiment.this,
+ getTimeRange());
+ broadcast(signal);
+ return;
+ }
+ }
+ }
+ final Thread thread = new Thread("Streaming Monitor for " + getName()) { //$NON-NLS-1$
+ LttngTimestamp safeTimestamp = null;
+ TmfTimeRange timeRange = null;
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
+ @Override
+ public void run() {
+ while (!fExecutor.isShutdown()) {
+ final TmfEventRequest<LttngEvent> request = new TmfEventRequest<LttngEvent>(LttngEvent.class, TmfTimeRange.Eternity, 0,
+ ExecutionType.FOREGROUND) {
+ @Override
+ public void handleCompleted() {
+ super.handleCompleted();
+ if (isIndexingBusy()) {
+ timeRange = null;
+ return;
+ }
+ long startTime = Long.MAX_VALUE;
+ long endTime = Long.MIN_VALUE;
+ for (ITmfTrace trace : getTraces()) {
+ if (trace instanceof LTTngTrace) {
+ LTTngTrace lttngTrace = (LTTngTrace) trace;
+ JniTrace jniTrace = lttngTrace.getCurrentJniTrace();
+ jniTrace.updateTrace();
+ startTime = Math.min(startTime, jniTrace.getStartTime().getTime());
+ endTime = Math.max(endTime, jniTrace.getEndTime().getTime());
+ }
+ }
+ LttngTimestamp startTimestamp = new LttngTimestamp(startTime);
+ LttngTimestamp endTimestamp = new LttngTimestamp(endTime);
+ if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0) {
+ timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
+ } else {
+ timeRange = null;
+ }
+ safeTimestamp = endTimestamp;
+ }
+ };
+ try {
+ sendRequest((ITmfDataRequest<T>) request);
+ request.waitForCompletion();
+ if (timeRange != null) {
+ TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(LTTngExperiment.this, LTTngExperiment.this,
+ timeRange);
+ broadcast(signal);
+ }
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+ thread.start();
+ }
+
+ @TmfSignalHandler
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) {
+ indexExperiment(false, (int) fNbEvents, signal.getRange());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
@SuppressWarnings("nls")
- public String toString() {
- return "[LTTngExperiment (" + getName() + ")]";
- }
+ public String toString() {
+ return "[LTTngExperiment (" + getName() + ")]";
+ }
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/TraceResource.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/TraceResource.java
index a7ad2d9ac8..2c1c1eb8dd 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/TraceResource.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/TraceResource.java
@@ -15,14 +15,15 @@ package org.eclipse.linuxtools.lttng.tracecontrol.model;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.eclipse.linuxtools.lttng.tracecontrol.Messages;
import org.eclipse.linuxtools.lttng.tracecontrol.model.config.TraceConfig;
-//import org.eclipse.linuxtools.lttng.ui.tracecontrol.Messages;
-import org.eclipse.linuxtools.lttng.tracecontrol.model.TargetResource;
-import org.eclipse.linuxtools.lttng.tracecontrol.model.TraceResource;
+import org.eclipse.linuxtools.lttng.tracecontrol.service.ILttControllerService;
import org.eclipse.rse.core.subsystems.AbstractResource;
import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.util.TCFTask;
/**
* <b><u>ProviderResource</u></b>
@@ -42,6 +43,8 @@ public class TraceResource extends AbstractResource implements Comparable<TraceR
public static final String Ltt_Trace_Property_NetworkTrace = "isNetwork"; //$NON-NLS-1$
public static final String Ltt_Trace_Property_TraceTransport = "transport"; //$NON-NLS-1$
+ public static final int DEFAULT_TCF_TASK_TIMEOUT = 10;
+
private static final Map<String, PropertyInfo> fPropertyInfo = new HashMap<String, PropertyInfo>();
static {
@@ -77,6 +80,7 @@ public class TraceResource extends AbstractResource implements Comparable<TraceR
private TargetResource fParent;
private TraceState fTraceState;
private TraceConfig fTraceConfig;
+ private ILttControllerService fService;
// ------------------------------------------------------------------------
// Constructors
@@ -84,8 +88,9 @@ public class TraceResource extends AbstractResource implements Comparable<TraceR
/**
* Constructor for TraceResource when given fParent subsystem.
*/
- public TraceResource(ISubSystem parentSubSystem) {
+ public TraceResource(ISubSystem parentSubSystem, ILttControllerService service) {
super(parentSubSystem);
+ fService = service;
}
// ------------------------------------------------------------------------
@@ -297,4 +302,196 @@ public class TraceResource extends AbstractResource implements Comparable<TraceR
public String toString() {
return "[TraceResource (" + fName + ")]";
}
+
+ /*
+ * Setup trace on the remote system.
+ */
+ public void setupTrace() throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Setup trace using Lttng controller service proxy
+ fService.setupTrace(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ new ILttControllerService.DoneSetupTrace() {
+
+ @Override
+ public void doneSetupTrace(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+ /*
+ * Enable or disable a channel on the remote system.
+ */
+ public void setChannelEnable(final String channelName, final boolean enabled) throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Set marker enable using Lttng controller service proxy
+ fService.setChannelEnable(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ channelName,
+ enabled,
+ new ILttControllerService.DoneSetChannelEnable() {
+
+ @Override
+ public void doneSetChannelEnable(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+ /*
+ * Set channel overwrite on the remote system.
+ */
+ public void setChannelOverwrite(final String channelName, final boolean overwrite) throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Set marker overwrite using Lttng controller service proxy
+ fService.setChannelOverwrite(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ channelName,
+ overwrite,
+ new ILttControllerService.DoneSetChannelOverwrite() {
+
+ @Override
+ public void doneSetChannelOverwrite(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+ /*
+ * Set channel timer on the remote system.
+ */
+ public void setChannelTimer(final String channelName, final long timer) throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Set marker switch_timer using Lttng controller service proxy
+ fService.setChannelTimer(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ channelName,
+ timer,
+ new ILttControllerService.DoneSetChannelTimer() {
+
+ @Override
+ public void doneSetChannelTimer(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+ /*
+ * Setup the size of the sub-buffer on the remote system.
+ */
+ public void setChannelSubbufNum(final String channelName, final long subbufNum) throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Set marker enable using Lttng controller service proxy
+ fService.setChannelSubbufNum(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ channelName,
+ subbufNum,
+ new ILttControllerService.DoneSetChannelSubbufNum() {
+
+ @Override
+ public void doneSetChannelSubbufNum(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+ /*
+ * Setup the size of the sub-buffer on the remote system.
+ */
+ public void setChannelSubbufSize(final String channelName, final long subbufSize) throws Exception {
+ // Create future task
+ new TCFTask<Boolean>() {
+ @Override
+ public void run() {
+
+ // Set marker enable using Lttng controller service proxy
+ fService.setChannelSubbufSize(fParent.getParent().getName(),
+ fParent.getName(),
+ fName,
+ channelName,
+ subbufSize,
+ new ILttControllerService.DoneSetChannelSubbufSize() {
+
+ @Override
+ public void doneSetChannelSubbufSize(IToken token, Exception error, Object str) {
+ if (error != null) {
+ // Notify with error
+ error(error);
+ return;
+ }
+
+ // Notify about success
+ done(Boolean.valueOf(true));
+ }
+ });
+ }}.get(DEFAULT_TCF_TASK_TIMEOUT, TimeUnit.SECONDS);
+ }
+
+
}
diff --git a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/config/TraceConfig.java b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/config/TraceConfig.java
index 7611f3a998..a963fc06d7 100644
--- a/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/config/TraceConfig.java
+++ b/lttng/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/tracecontrol/model/config/TraceConfig.java
@@ -13,7 +13,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.lttng.tracecontrol.model.config;
-import org.eclipse.linuxtools.lttng.tracecontrol.model.config.TraceChannels;
+import org.eclipse.core.resources.IProject;
+
/**
* <b><u>TraceChannel</u></b>
@@ -26,9 +27,8 @@ public class TraceConfig {
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
- public static final int NONE_MODE = 0;
+ public static final int NORMAL_MODE = 0;
public static final int FLIGHT_RECORDER_MODE = 1;
- public static final int NORMAL_MODE = 2;
public static final String InvalidTracePath = "network"; //$NON-NLS-1$
@@ -44,6 +44,7 @@ public class TraceConfig {
private int fMode = 0;
private int fNumChannel = 0;
private TraceChannels fChannels = null;
+ private IProject fProject = null;
// ------------------------------------------------------------------------
// Constructors
@@ -212,4 +213,23 @@ public class TraceConfig {
fChannels = new TraceChannels();
fChannels.putAll(channels);
}
+
+ /**
+ * Gets the trace project.
+ *
+ * @return project
+ */
+ public IProject getProject() {
+ return fProject;
+ }
+
+ /**
+ * Sets the trace project.
+ *
+ * @param project
+ */
+ public void setProject(IProject project) {
+ fProject = project;
+ }
+
}

Back to the top