use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class HistoryTreeBackend method doQuery.
@Override
public void doQuery(List<ITmfStateInterval> stateInfo, long t) throws TimeRangeException, StateSystemDisposedException {
checkValidTime(t);
/* Queue is a stack of nodes containing nodes intersecting t */
Deque<Integer> queue = new ArrayDeque<>();
/* We start by reading the information in the root node */
queue.add(getSHT().getRootNode().getSequenceNumber());
/* Then we follow the down in the relevant children */
try {
while (!queue.isEmpty()) {
int sequenceNumber = queue.pop();
HTNode currentNode = getSHT().readNode(sequenceNumber);
if (currentNode.getNodeType() == HTNode.NodeType.CORE) {
/* Here we add the relevant children nodes for BFS */
queue.addAll(((ParentNode) currentNode).selectNextChildren(t));
}
currentNode.writeInfoFromNode(stateInfo, t);
}
} catch (ClosedChannelException e) {
throw new StateSystemDisposedException(e);
}
/*
* The stateInfo should now be filled with everything needed, we pass
* the control back to the State System.
*/
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class FsmTest method testInitialStateWithCondition.
/**
* Compare the execution of two state machines doing the same job, the tid
* condition is ignored with the initial element and used with the
* initialState element. The result should be different.
*/
@Test
public void testInitialStateWithCondition() {
ITmfStateSystem stateSystem = fModule.getStateSystem(fModule.getId());
assertNotNull("state system exist", stateSystem);
try {
int quark = stateSystem.getQuarkAbsolute("fsm1");
@NonNull ITmfStateInterval interval = stateSystem.querySingleState(END_TIME, quark);
long count1 = interval.getStateValue().unboxLong();
quark = stateSystem.getQuarkAbsolute("fsm3");
interval = stateSystem.querySingleState(END_TIME, quark);
long count3 = interval.getStateValue().unboxLong();
assertTrue("Test the count value", count1 > count3);
} catch (AttributeNotFoundException | StateSystemDisposedException e) {
fail("Failed to query the state system");
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class TmfXmlConditionTest method testConditionsValidation.
/**
* Test basic conditions on a state provider analysis
*/
@Test
public void testConditionsValidation() {
ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace2);
DataDrivenAnalysisModule module = XmlUtilsTest.initializeModule(TmfXmlTestFiles.CONDITION_FILE);
try {
module.setTrace(trace);
module.schedule();
module.waitForCompletion();
ITmfStateSystem ss = module.getStateSystem();
assertNotNull(ss);
List<Integer> quarks = ss.getQuarks("*");
assertEquals(5, quarks.size());
for (Integer quark : quarks) {
String name = ss.getAttributeName(quark);
switch(name) {
case "test":
{
final int[] expectedStarts = { 1, 5, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
XmlUtilsTest.verifyStateIntervals("test", ss, quark, expectedStarts, expectedValues);
}
break;
case "test1":
{
final int[] expectedStarts = { 1, 3, 7, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.nullValue(), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
XmlUtilsTest.verifyStateIntervals("test1", ss, quark, expectedStarts, expectedValues);
}
break;
case "checkpoint":
{
final int[] expectedStarts = { 1, 5, 7, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
XmlUtilsTest.verifyStateIntervals("checkpoint", ss, quark, expectedStarts, expectedValues);
}
break;
case "and_three_operands":
{
final int[] expectedStarts = { 1, 5, 7, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
XmlUtilsTest.verifyStateIntervals("and_three_operands", ss, quark, expectedStarts, expectedValues);
}
break;
case "not_operand":
{
final int[] expectedStarts = { 1, 5, 7, 7 };
ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
XmlUtilsTest.verifyStateIntervals("not_operand", ss, quark, expectedStarts, expectedValues);
}
break;
default:
fail("Wrong attribute name " + name);
break;
}
}
} catch (TmfAnalysisException | AttributeNotFoundException | StateSystemDisposedException e) {
fail(e.getMessage());
} finally {
module.dispose();
trace.dispose();
}
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class DataDrivenScenarioHistoryBuilder method getStoredFieldValue.
/**
* Get the value of a special field in the state system
*
* @param container
* The state system container this class use
* @param attributeName
* The attribute name of the special field
* @param info
* The scenario details
* @param event
* The current event
*
* @return The value of a special field saved into the state system
*/
public ITmfStateValue getStoredFieldValue(IAnalysisDataContainer container, String attributeName, DataDrivenScenarioInfo info, ITmfEvent event) {
ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) container.getStateSystem();
long ts = event.getTimestamp().toNanos();
ITmfStateInterval state = null;
try {
int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STORED_FIELDS, attributeName);
state = ss.querySingleState(ts, attributeQuark);
} catch (StateSystemDisposedException e) {
// $NON-NLS-1$
Activator.logError("failed to get the value of the stored field " + attributeName, e);
}
return (state != null) ? NonNullUtils.checkNotNull(state.getStateValue()) : TmfStateValue.nullValue();
}
use of org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException in project tracecompass by tracecompass.
the class DataDrivenScenarioHistoryBuilder method getSpecificStateStartTime.
/**
* Get the start time of a specific state of the scenario
*
* @param container
* The state system container this class use
* @param stateName
* The name of the current state of the scenario
* @param info
* The scenario details
* @param event
* The current event
*
* @return The start time for the specified state
*/
public long getSpecificStateStartTime(IXmlStateSystemContainer container, String stateName, DataDrivenScenarioInfo info, ITmfEvent event) {
long ts = event.getTimestamp().getValue();
ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) container.getStateSystem();
try {
int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STATE, stateName, START_TIME);
ITmfStateInterval state = ss.querySingleState(ts, attributeQuark);
return state.getStartTime();
} catch (StateSystemDisposedException e) {
// $NON-NLS-1$
Activator.logError("failed the start time of the state " + stateName, e);
}
return -1l;
}
Aggregations