Source:
<code>public boolean apply(ServerConfiguration conf, CliFlags cmdFlags) { ClientConfiguration clientConf = new ClientConfiguration(conf); clientConf.setDiskWeightBasedPlacementEnabled(true); try (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 true; } System.out.println("Free disk space info:"); long totalFree = 0, total = 0; Map<String, BookieInfoReader.BookieInfo> dedupedMap = map.entrySet() .stream() .map(e -> { BookieInfoReader.BookieInfo bInfo = e.getValue(); BookieSocketAddress bookieId = e.getKey(); <START> System.out.println(CommandHelpers.getBookieSocketAddrStringRepresentation(bookieId) <END> + ":\tFree: " + bInfo.getFreeDiskSpace() + getReadable(bInfo.getFreeDiskSpace()) + "\tTotal: " + bInfo.getTotalDiskSpace() + getReadable(bInfo.getTotalDiskSpace())); return e; }) .collect( Collectors.toMap( entry -> entry.getKey().getHostName(), entry -> entry.getValue(), (key1, key2) -> key2 )); for (BookieInfoReader.BookieInfo bookieInfo : dedupedMap.values()) { totalFree += bookieInfo.getFreeDiskSpace(); total += bookieInfo.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 true; } catch (IOException | InterruptedException | BKException e) { e.printStackTrace(); } return true; }</code><technical_language>is a good practice output data in 'map' if do streams API code</technical_language>

Target:
public boolean apply(ServerConfiguration conf, CliFlags cmdFlags) { ClientConfiguration clientConf = new ClientConfiguration(conf); clientConf.setDiskWeightBasedPlacementEnabled(true); try (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 true; } 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(CommandHelpers.getBookieSocketAddrStringRepresentation(bookieId) + ":\tFree: " + bInfo.getFreeDiskSpace() + getReadable(bInfo.getFreeDiskSpace()) + "\tTotal: " + bInfo.getTotalDiskSpace() + getReadable(bInfo.getTotalDiskSpace())); } Map<String, BookieInfo> dedupedMap = map.entrySet() .stream() .collect(Collectors.toMap( entry -> entry.getKey().getHostName(), entry -> entry.getValue(), (key1, key2) -> key2 )); for (BookieInfo bookieInfo : dedupedMap.values()) { totalFree += bookieInfo.getFreeDiskSpace(); total += bookieInfo.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 true; } catch (IOException | InterruptedException | BKException e) { e.printStackTrace(); } return true; }