Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -1144,6 +1145,7 @@ public static class MetricName implements Comparable<MetricName>
private final String name;
private final String scope;
private final String mBeanName;
private volatile ObjectName objectName;
private final String systemViewName;

/**
Expand Down Expand Up @@ -1299,25 +1301,26 @@ public boolean hasScope()
*/
public ObjectName getMBeanName()
{

String mname = mBeanName;

if (mname == null)
mname = getMetricName();
ObjectName local = objectName;
if (local != null)
return local;

try
{
Hashtable<String, String> props = new Hashtable<>(4);
if (scope != null)
props.put("scope", scope);

return new ObjectName(mname);
} catch (MalformedObjectNameException e)
if (!name.isEmpty())
props.put("name", name);

local = new ObjectName(group, props);
objectName = local;
return local;
}
catch (MalformedObjectNameException e)
{
try
{
return new ObjectName(ObjectName.quote(mname));
} catch (MalformedObjectNameException e1)
{
throw new RuntimeException(e1);
}
throw new RuntimeException("Invalid JMX ObjectName for metric", e);
}
}

Expand Down