/** * 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(); }
/** * 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(); }
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); } } } }
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); } } } }
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; }
/** * 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); } } } } }
public static Map<String, BeanInfo> getMBeanInfo(JmxCollection collection) { final Map<String, BeanInfo> map = new HashMap<String, BeanInfo>(); if (collection == null) { return Collections.unmodifiableMap(map); } for (Mbean mbean : collection.getMbeans()) { BeanInfo beanInfo = new BeanInfo(); beanInfo.setMbeanName(mbean.getName()); beanInfo.setObjectName(mbean.getObjectname()); beanInfo.setKeyField(mbean.getKeyfield()); beanInfo.setExcludes(mbean.getExclude()); beanInfo.setKeyAlias(mbean.getKeyAlias()); List<String> attribNameList = new ArrayList<String>(); List<String> compAttribNameList = new ArrayList<String>(); for (CompAttrib myCa : mbean.getCompAttribList()) { for (CompMember myCm : myCa.getCompMemberList()) { attribNameList.add(myCa.getName() + "|" + myCm.getName()); compAttribNameList.add(myCa.getName() + "|" + myCm.getName()); } } for (Attrib myA : mbean.getAttribList()) { attribNameList.add(myA.getName()); } beanInfo.setAttributes(attribNameList); beanInfo.setCompositeAttributes(compAttribNameList); map.put(mbean.getObjectname(), beanInfo); } return Collections.unmodifiableMap(map); }
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; }
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; }
/** * 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); } } } } }
private Collection<Report> generateCompositeMemberReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (CompAttrib compAttrib : mbean.getCompAttribList()) { for (CompMember compMember : compAttrib.getCompMemberList()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + compAttrib.getName() + "." + compMember.getName() + "." + COMPOSITATTRIBEREPORT; Report report = new Report(reportId, reportId, reportId, "verticalLabel"); report.addGraph(new Graph(compMember.getAlias(), compMember.getName(), compMember.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); reports.add(report); Colors.resetColor(); } } return reports; } }
private Collection<Report> generateCompositeMemberReportsByMBean(Mbean mbean) { Collection<Report> reports = new ArrayList<>(); for (CompAttrib compAttrib : mbean.getCompAttribList()) { for (CompMember compMember : compAttrib.getCompMemberList()) { String reportId = StringUtils.deleteWhitespace(mbean.getName()) + "." + compAttrib.getName() + "." + compMember.getName() + "." + COMPOSITATTRIBEREPORT; Report report = new Report(reportId, reportId, reportId, "verticalLabel"); report.addGraph(new Graph(compMember.getAlias(), compMember.getName(), compMember.getAlias(), Colors.getNextColor(), Colors.getNextColor(), Colors.getNextColor())); reports.add(report); Colors.resetColor(); } } return reports; } }
/** * 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; }
/** * 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; }
if (!cloneCompAtt.getCompMemberList().isEmpty()) { exportBean.addCompAttrib(cloneCompAtt);
if (!cloneCompAtt.getCompMemberList().isEmpty()) { exportBean.addCompAttrib(cloneCompAtt);