aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-10 01:09:43 (EST)
committerAlexandre Montplaisir2013-12-10 14:18:29 (EST)
commit02d6db67bdde414a9829cdbe52445761041184d7 (patch)
tree4c6f9f6e5007afaba78adc95c0552add7af30b22
parent3dda649fb6c0bacecb4e0b9a9cd347520a6b4fd5 (diff)
downloadorg.eclipse.linuxtools-02d6db67bdde414a9829cdbe52445761041184d7.zip
org.eclipse.linuxtools-02d6db67bdde414a9829cdbe52445761041184d7.tar.gz
org.eclipse.linuxtools-02d6db67bdde414a9829cdbe52445761041184d7.tar.bz2
tmf: Code cleanup in the history treerefs/changes/60/19560/4
The method preOrderPrint wasn't thread safe because it was using a "global" field. This is not a big issue, but it's cleaner this way. I did a cleanup pass on this file. Change-Id: I6255be52d3b2a8f84ef95a093578e10489c234eb Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Reviewed-on: https://git.eclipse.org/r/19560 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java36
1 files changed, 16 insertions, 20 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java
index fa2378b..12f14ce 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/historytree/HistoryTree.java
@@ -206,6 +206,7 @@ class HistoryTree {
* file.
*
* @param requestedEndTime
+ * The greatest timestamp present in the history tree
*/
void closeTree(long requestedEndTime) {
FileChannel fc;
@@ -327,6 +328,7 @@ class HistoryTree {
* Insert an interval in the tree
*
* @param interval
+ * The interval to be inserted
*/
void insertInterval(HTInterval interval) throws TimeRangeException {
if (interval.getStartTime() < config.getTreeStart()) {
@@ -376,7 +378,6 @@ class HistoryTree {
if (interval.getEndTime() > this.treeEnd) {
this.treeEnd = interval.getEndTime();
}
- return;
}
/**
@@ -418,7 +419,6 @@ class HistoryTree {
latestBranch.set(i, newNode);
}
- return;
}
/**
@@ -485,7 +485,9 @@ class HistoryTree {
* branch.
*
* @param currentNode
+ * The node on which the request is made
* @param t
+ * The timestamp to choose which child is the next one
* @return The child node intersecting t
* @throws ClosedChannelException
* If the file channel was closed while we were reading the tree
@@ -501,6 +503,7 @@ class HistoryTree {
break;
}
}
+
/*
* Once we exit this loop, we should have found a children to follow. If
* we didn't, there's a problem.
@@ -621,41 +624,35 @@ class HistoryTree {
+ latestBranch.get(latestBranch.size() - 1).getSequenceNumber();
}
- private int curDepth;
-
/**
* 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,
- CoreNode currentNode) {
- /* Only used for debugging, shouldn't be externalized */
- int i, j;
- HTNode nextNode;
+ CoreNode currentNode, int curDepth) {
writer.println(currentNode.toString());
if (printIntervals) {
currentNode.debugPrintIntervals(writer);
}
- curDepth++;
try {
- for (i = 0; i < currentNode.getNbChildren(); i++) {
- nextNode = treeIO.readNode(currentNode.getChild(i));
+ for (int i = 0; i < currentNode.getNbChildren(); i++) {
+ HTNode nextNode = treeIO.readNode(currentNode.getChild(i));
assert (nextNode instanceof CoreNode); // TODO temporary
- for (j = 0; j < curDepth - 1; j++) {
+ for (int j = 0; j < curDepth; j++) {
writer.print(" ");
}
writer.print("+-");
- preOrderPrint(writer, printIntervals, (CoreNode) nextNode);
+ preOrderPrint(writer, printIntervals, (CoreNode) nextNode,
+ curDepth + 1);
}
} catch (ClosedChannelException e) {
e.printStackTrace();
}
- curDepth--;
- return;
}
/**
@@ -664,17 +661,16 @@ class HistoryTree {
* @param writer
* PrintWriter in which to write the output
* @param printIntervals
- * Says if you want to output the full interval information
+ * Flag to enable full output of the interval information
*/
void debugPrintFullTree(PrintWriter writer, boolean printIntervals) {
/* Only used for debugging, shouldn't be externalized */
- curDepth = 0;
- this.preOrderPrint(writer, false, latestBranch.get(0));
+
+ this.preOrderPrint(writer, false, latestBranch.get(0), 0);
if (printIntervals) {
writer.println("\nDetails of intervals:"); //$NON-NLS-1$
- curDepth = 0;
- this.preOrderPrint(writer, true, latestBranch.get(0));
+ this.preOrderPrint(writer, true, latestBranch.get(0), 0);
}
writer.println('\n');
}