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