Class TestSinkCommitterMetricGroup

java.lang.Object
org.apache.flink.runtime.metrics.groups.ProxyMetricGroup<org.apache.flink.metrics.MetricGroup>
io.github.flink.gcp.connector.testutils.TestSinkCommitterMetricGroup
All Implemented Interfaces:
org.apache.flink.metrics.groups.OperatorMetricGroup, org.apache.flink.metrics.groups.SinkCommitterMetricGroup, org.apache.flink.metrics.MetricGroup

@Internal public final class TestSinkCommitterMetricGroup extends org.apache.flink.runtime.metrics.groups.ProxyMetricGroup<org.apache.flink.metrics.MetricGroup> implements org.apache.flink.metrics.groups.SinkCommitterMetricGroup
A SinkCommitterMetricGroup whose metrics can be read back by the names they registered under — TestSinkCommitterMetricGroup is to a committer what TestSinkWriterMetricGroup is to a writer, and for the same reason: UnregisteredMetricsGroup.createSinkCommitterMetricGroup() hands out a fresh SimpleCounter per call, so a counter the committer registered is unreachable afterwards.

The framework's own committer counters are registered here under the names a reporter sees ("totalCommittables" and friends, which are not the accessor names on the interface), so a test asserting a connector's custom counter cannot accidentally collide with one of them. The registered metrics are read back through the inherited counterValue(String...), gaugeValue(String...) and hasMetric(String...) accessors.

  • Field Details

    • TOTAL_COMMITTABLES

      public static final String TOTAL_COMMITTABLES
      Name of the framework's arrived-committables counter, as a reporter sees it.
      See Also:
    • SUCCESSFUL_COMMITTABLES

      public static final String SUCCESSFUL_COMMITTABLES
      Name of the framework's successful-committables counter.
      See Also:
    • ALREADY_COMMITTED_COMMITTABLES

      public static final String ALREADY_COMMITTED_COMMITTABLES
      Name of the framework's already-committed-committables counter.
      See Also:
    • FAILED_COMMITTABLES

      public static final String FAILED_COMMITTABLES
      Name of the framework's failed-committables counter.
      See Also:
    • RETRIED_COMMITTABLES

      public static final String RETRIED_COMMITTABLES
      Name of the framework's retried-committables counter.
      See Also:
  • Method Details

    • create

      public static TestSinkCommitterMetricGroup create()
      Creates a group over a fresh listener.
    • getCurrentPendingCommittablesGauge

      @Nullable public org.apache.flink.metrics.Gauge<Integer> getCurrentPendingCommittablesGauge()
    • getNumCommittablesTotalCounter

      public org.apache.flink.metrics.Counter getNumCommittablesTotalCounter()
      Specified by:
      getNumCommittablesTotalCounter in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • getNumCommittablesFailureCounter

      public org.apache.flink.metrics.Counter getNumCommittablesFailureCounter()
      Specified by:
      getNumCommittablesFailureCounter in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • getNumCommittablesRetryCounter

      public org.apache.flink.metrics.Counter getNumCommittablesRetryCounter()
      Specified by:
      getNumCommittablesRetryCounter in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • getNumCommittablesSuccessCounter

      public org.apache.flink.metrics.Counter getNumCommittablesSuccessCounter()
      Specified by:
      getNumCommittablesSuccessCounter in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • getNumCommittablesAlreadyCommittedCounter

      public org.apache.flink.metrics.Counter getNumCommittablesAlreadyCommittedCounter()
      Specified by:
      getNumCommittablesAlreadyCommittedCounter in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • setCurrentPendingCommittablesGauge

      public void setCurrentPendingCommittablesGauge(org.apache.flink.metrics.Gauge<Integer> currentPendingCommittablesGauge)
      Specified by:
      setCurrentPendingCommittablesGauge in interface org.apache.flink.metrics.groups.SinkCommitterMetricGroup
    • getIOMetricGroup

      public org.apache.flink.metrics.groups.OperatorIOMetricGroup getIOMetricGroup()
      Specified by:
      getIOMetricGroup in interface org.apache.flink.metrics.groups.OperatorMetricGroup
    • counterValue

      public final long counterValue(String... identifier)
      Returns the counter registered under identifier, relative to the group.
      Parameters:
      identifier - the name path, one element per group level (for example "errorClass", "UNAVAILABLE", "errors")
      Returns:
      the counter's value
      Throws:
      AssertionError - if nothing was registered under that name
    • registeredCounter

      public final org.apache.flink.metrics.Counter registeredCounter(String... identifier)
      Returns the counter registered under identifier itself — for the assertion that cares which implementation a runtime registered, such as a thread-safe one on a surface whose counts arrive from client threads.
      Parameters:
      identifier - the name path, one element per group level
      Returns:
      the registered counter
      Throws:
      AssertionError - if nothing was registered under that name
    • hasMetric

      public final boolean hasMetric(String... identifier)
      Whether any metric is registered under identifier — the assertion a metric that may legitimately be absent needs, since "not registered" is not "registered at zero".
    • gaugeValue

      public final <T> T gaugeValue(String... identifier)
      Returns the value of the gauge registered under identifier.
      Type Parameters:
      T - the gauge's value type
      Parameters:
      identifier - the name path, one element per group level
      Returns:
      the gauge's current value
      Throws:
      AssertionError - if nothing was registered under that name