Skip to content

Commit

Permalink
[FLINK-23658][metrics][jmx] Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
zentol committed Aug 23, 2021
1 parent 2b90aea commit 48f531d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ public class JMXReporter implements MetricReporter {

private static final Logger LOG = LoggerFactory.getLogger(JMXReporter.class);

private static final CharacterFilter CHARACTER_FILTER =
new CharacterFilter() {
@Override
public String filterCharacters(String input) {
return replaceInvalidChars(input);
}
};
private static final CharacterFilter CHARACTER_FILTER = JMXReporter::replaceInvalidChars;

// ------------------------------------------------------------------------

Expand Down Expand Up @@ -120,7 +114,7 @@ public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup gr
try {
jmxName = new ObjectName(domain, table);
} catch (MalformedObjectNameException e) {
/**
/*
* There is an implementation error on our side if this occurs. Either the domain was
* modified and no longer conforms to the JMX domain rules or the table wasn't properly
* generated.
Expand Down Expand Up @@ -278,7 +272,7 @@ public interface JmxCounterMBean extends MetricMBean {
}

private static class JmxCounter extends AbstractBean implements JmxCounterMBean {
private Counter counter;
private final Counter counter;

JmxCounter(Counter counter) {
this.counter = counter;
Expand Down Expand Up @@ -310,6 +304,7 @@ public Object getValue() {
}

/** The MBean interface for an exposed histogram. */
@SuppressWarnings("unused")
public interface JmxHistogramMBean extends MetricMBean {
long getCount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,11 @@ public void testPortConflictHandling() throws Exception {
rep1.notifyOfRemovedMetric(g2, "rep2", null);
}

/**
* Verifies that we can connect to multiple JMXReporters running on the same machine.
*
* @throws Exception
*/
/** Verifies that we can connect to multiple JMXReporters running on the same machine. */
@Test
public void testJMXAvailability() throws Exception {
final MetricReporter rep1 = new JMXReporter("9040-9055");
final MetricReporter rep2 = new JMXReporter("9040-9055");
final JMXReporter rep1 = new JMXReporter("9040-9055");
final JMXReporter rep2 = new JMXReporter("9040-9055");

Gauge<Integer> g1 = () -> 1;
Gauge<Integer> g2 = () -> 2;
Expand All @@ -166,9 +162,9 @@ public void testJMXAvailability() throws Exception {
JMXServiceURL url1 =
new JMXServiceURL(
"service:jmx:rmi:https://localhost:"
+ ((JMXReporter) rep1).getPort().get()
+ rep1.getPort().get()
+ "/jndi/rmi:https://localhost:"
+ ((JMXReporter) rep1).getPort().get()
+ rep1.getPort().get()
+ "/jmxrmi");
JMXConnector jmxCon1 = JMXConnectorFactory.connect(url1);
MBeanServerConnection mCon1 = jmxCon1.getMBeanServerConnection();
Expand All @@ -181,9 +177,9 @@ public void testJMXAvailability() throws Exception {
JMXServiceURL url2 =
new JMXServiceURL(
"service:jmx:rmi:https://localhost:"
+ ((JMXReporter) rep2).getPort().get()
+ rep2.getPort().get()
+ "/jndi/rmi:https://localhost:"
+ ((JMXReporter) rep2).getPort().get()
+ rep2.getPort().get()
+ "/jmxrmi");
JMXConnector jmxCon2 = JMXConnectorFactory.connect(url2);
MBeanServerConnection mCon2 = jmxCon2.getMBeanServerConnection();
Expand Down

0 comments on commit 48f531d

Please sign in to comment.