@Test public void read() throws Exception { final MBeanGroup mbg = new MBeanGroup(obj_name, NamedResolverMap.EMPTY); test_value.setBoolval(true); test_value.setIntval(7); test_value.setStringval("foobar"); test_value.getNested().setDblval(17); Metric[] metrics = mbg.getMetrics(jmx.getConnection(threadpool).get().get().getMBeanServerConnection()).get().getMetrics(); Map<MetricName, MetricValue> metrics_map = Arrays.stream(metrics).collect(Collectors.toMap(Metric::getName, Metric::getValue)); assertThat(metrics_map, allOf( hasEntry(MetricName.valueOf("Boolval"), MetricValue.TRUE), hasEntry(MetricName.valueOf("Intval"), MetricValue.fromIntValue(7)), hasEntry(MetricName.valueOf("Nested", "dblval"), MetricValue.fromDblValue(17)), hasEntry(MetricName.valueOf("Stringval"), MetricValue.fromStrValue("foobar")))); }
public Optional<MetricGroup> getMetrics(MBeanServerConnection conn) { MBeanAttributeInfo[] attributes; try { attributes = conn.getMBeanInfo(obj_name_).getAttributes(); } catch (InstanceNotFoundException ex) { return Optional.empty(); } catch (IntrospectionException | ReflectionException | IOException ex) { LOG.log(Level.WARNING, "failed to load properties on " + obj_name_, ex); return Optional.empty(); } return Optional.of(new SimpleMetricGroup( getName(), Arrays.stream(attributes) .map(MBeanAttributeInfo::getName) .distinct() .flatMap(attribute -> resolve_(conn, attribute)) .map(m -> new SimpleMetric(m.getKey(), m.getValue())))); }
MBeanGroup { public Optional<MetricGroup> getMetrics(MBeanServerConnection conn) { MBeanAttributeInfo[] attributes; try { attributes = conn.getMBeanInfo(obj_name_).getAttributes(); } catch (InstanceNotFoundException ex) { return Optional.empty(); } catch (IntrospectionException | ReflectionException | IOException ex) { LOG.log(Level.WARNING, "failed to load properties on " + obj_name_, ex); return Optional.empty(); } return Optional.of(new SimpleMetricGroup( getName(), Arrays.stream(attributes) .map(MBeanAttributeInfo::getName) .distinct() .flatMap(attribute -> resolve_(conn, attribute)) .map(m -> new SimpleMetric(m.getKey(), m.getValue())))); } }
MBeanGroup { public Optional<MetricGroup> getMetrics(MBeanServerConnection conn) { MBeanAttributeInfo[] attributes; try { attributes = conn.getMBeanInfo(obj_name_).getAttributes(); } catch (InstanceNotFoundException ex) { return Optional.empty(); } catch (IntrospectionException | ReflectionException | IOException ex) { LOG.log(Level.WARNING, "failed to load properties on " + obj_name_, ex); return Optional.empty(); } return Optional.of(new SimpleMetricGroup( getName(), Arrays.stream(attributes) .map(MBeanAttributeInfo::getName) .distinct() .flatMap(attribute -> resolve_(conn, attribute)) .map(m -> new SimpleMetric(m.getKey(), m.getValue())))); } MBeanGroup(GroupName name, ObjectName obj_name);  MBeanGroup(ObjectName obj_name, NamedResolverMap resolvedMap); }
MBeanGroup { public Optional<MetricGroup> getMetrics(MBeanServerConnection conn) { MBeanAttributeInfo[] attributes; try { attributes = conn.getMBeanInfo(obj_name_).getAttributes(); } catch (InstanceNotFoundException ex) { return Optional.empty(); } catch (IntrospectionException | ReflectionException | IOException ex) { LOG.log(Level.WARNING, "failed to load properties on " + obj_name_, ex); return Optional.empty(); } return Optional.of(new SimpleMetricGroup( getName(), Arrays.stream(attributes) .map(MBeanAttributeInfo::getName) .distinct() .flatMap(attribute -> resolve_(conn, attribute)) .map(m -> new SimpleMetric(m.getKey(), m.getValue())))); } MBeanGroup(GroupName name, ObjectName obj_name);  MBeanGroup(ObjectName obj_name, NamedResolverMap resolvedMap); Optional<MetricGroup> getMetrics(MBeanServerConnection conn); GroupName getName(); ObjectName getMonitoredMBeanName(); }
MBeanGroup { public Optional<MetricGroup> getMetrics(MBeanServerConnection conn) { MBeanAttributeInfo[] attributes; try { attributes = conn.getMBeanInfo(obj_name_).getAttributes(); } catch (InstanceNotFoundException ex) { return Optional.empty(); } catch (IntrospectionException | ReflectionException | IOException ex) { LOG.log(Level.WARNING, "failed to load properties on " + obj_name_, ex); return Optional.empty(); } return Optional.of(new SimpleMetricGroup( getName(), Arrays.stream(attributes) .map(MBeanAttributeInfo::getName) .distinct() .flatMap(attribute -> resolve_(conn, attribute)) .map(m -> new SimpleMetric(m.getKey(), m.getValue())))); } MBeanGroup(GroupName name, ObjectName obj_name);  MBeanGroup(ObjectName obj_name, NamedResolverMap resolvedMap); Optional<MetricGroup> getMetrics(MBeanServerConnection conn); GroupName getName(); ObjectName getMonitoredMBeanName();  }