use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfXmlTraceStubNs method setupTrace.
/**
* Validate and initialize a {@link TmfXmlTraceStubNs} object
*
* @param absolutePath
* The absolute file path of the trace file
* @return The trace
*/
public static TmfXmlTraceStubNs setupTrace(IPath absolutePath) {
TmfXmlTraceStubNs trace = new TmfXmlTraceStubNs();
IStatus status = trace.validate(null, absolutePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
trace.dispose();
fail(e.getMessage());
}
return trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfXmlTraceStubSec method setupTrace.
/**
* Validate and initialize a {@link TmfXmlTraceStubSec} object
*
* @param absolutePath
* The absolute file path of the trace file
* @return The trace
*/
public static TmfXmlTraceStubSec setupTrace(IPath absolutePath) {
TmfXmlTraceStubSec trace = new TmfXmlTraceStubSec();
IStatus status = trace.validate(null, absolutePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
trace.dispose();
fail(e.getMessage());
}
return trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfStateSystemAnalysisModule method createPartialHistory.
/*
* Create a new state system backed with a partial history. A partial history is
* similar to a "full" one (which you get with {@link #newFullHistory}), except
* that the file on disk is much smaller, but queries are a bit slower.
*
* Also note that single-queries are implemented using a full-query underneath,
* (which are much slower), so this might not be a good fit for a use case where
* you have to do lots of single queries.
*/
private void createPartialHistory(String id, ITmfStateProvider provider, File htPartialFile) throws TmfTraceException {
/*
* The order of initializations is very tricky (but very important!) here. We
* need to follow this pattern: (1 is done before the call to this method)
* <ol>
* <li>Instantiate realStateProvider</li>
* <li>Instantiate realBackend</li>
* <li>Instantiate partialBackend, with prereqs:
* <ol>
* <li>Instantiate partialProvider, via realProvider.getNew()</li>
* <li>Instantiate nullBackend (partialSS's backend)</li>
* <li>Instantiate partialSS</li>
* <li>partialProvider.assignSS(partialSS)</li>
* </ol>
* <li>Instantiate realSS</li>
* <li>partialSS.assignUpstream(realSS)</li>
* <li>realProvider.assignSS (realSS)</li>
* <li>Call HistoryBuilder(realProvider, realSS, partialBackend) to build the
* thing.</li></li>
*/
/* Size of the blocking queue to use when building a state history */
final int QUEUE_SIZE = 10000;
final long granularity = 50000;
/* 2 */
IStateHistoryBackend realBackend = null;
try {
realBackend = StateHistoryBackendFactory.createHistoryTreeBackendNewFile(id, htPartialFile, provider.getVersion(), provider.getStartTime(), QUEUE_SIZE);
} catch (IOException e) {
throw new TmfTraceException(e.toString(), e);
}
/* 3a */
ITmfStateProvider partialProvider = provider.getNewInstance();
/* 3b-3c, constructor automatically uses a NullBackend */
PartialStateSystem pss = new PartialStateSystem();
/* 3d */
partialProvider.assignTargetStateSystem(pss);
/* 3 */
// $NON-NLS-1$
IStateHistoryBackend partialBackend = new PartialHistoryBackend(id + ".partial", partialProvider, pss, realBackend, granularity);
/* 4 */
ITmfStateSystemBuilder realSS = StateSystemFactory.newStateSystem(partialBackend);
/* 5 */
pss.assignUpstream(realSS);
/* 6 */
provider.assignTargetStateSystem(realSS);
/* 7 */
fStateSystem = realSS;
build(provider);
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfStateSystemAnalysisModule method createFullHistory.
// ------------------------------------------------------------------------
// History creation methods
// ------------------------------------------------------------------------
/*
* Load the history file matching the target trace. If the file already exists,
* it will be opened directly. If not, it will be created from scratch.
*/
private void createFullHistory(String id, ITmfStateProvider provider, File htFile) throws TmfTraceException {
if (htFile.exists()) {
/* Load an existing history */
final int version = provider.getVersion();
try {
IStateHistoryBackend backend = StateHistoryBackendFactory.createHistoryTreeBackendExistingFile(id, htFile, version);
fStateSystem = StateSystemFactory.newStateSystem(backend, false);
analysisReady(true);
return;
} catch (IOException e) {
/*
* There was an error opening the existing file. Perhaps it was corrupted,
* perhaps it's an old version? We'll just fall-through and try to build a new
* one from scratch instead.
*/
}
}
/* Size of the blocking queue to use when building a state history */
final int QUEUE_SIZE = 10000;
try {
IStateHistoryBackend backend = StateHistoryBackendFactory.createHistoryTreeBackendNewFile(id, htFile, provider.getVersion(), provider.getStartTime(), QUEUE_SIZE);
fStateSystem = StateSystemFactory.newStateSystem(backend);
provider.assignTargetStateSystem(fStateSystem);
build(provider);
} catch (IOException e) {
/*
* If it fails here however, it means there was a problem writing to the disk,
* so throw a real exception this time.
*/
throw new TmfTraceException(e.toString(), e);
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfStateSystemAnalysisModule method createCustomHistory.
private void createCustomHistory(String id, ITmfStateProvider provider) throws TmfTraceException {
ICustomStateHistoryBackend backend = getCustomBackend(id, provider);
if (backend.isBuilt()) {
try {
fStateSystem = StateSystemFactory.newStateSystem(backend, false);
analysisReady(true);
return;
} catch (IOException e) {
// $NON-NLS-1$
throw new TmfTraceException("Could not create custom backend", e);
}
}
@NonNull ITmfStateSystemBuilder stateSystemBuilder = StateSystemFactory.newStateSystem(backend);
fStateSystem = stateSystemBuilder;
provider.assignTargetStateSystem(stateSystemBuilder);
build(provider);
}
Aggregations