}
allocs.addTo(nodeId, 1);
}
Table table = getTableWithHeader(request);
for (NodeStats nodeStats : stats.getNodes()) {
DiscoveryNode node = nodeStats.getNode();
int shardCount = 0;
if (allocs.containsKey(node.id())) {
shardCount = allocs.lget();
}
ByteSizeValue total = nodeStats.getFs().getTotal().getTotal();
ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable();
//if we don't know how much we use (non data nodes), it means 0
long used = 0;
short diskPercent = -1;
if (total.bytes() > 0) {
used = total.bytes() - avail.bytes();
if (used >= 0 && avail.bytes() >= 0) {
diskPercent = (short) (used * 100 / (used + avail.bytes()));
}
}
table.startRow();
table.addCell(shardCount);
table.addCell(used < 0 ? null : new ByteSizeValue(used));
table.addCell(avail.bytes() < 0 ? null : avail);
table.addCell(total.bytes() < 0 ? null : total);
table.addCell(diskPercent < 0 ? null : diskPercent);
table.addCell(node.getHostName());
table.addCell(node.getHostAddress());
table.addCell(node.name());
table.endRow();
}
if (allocs.containsKey("UNASSIGNED")) {
table.startRow();
table.addCell(allocs.lget());
table.addCell(null);
table.addCell(null);
table.addCell(null);
table.addCell(null);
table.addCell(null);
table.addCell(null);
table.addCell("UNASSIGNED");
table.endRow();
}
return table;
}