tmf.ctf: Split the classes into proper packages
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / lttng2 / kernel / core / trace / LttngKernelTrace.java
CommitLineData
11d6f468 1/*******************************************************************************
cd43d683 2 * Copyright (c) 2012, 2014 Ericsson
11d6f468
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 and implementation
a94410d9 11 * Matthew Khouzam - Improved validation
11d6f468
AM
12 ******************************************************************************/
13
9bc60be7 14package org.eclipse.tracecompass.lttng2.kernel.core.trace;
11d6f468 15
96c0f2af 16import java.nio.BufferOverflowException;
11d6f468
AM
17
18import org.eclipse.core.resources.IProject;
a94410d9
MK
19import org.eclipse.core.runtime.IStatus;
20import org.eclipse.core.runtime.Status;
f357bcd4
AM
21import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException;
22import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
9bc60be7 23import org.eclipse.tracecompass.internal.lttng2.kernel.core.Activator;
2bdf0193 24import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
9722e5d7 25import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
11d6f468
AM
26
27/**
28 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
4bc53929 29 * traces.
d85d2a6d 30 *
2cb26548 31 * @author Alexandre Montplaisir
d3ba47d4 32 * @since 2.0
11d6f468 33 */
d3ba47d4 34public class LttngKernelTrace extends CtfTmfTrace {
11d6f468 35
cd43d683
PT
36 private static final int CONFIDENCE = 100;
37
d85d2a6d
AM
38 /**
39 * Default constructor
40 */
d3ba47d4 41 public LttngKernelTrace() {
11d6f468
AM
42 super();
43 }
44
a94410d9 45 /**
cd43d683
PT
46 * {@inheritDoc}
47 * <p>
48 * This implementation sets the confidence to 100 if the trace is a valid
49 * CTF trace in the "kernel" domain.
a94410d9 50 */
11d6f468 51 @Override
dd9752d5 52 public IStatus validate(final IProject project, final String path) {
7c60c8b4
AM
53 /*
54 * Make sure the trace is openable as a CTF trace. We do this here
55 * instead of calling super.validate() to keep the reference to "temp".
56 */
dd9752d5
AM
57 try (CTFTrace temp = new CTFTrace(path);) {
58 /* Make sure the domain is "kernel" in the trace's env vars */
59 String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
60 if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
61 return new TraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID);
62 }
63 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_DomainError);
64
7c60c8b4 65 } catch (CTFReaderException e) {
dd9752d5
AM
66 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
67 } catch (NullPointerException e) {
68 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
96c0f2af 69 } catch (final BufferOverflowException e) {
dd9752d5 70 return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngKernelTrace_TraceReadError + ": " + Messages.LttngKernelTrace_MalformedTrace); //$NON-NLS-1$
7c60c8b4 71 }
11d6f468
AM
72 }
73
11d6f468 74}
This page took 0.058256 seconds and 5 git commands to generate.