1111
1212import static com .google .common .base .Preconditions .checkNotNull ;
1313
14+ /**
15+ * A frame of execution, it describes a set of data that is available within this frame and contains lists of metrics
16+ * that are ready for finalization within this frame. Each frame represents a frame of execution in
17+ * {@link nl.rug.jbi.jsm.core.execution.PipelineExecutor}.
18+ *
19+ * @author David van Leusen
20+ * @since 2014-06-02
21+ */
1422public class PipelineFrame {
1523 private final MetricScope scope ;
1624 private final Set <Class > availableData = Sets .newHashSet ();
@@ -19,38 +27,56 @@ public class PipelineFrame {
1927 private final List <ProducerMetric > producerMetrics = Lists .newLinkedList ();
2028 private PipelineFrame nextFrame = null ;
2129
22- public PipelineFrame (final MetricScope scope ) {
30+ PipelineFrame (final MetricScope scope ) {
2331 this .scope = checkNotNull (scope );
2432 }
2533
26- public PipelineFrame (final MetricScope scope , final Set <Class > initData ) {
34+ PipelineFrame (final MetricScope scope , final Set <Class > initData ) {
2735 this (scope );
2836 this .availableData .addAll (
2937 checkNotNull (initData )
3038 );
3139 }
3240
33- public PipelineFrame (final PipelineFrame previousFrame ) {
34- this (checkNotNull (previousFrame ).getScope ());
35- this .availableData .addAll (previousFrame .availableData );
41+ PipelineFrame (final PipelineFrame previousFrame ) {
42+ this (checkNotNull (previousFrame ).getScope (), previousFrame .availableData );
3643 previousFrame .setNextFrame (this );
3744 }
3845
46+ /**
47+ * Adds a type of data that will be available in this frame AND all subsequent frames.
48+ *
49+ * @param dataClass Data to register
50+ */
3951 public void addDataClass (final Class dataClass ) {
4052 this .availableData .add (dataClass );
4153 if (this .nextFrame != null ) {
4254 this .nextFrame .addDataClass (dataClass );
4355 }
4456 }
4557
58+ /**
59+ * @return The scope in which this frame will be evaluated.
60+ */
4661 public MetricScope getScope () {
4762 return this .scope ;
4863 }
4964
65+ /**
66+ * Checks whether this frame has all the given data available. The set of data available in this frame is determined
67+ * by the base set of data in {@link nl.rug.jbi.jsm.core.pipeline.Pipeline} and the results of any producers in
68+ * previous frames.
69+ *
70+ * @param requiredData The set of data that needs to be available.
71+ * @return Whether said data is available.
72+ */
5073 public boolean checkAvailableData (final Set <Class > requiredData ) {
5174 return this .availableData .containsAll (requiredData );
5275 }
5376
77+ /**
78+ * @return The next frame of execution, can be NULL.
79+ */
5480 public PipelineFrame getNextFrame () {
5581 return this .nextFrame ;
5682 }
@@ -59,19 +85,28 @@ private void setNextFrame(final PipelineFrame nextFrame) {
5985 this .nextFrame = nextFrame ;
6086 }
6187
88+ /**
89+ * @return Unmodifiable list of all isolated metrics that are finished in this frame.
90+ */
6291 public List <IsolatedMetric > getIsolatedMetrics () {
6392 return Collections .unmodifiableList (this .isolatedMetrics );
6493 }
6594
95+ /**
96+ * @return Unmodifiable list of all shared metrics that are finished in this frame.
97+ */
6698 public List <SharedMetric > getSharedMetrics () {
6799 return Collections .unmodifiableList (this .sharedMetrics );
68100 }
69101
102+ /**
103+ * @return Unmodifiable list of all producers that are finished in this frame.
104+ */
70105 public List <ProducerMetric > getProducerMetrics () {
71106 return Collections .unmodifiableList (this .producerMetrics );
72107 }
73108
74- public void registerMetric (final BaseMetric metric ) throws MetricPreparationException {
109+ void registerMetric (final BaseMetric metric ) throws MetricPreparationException {
75110 if (metric instanceof IsolatedMetric ) {
76111 this .isolatedMetrics .add ((IsolatedMetric ) metric );
77112 } else if (metric instanceof SharedMetric ) {
0 commit comments