Class ResidueCounter

java.lang.Object
io.github.flink.gcp.connector.pubsub.ResidueCounter
All Implemented Interfaces:
org.apache.flink.metrics.Counter, org.apache.flink.metrics.Metric

@Internal public final class ResidueCounter extends Object implements org.apache.flink.metrics.Counter
A read-only Counter view of one PubSubShutdownResidue adder, so a residue registers as the counter it is rather than as a gauge over a monotonic total.

Named for the storage rather than for one of the things stored, which the four adders it serves make necessary: a subscriber failure nothing consumed is a teardown outcome and not an abandoned shutdown, so a name about abandoning would be false at one of the four call sites.

Registering a caller-supplied Counter is what lets the instrument be right while the storage stays process-wide: the count has to outlive the task (see PubSubShutdownResidue), and a cumulative count of events is a counter by the naming convention.

The mutators throw. Nothing calls them: a metric group only registers the instance and reporters only read getCount() — incrementing is done by the teardowns, through the adder PubSubShutdownResidue hands them. A silent no-op would hide a caller that believed it was counting something.

  • Constructor Details

    • ResidueCounter

      public ResidueCounter(LongAdder residue)
      Creates the view.
      Parameters:
      residue - the adder the teardowns count into
  • Method Details

    • inc

      public void inc()
      Specified by:
      inc in interface org.apache.flink.metrics.Counter
    • inc

      public void inc(long n)
      Specified by:
      inc in interface org.apache.flink.metrics.Counter
    • dec

      public void dec()
      Specified by:
      dec in interface org.apache.flink.metrics.Counter
    • dec

      public void dec(long n)
      Specified by:
      dec in interface org.apache.flink.metrics.Counter
    • getCount

      public long getCount()
      Specified by:
      getCount in interface org.apache.flink.metrics.Counter