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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the framework's already-committed-committables counter.static final StringName of the framework's failed-committables counter.static final StringName of the framework's retried-committables counter.static final StringName of the framework's successful-committables counter.static final StringName of the framework's arrived-committables counter, as a reporter sees it.Fields inherited from class org.apache.flink.runtime.metrics.groups.ProxyMetricGroup
parentMetricGroup -
Method Summary
Modifier and TypeMethodDescriptionfinal longcounterValue(String... identifier) Returns the counter registered underidentifier, relative to the group.static TestSinkCommitterMetricGroupcreate()Creates a group over a fresh listener.final <T> TgaugeValue(String... identifier) Returns the value of the gauge registered underidentifier.org.apache.flink.metrics.Gauge<Integer>The gauge a committer passed tosetCurrentPendingCommittablesGauge(org.apache.flink.metrics.Gauge<java.lang.Integer>), or null.org.apache.flink.metrics.groups.OperatorIOMetricGrouporg.apache.flink.metrics.Counterorg.apache.flink.metrics.Counterorg.apache.flink.metrics.Counterorg.apache.flink.metrics.Counterorg.apache.flink.metrics.Counterfinal booleanWhether any metric is registered underidentifier— the assertion a metric that may legitimately be absent needs, since "not registered" is not "registered at zero".final org.apache.flink.metrics.CounterregisteredCounter(String... identifier) Returns the counter registered underidentifieritself — 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.voidsetCurrentPendingCommittablesGauge(org.apache.flink.metrics.Gauge<Integer> currentPendingCommittablesGauge) Methods inherited from class org.apache.flink.runtime.metrics.groups.ProxyMetricGroup
addEvent, addGroup, addGroup, addSpan, counter, counter, gauge, getAllVariables, getMetricIdentifier, getMetricIdentifier, getScopeComponents, histogram, meterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.metrics.MetricGroup
addEvent, addGroup, addGroup, addGroup, addSpan, counter, counter, counter, counter, gauge, gauge, getAllVariables, getMetricIdentifier, getMetricIdentifier, getScopeComponents, histogram, histogram, meter, meter
-
Field Details
-
TOTAL_COMMITTABLES
Name of the framework's arrived-committables counter, as a reporter sees it.- See Also:
-
SUCCESSFUL_COMMITTABLES
Name of the framework's successful-committables counter.- See Also:
-
ALREADY_COMMITTED_COMMITTABLES
Name of the framework's already-committed-committables counter.- See Also:
-
FAILED_COMMITTABLES
Name of the framework's failed-committables counter.- See Also:
-
RETRIED_COMMITTABLES
Name of the framework's retried-committables counter.- See Also:
-
-
Method Details
-
create
Creates a group over a fresh listener. -
getCurrentPendingCommittablesGauge
The gauge a committer passed tosetCurrentPendingCommittablesGauge(org.apache.flink.metrics.Gauge<java.lang.Integer>), or null. -
getNumCommittablesTotalCounter
public org.apache.flink.metrics.Counter getNumCommittablesTotalCounter()- Specified by:
getNumCommittablesTotalCounterin interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
getNumCommittablesFailureCounter
public org.apache.flink.metrics.Counter getNumCommittablesFailureCounter()- Specified by:
getNumCommittablesFailureCounterin interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
getNumCommittablesRetryCounter
public org.apache.flink.metrics.Counter getNumCommittablesRetryCounter()- Specified by:
getNumCommittablesRetryCounterin interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
getNumCommittablesSuccessCounter
public org.apache.flink.metrics.Counter getNumCommittablesSuccessCounter()- Specified by:
getNumCommittablesSuccessCounterin interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
getNumCommittablesAlreadyCommittedCounter
public org.apache.flink.metrics.Counter getNumCommittablesAlreadyCommittedCounter()- Specified by:
getNumCommittablesAlreadyCommittedCounterin interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
setCurrentPendingCommittablesGauge
public void setCurrentPendingCommittablesGauge(org.apache.flink.metrics.Gauge<Integer> currentPendingCommittablesGauge) - Specified by:
setCurrentPendingCommittablesGaugein interfaceorg.apache.flink.metrics.groups.SinkCommitterMetricGroup
-
getIOMetricGroup
public org.apache.flink.metrics.groups.OperatorIOMetricGroup getIOMetricGroup()- Specified by:
getIOMetricGroupin interfaceorg.apache.flink.metrics.groups.OperatorMetricGroup
-
counterValue
Returns the counter registered underidentifier, 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
Returns the counter registered underidentifieritself — 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
Whether any metric is registered underidentifier— the assertion a metric that may legitimately be absent needs, since "not registered" is not "registered at zero". -
gaugeValue
Returns the value of the gauge registered underidentifier.- 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
-