1 /*******************************************************************************
2 * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others
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
.internal
.statesystem
.core
.backend
.historytree
;
13 import java
.io
.FileInputStream
;
14 import java
.io
.IOException
;
15 import java
.nio
.channels
.ClosedChannelException
;
16 import java
.util
.Collection
;
18 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.TimeRangeException
;
21 * Meta-container for the History Tree. This structure contains all the
22 * high-level data relevant to the tree.
24 * @author Alexandre Montplaisir
25 * @author Geneviève Bastien
27 public interface IHistoryTree
{
30 * Interface for history to create the various HTNodes
32 interface IHTNodeFactory
{
35 * Creates a new core node for the specific history tree
38 * Configuration of the History Tree
40 * The (unique) sequence number assigned to this particular
42 * @param parentSeqNumber
43 * The sequence number of this node's parent node
45 * The earliest timestamp stored in this node
46 * @return The new core node
48 * any exception occurring while trying to read/create the
51 HTNode
createCoreNode(HTConfig config
, int seqNumber
, int parentSeqNumber
, long start
) throws IOException
;
54 * Creates a new core node for the specific history tree
57 * Configuration of the History Tree
59 * The (unique) sequence number assigned to this particular
61 * @param parentSeqNumber
62 * The sequence number of this node's parent node
64 * The earliest timestamp stored in this node
65 * @return The new core node
67 * any exception occurring while trying to read/create the
70 HTNode
createLeafNode(HTConfig config
, int seqNumber
, int parentSeqNumber
, long start
) throws IOException
;
74 * Size of the "tree header" in the tree-file The nodes will use this offset
75 * to know where they should be in the file. This should always be a
78 int TREE_HEADER_SIZE
= 4096;
81 * "Save" the tree to disk. This method will cause the treeIO object to
82 * commit all nodes to disk and then return the RandomAccessFile descriptor
83 * so the Tree object can save its configuration into the header of the
86 * @param requestedEndTime
87 * The greatest timestamp present in the history tree
89 void closeTree(long requestedEndTime
);
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * Get the start time of this tree.
98 * @return The start time
103 * Get the current end time of this tree.
105 * @return The end time
110 * Get the number of nodes in this tree.
112 * @return The number of nodes
117 * Get the current root node of this tree
119 * @return The root node
121 HTNode
getRootNode();
123 // ------------------------------------------------------------------------
125 // ------------------------------------------------------------------------
128 * Return the FileInputStream reader with which we will read an attribute
129 * tree (it will be sought to the correct position).
131 * @return The FileInputStream indicating the file and position from which
132 * the attribute tree can be read.
134 FileInputStream
supplyATReader();
137 * Return the file to which we will write the attribute tree.
139 * @return The file to which we will write the attribute tree
141 File
supplyATWriterFile();
144 * Return the position in the file (given by {@link #supplyATWriterFile})
145 * where to start writing the attribute tree.
147 * @return The position in the file where to start writing
149 long supplyATWriterFilePos();
152 * Read a node from the tree.
155 * The sequence number of the node to read
157 * @throws ClosedChannelException
158 * If the tree IO is unavailable
160 HTNode
readNode(int seqNumber
) throws ClosedChannelException
;
163 * Write a node object to the history file.
166 * The node to write to disk
168 void writeNode(HTNode node
);
171 * Close the history file.
176 * Delete the history file.
180 // ------------------------------------------------------------------------
182 // ------------------------------------------------------------------------
185 * Insert an interval in the tree.
188 * The interval to be inserted
189 * @throws TimeRangeException
190 * If the start of end time of the interval are invalid
192 void insertInterval(HTInterval interval
) throws TimeRangeException
;
195 * Inner method to select the next children of the current node intersecting
196 * the given timestamp. Useful for moving down the tree following one
200 * The node on which the request is made
202 * The timestamp to choose which child is the next one
203 * @return The child nodes intersecting t
204 * @throws ClosedChannelException
205 * If the file channel was closed while we were reading the tree
207 Collection
<HTNode
> selectNextChildren(ParentNode currentNode
, long t
) throws ClosedChannelException
;
210 * Get the current size of the history file.
212 * @return The history file size
This page took 0.034772 seconds and 5 git commands to generate.