JMXTabularAttribute.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:jmxfetch 作者:
private Object getValue(String key, String subAttribute) throws AttributeNotFoundException,
        InstanceNotFoundException,
        MBeanException, ReflectionException, IOException {

    try{
        Object value = this.getJmxValue();
        String attributeType = getAttribute().getType();

        TabularData data = (TabularData) value;
        for (Object rowKey : data.keySet()) {
            Collection keys = (Collection) rowKey;
            String pathKey = getMultiKey(keys);
            if (key.equals(pathKey)) {
                CompositeData compositeData = data.get(keys.toArray());
                if (subAttribute.contains(".")) {
                    // walk down the path
                    Object o;
                    for (String subPathKey : subAttribute.split("\\.")) {
                        o = compositeData.get(subPathKey);
                        if (o instanceof CompositeData) {
                            compositeData = (CompositeData) o;
                        } else {
                            return compositeData.get(subPathKey);
                        }
                    }
                } else {
                    return compositeData.get(subAttribute);
                }
            }
        }
    }
    catch (InvalidKeyException e){
        LOGGER.warn("`"+getAttribute().getName()+"` attribute does not have a `"+subAttribute+"` key.");
        return null;
    }

    throw new NumberFormatException();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号