ede7014b0efd63f4712ee9974e76237bb087dfd2
1 /*******************************************************************************
2 * Copyright (c) 2016 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.statesystem
.core
.tests
.stubs
.backend
;
13 import java
.io
.IOException
;
14 import java
.io
.PrintWriter
;
16 import org
.eclipse
.tracecompass
.internal
.statesystem
.core
.backend
.historytree
.HTConfig
;
17 import org
.eclipse
.tracecompass
.internal
.statesystem
.core
.backend
.historytree
.HistoryTreeBackend
;
18 import org
.eclipse
.tracecompass
.internal
.statesystem
.core
.backend
.historytree
.IHistoryTree
;
21 * Stub class for the {@link HistoryTreeBackend}. It creates a
22 * {@link HistoryTreeClassicStub} to grant access to some protected methods.
24 * @author Geneviève Bastien
26 public class HistoryTreeBackendStub
extends HistoryTreeBackend
{
28 private static HistoryTreeType HT_TYPE
= HistoryTreeType
.CLASSIC
;
31 * Sets the type of tree to build. Since the history tree is initialized in
32 * the parent's constructor, this stub class needs to know the type of tree
36 * The type of history tree to build for this backend
38 public static void setTreeType(HistoryTreeType htType
) {
43 * Enumeration of all history tree types implemented. This will be used to
44 * create the right type of history tree
46 public enum HistoryTreeType
{
48 * The classic history tree
54 * Constructor for new history files. Use this when creating a new history
58 * The state system's ID
60 * The filename/location where to store the state history (Should
62 * @param providerVersion
63 * Version of of the state provider. We will only try to reopen
64 * existing files if this version matches the one in the
67 * The earliest time stamp that will be stored in the history
69 * The size of the blocks in the history file. This should be a
72 * The maximum number of children each core node can have
74 * Thrown if we can't create the file for some reason
76 public HistoryTreeBackendStub(String ssid
,
81 int maxChildren
) throws IOException
{
82 super(ssid
, newStateFile
, providerVersion
, startTime
, blockSize
, maxChildren
);
86 * Existing history constructor. Use this to open an existing state-file.
89 * The state system's id
90 * @param existingStateFile
91 * Filename/location of the history we want to load
92 * @param providerVersion
93 * Expected version of of the state provider plugin.
95 * If we can't read the file, if it doesn't exist, is not
96 * recognized, or if the version of the file does not match the
97 * expected providerVersion.
99 public HistoryTreeBackendStub(String ssid
, File existingStateFile
, int providerVersion
)
101 super(ssid
, existingStateFile
, providerVersion
);
105 protected IHistoryTree
initializeSHT(HTConfig conf
) throws IOException
{
108 return new HistoryTreeClassicStub(conf
);
110 return new HistoryTreeClassicStub(conf
);
115 protected IHistoryTree
initializeSHT(File existingStateFile
, int providerVersion
) throws IOException
{
118 return new HistoryTreeClassicStub(existingStateFile
, providerVersion
);
120 return new HistoryTreeClassicStub(existingStateFile
, providerVersion
);
125 * Get the History Tree built by this backend.
127 * @return The history tree
129 public HistoryTreeClassicStub
getHistoryTree() {
130 return (HistoryTreeClassicStub
) super.getSHT();
134 * Debug method to print the contents of the history backend.
137 * The PrintWriter where to write the output
139 public void debugPrint(PrintWriter writer
) {
140 /* By default don't print out all the intervals */
141 debugPrint(writer
, false, -1);
145 * The basic debugPrint method will print the tree structure, but not their
148 * This method here print the contents (the intervals) as well.
151 * The PrintWriter to which the debug info will be written
152 * @param printIntervals
153 * Should we also print every contained interval individually?
155 * The timestamp that nodes have to intersect for intervals to be
156 * printed. A negative value will print intervals for all nodes.
157 * The timestamp only applies if printIntervals is true.
159 public void debugPrint(PrintWriter writer
, boolean printIntervals
, long ts
) {
160 /* Only used for debugging, shouldn't be externalized */
161 writer
.println("------------------------------"); //$NON-NLS-1$
162 writer
.println("State History Tree:\n"); //$NON-NLS-1$
163 writer
.println(getSHT().toString());
164 writer
.println("Average node utilization: " //$NON-NLS-1$
165 + getAverageNodeUsage());
166 writer
.println(""); //$NON-NLS-1$
168 getHistoryTree().debugPrintFullTree(writer
, printIntervals
, ts
);
This page took 0.058649 seconds and 4 git commands to generate.