import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.statesystem.core.Activator;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.CoreNode;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTConfig;
import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HTInterval;
*/
public class HistoryTreeBackend implements IStateHistoryBackend {
- private final @NonNull String ssid;
+ private final @NonNull String fSsid;
/**
* The history tree that sits underneath.
*/
- private final HistoryTree sht;
+ private final HistoryTree fSht;
/** Indicates if the history tree construction is done */
private volatile boolean fFinishedBuilding = false;
* is the history tree finished building
*/
protected void setFinishedBuilding(boolean isFinishedBuilding) {
- this.fFinishedBuilding = isFinishedBuilding;
+ fFinishedBuilding = isFinishedBuilding;
}
/**
long startTime,
int blockSize,
int maxChildren) throws IOException {
- this.ssid = ssid;
+ fSsid = ssid;
final HTConfig conf = new HTConfig(newStateFile, blockSize, maxChildren,
providerVersion, startTime);
- sht = new HistoryTree(conf);
+ fSht = new HistoryTree(conf);
}
/**
*/
public HistoryTreeBackend(@NonNull String ssid, File existingStateFile, int providerVersion)
throws IOException {
- this.ssid = ssid;
- sht = new HistoryTree(existingStateFile, providerVersion);
+ fSsid = ssid;
+ fSht = new HistoryTree(existingStateFile, providerVersion);
fFinishedBuilding = true;
}
* @return The history tree
*/
protected HistoryTree getSHT() {
- return sht;
+ return fSht;
}
@Override
public String getSSID() {
- return ssid;
+ return fSsid;
}
@Override
public long getStartTime() {
- return sht.getTreeStart();
+ return fSht.getTreeStart();
}
@Override
public long getEndTime() {
- return sht.getTreeEnd();
+ return fSht.getTreeEnd();
}
@Override
quark, (TmfStateValue) value);
/* Start insertions at the "latest leaf" */
- sht.insertInterval(interval);
+ fSht.insertInterval(interval);
}
@Override
public void finishedBuilding(long endTime) {
- sht.closeTree(endTime);
+ fSht.closeTree(endTime);
fFinishedBuilding = true;
}
@Override
public FileInputStream supplyAttributeTreeReader() {
- return sht.supplyATReader();
+ return fSht.supplyATReader();
}
@Override
public File supplyAttributeTreeWriterFile() {
- return sht.supplyATWriterFile();
+ return fSht.supplyATWriterFile();
}
@Override
public long supplyAttributeTreeWriterFilePosition() {
- return sht.supplyATWriterFilePos();
+ return fSht.supplyATWriterFilePos();
}
@Override
public void removeFiles() {
- sht.deleteFile();
+ fSht.deleteFile();
}
@Override
public void dispose() {
if (fFinishedBuilding) {
- sht.closeFile();
+ fSht.closeFile();
} else {
/*
* The build is being interrupted, delete the file we partially
* built since it won't be complete, so shouldn't be re-used in the
* future (.deleteFile() will close the file first)
*/
- sht.deleteFile();
+ fSht.deleteFile();
}
}
checkValidTime(t);
/* We start by reading the information in the root node */
- HTNode currentNode = sht.getRootNode();
+ HTNode currentNode = fSht.getRootNode();
currentNode.writeInfoFromNode(stateInfo, t);
/* Then we follow the branch down in the relevant children */
try {
while (currentNode.getNodeType() == HTNode.NodeType.CORE) {
- currentNode = sht.selectNextChild((CoreNode) currentNode, t);
+ currentNode = fSht.selectNextChild((CoreNode) currentNode, t);
currentNode.writeInfoFromNode(stateInfo, t);
}
} catch (ClosedChannelException e) {
* The stateInfo should now be filled with everything needed, we pass
* the control back to the State System.
*/
- return;
}
@Override
}
private void checkValidTime(long t) {
- long treeStart = sht.getTreeStart();
- long treeEnd = sht.getTreeEnd();
+ long treeStart = fSht.getTreeStart();
+ long treeEnd = fSht.getTreeEnd();
if (t < treeStart || t > treeEnd) {
- throw new TimeRangeException(ssid + " Time:" + t + ", Start:" + treeStart + ", End:" + treeEnd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw new TimeRangeException(fSsid + " Time:" + t + ", Start:" + treeStart + ", End:" + treeEnd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
throws TimeRangeException, StateSystemDisposedException {
checkValidTime(t);
- HTNode currentNode = sht.getRootNode();
+ HTNode currentNode = fSht.getRootNode();
HTInterval interval = currentNode.getRelevantInterval(key, t);
try {
while (interval == null && currentNode.getNodeType() == HTNode.NodeType.CORE) {
- currentNode = sht.selectNextChild((CoreNode) currentNode, t);
+ currentNode = fSht.selectNextChild((CoreNode) currentNode, t);
interval = currentNode.getRelevantInterval(key, t);
}
} catch (ClosedChannelException e) {
* @return The current size of the history file in bytes
*/
public long getFileSize() {
- return sht.getFileSize();
+ return fSht.getFileSize();
}
/**
long ret;
try {
- for (int seq = 0; seq < sht.getNodeCount(); seq++) {
- node = sht.readNode(seq);
+ for (int seq = 0; seq < fSht.getNodeCount(); seq++) {
+ node = fSht.readNode(seq);
total += node.getNodeUsagePercent();
}
} catch (ClosedChannelException e) {
- e.printStackTrace();
+ Activator.getDefault().logError(e.getMessage(), e);
}
- ret = total / sht.getNodeCount();
+ ret = total / fSht.getNodeCount();
assert (ret >= 0 && ret <= 100);
return (int) ret;
}
@Override
public void debugPrint(PrintWriter writer) {
/* By default don't print out all the intervals */
- this.debugPrint(writer, false);
+ debugPrint(writer, false);
}
/**
/* Only used for debugging, shouldn't be externalized */
writer.println("------------------------------"); //$NON-NLS-1$
writer.println("State History Tree:\n"); //$NON-NLS-1$
- writer.println(sht.toString());
+ writer.println(fSht.toString());
writer.println("Average node utilization: " //$NON-NLS-1$
- + this.getAverageNodeUsage());
+ + getAverageNodeUsage());
writer.println(""); //$NON-NLS-1$
- sht.debugPrintFullTree(writer, printIntervals);
+ fSht.debugPrintFullTree(writer, printIntervals);
}
}