/** * Clones a CompAttrib object. Makes a deep copy! * * @param input * @return */ public static CompAttrib clone(CompAttrib input) { CompAttrib output = new CompAttrib(); output.setAlias(input.getAlias()); output.setName(input.getName()); output.setType(input.getType()); for (CompMember inputMember : input.getCompMemberList()) { output.addCompMember(clone(inputMember)); } return output; }
/** * Extracts all Composite members from a given composite attribute name. * * @param bean The mbean the composite attribute belongs to. * @param compAttributeName The composite attribute name. * @return A list of all Composite Members of the given composite attribute. May be empty. The list is unmodifiable. */ private List<CompMember> getCompositeMembers(Mbean bean, String compAttributeName) { for (CompAttrib eachAttrib : bean.getCompAttribList()) { if (Objects.equals(compAttributeName, eachAttrib.getName())) { List<CompMember> list = eachAttrib.getCompMemberList(); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
@Override public String render(CompAttrib input) { return input.getName(); } });
Boolean contentAdded = false; CompAttrib xmlCompAttrib = new CompAttrib(); xmlCompAttrib.setName(jmxMBeanAttributeInfo.getName()); xmlCompAttrib.setType("Composite"); xmlCompAttrib.setAlias(jmxMBeanAttributeInfo.getName()); xmlCompMember.setAlias(alias); xmlCompMember.setType(AttributeType.GAUGE); xmlCompAttrib.addCompMember(xmlCompMember);
for (CompAttrib compAtt : selectionManager.getSelectedCompositeAttributes(mbean)) { CompAttrib cloneCompAtt = JmxCollectionCloner.clone(compAtt); cloneCompAtt.clearCompMembers(); for (CompMember compMember : selectionManager.getSelectedCompositeMembers(compAtt)) { cloneCompAtt.addCompMember(JmxCollectionCloner.clone(compMember)); if (!cloneCompAtt.getCompMemberList().isEmpty()) { exportBean.addCompAttrib(cloneCompAtt);
private static void sort(List<Mbean> input) { // 1st sort the mbeans Collections.sort(input, new Comparator<Mbean>() { @Override public int compare(Mbean o1, Mbean o2) { return o1.getObjectname().compareTo(o2.getObjectname()); } }); // 2nd sort the mbean tree (attributes, composite attributes, composite members) for (Mbean eachMbean : input) { // Sort attributes final List<Attrib> attribs = new ArrayList<>(eachMbean.getAttribList()); Collections.sort(attribs); eachMbean.setAttribCollection(attribs); // sort Composite Attributes final List<CompAttrib> compAttribs = new ArrayList<>(eachMbean.getCompAttribList()); Collections.sort(compAttribs); eachMbean.setCompAttribCollection(compAttribs); // Sort Composite Members for (CompAttrib eachCompAttrib : eachMbean.getCompAttribList()) { final List<CompMember> compMembers = new ArrayList<>(eachCompAttrib.getCompMemberList()); Collections.sort(compMembers); eachCompAttrib.setCompMemberList(compMembers); } } } }
/** * The generated values for the JMX datacollection may not be correct. In detail the name/alias fields * of MBeans/Attribs/CompMembers/CompAttribs may be too long or not unique in the whole JMX datacollection. * In order to keep the usability up, this method allows to filter values retrieved from the * {@link javax.management.MBeanServerConnection} to fix naming issues. * * @param config The {@link JmxDatacollectionConfig} retrieved from the {@link javax.management.MBeanServerConnection}. */ private void applyFilters(JmxDatacollectionConfig config) { for (Mbean eachMbean : config.getJmxCollectionList().get(0).getMbeans()) { applyFilters(eachMbean); for (Attrib eachAttrib : eachMbean.getAttribList()) { applyFilters(eachAttrib); } for (CompAttrib eachCompAttrib : eachMbean.getCompAttribList()) { applyFilters(eachCompAttrib); for (CompMember eachCompMember : eachCompAttrib.getCompMemberList()) { applyFilters(eachCompMember); } } } } }
/** * Extracts all Composite members from a given composite attribute name. * * @param bean The mbean the composite attribute belongs to. * @param compAttributeName The composite attribute name. * @return A list of all Composite Members of the given composite attribute. May be empty. The list is unmodifiable. */ private List<CompMember> getCompositeMembers(Mbean bean, String compAttributeName) { for (CompAttrib eachAttrib : bean.getCompAttribList()) { if (Objects.equals(compAttributeName, eachAttrib.getName())) { List<CompMember> list = eachAttrib.getCompMemberList(); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
@Override public String render(CompAttrib input) { return input.getName(); } });
Boolean contentAdded = false; CompAttrib xmlCompAttrib = new CompAttrib(); xmlCompAttrib.setName(jmxMBeanAttributeInfo.getName()); xmlCompAttrib.setType("Composite"); xmlCompAttrib.setAlias(jmxMBeanAttributeInfo.getName()); xmlCompMember.setAlias(alias); xmlCompMember.setType(AttributeType.GAUGE); xmlCompAttrib.addCompMember(xmlCompMember);
for (CompAttrib compAtt : selectionManager.getSelectedCompositeAttributes(mbean)) { CompAttrib cloneCompAtt = JmxCollectionCloner.clone(compAtt); cloneCompAtt.clearCompMembers(); for (CompMember compMember : selectionManager.getSelectedCompositeMembers(compAtt)) { cloneCompAtt.addCompMember(JmxCollectionCloner.clone(compMember)); if (!cloneCompAtt.getCompMemberList().isEmpty()) { exportBean.addCompAttrib(cloneCompAtt);
private static void sort(List<Mbean> input) { // 1st sort the mbeans Collections.sort(input, new Comparator<Mbean>() { @Override public int compare(Mbean o1, Mbean o2) { return o1.getObjectname().compareTo(o2.getObjectname()); } }); // 2nd sort the mbean tree (attributes, composite attributes, composite members) for (Mbean eachMbean : input) { // Sort attributes final List<Attrib> attribs = new ArrayList<>(eachMbean.getAttribList()); Collections.sort(attribs); eachMbean.setAttribCollection(attribs); // sort Composite Attributes final List<CompAttrib> compAttribs = new ArrayList<>(eachMbean.getCompAttribList()); Collections.sort(compAttribs); eachMbean.setCompAttribCollection(compAttribs); // Sort Composite Members for (CompAttrib eachCompAttrib : eachMbean.getCompAttribList()) { final List<CompMember> compMembers = new ArrayList<>(eachCompAttrib.getCompMemberList()); Collections.sort(compMembers); eachCompAttrib.setCompMemberList(compMembers); } } } }
/** * The generated values for the JMX datacollection may not be correct. In detail the name/alias fields * of MBeans/Attribs/CompMembers/CompAttribs may be too long or not unique in the whole JMX datacollection. * In order to keep the usability up, this method allows to filter values retrieved from the * {@link javax.management.MBeanServerConnection} to fix naming issues. * * @param config The {@link JmxDatacollectionConfig} retrieved from the {@link javax.management.MBeanServerConnection}. */ private void applyFilters(JmxDatacollectionConfig config) { for (Mbean eachMbean : config.getJmxCollectionList().get(0).getMbeans()) { applyFilters(eachMbean); for (Attrib eachAttrib : eachMbean.getAttribList()) { applyFilters(eachAttrib); } for (CompAttrib eachCompAttrib : eachMbean.getCompAttribList()) { applyFilters(eachCompAttrib); for (CompMember eachCompMember : eachCompAttrib.getCompMemberList()) { applyFilters(eachCompMember); } } } } }
/** * Clones a CompAttrib object. Makes a deep copy! * * @param input * @return */ public static CompAttrib clone(CompAttrib input) { CompAttrib output = new CompAttrib(); output.setAlias(input.getAlias()); output.setName(input.getName()); output.setType(input.getType()); for (CompMember inputMember : input.getCompMemberList()) { output.addCompMember(clone(inputMember)); } return output; }
public static Map<String, List<Attrib>> getAttributeMap(JmxCollection collection, String aSysoid, String anAddress) { final Map<String, List<Attrib>> attributeMap = new HashMap<String, List<Attrib>>(); if (aSysoid == null) { LOG.debug("getMibObjectList: aSysoid parameter is NULL..."); return attributeMap; } if (collection == null) { return attributeMap; } for(Mbean mbean : collection.getMbeans()) { // Make sure to create a new ArrayList because we add to it below List<Attrib> list = new ArrayList<Attrib>(mbean.getAttribList()); for(CompAttrib compAttrib : mbean.getCompAttribList()) { for (CompMember compMember : compAttrib.getCompMemberList()) { Attrib attribWrapper = new Attrib(); attribWrapper.setName(compAttrib.getName() + "|" + compMember.getName()); attribWrapper.setAlias(compMember.getAlias()); attribWrapper.setType(compMember.getType()); list.add(attribWrapper); } } attributeMap.put(mbean.getObjectname(), list); } return attributeMap; }
private Collection<Report> generateCompositeReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (CompAttrib compAttrib : mbean.getCompAttribList()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + compAttrib.getName() + "." + COMPOSITEREPORT; Report report = new Report(reportId, reportId, reportId, "verticalLabel"); for (CompMember compMember : compAttrib.getCompMemberList()) { report.addGraph(new Graph(compMember.getAlias(), compMember.getName(), compMember.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); } reports.add(report); Colors.resetColor(); } return reports; }
/** * Extracts all Attribute and Composite Attribute Names * from the given MBean. * * @param bean The MBean to extract attributes from. * @return An unmodifiable list of Attribute/Composite Attribute Names. */ private List<String> extractAttributeNames(Mbean bean) { List<String> attributes = new ArrayList<>(); for (Attrib eachAttrib : bean.getAttribList()) { attributes.add(eachAttrib.getName()); } for (CompAttrib eachCompAttrib : bean.getCompAttribList()) { attributes.add(eachCompAttrib.getName()); } return Collections.unmodifiableList(attributes); }
private Collection<Report> generateCompositeReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (CompAttrib compAttrib : mbean.getCompAttribList()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + compAttrib.getName() + "." + COMPOSITEREPORT; Report report = new Report(reportId, reportId, reportId, "verticalLabel"); for (CompMember compMember : compAttrib.getCompMemberList()) { report.addGraph(new Graph(compMember.getAlias(), compMember.getName(), compMember.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); } reports.add(report); Colors.resetColor(); } return reports; }
/** * Extracts all Attribute and Composite Attribute Names * from the given MBean. * * @param bean The MBean to extract attributes from. * @return An unmodifiable list of Attribute/Composite Attribute Names. */ private List<String> extractAttributeNames(Mbean bean) { List<String> attributes = new ArrayList<>(); for (Attrib eachAttrib : bean.getAttribList()) { attributes.add(eachAttrib.getName()); } for (CompAttrib eachCompAttrib : bean.getCompAttribList()) { attributes.add(eachCompAttrib.getName()); } return Collections.unmodifiableList(attributes); }