DESCRIPTION

TMF: Add XML state provider analysis module and XML utilities

This patch adds an analysis module for an XML-defined state system. It does not
actually build the state system, the details will come in another patch.

It also contains the [stripped-down] XML schema definition and the methods to
read an XML file and validate it.

Change-Id: I2a3d322f96742d995912700d223e2ecb9e07d8f5
Signed-off-by: Aryana Jones xxx@xxx.xxx
Signed-off-by: Ayanna Reed xxx@xxx.xxx


COMMENTS

author: Annalise Jimenez
date: 2014-01-14 03:29:35.000000000

Uploaded patch set 6.

-------------------------------------
author: Annalise Jimenez
date: 2014-01-14 03:32:11.000000000

Patch Set 6:

All good now,
ptal

-------------------------------------
author: Brenden Conley
date: 2014-01-14 04:11:15.000000000

Patch Set 6:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/5025/

-------------------------------------
author: Brenden Conley
date: 2014-01-14 04:50:23.000000000

Patch Set 6: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/5025/ : SUCCESS

-------------------------------------
author: Braxton Mccarthy
date: 2014-01-14 23:01:46.000000000

Patch Set 6: Code-Review-1

(14 comments)

This patch could even be split further:

- Xml -> XML change, and copyright years updates
- New functionality 
- Tests

I also wonder why the XmlStateProvider class is to be filled later, is it really separate functionality?

Line:162, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/XmlUtils.java -> This is very C-like ;) 

Why not return an IStatus, with the corresponding error if there is one, instead of just a boolean?

That also makes it a bit more multi-thread safe: if two threads call two different methods in here, and both fail, one of the error messages will be lost.

Line:39, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateSystemModule.java -> Why is this hard-coded? It could come from the XML file? (or passed as parameter?)

Line:43, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateSystemModule.java -> xxx@xxx.xxx before protected (annotations go first)

Line:59, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateSystemModule.java -> > Oups, I have a feeling Alex will say to override getTrace/setTrace and manage the trace type there ;-)

Even better, it should be using ITmfTrace directly ;)

File Comment: lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/test_xml_files/test_invalid.xml -> maybe add a comment in this file, indicating which part is invalid

Line:49, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> hmm, this should not be hard-coded to one value. If the XML changes, it should be reflected in the state provider. Perhaps this should be a field that has to be present in the XML file?

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> Even though it wasn't tested, this functionality should be trace-type-agnostic, right? It should not use CTF-specific classes here.

(eventually, ctfadaptor will move to its own plugin, so it would have been obvious just from looking at the Manifest ;) )

Line:105, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> This will be filled in later, right? Perhaps add a comment saying so.

"// TODO Auto-generated method stub" often means "I just clicked 'Add unimplemented methods' and I forgot to fill them in" ;)

Line:162, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> here too, add a comment saying it will be filled in later

Line:18, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/META-INF/MANIFEST.MF -> Who will need the TmfXmlTestFiles, other than maybe tmf.analysis.xml.ui.tests?

In a such a case, it could be exported only to that plugin (x-friends=...) and the package be called .files maybe instead of .shared.

Line:24, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/model/TmfXmlStrings.java -> remove public, no need in an interface

Line:29, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/model/TmfXmlStrings.java -> It looked cute aligned, but a Ctrl+Shift+F is fine too.

Line:23, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/src/org/eclipse/linuxtools/tmf/analysis/xml/core/tests/module/AllTests.java -> }) on its own line

I also said "add an empty line" in a previous review today, didn't I? Scratch that one, no empty line.

Line:21, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/IXmlModule.java -> XmlModule is quite generic, should it be IXmlAnalysisModule?

-------------------------------------
author: Annalise Jimenez
date: 2014-01-15 14:56:49.000000000

Patch Set 6:

(7 comments)

> This patch could even be split further:
>
>    Xml -> XML change, and copyright years updates
>    New functionality
>    Tests

Is that wishful thinking for next patch series or strong suggestion for now?

In both cases, I'll argue for keeping tests with functionnality. It may make sense to divide them for single feature, but for a patch series, I think it's better to keep the unit test with the single small functionnalities because

1- It shows at first sight which single functionnalities in the series are unit tested and which are not

2- It's hard enough to split a big feature as it is. Keeping the tests makes sure you didn't misplace a hunk of code in another patch of the series and that the ordering of the small functionnality is ok (far from trivial sometimes, see experiment types :p)

> I also wonder why the XmlStateProvider class is to be filled later, is it really separate functionality?

Yes, it is intricately related with the XSD schema definition of a state system, so once the schema is accepted, the state provider itself may change.

Line:162, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/XmlUtils.java -> Right! This is what IStatus are for! Good catch

