beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject [26/50] beam git commit: Increase visibility of some Metrics methods
Date Thu, 08 Jun 2017 01:35:15 GMT
Increase visibility of some Metrics methods

Also revise the Javadoc on MetricsContainers.


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/39674ca8
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/39674ca8
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/39674ca8

Branch: refs/heads/DSL_SQL
Commit: 39674ca8d0ae1d82bfb5da6a81f26843613d3cd7
Parents: 6853d8e
Author: bchambers <bchambers@google.com>
Authored: Tue Jun 6 15:08:46 2017 -0700
Committer: bchambers <bchambers@google.com>
Committed: Tue Jun 6 15:08:55 2017 -0700

----------------------------------------------------------------------
 .../apache/beam/runners/core/metrics/CounterCell.java    | 10 +++++++---
 .../org/apache/beam/runners/core/metrics/DirtyState.java |  4 +++-
 .../beam/runners/core/metrics/DistributionCell.java      | 10 +++++++---
 .../org/apache/beam/runners/core/metrics/GaugeCell.java  | 11 +++++++----
 .../beam/runners/core/metrics/MetricsContainerImpl.java  |  4 +++-
 .../org/apache/beam/sdk/metrics/MetricsContainer.java    |  3 ++-
 6 files changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/CounterCell.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/CounterCell.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/CounterCell.java
index 4378bb9..886d681 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/CounterCell.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/CounterCell.java
@@ -21,8 +21,10 @@ package org.apache.beam.runners.core.metrics;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.beam.sdk.annotations.Experimental;
 import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.annotations.Internal;
 import org.apache.beam.sdk.metrics.Counter;
 import org.apache.beam.sdk.metrics.MetricName;
+import org.apache.beam.sdk.metrics.MetricsContainer;
 
 /**
  * Tracks the current value (and delta) for a Counter metric for a specific context and bundle.
@@ -40,10 +42,12 @@ public class CounterCell implements Counter, MetricCell<Long> {
   private final MetricName name;
 
   /**
-   * Package-visibility because all {@link CounterCell CounterCells} should be created by
-   * {@link MetricsContainerImpl#getCounter(MetricName)}.
+   * Generally, runners should construct instances using the methods in
+   * {@link MetricsContainerImpl}, unless they need to define their own version of
+   * {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
    */
-  CounterCell(MetricName name) {
+  @Internal
+  public CounterCell(MetricName name) {
     this.name = name;
   }
 

http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DirtyState.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DirtyState.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DirtyState.java
index 532fc2a..1976049 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DirtyState.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DirtyState.java
@@ -22,6 +22,7 @@ import java.io.Serializable;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.beam.sdk.annotations.Experimental;
 import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.annotations.Internal;
 
 /**
  * Atomically tracks the dirty-state of a metric.
@@ -42,7 +43,8 @@ import org.apache.beam.sdk.annotations.Experimental.Kind;
  * completed.
  */
 @Experimental(Kind.METRICS)
-class DirtyState implements Serializable {
+@Internal
+public class DirtyState implements Serializable {
   private enum State {
     /** Indicates that there have been changes to the MetricCell since last commit. */
     DIRTY,

http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DistributionCell.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DistributionCell.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DistributionCell.java
index 5a5099a..8713ec4 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DistributionCell.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/DistributionCell.java
@@ -21,8 +21,10 @@ package org.apache.beam.runners.core.metrics;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.beam.sdk.annotations.Experimental;
 import org.apache.beam.sdk.annotations.Experimental.Kind;
+import org.apache.beam.sdk.annotations.Internal;
 import org.apache.beam.sdk.metrics.Distribution;
 import org.apache.beam.sdk.metrics.MetricName;
+import org.apache.beam.sdk.metrics.MetricsContainer;
 
 /**
  * Tracks the current value (and delta) for a Distribution metric.
@@ -41,10 +43,12 @@ public class DistributionCell implements Distribution, MetricCell<DistributionDa
   private final MetricName name;
 
   /**
-   * Package-visibility because all {@link DistributionCell DistributionCells} should be
created by
-   * {@link MetricsContainerImpl#getDistribution(MetricName)}.
+   * Generally, runners should construct instances using the methods in
+   * {@link MetricsContainerImpl}, unless they need to define their own version of
+   * {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
    */
-  DistributionCell(MetricName name) {
+  @Internal
+  public DistributionCell(MetricName name) {
     this.name = name;
   }
 

http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/GaugeCell.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/GaugeCell.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/GaugeCell.java
index 795e826..1c55021 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/GaugeCell.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/GaugeCell.java
@@ -20,8 +20,10 @@ package org.apache.beam.runners.core.metrics;
 
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Internal;
 import org.apache.beam.sdk.metrics.Gauge;
 import org.apache.beam.sdk.metrics.MetricName;
+import org.apache.beam.sdk.metrics.MetricsContainer;
 
 /**
  * Tracks the current value (and delta) for a {@link Gauge} metric.
@@ -39,10 +41,12 @@ public class GaugeCell implements Gauge, MetricCell<GaugeData> {
   private final MetricName name;
 
   /**
-   * Package-visibility because all {@link GaugeCell GaugeCells} should be created by
-   * {@link MetricsContainerImpl#getGauge(MetricName)}.
+   * Generally, runners should construct instances using the methods in
+   * {@link MetricsContainerImpl}, unless they need to define their own version of
+   * {@link MetricsContainer}. These constructors are *only* public so runners can instantiate.
    */
-  GaugeCell(MetricName name) {
+  @Internal
+  public GaugeCell(MetricName name) {
     this.name = name;
   }
 
@@ -70,7 +74,6 @@ public class GaugeCell implements Gauge, MetricCell<GaugeData> {
     return gaugeValue.get();
   }
 
-
   @Override
   public MetricName getName() {
     return name;

http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
----------------------------------------------------------------------
diff --git a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
index 6967bf0..99d7454 100644
--- a/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
+++ b/runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
@@ -31,7 +31,9 @@ import org.apache.beam.sdk.metrics.MetricName;
 import org.apache.beam.sdk.metrics.MetricsContainer;
 
 /**
- * Holds the metrics for a single step and unit-of-commit (bundle).
+ * Holds the metrics for a single step and uses metric cells that allow extracting the cumulative
+ * value. Generally, this implementation should be used for a specific unit of commitment
(bundle)
+ * that wishes to report the values since the start of the bundle (eg., for committed metrics).
  *
  * <p>This class is thread-safe. It is intended to be used with 1 (or more) threads
are updating
  * metrics and at-most 1 thread is extracting updates by calling {@link #getUpdates} and

http://git-wip-us.apache.org/repos/asf/beam/blob/39674ca8/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsContainer.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsContainer.java
b/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsContainer.java
index 62b0806..361c75f 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsContainer.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsContainer.java
@@ -23,7 +23,8 @@ import org.apache.beam.sdk.annotations.Experimental;
 import org.apache.beam.sdk.annotations.Experimental.Kind;
 
 /**
- * Holds the metrics for a single step and unit-of-commit (bundle).
+ * Holds the metrics for a single step. Each of the methods should return an implementation
of the
+ * appropriate metrics interface for the "current" step.
  */
 @Experimental(Kind.METRICS)
 public interface MetricsContainer extends Serializable {


Mime
View raw message