lttng: Help stabilize some TimeGraphs tests
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core / src / org / eclipse / tracecompass / statesystem / core / ITmfStateSystemBuilder.java
CommitLineData
d26f90fd 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 Ericsson
d26f90fd
AM
3 *
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 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API
11 ******************************************************************************/
12
e894a508 13package org.eclipse.tracecompass.statesystem.core;
d26f90fd 14
feea3b3c 15import org.eclipse.jdt.annotation.NonNull;
e894a508
AM
16import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
17import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
18import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
19import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
d26f90fd
AM
20
21/**
22 * This is the external interface to build or modify an existing state history.
2cb26548 23 *
f1f86dfb
AM
24 * It extends ITmfStateSystem, so you can still use it for reading the history,
25 * but it also provides write-access to it with the quark-creating and
d26f90fd 26 * state-change insertion methods.
2cb26548 27 *
f1f86dfb
AM
28 * This should only be used by classes that need to build or modify the state
29 * history. Views, etc. (who will only be reading from it) should use the
30 * ITmfStateSystem interface instead.
31 *
2cb26548 32 * @author Alexandre Montplaisir
1dd75589
AM
33 * @noimplement Only the internal StateSystem class should implement this
34 * interface.
d26f90fd 35 */
f1f86dfb 36public interface ITmfStateSystemBuilder extends ITmfStateSystem {
d26f90fd 37
bcec0116
AM
38 /**
39 * Special state provider version number that will tell the backend to
40 * ignore the version check and open an existing file even if the versions
41 * don't match.
42 */
304712fe 43 int IGNORE_PROVIDER_VERSION = -42;
bcec0116 44
d26f90fd
AM
45 /**
46 * @name Read/write quark-getting methods
47 */
48
49 /**
50 * Basic quark-retrieving method. Pass an attribute in parameter as an array
51 * of strings, the matching quark will be returned.
2cb26548 52 *
d26f90fd
AM
53 * This version WILL create new attributes: if the attribute passed in
54 * parameter is new in the system, it will be added and its new quark will
55 * be returned.
2cb26548 56 *
d26f90fd
AM
57 * @param attribute
58 * Attribute given as its full path in the Attribute Tree
59 * @return The quark of the attribute (which either existed or just got
60 * created)
61 */
57a2a5ca 62 int getQuarkAbsoluteAndAdd(String... attribute);
d26f90fd
AM
63
64 /**
65 * "Relative path" quark-getting method. Instead of specifying a full path,
66 * if you know the path is relative to another attribute for which you
67 * already have the quark, use this for better performance.
2cb26548 68 *
d26f90fd
AM
69 * This is useful for cases where a lot of modifications or queries will
70 * originate from the same branch of the attribute tree : the common part of
71 * the path won't have to be re-hashed for every access.
2cb26548 72 *
d26f90fd
AM
73 * This version WILL create new attributes: if the attribute passed in
74 * parameter is new in the system, it will be added and its new quark will
75 * be returned.
2cb26548 76 *
d26f90fd
AM
77 * @param startingNodeQuark
78 * The quark of the attribute from which 'subPath' originates.
79 * @param subPath
80 * "Rest" of the path to get to the final attribute
81 * @return The matching quark, either if it's new of just got created.
82 */
57a2a5ca 83 int getQuarkRelativeAndAdd(int startingNodeQuark, String... subPath);
d26f90fd
AM
84
85 /**
86 * @name State-changing methods
87 */
88
89 /**
90 * Modify a current "ongoing" state (instead of inserting a state change,
91 * like modifyAttribute() and others).
2cb26548 92 *
d26f90fd
AM
93 * This can be used to update the value of a previous state change, for
94 * example when we get information at the end of the state and not at the
95 * beginning. (return values of system calls, etc.)
2cb26548 96 *
d26f90fd
AM
97 * Note that past states can only be modified while they are still in
98 * memory, so only the "current state" can be updated. Once they get
99 * committed to disk (by inserting a new state change) it becomes too late.
2cb26548 100 *
d26f90fd
AM
101 * @param newValue
102 * The new value that will overwrite the "current" one.
103 * @param attributeQuark
104 * For which attribute in the system
105 * @throws AttributeNotFoundException
106 * If the requested attribute is invalid
107 */
feea3b3c 108 void updateOngoingState(@NonNull ITmfStateValue newValue, int attributeQuark)
d26f90fd
AM
109 throws AttributeNotFoundException;
110
111 /**
112 * Basic attribute modification method, we simply specify a new value, for a
113 * given attribute, effective at the given timestamp.
2cb26548 114 *
d26f90fd
AM
115 * @param t
116 * Timestamp of the state change
117 * @param value
118 * The State Value we want to assign to the attribute
119 * @param attributeQuark
120 * Integer value of the quark corresponding to the attribute we
121 * want to modify
122 * @throws TimeRangeException
123 * If the requested time is outside of the trace's range
124 * @throws AttributeNotFoundException
125 * If the requested attribute quark is invalid
126 * @throws StateValueTypeException
127 * If the inserted state value's type does not match what is
128 * already assigned to this attribute.
129 */
57a2a5ca 130 void modifyAttribute(long t, ITmfStateValue value, int attributeQuark)
6dd46830 131 throws AttributeNotFoundException, StateValueTypeException;
d26f90fd
AM
132
133 /**
134 * Increment attribute method. Reads the current value of a given integer
135 * attribute (this value is right now in the Transient State), and increment
136 * it by 1. Useful for statistics.
2cb26548 137 *
d26f90fd
AM
138 * @param t
139 * Timestamp of the state change
140 * @param attributeQuark
141 * Attribute to increment. If it doesn't exist it will be added,
142 * with a new value of 1.
143 * @throws StateValueTypeException
144 * If the attribute already exists but is not of type Integer
145 * @throws TimeRangeException
146 * If the given timestamp is invalid
147 * @throws AttributeNotFoundException
148 * If the quark is invalid
149 */
57a2a5ca 150 void incrementAttribute(long t, int attributeQuark)
6dd46830 151 throws AttributeNotFoundException, StateValueTypeException;
d26f90fd
AM
152
153 /**
154 * "Push" helper method. This uses the given integer attribute as a stack:
155 * The value of that attribute will represent the stack depth (always >= 1).
156 * Sub-attributes will be created, their base-name will be the position in
157 * the stack (1, 2, etc.) and their value will be the state value 'value'
158 * that was pushed to this position.
2cb26548 159 *
d26f90fd
AM
160 * @param t
161 * Timestamp of the state change
162 * @param value
163 * State value to assign to this stack position.
164 * @param attributeQuark
165 * The base attribute to use as a stack. If it does not exist if
166 * will be created (with depth = 1)
167 * @throws TimeRangeException
168 * If the requested timestamp is invalid
169 * @throws AttributeNotFoundException
170 * If the attribute is invalid
171 * @throws StateValueTypeException
172 * If the attribute 'attributeQuark' already exists, but is not
173 * of integer type.
174 */
57a2a5ca 175 void pushAttribute(long t, ITmfStateValue value, int attributeQuark)
6dd46830 176 throws AttributeNotFoundException, StateValueTypeException;
d26f90fd
AM
177
178 /**
179 * Antagonist of the pushAttribute(), pops the top-most attribute on the
180 * stack-attribute. If this brings it back to depth = 0, the attribute is
181 * kept with depth = 0. If the value is already 0, or if the attribute
182 * doesn't exist, nothing is done.
2cb26548 183 *
d26f90fd
AM
184 * @param t
185 * Timestamp of the state change
186 * @param attributeQuark
187 * Quark of the stack-attribute to pop
5896eb76
AM
188 * @return The state value that was popped, or 'null' if nothing was
189 * actually removed from the stack.
d26f90fd
AM
190 * @throws AttributeNotFoundException
191 * If the attribute is invalid
192 * @throws TimeRangeException
193 * If the timestamp is invalid
194 * @throws StateValueTypeException
195 * If the target attribute already exists, but its state value
196 * type is invalid (not an integer)
197 */
57a2a5ca 198 ITmfStateValue popAttribute(long t, int attributeQuark)
6dd46830 199 throws AttributeNotFoundException, StateValueTypeException;
d26f90fd
AM
200
201 /**
202 * Remove attribute method. Similar to the above modify- methods, with value
203 * = 0 / null, except we will also "nullify" all the sub-contents of the
204 * requested path (a bit like "rm -rf")
2cb26548 205 *
d26f90fd
AM
206 * @param t
207 * Timestamp of the state change
208 * @param attributeQuark
209 * Attribute to remove
210 * @throws TimeRangeException
211 * If the timestamp is invalid
212 * @throws AttributeNotFoundException
213 * If the quark is invalid
214 */
57a2a5ca 215 void removeAttribute(long t, int attributeQuark)
6dd46830 216 throws AttributeNotFoundException;
d26f90fd
AM
217
218 /**
219 * Method to close off the History Provider. This happens for example when
220 * we are done reading an off-line trace. First we close the TransientState,
221 * commit it to the Provider, mark it as inactive, then we write the
222 * Attribute Tree somewhere so we can reopen it later.
2cb26548 223 *
d26f90fd
AM
224 * @param endTime
225 * The requested End Time of the history, since it could be
226 * bigger than the timestamp of the last event or state change we
227 * have seen. All "ongoing" states will be extended until this
228 * 'endTime'.
229 * @throws TimeRangeException
230 * If the passed endTime doesn't make sense (for example, if
231 * it's earlier than the latest time) and the backend doesn't
232 * know how to handle it.
233 */
6dd46830 234 void closeHistory(long endTime);
d26f90fd 235}
This page took 0.150501 seconds and 5 git commands to generate.