DESCRIPTION

[WIP] tmf: Add TmfCompositeComponent interface and implementation

This is helpful for components which have a parent child relationship
for example experiments and children.

Change-Id: I2fec1da979033454552c45b52e4e2e3153295cd0
Signed-off-by: Ricky Reeves <Meredith xxx@xxx.xxx


COMMENTS

author: Ricky Reeves
date: 2014-03-19 19:53:37.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2014-03-19 19:53:44.000000000

Patch Set 1:

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

-------------------------------------
author: Brenden Conley
date: 2014-03-19 20:49:42.000000000

Patch Set 1: Verified+1

Build Successful 

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

-------------------------------------
author: Annalise Jimenez
date: 2014-03-20 15:14:35.000000000

Patch Set 1: Code-Review-1

(6 comments)

Some initial comments

Line:436, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java -> extra line here

Line:420, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java -> Log the exception with Activator.logError()

Line:37, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfCompositeComponent.java -> Just a question on synchronization, as I'm no expert on the subject:

I see you use here a synchronized list and synchronize most of the methods on that list, except those modifying that list directly. Would it have been the same to have all methods synchronized instead? Is there an advantage to any one of those approaches?

Line:52, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfCompositeComponent.java -> Do you plan to add anything here? Otherwise, there's no need to override this.

Line:21, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfCompositeComponent.java -> Could you define what a composite component is? eg. a component that has a parent/child relationships.

Line:32, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfCompositeComponent.java -> "returns" unnecessary

-------------------------------------
author: Ricky Reeves
date: 2014-03-21 14:13:49.000000000

Patch Set 1:

(5 comments)

Genevieve, thanks for comments.

Line:420, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java -> Done! This print-out helped to find a bug in my implementation.

Line:37, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfCompositeComponent.java -> Achieving thread-safety is a complex topic. There are different approaches to achieve thread-safety. Often this is achieved by using lock object. If you synchronize on a method you synchronize on the this object of that class which basically the same as:
synchronized(this) {
}

Another way is to use other objects to synchronize. Here we uses the fChildren by itself. Since fChildren = Collections.synchronizedList() all access internally is synchronized at the object that Collections.synchronizeList() returns. However, if you do compound operations like iterating over the list you need to synchronize on that object to avoid that elements are added or removed while iterating.

There are many other approaches and depending what we want to achieve we have to select the appropriate one. And often there multiple approaches that are ok.

I didn't chose to synchronized on the this object because adding and removing children is not done very dynamically (e.g. during reading a trace) and therefore it's unrelated (Remember experiments/traces are TmfCompositeComponents). As probably noticed calling fChildren.add() or fChildren.isEmpty() doesn't need to be synchronized externally because it's done in the class.

Line:52, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfCompositeComponent.java -> Done

Line:21, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfCompositeComponent.java -> Done

Line:32, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfCompositeComponent.java -> Done

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