Search in sources :

Example 16 with TmfTraceException

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)

Example 17 with TmfTraceException

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)

Example 18 with TmfTraceException

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);
}
Also used : PartialStateSystem(org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial.PartialStateSystem) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) IOException(java.io.IOException) PartialHistoryBackend(org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial.PartialHistoryBackend) IStateHistoryBackend(org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)

Example 19 with TmfTraceException

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);
    }
}
Also used : TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) IOException(java.io.IOException) IStateHistoryBackend(org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend)

Example 20 with TmfTraceException

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);
}
Also used : TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) NonNull(org.eclipse.jdt.annotation.NonNull) ICustomStateHistoryBackend(org.eclipse.tracecompass.statesystem.core.backend.ICustomStateHistoryBackend) ITmfStateSystemBuilder(org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder) IOException(java.io.IOException)

Aggregations

TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)50 File (java.io.File)17 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)14 IStatus (org.eclipse.core.runtime.IStatus)12 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)12 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)11 IOException (java.io.IOException)10 IPath (org.eclipse.core.runtime.IPath)8 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)8 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)8 TmfXmlKernelTraceStub (org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub)7 Performance (org.eclipse.test.performance.Performance)6 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)6 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)6 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)6 Before (org.junit.Before)6 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4