}
public String getColumnText(Object element, int columnIndex) {
if (element instanceof InstanceStatsAndInfo) {
InstanceStatsAndInfo statsAndInfo = (InstanceStatsAndInfo) element;
InstanceStats stats = statsAndInfo.getStats();
Usage usage = stats.getUsage();
double cpu = 0.0;
String memory = "0M"; //$NON-NLS-1$
String disk = "0M"; //$NON-NLS-1$
if (usage != null) {
cpu = usage.getCpu();
memory = getFormattedMemory(usage.getMem() / 1024);
disk = getFormattedMemory(usage.getDisk() / 1024);
}
switch (columnIndex) {
case 0:
return stats.getId();
case 1:
return stats.getHost();
case 2:
return stats.getPort() + ""; //$NON-NLS-1$
case 3:
return String.valueOf(cpu) + "% (" + String.valueOf(stats.getCores()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case 4:
return memory + " (" + getFormattedMemory(stats.getMemQuota() / 1024) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case 5:
return disk + " (" + getFormattedMemory(stats.getDiskQuota() / 1024) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case 6:
return getFormattedDuration(Math.round(stats.getUptime()));
}
}
return null;
}