use of javax.management.ObjectName.WILDCARD in project presto by prestodb.
the class JmxMetadata method getJmxTableHandle.
private JmxTableHandle getJmxTableHandle(SchemaTableName tableName) {
try {
String canonicalName = new ObjectName(tableName.getTableName()).getCanonicalName();
Optional<ObjectName> objectName = mbeanServer.queryNames(WILDCARD, null).stream().filter(name -> canonicalName.equalsIgnoreCase(name.getCanonicalName())).findFirst();
if (!objectName.isPresent()) {
return null;
}
MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName.get());
ImmutableList.Builder<JmxColumnHandle> columns = ImmutableList.builder();
columns.add(new JmxColumnHandle(NODE_COLUMN_NAME, createUnboundedVarcharType()));
// Since this method is being called on all nodes in the cluster, we must ensure (by sorting)
// that attributes are in the same order on all of them.
Arrays.stream(mbeanInfo.getAttributes()).filter(MBeanAttributeInfo::isReadable).map(attribute -> new JmxColumnHandle(attribute.getName(), getColumnType(attribute))).sorted((column1, column2) -> column1.getColumnName().compareTo(column2.getColumnName())).forEach(columns::add);
return new JmxTableHandle(objectName.get().toString(), columns.build(), true);
} catch (JMException e) {
return null;
}
}
Aggregations