Line:39, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateSystemModule.java -> Not supported yet. But it should be somewhere in the XML file, header in the header information of the state provider or as an attribute of it, not sure yet.

Line:49, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> Indeed, Florian, what do you think of it?

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> I think it's mostly the CtfTmfEvent that poses problem. The rest of the code supposes CtfTmfEvent.

It should eventually be trace-type-agnostic, but instead of half supporting an untested feature, it's better to plainly state it is not supported yet imho.

Line:18, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/META-INF/MANIFEST.MF -> Who knows which packages will make use of this one. Let's be forward compatible, it doesn't matter anyway... right?

Line:29, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/model/TmfXmlStrings.java -> All other string files were Ctrl-Shift-F, so I did that here too...

Line:21, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/IXmlModule.java -> No, it's not an analysis module, rather an extension to the modules, to add extra data (for now the XML header part)
IXmlModuleData maybe?

-------------------------------------
author: Braxton Mccarthy
date: 2014-01-16 21:17:39.000000000

Patch Set 6:

(3 comments)

Some replies.

About splitting the unit tests: it's not really problematic if the unit tests come RIGHT after a patch. "Implement feature Y" followed by "Add tests for feature Y" is easy to follow. And we see the next patch of the series on the gerrit review page.

As for splitting them at commit time, it shouldn't be that hard: they are in different plugins, so a
 git add plugin.core/ -> commit as first patch
 git add plugin.core.tests/ -> commit as second patch

If your unit test patch has to change things in the implementation, it means there is a problem with the first patch ;)

But for this particular patch here it's fine, you can leave it as is. But for future patches, it might help get things in faster (a comment in the tests doesn't delay the first part, for instance).

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> When you say it "supposes" CtfTmfEvent, does it uses methods only available in CtfTmfEvent? If it can compile with ITmfEvent, I'd rather we use that, and adding a big warning NOT TESTED WITH NON-CTF THINGS if needed.

It's really the direct dependency between this plugin and the CTF plugin that is problematic.

Line:18, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/META-INF/MANIFEST.MF -> Hrm, I'd rather we expose things on a need basis, rather than a "what if". Or else you end up like the initial CTF implementation :P

ctf.core.tests.shared is exposed because it contains the CTF test traces, which are used by the TMF tests. tmf.core.tests.shared is then exposed, because the lttng2.tests use those traces.

If at the moment, no other plugin needs the XML test traces, they should remain in here.

Line:21, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/IXmlModule.java -> Ok, IXmlModuleData seems fine (even though it's a juxtaposition of words than don't mean anything independently ;) )

-------------------------------------
author: Ayanna Reed
date: 2014-01-16 22:04:29.000000000

Patch Set 6:

(3 comments)

some answers

Line:49, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> I'm aggre with Alexandre. Version means a modification in the big switch/case in java. Here the modification id can be a field in the XML head.

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> I use the methode getCPU() and getEventName in CtfTmfEvent. I'm not sure if we must use this methods.

Line:29, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/model/TmfXmlStrings.java -> :(

-------------------------------------
author: Annalise Jimenez
date: 2014-01-17 16:09:28.000000000

Patch Set 6:

(3 comments)

Line:49, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> Indeed, we'll add that to the header. It's actually a field internal to the developers of the XML state provider, like a serial number indicating which version of state provider xyz is being used.

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> Ok so here's the plan. For this patch (and the rest of the series), we keep the CtfTmfEvent requirement.

But when we reach the state provider, we can start thinking how to bypass the getCPU requirement or how to manage to specify it somehow, or cast the event to the right event type without knowing what might be the event type classes.

Line:21, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/module/IXmlModule.java -> Even better IXmlModuleMetadata!

or maybe perhaps IXmlModuleExtension?

-------------------------------------
author: Braxton Mccarthy
date: 2014-01-17 16:56:46.000000000

Patch Set 6:

(1 comment)

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> I'm very VERY weary about even merging it using CtfTmfEvent. Quite often we have the best of intentions, but stuff happens, priorities get shuffled, and "temporary hacks" end up being the version that is shipped in production...

If this plugin depends on ctfadaptor, that means we won't be able to split ctfadaptor in a separate plugin (which we should do soon rather than later), becuase it will have circular dependencies.

To get the CPU, can't you use ITmfEvent.getSource() ? (CtfTmfEvent's constructor already passes String.valueOf(cpu) to the super constructor).

-------------------------------------
author: Annalise Jimenez
date: 2014-01-17 18:54:39.000000000

Patch Set 6:

(1 comment)

Line:74, lttng/org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java -> You're weary really? :p

Ok, I'll try to fix it before next push then. *weary sigh*

-------------------------------------
