StephanEwen commented on a change in pull request #11463: FLINK-16697 - Disable
JMX rebinding
URL: https://github.com/apache/flink/pull/11463#discussion_r396670180
##########
File path:
flink-metrics/flink-metrics-jmx/src/main/java/org/apache/flink/metrics/jmx/JMXReporter.java
##########
@@ -541,5 +552,40 @@ public void stop() throws IOException {
}
}
}
+
+ /*
+ * Better to use the internal API than re-invent the wheel.
+ */
+ @SuppressWarnings("restriction")
+ private class JmxRegistry extends sun.rmi.registry.RegistryImpl
{
+ private final String lookupName;
+
+ JmxRegistry(final int port, final String lookupName)
throws RemoteException {
+ super(port);
+ this.lookupName = lookupName;
+ }
+
+ @Override
+ public Remote lookup(String s) throws RemoteException,
NotBoundException {
+ return lookupName.equals(s) ? remoteServerStub
: null;
Review comment:
The `remoteServerStub` would be null between starting the registry and
starting the server. Probably not a big issue in practice, but looks like the
separation between `startRmiRegistry()` and `startJmxService()` does not work
well here.
Looks almost like the `startJmxService()` should happen before the
`startRmiRegistry()` and then pass the stub to the registry. But I don't know
the internals of JMX well enough to judge whether this makes sense.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services