tmf: Rename StateSystemManager to TmfStateSystemFactory
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core / src / org / eclipse / linuxtools / lttng2 / kernel / core / trace / CtfKernelTrace.java
... / ...
CommitLineData
1/*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
11 * Matthew Khouzam - Improved validation
12 ******************************************************************************/
13
14package org.eclipse.linuxtools.lttng2.kernel.core.trace;
15
16import java.io.File;
17
18import org.eclipse.core.resources.IProject;
19import org.eclipse.core.resources.IResource;
20import org.eclipse.core.runtime.CoreException;
21import org.eclipse.core.runtime.IStatus;
22import org.eclipse.core.runtime.Status;
23import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
24import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
25import org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator;
26import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
27import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
28import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
29import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
30import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
31import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
32import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
33
34/**
35 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
36 * traces. It uses the CtfKernelStateInput to generate the state history.
37 *
38 * @version 1.0
39 * @author Alexandre Montplaisir
40 */
41public class CtfKernelTrace extends CtfTmfTrace {
42
43 /**
44 * The file name of the History Tree
45 */
46 public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
47
48 /**
49 * ID of the state system we will build
50 * @since 2.0
51 * */
52 public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
53
54 /**
55 * Default constructor
56 */
57 public CtfKernelTrace() {
58 super();
59 }
60
61 /**
62 * @since 2.0
63 */
64 @Override
65 public IStatus validate(final IProject project, final String path) {
66 CTFTrace temp;
67 IStatus validStatus;
68 /*
69 * Make sure the trace is openable as a CTF trace. We do this here
70 * instead of calling super.validate() to keep the reference to "temp".
71 */
72 try {
73 temp = new CTFTrace(path);
74 } catch (CTFReaderException e) {
75 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
76 return validStatus;
77 } catch (NullPointerException e){
78 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
79 return validStatus;
80 }
81
82 /* Make sure the domain is "kernel" in the trace's env vars */
83 String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
84 temp.dispose();
85 if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
86 return Status.OK_STATUS;
87 }
88 validStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfKernelTrace_DomainError);
89 return validStatus;
90 }
91
92 @Override
93 protected void buildStateSystem() throws TmfTraceException {
94 super.buildStateSystem();
95
96 /* Set up the path to the history tree file we'll use */
97 IResource resource = this.getResource();
98 String supplDirectory = null;
99
100 try {
101 // get the directory where the history file will be stored.
102 supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
103 } catch (CoreException e) {
104 throw new TmfTraceException(e.toString(), e);
105 }
106
107 final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
108 final ITmfStateProvider htInput = new CtfKernelStateProvider(this);
109
110 ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
111 fStateSystems.put(STATE_ID, ss);
112 }
113
114}
This page took 0.025199 seconds and 5 git commands to generate.