通过TelnetClient获取Zookeeper监控数据(3)

private Long translateStrToLong(String value) {
        if (org.apache.commons.lang.StringUtils.isAlphanumeric(value)) {
            return Long.valueOf(value);
        }
        return 0L;
    }

private Map<String, String> parseTelnetResult(String rs) {
        //The output contains multiple lines with the following format:
        //key \t value
        String[] resultArray = rs.split("\n");
        Map<String, String> resultMap = new HashMap<String, String>();
        for (String recordLine : resultArray) {
            String[] recordKeyValue = recordLine.split("\t");
            LOGGER.debug("############recordKeyValue.size:" + recordKeyValue.length + " recordKeyValue:" + Arrays.toString(recordKeyValue));
            if (recordKeyValue != null && recordKeyValue.length == 2) {
                resultMap.put(recordKeyValue[0], recordKeyValue[1]);
            }
        }
        return resultMap;
    }


    public static void main(String[] args) {
        System.out.println(new ZookeeperDataProvider().extractMonitorData());
    }

}

--------------------------------------分割线 --------------------------------------

Ubuntu 14.04安装分布式存储Sheepdog+ZooKeeper 

CentOS 6安装sheepdog 虚拟机分布式储存 

ZooKeeper集群配置

使用ZooKeeper实现分布式共享锁

分布式服务框架 ZooKeeper -- 管理分布式环境中的数据

ZooKeeper集群环境搭建实践

ZooKeeper服务器集群环境配置实测

ZooKeeper集群安装

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/991f8042ac5151dde4afc038b26f21a2.html