/**
* Build the state history without waiting for signals or anything
*/
- @SuppressWarnings("unchecked")
private void buildManually() {
StateSystemBuildRequest request = new StateSystemBuildRequest(this);
* signal will coalesce this request with the one from the
* indexer and histogram.
*/
- @SuppressWarnings("unchecked")
@TmfSignalHandler
public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
StateSystemBuildRequest request;
private final IStateChangeInput sci;
private final ITmfTrace<ITmfEvent> trace;
- @SuppressWarnings("unchecked")
StateSystemBuildRequest(HistoryBuilder builder) {
super((Class<ITmfEvent>) builder.getInputPlugin().getExpectedEventType().getClass(),
TmfTimeRange.ETERNITY,
// ------------------------------------------------------------------------
/**
+ * Standard constructor
+ *
* @param contexts
+ * The matching context for each trace in the experiment
*/
public TmfExperimentContext(final ITmfContext[] contexts) {
super();
}
/**
+ * Copy constructor
+ *
* @param other
+ * The experiment context to copy
*/
public TmfExperimentContext(final TmfExperimentContext other) {
this(other.cloneContexts());
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * Get the trace contexts composing this experiment context.
+ *
+ * @return The array of trace contexts
+ */
public ITmfContext[] getContexts() {
return fContexts;
}
+ /**
+ * Get the trace events located at this experiment context's location.
+ *
+ * @return The array of trace events
+ */
public ITmfEvent[] getEvents() {
return fEvents;
}
+ /**
+ * Get the index of the trace that was last read (so the trace whose
+ * current context will match this experiment's).
+ *
+ * @return The index of the trace
+ */
public int getLastTrace() {
return fLastTraceRead;
}
+ /**
+ * Set the last trace read index
+ *
+ * @param newIndex
+ * The new value to assign
+ */
public void setLastTrace(final int newIndex) {
fLastTraceRead = newIndex;
}
// ------------------------------------------------------------------------
/**
- * The standard constructor
+ * Get the locations inside this array
*
- * @param locations the locations
+ * @return the locations
*/
public ITmfLocation<? extends Comparable<?>>[] getLocations() {
return fLocations;
// ------------------------------------------------------------------------
@Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings("rawtypes")
public int compareTo(TmfLocationArray o) {
for (int i = 0; i < fLocations.length; i++) {
ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) fLocations[i].getLocation();
*/
public void sendRequest(ITmfDataRequest<T> request);
+ /**
+ * Queue the coalesced requests.
+ */
public void fireRequest();
+
+ /**
+ * Increments/decrements the pending requests counters and fires the request
+ * if necessary (counter == 0). Used for coalescing requests across multiple
+ * TmfDataProvider's.
+ *
+ * @param isIncrement
+ * Should we increment (true) or decrement (false) the pending
+ * counter
+ */
public void notifyPendingRequest(boolean isIncrement);
/**
// Constants
// ------------------------------------------------------------------------
+ /** Default amount of events per request "chunk" */
public static final int DEFAULT_BLOCK_SIZE = 50000;
+
+ /** Default size of the queue */
public static final int DEFAULT_QUEUE_SIZE = 1000;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public TmfDataProvider() {
super();
fQueueSize = DEFAULT_QUEUE_SIZE;
fExecutor = new TmfRequestExecutor();
}
+ /**
+ * Initialize this data provider
+ *
+ * @param name
+ * Name of the provider
+ * @param type
+ * The type of events that will be handled
+ */
public void init(String name, Class<T> type) {
super.init(name);
fType = type;
init(name, type);
}
+ /**
+ * Copy constructor
+ *
+ * @param other
+ * The other object to copy
+ */
public TmfDataProvider(TmfDataProvider<T> other) {
this();
init(other.getName(), other.fType);
}
+ /**
+ * Standard constructor. Instantiate and initialize at the same time.
+ *
+ * @param name
+ * Name of the provider
+ * @param type
+ * The type of events that will be handled
+ */
public TmfDataProvider(String name, Class<T> type) {
this(name, type, DEFAULT_QUEUE_SIZE);
}
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * Get the queue size of this provider
+ *
+ * @return The size of the queue
+ */
public int getQueueSize() {
return fQueueSize;
}
+ /**
+ * Get the event type this provider handles
+ *
+ * @return The type of ITmfEvent
+ */
public Class<?> getType() {
return fType;
}
}
}
- /**
- * This method queues the coalesced requests.
- */
@Override
public void fireRequest() {
synchronized (fLock) {
}
/**
- * Increments/decrements the pending requests counters and fires the request if necessary (counter == 0). Used for
- * coalescing requests accross multiple TmfDataProvider.
- *
+ * Increments/decrements the pending requests counters and fires the request
+ * if necessary (counter == 0). Used for coalescing requests accross
+ * multiple TmfDataProvider.
+ *
* @param isIncrement
*/
@Override
// Signal handlers
// ------------------------------------------------------------------------
+ /**
+ * Handler for the start synch signal
+ *
+ * @param signal
+ * Incoming signal
+ */
@TmfSignalHandler
public void startSynch(TmfStartSynchSignal signal) {
synchronized (fLock) {
}
}
+ /**
+ * Handler for the end synch signal
+ *
+ * @param signal
+ * Incoming signal
+ */
@TmfSignalHandler
public void endSynch(TmfEndSynchSignal signal) {
synchronized (fLock) {
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public TmfEventProvider() {
super();
}
super.init(name, type);
}
- public TmfEventProvider(String name, Class<T> type) {
+ /**
+ * Standard constructor
+ *
+ * @param name
+ * The name of the provider
+ * @param type
+ * The type of handled events
+ */
+ public TmfEventProvider(String name, Class<T> type) {
super(name, type);
}
+ /**
+ * Standard constructor which also sets the queue size
+ *
+ * @param name
+ * The name of the provider
+ * @param type
+ * The type of handled events
+ * @param queueSize
+ * The size of the queue
+ */
public TmfEventProvider(String name, Class<T> type, int queueSize) {
super(name, type, queueSize);
}
+ /**
+ * Copy constructor
+ *
+ * @param other
+ * The other TmfEventProvider to copy
+ */
public TmfEventProvider(TmfEventProvider<T> other) {
super(other);
}
* the StreamInputReader).
*
* @param eventDef
-
- * @param fileName String
- * @param originTrace CtfTmfTrace
+ * CTF EventDefinition object corresponding to this trace event
+ * @param fileName
+ * The path to the trace file
+ * @param originTrace
+ * The trace from which this event originates
*/
public CtfTmfEvent(EventDefinition eventDef, String fileName,
CtfTmfTrace originTrace) {
* mess, and put them into something ITmfEventField can cope with.
*
* @param eventDef
-
- * @return CtfTmfEventField[]
+ * CTF EventDefinition to read
+ * @return CtfTmfEventField[] The array of fields that were read
*/
public static CtfTmfEventField[] parseFields(EventDefinition eventDef) {
List<CtfTmfEventField> fields = new ArrayList<CtfTmfEventField>();
* Copy constructor
*
* @param other
+ * CtfTmfEvent to copy
*/
public CtfTmfEvent(CtfTmfEvent other) {
this.fTrace = other.getTrace();
import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
/**
- * The CTF extension of the TMF event type
- *
+ * The CTF extension of the TMF event type
+ *
* @version 1.0
* @author Matthew khouzam
*/
public class CtfTmfEventType extends TmfEventType {
private static final String CONTEXT_ID = "Ctf Event"; //$NON-NLS-1$
+
/**
* Constructor for CtfTmfEventType.
- * @param contextId String
- * @param eventName String
- * @param content ITmfEventField
+ *
+ * @param eventName
+ * String
+ * @param content
+ * ITmfEventField
*/
public CtfTmfEventType(String eventName, ITmfEventField content) {
super(CONTEXT_ID, eventName, content);
/**
* Method toString.
+ *
* @return String
*/
@Override
/**
* gets the event type for an event name
- * @param eventName the event name
+ *
+ * @param eventName
+ * the event name
* @return the event type
*/
public static CtfTmfEventType get(String eventName){
//-------------------------------------------
/**
* Method initTrace.
- * @param resource IResource
- * @param path String
- * @param eventType Class<CtfTmfEvent>
+ *
+ * @param resource
+ * The resource associated with this trace
+ * @param path
+ * The path to the trace file
+ * @param eventType
+ * The type of events that will be read from this trace
* @throws TmfTraceException
+ * If something when wrong while reading the trace
*/
@Override
public void initTrace(final IResource resource, final String path, final Class<CtfTmfEvent> eventType)
/**
* Suppressing the warning, because the 'throws' will usually happen in
* sub-classes.
+ *
* @throws TmfTraceException
*/
+ @SuppressWarnings("unused")
protected void buildStateSystem() throws TmfTraceException {
/*
* Nothing is done in the basic implementation, please specify
/*******************************************************************************
* Copyright (c) 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* The generic event payload in TMF. Each field can be either a terminal or
* further decomposed into subfields.
- *
+ *
* @version 1.0
* @author Francois Chouinard
*
public String[] getFieldNames();
/**
+ * @param index The index of the field
* @return the nth field name (null if absent or inexistent)
*/
public String getFieldName(int index);
public ITmfEventField[] getFields();
/**
+ * @param name The name of the field
* @return a specific subfield by name (null if absent or inexistent)
*/
public ITmfEventField getField(String name);
/**
+ * @param index The index of the field to return
* @return a specific subfield by index (null if absent or inexistent)
*/
public ITmfEventField getField(int index);
* Copyright (c) 2012 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.exceptions;
/**
* This exception gets thrown when the user tries to access an attribute which
* doesn't exist in the system, of if the quark is simply invalid (ie, < 0).
- *
- * @author alexmont
- *
+ *
+ * @author Alexandre Montplaisir
*/
public class AttributeNotFoundException extends Exception {
private static final long serialVersionUID = 7964275803369706145L;
+ /**
+ * Default constructor
+ */
public AttributeNotFoundException() {
super();
}
+ /**
+ * Constructor with a message
+ *
+ * @param message
+ * Message to attach to this exception
+ */
public AttributeNotFoundException(String message) {
super(message);
}
* Copyright (c) 2012 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.exceptions;
* The StateValue is a wrapper around the different type of values that can be
* used and stored in the state system and history. "Unboxing" the value means
* retrieving the base type (int, String, etc.) inside it.
- *
+ *
* This exception is thrown if the user tries to unbox a StateValue with an
* incorrect type (for example, tries to read a String value as an Int).
- *
- * @author alexmont
- *
+ *
+ * @author Alexandre Montplaisir
+ *
*/
public class StateValueTypeException extends Exception {
private static final long serialVersionUID = -4548793451746144513L;
+ /**
+ * Default constructor
+ */
public StateValueTypeException() {
super();
}
+ /**
+ * Constructor with a message
+ *
+ * @param message
+ * Message to attach to this exception
+ */
public StateValueTypeException(String message) {
super(message);
}
long real_pos = 0;\r
StringBuilder sb = new StringBuilder();\r
\r
+ /**\r
+ * Constructor using the default buffer size\r
+ *\r
+ * @param name\r
+ * File path. This is passed as-is to the RandomeAccessFile's\r
+ * constructor.\r
+ * @param mode\r
+ * File open mode ("r", "rw", etc.). This is passed as-is to\r
+ * RandomAccessFile's constructor.\r
+ * @throws IOException\r
+ * If the file was not found or couldn't be opened with the\r
+ * request permissions\r
+ */\r
public BufferedRandomAccessFile(String name, String mode) throws IOException {\r
this(name, mode, DEFAULT_BUF_SIZE);\r
}\r
\r
+ /**\r
+ * Constructor using the default buffer size\r
+ *\r
+ * @param file\r
+ * File object. This is passed as-is to the RandomeAccessFile's\r
+ * constructor.\r
+ * @param mode\r
+ * File open mode ("r", "rw", etc.). This is passed as-is to\r
+ * RandomAccessFile's constructor.\r
+ * @throws IOException\r
+ * If the file was not found or couldn't be opened with the\r
+ * request permissions\r
+ */\r
public BufferedRandomAccessFile(File file, String mode) throws IOException {\r
this(file, mode, DEFAULT_BUF_SIZE);\r
}\r
\r
+ /**\r
+ * Standard constructor.\r
+ *\r
+ * @param name\r
+ * File path. This is passed as-is to the RandomeAccessFile's\r
+ * constructor.\r
+ * @param mode\r
+ * File open mode ("r", "rw", etc.). This is passed as-is to\r
+ * RandomAccessFile's constructor.\r
+ * @param bufsize\r
+ * Buffer size to use, in bytes\r
+ * @throws IOException\r
+ * If the file was not found or couldn't be opened with the\r
+ * request permissions\r
+ */\r
public BufferedRandomAccessFile(String name, String mode, int bufsize) throws IOException {\r
super(name, mode);\r
invalidate();\r
buffer = new byte[BUF_SIZE];\r
}\r
\r
+ /**\r
+ * Standard constructor.\r
+ *\r
+ * @param file\r
+ * File object. This is passed as-is to the RandomeAccessFile's\r
+ * constructor.\r
+ * @param mode\r
+ * File open mode ("r", "rw", etc.). This is passed as-is to\r
+ * RandomAccessFile's constructor.\r
+ * @param bufsize\r
+ * Buffer size to use, in bytes\r
+ * @throws IOException\r
+ * If the file was not found or couldn't be opened with the\r
+ * request permissions\r
+ */\r
public BufferedRandomAccessFile(File file, String mode, int bufsize) throws IOException {\r
super(file, mode);\r
invalidate();\r
}\r
}\r
\r
+ /**\r
+ * Read the next line from the buffer (ie, until the next '\n'). The bytes\r
+ * are interpreted as UTF-8 characters.\r
+ *\r
+ * @return The String that was read\r
+ * @throws IOException\r
+ * If we failed reading the file\r
+ */\r
public final String getNextLine() throws IOException {\r
String str = null;\r
if (buf_end - buf_pos <= 0) {\r
// Constants
// ------------------------------------------------------------------------
- // The default maximum number of events per chunk
+ /** The default maximum number of events per chunk */
public static final int DEFAULT_BLOCK_SIZE = 1000;
- // The request count for all the events
+ /** The request count for all the events */
public static final int ALL_DATA = Integer.MAX_VALUE;
private static int fRequestNumber = 0;
* To suspend the client thread until the request starts (or is canceled).
*
* @throws InterruptedException
+ * If the thread was interrupted while waiting
*/
public void waitForStart() throws InterruptedException {
while (!fRequestRunning) {
}
/**
- * To suspend the client thread until the request completes (or is canceled).
- *
+ * To suspend the client thread until the request completes (or is
+ * canceled).
+ *
* @throws InterruptedException
+ * If the thread was interrupted while waiting
*/
@Override
public void waitForCompletion() throws InterruptedException {
return handlers.toArray(new Method[handlers.size()]);
}
+ static int fSignalId = 0;
+
/**
* Invokes the handling methods that listens to signals of a given type.
*
*
* @param signal the signal to dispatch
*/
- static int fSignalId = 0;
static public synchronized void dispatchSignal(TmfSignal signal) {
int signalId = fSignalId++;
sendSignal(new TmfStartSynchSignal(signalId));
* @param resource the trace resource
* @param path the trace path
* @param type the trace event type
- * @throws TmfTraceException
+ * @throws TmfTraceException If we couldn't open the trace
*/
public void initTrace(IResource resource, String path, Class<T> type) throws TmfTraceException;
* intervals to indicate its progress.
* <p>
* <b>Example 1</b>: Index a whole trace asynchronously
+ *
* <pre>
* trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
* </pre>
+ *
* <b>Example 2</b>: Index a whole trace synchronously
+ *
* <pre>
* trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
* </pre>
+ *
* <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
+ *
* <pre>
* trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
* </pre>
- * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for events between
- * T1 and T2 (inclusive). This is used for incremental indexing.
+ *
+ * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
+ * events between T1 and T2 (inclusive). This is used for incremental
+ * indexing.
+ *
* <pre>
* TmfTimeRange range = new TmfTimeRange(T1, T2);
* trace.getIndexer().buildIndex(100, range, false);
* </pre>
*
- * @param offset The offset of the first event to consider
- * @param range The time range to consider
+ * @param offset
+ * The offset of the first event to consider
+ * @param range
+ * The time range to consider
* @param waitForCompletion
+ * Should we block the calling thread until the build is
+ * complete?
*/
public void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
/**
* Adds an entry to the trace index.
*
- * @param context
- * @param timestamp
+ * @param context The trace context to save
+ * @param timestamp The timestamp matching this context
*/
public void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
* Full constructor
*
* @param timestamp the checkpoint timestamp
- * @param location the corresponding trace location
+ * @param context the corresponding trace location
*/
public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfContext context) {
fTimestamp = timestamp;
/**
* Signal handler for the TmfExperimentSelectedSignal signal
*
- * @param signal
+ * @param signal The incoming signal
*/
@TmfSignalHandler
public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
/**
* Signal handler for the TmfEndSynchSignal signal
*
- * @param signal
+ * @param signal The incoming signal
*/
@TmfSignalHandler
public void endSync(final TmfEndSynchSignal signal) {
/**
* Signal handler for the TmfTraceUpdatedSignal signal
*
- * @param signal
+ * @param signal The incoming signal
*/
@TmfSignalHandler
public void traceUpdated(final TmfTraceUpdatedSignal signal) {
/**
* Signal handler for the TmfExperimentRangeUpdatedSignal signal
*
- * @param signal
+ * @param signal The incoming signal
*/
@TmfSignalHandler
public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
* Copy constructor
*
* @param trace the original trace
+ * @throws TmfTraceException Should not happen usually
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public TmfTrace(final TmfTrace<T> trace) throws TmfTraceException {
* @param newLength Length of the copy to be returned.
* @return A new array consisting of the elements specified.
*/
- @SuppressWarnings("unchecked")
private static <E> E[] copyOf(final E[] array, int newLength) {
E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), newLength); // Is it useful to use newInstance?
System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
* @param newType Type of the array to be returned.
* @return A new array consisting of the elements specified.
*/
- @SuppressWarnings("unchecked")
private static <E, U> E[] copyOf(final U[] array, int newLength, Class<? extends E[]> newType) {
E[] result = (E[])Array.newInstance(newType.getComponentType(), newLength);
System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
* @param end Ending position of the range, exclusive.
* @return A new array consisting of the elements specified. The length of the new array is equal to end-start
*/
- @SuppressWarnings("unchecked")
private static <E> E[] copyOfRange(final E[] array, int start, int end) {
E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), end - start);
System.arraycopy(array, start, result, 0, end - start);
* @see java.util.AbstractCollection#toArray(T[])
*/
@Override
- @SuppressWarnings("unchecked")
public <E> E[] toArray(E[] array)
{
if(array.length < fArray.length) {
/*******************************************************************************
* Copyright (c) 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
/**
* Implementation of a sorted array list.
- *
+ *
* @version 1.0
- * @Francois Chouinard
+ * @author Francois Chouinard
*/
public class TmfSortedArrayList<T> extends ArrayList<T> {
private static final long serialVersionUID = 1L;
/**
- * Inserts a new value in the list according to its sorted position.
- *
- * @param value A value to insert
+ * Inserts a new value in the list according to its sorted position.
+ *
+ * @param value A value to insert
*/
@SuppressWarnings("unchecked")
public void insertSorted(T value) {