@Override public int runCmd(CommandLine cmdLine) throws Exception { ClientConfiguration clientConf = new ClientConfiguration(bkConf); clientConf.setDiskWeightBasedPlacementEnabled(true); BookKeeper bk = new BookKeeper(clientConf); Map<BookieSocketAddress, BookieInfo> map = bk.getBookieInfo(); if (map.size() == 0) { System.out.println("Failed to retrieve bookie information from any of the bookies"); bk.close(); return 0; } System.out.println("Free disk space info:"); long totalFree = 0, total = 0; for (Map.Entry<BookieSocketAddress, BookieInfo> e : map.entrySet()) { BookieInfo bInfo = e.getValue(); BookieSocketAddress bookieId = e.getKey(); System.out.println(getBookieSocketAddrStringRepresentation(bookieId) + ":\tFree: " + bInfo.getFreeDiskSpace() + getReadable(bInfo.getFreeDiskSpace()) + "\tTotal: " + bInfo.getTotalDiskSpace() + getReadable(bInfo.getTotalDiskSpace())); totalFree += bInfo.getFreeDiskSpace(); total += bInfo.getTotalDiskSpace(); } System.out.println("Total free disk space in the cluster:\t" + totalFree + getReadable(totalFree)); System.out.println("Total disk capacity in the cluster:\t" + total + getReadable(total)); bk.close(); return 0; } }
BookKeeper bk = new BookKeeper(clientConf); Map<BookieSocketAddress, BookieInfoReader.BookieInfo> map = bk.getBookieInfo(); if (map.size() == 0) { bk.close();