peterxcli commented on code in PR #10478:
URL: https://github.com/apache/ozone/pull/10478#discussion_r3394234038
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
Review Comment:
what if we add a metrics handle for `ContainerClientMetrics`?
```java
/**
* Handle for ContainerClientMetrics.
*/
public static final class Handle implements AutoCloseable {
private final ContainerClientMetrics metrics;
private final AtomicBoolean closed = new AtomicBoolean(false);
private Handle(ContainerClientMetrics metrics) {
this.metrics = metrics;
}
public ContainerClientMetrics metrics() {
return metrics;
}
@Override
public void close() {
if (closed.compareAndSet(false, true)) {
release();
}
}
}
public static Handle acquireHandle() {
return new Handle(acquire());
}
```
so inside the `RpcClient`:
```java
public RpcClient(ConfigurationSource conf, String omServiceId) throws
IOException {
// ...
this.clientMetricsHandle = ContainerClientMetrics.acquireHandle();
this.clientMetrics = clientMetricsHandle.metrics();
// ...
}
@Override
public void close() throws IOException {
// ...
// ContainerClientMetrics.release();
clientMetricsHandle.close();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]