import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTConfig;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HistoryTreeBackend;
return (HistoryTreeClassicStub) super.getSHT();
}
+ /**
+ * Debug method to print the contents of the history backend.
+ *
+ * @param writer
+ * The PrintWriter where to write the output
+ */
+ public void debugPrint(PrintWriter writer) {
+ /* By default don't print out all the intervals */
+ debugPrint(writer, false, -1);
+ }
+
+ /**
+ * The basic debugPrint method will print the tree structure, but not their
+ * contents.
+ *
+ * This method here print the contents (the intervals) as well.
+ *
+ * @param writer
+ * The PrintWriter to which the debug info will be written
+ * @param printIntervals
+ * Should we also print every contained interval individually?
+ * @param ts
+ * The timestamp that nodes have to intersect for intervals to be
+ * printed. A negative value will print intervals for all nodes.
+ * The timestamp only applies if printIntervals is true.
+ */
+ public void debugPrint(PrintWriter writer, boolean printIntervals, long ts) {
+ /* Only used for debugging, shouldn't be externalized */
+ writer.println("------------------------------"); //$NON-NLS-1$
+ writer.println("State History Tree:\n"); //$NON-NLS-1$
+ writer.println(getSHT().toString());
+ writer.println("Average node utilization: " //$NON-NLS-1$
+ + getAverageNodeUsage());
+ writer.println(""); //$NON-NLS-1$
+
+ getHistoryTree().debugPrintFullTree(writer, printIntervals, ts);
+ }
}
import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
import java.nio.channels.ClosedChannelException;
import java.util.List;
super(existingStateFile, expProviderVersion);
}
+ // ------------------------------------------------------------------------
+ // Extra test accessors
+ // ------------------------------------------------------------------------
+
@Override
public List<HTNode> getLatestBranch() {
+ /* Super method is not public */
return checkNotNull(super.getLatestBranch());
}
return getLatestBranch().size();
}
+ // ------------------------------------------------------------------------
+ // Debug printing methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Print out the full tree for debugging purposes
+ *
+ * @param writer
+ * PrintWriter in which to write the output
+ * @param printIntervals
+ * Flag to enable full output of the interval information
+ * @param ts
+ * The timestamp that nodes have to intersect for intervals to be
+ * printed. A negative value will print intervals for all nodes.
+ * The timestamp only applies if printIntervals is true.
+ */
+ public void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts) {
+ preOrderPrint(writer, false, getLatestBranch().get(0), 0, ts);
+
+ if (printIntervals) {
+ preOrderPrint(writer, true, getLatestBranch().get(0), 0, ts);
+ }
+ writer.println('\n');
+ }
+
+ /**
+ * Start at currentNode and print the contents of all its children, in
+ * pre-order. Give the root node in parameter to visit the whole tree, and
+ * have a nice overview.
+ */
+ private void preOrderPrint(PrintWriter writer, boolean printIntervals,
+ HTNode currentNode, int curDepth, long ts) {
+
+ writer.println(currentNode.toString());
+ /*
+ * Print intervals only if timestamp is negative or within the range of
+ * the node
+ */
+ if (printIntervals &&
+ (ts <= 0 ||
+ (ts >= currentNode.getNodeStart() && ts <= currentNode.getNodeEnd()))) {
+ currentNode.debugPrintIntervals(writer);
+ }
+
+ switch (currentNode.getNodeType()) {
+ case LEAF:
+ /* Stop if it's the leaf node */
+ return;
+
+ case CORE:
+ try {
+ final CoreNode node = (CoreNode) currentNode;
+ /* Print the extensions, if any */
+ int extension = node.getExtensionSequenceNumber();
+ while (extension != -1) {
+ HTNode nextNode = getTreeIO().readNode(extension);
+ preOrderPrint(writer, printIntervals, nextNode, curDepth, ts);
+ }
+
+ /* Print the child nodes */
+ for (int i = 0; i < node.getNbChildren(); i++) {
+ HTNode nextNode = getTreeIO().readNode(node.getChild(i));
+ for (int j = 0; j < curDepth; j++) {
+ writer.print(" ");
+ }
+ writer.print("+-");
+ preOrderPrint(writer, printIntervals, nextNode, curDepth + 1, ts);
+ }
+ } catch (ClosedChannelException e) {
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Assertion methods, for use with JUnit tests
+ // ------------------------------------------------------------------------
+
+ /**
+ * Check the integrity of all the nodes in the tree. Calls
+ * {@link #assertNodeIntegrity} for every node in the tree.
+ */
+ public void assertIntegrity() {
+ try {
+ for (int i = 0; i < getNodeCount(); i++) {
+ assertNodeIntegrity(getNode(i));
+ }
+ } catch (ClosedChannelException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Debugging method to make sure all intervals contained in the given node
+ * have valid start and end times.
+ *
+ * @param node
+ * The node to check
+ */
+ private void assertNodeIntegrity(HTNode node) {
+ if (node instanceof CoreNode) {
+ assertChildrenIntegrity((CoreNode) node);
+ }
+
+ /* Check that all intervals are within the node's range */
+ // TODO: Get the intervals of a node
+
+ }
+
private void assertChildrenIntegrity(CoreNode node) {
try {
/*
}
}
- /**
- * Debugging method to make sure all intervals contained in the given node
- * have valid start and end times.
- *
- * @param node
- * The node to check
- */
- private void assertNodeIntegrity(HTNode node) {
- if (node instanceof CoreNode) {
- assertChildrenIntegrity((CoreNode) node);
- }
-
- /* Check that all intervals are within the node's range */
- // TODO: Get the intervals of a node
-
- }
-
- /**
- * Check the integrity of all the nodes in the tree. Calls
- * {@link #assertNodeIntegrity} for every node in the tree.
- */
- public void assertIntegrity() {
- try {
- for (int i = 0; i < getNodeCount(); i++) {
- assertNodeIntegrity(getNode(i));
- }
- } catch (ClosedChannelException e) {
- fail(e.getMessage());
- }
- }
-
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.tracecompass.statesystem.core" version="2">
+ <resource path="src/org/eclipse/tracecompass/statesystem/core/backend/IStateHistoryBackend.java" type="org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend">
+ <filter comment="Removed debugPrint() method which was only used for testing" id="405901410">
+ <message_arguments>
+ <message_argument value="org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend"/>
+ <message_argument value="debugPrint(PrintWriter)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
attribute + " at time " + timestamp + //$NON-NLS-1$
", returning dummy interval"); //$NON-NLS-1$
}
-
- /**
- * Print out the contents of the inner structures.
- *
- * @param writer
- * The PrintWriter in which to print the output
- */
- public void debugPrint(@NonNull PrintWriter writer) {
- getAttributeTree().debugPrint(writer);
- transState.debugPrint(writer);
- backend.debugPrint(writer);
- }
-
}
import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
/* Nothing to do */
}
- @Override
- public void debugPrint(PrintWriter writer) {
- synchronized (intervals) {
- writer.println(intervals.toString());
- }
- }
-
private static Iterator<ITmfStateInterval> searchforEndTime(NavigableSet<ITmfStateInterval> tree, long time) {
ITmfStateInterval dummyInterval = new TmfStateInterval(-1, time, -1, TmfStateValue.nullValue());
ITmfStateInterval myInterval = tree.lower(dummyInterval);
import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
/* Cannot do past queries */
return null;
}
-
- @Override
- public void debugPrint(PrintWriter writer) {
- writer.println("Null history backend"); //$NON-NLS-1$
- }
}
*
* @author Alexandre Montplaisir
*/
-class HT_IO {
+public class HT_IO {
private static final Logger LOGGER = TraceCompassLog.getLogger(HT_IO.class);
}
}
+ /**
+ * Write the given node to disk.
+ *
+ * @param node
+ * The node to write.
+ */
public void writeNode(HTNode node) {
try {
int seqNumber = node.getSequenceNumber();
}
}
+ /**
+ * Get the output file channel, used for writing.
+ *
+ * @return The output file channel
+ */
public FileChannel getFcOut() {
return fFileChannelOut;
}
+ /**
+ * Retrieve the input stream with which to write the attribute tree.
+ *
+ * @param nodeOffset
+ * The offset in the file, in number of nodes. This should be
+ * after all the nodes.
+ * @return The correctly-seeked input stream
+ */
public FileInputStream supplyATReader(int nodeOffset) {
try {
/*
return fFileInputStream;
}
+ /**
+ * Close all file channels and streams.
+ */
public synchronized void closeFile() {
try {
fFileInputStream.close();
}
}
+ /**
+ * Delete the history tree file
+ */
public synchronized void deleteFile() {
closeFile();
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.PrintWriter;
import java.nio.channels.ClosedChannelException;
import java.util.List;
return (int) ret;
}
- @Override
- public void debugPrint(PrintWriter writer) {
- /* By default don't print out all the intervals */
- debugPrint(writer, false, -1);
- }
-
- /**
- * The basic debugPrint method will print the tree structure, but not their
- * contents.
- *
- * This method here print the contents (the intervals) as well.
- *
- * @param writer
- * The PrintWriter to which the debug info will be written
- * @param printIntervals
- * Should we also print every contained interval individually?
- * @param ts
- * The timestamp that nodes have to intersect for intervals to be
- * printed. A negative value will print intervals for all nodes.
- * The timestamp only applies if printIntervals is true.
- */
- public void debugPrint(PrintWriter writer, boolean printIntervals, long ts) {
- /* Only used for debugging, shouldn't be externalized */
- writer.println("------------------------------"); //$NON-NLS-1$
- writer.println("State History Tree:\n"); //$NON-NLS-1$
- writer.println(getSHT().toString());
- writer.println("Average node utilization: " //$NON-NLS-1$
- + getAverageNodeUsage());
- writer.println(""); //$NON-NLS-1$
-
- getSHT().debugPrintFullTree(writer, printIntervals, ts);
- }
}
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.ClosedChannelException;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.statesystem.core.Activator;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
private final HTConfig fConfig;
/** Reader/writer object */
- private final HT_IO fTreeIO;
+ private final @NonNull HT_IO fTreeIO;
// ------------------------------------------------------------------------
// Variable Fields (will change throughout the existence of the SHT)
return fTreeIO.readNode(seqNum);
}
+ /**
+ * Retrieve the TreeIO object. Should only be used for testing.
+ *
+ * @return The TreeIO
+ */
+ @VisibleForTesting
+ protected @NonNull HT_IO getTreeIO() {
+ return fTreeIO;
+ }
+
// ------------------------------------------------------------------------
// HT_IO interface
// ------------------------------------------------------------------------
+ fLatestBranch.get(fLatestBranch.size() - 1).getSequenceNumber();
}
- /**
- * Start at currentNode and print the contents of all its children, in
- * pre-order. Give the root node in parameter to visit the whole tree, and
- * have a nice overview.
- */
- /* Only used for debugging, shouldn't be externalized */
- @SuppressWarnings("nls")
- private void preOrderPrint(PrintWriter writer, boolean printIntervals,
- HTNode currentNode, int curDepth, long ts) {
-
- writer.println(currentNode.toString());
- /* Print intervals only if timestamp is negative or within the range of the node */
- if (printIntervals &&
- (ts <= 0 ||
- (ts >= currentNode.getNodeStart() && ts <= currentNode.getNodeEnd()))) {
- currentNode.debugPrintIntervals(writer);
- }
-
- switch (currentNode.getNodeType()) {
- case LEAF:
- /* Stop if it's the leaf node */
- return;
-
- case CORE:
- try {
- final CoreNode node = (CoreNode) currentNode;
- /* Print the extensions, if any */
- int extension = node.getExtensionSequenceNumber();
- while (extension != -1) {
- HTNode nextNode = fTreeIO.readNode(extension);
- preOrderPrint(writer, printIntervals, nextNode, curDepth, ts);
- }
-
- /* Print the child nodes */
- for (int i = 0; i < node.getNbChildren(); i++) {
- HTNode nextNode = fTreeIO.readNode(node.getChild(i));
- for (int j = 0; j < curDepth; j++) {
- writer.print(" ");
- }
- writer.print("+-");
- preOrderPrint(writer, printIntervals, nextNode, curDepth + 1, ts);
- }
- } catch (ClosedChannelException e) {
- Activator.getDefault().logError(e.getMessage());
- }
- break;
-
- default:
- break;
- }
- }
-
- @Override
- public void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts) {
- /* Only used for debugging, shouldn't be externalized */
-
- preOrderPrint(writer, false, fLatestBranch.get(0), 0, ts);
-
- if (printIntervals) {
- preOrderPrint(writer, true, fLatestBranch.get(0), 0, ts);
- }
- writer.println('\n');
- }
-
}
import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
import java.nio.channels.ClosedChannelException;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
*/
long getFileSize();
- /**
- * Print out the full tree for debugging purposes
- *
- * @param writer
- * PrintWriter in which to write the output
- * @param printIntervals
- * Flag to enable full output of the interval information
- * @param ts
- * The timestamp that nodes have to intersect for intervals to be
- * printed. A negative value will print intervals for all nodes.
- * The timestamp only applies if printIntervals is true.
- */
- void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts);
-
}
import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
ITmfStateInterval doSingularQuery(long t, int attributeQuark)
throws TimeRangeException, StateSystemDisposedException;
- /**
- * Debug method to print the contents of the history backend.
- *
- * @param writer
- * The PrintWriter where to write the output
- */
- void debugPrint(PrintWriter writer);
}
import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
return (t >= getStartTime() && t <= getEndTime());
}
- @Override
- public void debugPrint(PrintWriter writer) {
- // TODO Auto-generated method stub
- }
-
private void waitForCheckpoints() {
try {
fCheckpointsReady.await();