AHeise commented on a change in pull request #16345:
URL: https://github.com/apache/flink/pull/16345#discussion_r663943034
##########
File path:
flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/RpcSystem.java
##########
@@ -25,7 +25,7 @@
* This interface serves as a factory interface for RPC services, with some
additional utilities
* that are reliant on implementation details of the RPC service.
*/
-public interface RpcSystem extends RpcSystemUtils {
+public interface RpcSystem extends RpcSystemUtils, AutoCloseable {
Review comment:
I'd actually always go for `Closeable` unless you need to throw checked
exceptions beyond `IOException`.
The practical implications are actually quite small except that you can use
Guava's `Closer` only with `Closeables` but there may also other code that
still requires the more specific interface.
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/util/MetricUtilsTest.java
##########
@@ -84,23 +83,8 @@ public void
testStartMetricActorSystemRespectsThreadPriority() throws Exception
configuration, "localhost", RpcSystemLoader.load());
try {
- // dirty reflection code to avoid ClassCastExceptions
- final Method getActorSystem =
rpcService.getClass().getMethod("getActorSystem");
- final Object actorSystem = getActorSystem.invoke(rpcService);
-
- final Method settingsMethod =
actorSystem.getClass().getMethod("settings");
- final Object settings = settingsMethod.invoke(actorSystem);
-
- final Method configMethod =
settings.getClass().getMethod("config");
- final Object config = configMethod.invoke(settings);
-
- final Method getIntMethod = config.getClass().getMethod("getInt",
String.class);
- getIntMethod.setAccessible(true);
final int threadPriority =
- (int)
- getIntMethod.invoke(
- config,
"akka.actor.default-dispatcher.thread-priority");
-
+ rpcService.execute(() ->
Thread.currentThread().getPriority()).get();
Review comment:
👍
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/minicluster/MiniCluster.java
##########
@@ -1069,7 +1069,7 @@ private void terminateMiniClusterServices() throws
Exception {
}
try {
- rpcSystem.cleanup();
+ rpcSystem.close();
Review comment:
Here this whole block would be a few lines of code with Guava `Closer`.
--
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]