@Test public void oneMBeanOneMetricP2PApp() throws MalformedObjectNameException, IntrospectionException, ReflectionException, AttributeNotFoundException, MBeanException, InstanceNotFoundException { ObjectName mBeanName = new ObjectName("domain", "key", "value"); names.add(mBeanName); AppType appType = AppType.P2P; ObjectName objName = new ObjectName("org.glassfish.jersey:type=P2PRestApp,subType=Resources,resource=com.quorum.tessera.*,executionTimes=RequestTimes,detail=methods,method=*"); when(mBeanServer.queryNames(objName, null)).thenReturn(names); String attributeName = "name_total"; MBeanAttributeInfo[] mBeanAttributes = {new MBeanAttributeInfo(attributeName, "type", "desc", true, false, false)}; MBeanInfo mBeanInfo = new MBeanInfo(null, null, mBeanAttributes, null, null, null); when(mBeanServer.getMBeanInfo(mBeanName)).thenReturn(mBeanInfo); when(mBeanServer.getAttribute(any(ObjectName.class), any(String.class))).thenReturn(1); List<MBeanMetric> metrics = metricsEnquirer.getMBeanMetrics(appType); assertThat(metrics.size()).isEqualTo(1); assertThat(metrics.get(0).getName()).isEqualTo("name_total"); }
public List<MBeanMetric> getMBeanMetrics(AppType appType) { List<MBeanMetric> mBeanMetrics = new ArrayList<>(); Set<ObjectName> mBeanNames; try { mBeanNames = getTesseraResourceMBeanNames(appType); for(ObjectName mBeanName : mBeanNames) { List<MBeanMetric> temp; try { temp = getMetricsForMBean(mBeanName); } catch (AttributeNotFoundException | MBeanException | InstanceNotFoundException | ReflectionException | IntrospectionException e) { throw new RuntimeException(e); } mBeanMetrics.addAll(temp); } } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } return Collections.unmodifiableList(mBeanMetrics); }
MetricsEnquirer { public List<MBeanMetric> getMBeanMetrics(AppType appType) { List<MBeanMetric> mBeanMetrics = new ArrayList<>(); Set<ObjectName> mBeanNames; try { mBeanNames = getTesseraResourceMBeanNames(appType); for(ObjectName mBeanName : mBeanNames) { List<MBeanMetric> temp; try { temp = getMetricsForMBean(mBeanName); } catch (AttributeNotFoundException | MBeanException | InstanceNotFoundException | ReflectionException | IntrospectionException e) { throw new RuntimeException(e); } mBeanMetrics.addAll(temp); } } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } return Collections.unmodifiableList(mBeanMetrics); } }
MetricsEnquirer { public List<MBeanMetric> getMBeanMetrics(AppType appType) { List<MBeanMetric> mBeanMetrics = new ArrayList<>(); Set<ObjectName> mBeanNames; try { mBeanNames = getTesseraResourceMBeanNames(appType); for(ObjectName mBeanName : mBeanNames) { List<MBeanMetric> temp; try { temp = getMetricsForMBean(mBeanName); } catch (AttributeNotFoundException | MBeanException | InstanceNotFoundException | ReflectionException | IntrospectionException e) { throw new RuntimeException(e); } mBeanMetrics.addAll(temp); } } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } return Collections.unmodifiableList(mBeanMetrics); } MetricsEnquirer(MBeanServer mBeanServer); }
MetricsEnquirer { public List<MBeanMetric> getMBeanMetrics(AppType appType) { List<MBeanMetric> mBeanMetrics = new ArrayList<>(); Set<ObjectName> mBeanNames; try { mBeanNames = getTesseraResourceMBeanNames(appType); for(ObjectName mBeanName : mBeanNames) { List<MBeanMetric> temp; try { temp = getMetricsForMBean(mBeanName); } catch (AttributeNotFoundException | MBeanException | InstanceNotFoundException | ReflectionException | IntrospectionException e) { throw new RuntimeException(e); } mBeanMetrics.addAll(temp); } } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } return Collections.unmodifiableList(mBeanMetrics); } MetricsEnquirer(MBeanServer mBeanServer); List<MBeanMetric> getMBeanMetrics(AppType appType); }
MetricsEnquirer { public List<MBeanMetric> getMBeanMetrics(AppType appType) { List<MBeanMetric> mBeanMetrics = new ArrayList<>(); Set<ObjectName> mBeanNames; try { mBeanNames = getTesseraResourceMBeanNames(appType); for(ObjectName mBeanName : mBeanNames) { List<MBeanMetric> temp; try { temp = getMetricsForMBean(mBeanName); } catch (AttributeNotFoundException | MBeanException | InstanceNotFoundException | ReflectionException | IntrospectionException e) { throw new RuntimeException(e); } mBeanMetrics.addAll(temp); } } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } return Collections.unmodifiableList(mBeanMetrics); } MetricsEnquirer(MBeanServer mBeanServer); List<MBeanMetric> getMBeanMetrics(AppType appType);  }