Table tab = new Table(3);
tab.addCell("Exchange");
tab.addCell("Config. Type");
tab.addCell("Remark");
List<String> fixed_ex = new ZNode(ZNODE_FIXED).getChildren();
for(String name: fixed_ex) {
ZooKeeperInfo.Exchange.Builder builder = ZooKeeperInfo.Exchange.newBuilder();
TextFormat.merge(new String(new ZNode(ZNODE_FIXED + "/" + name).getContent()), builder);
tab.addCell("{queue,topic}:" + name);
tab.addCell("Fixed", new CellStyle(HorizontalAlign.center));
tab.addCell(builder.build().getHost());
}
List<String> drop_ex = new ZNode(ZNODE_DROP).getChildren();
for(String name : drop_ex) {
ZooKeeperInfo.DropConfig.Builder drop_builder = ZooKeeperInfo.DropConfig.newBuilder();
TextFormat.merge(new String(new ZNode(ZNODE_DROP + "/" + name).getContent()), drop_builder);
tab.addCell(name);
tab.addCell("Drop Polocy", new CellStyle(HorizontalAlign.center));
tab.addCell(drop_builder.build().getPolicy() == DropConfig.Policy.NEWEST ? "newest": "oldest");
}
List<String> limit_ex = new ZNode(ZNODE_LIMIT).getChildren();
for(String name : limit_ex) {
ZooKeeperInfo.TotalLimit.Builder limit_builder = ZooKeeperInfo.TotalLimit.newBuilder();
TextFormat.merge(new String(new ZNode(ZNODE_LIMIT + "/" + name).getContent()), limit_builder);
tab.addCell(name);
tab.addCell("Maximum limit", new CellStyle(HorizontalAlign.center));
ZooKeeperInfo.TotalLimit limit = limit_builder.build();
tab.addCell(String.format("%d bytes / %d messages", limit.getSizeBytes(), limit.getCount()));
}
List<String> alert_limit_ex = new ZNode(ZNODE_ALERT_LIMIT).getChildren();
for(String name : alert_limit_ex) {
ZooKeeperInfo.AlertConfig.Builder alert_limit_builder = ZooKeeperInfo.AlertConfig.newBuilder();
TextFormat.merge(new ZNode(ZNODE_ALERT_LIMIT + "/" + name).getContentString(), alert_limit_builder);
ZooKeeperInfo.AlertConfig alertConfig = alert_limit_builder.build();
tab.addCell(name);
tab.addCell("Alert limit", new CellStyle(HorizontalAlign.center));
tab.addCell(String.format("%d messages to %s", alertConfig.getCount(), alertConfig.getReceiver()));
}