Commit f0530196 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Simplify getStatsString methods.

parent 5ad9518d
......@@ -817,24 +817,20 @@ public class DocumentStore {
/** Returns a string with statistics on document storage operations. */
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ")
.append(FormattingUtils.formatDecimalNumber(listOperations))
.append(" list operations performed\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(listedFiles))
.append(" files listed\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(storedFiles))
.append(" files stored\n");
sb.append(" ").append(FormattingUtils.formatBytes(storedBytes))
.append(" stored\n");
sb.append(" ")
.append(FormattingUtils.formatDecimalNumber(retrievedFiles))
.append(" files retrieved\n");
sb.append(" ").append(FormattingUtils.formatBytes(retrievedBytes))
.append(" retrieved\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(removedFiles))
.append(" files removed\n");
return sb.toString();
return String.format(" %s list operations performed\n"
+ " %s files listed\n"
+ " %s files stored\n"
+ " %s stored\n"
+ " %s files retrieved\n"
+ " %s retrieved\n"
+ " %s files removed\n",
FormattingUtils.formatDecimalNumber(listOperations),
FormattingUtils.formatDecimalNumber(listedFiles),
FormattingUtils.formatDecimalNumber(storedFiles),
FormattingUtils.formatBytes(storedBytes),
FormattingUtils.formatDecimalNumber(retrievedFiles),
FormattingUtils.formatBytes(retrievedBytes),
FormattingUtils.formatDecimalNumber(removedFiles));
}
}
......@@ -172,14 +172,11 @@ public class ClientsStatusUpdater implements DescriptorListener,
for (SortedSet<ClientsHistory> hist : this.newResponses.values()) {
newIntervals += hist.size();
}
StringBuilder sb = new StringBuilder();
sb.append(" ")
.append(FormattingUtils.formatDecimalNumber(newIntervals / 2))
.append(" client statistics processed from extra-info descriptors\n");
sb.append(" ")
.append(FormattingUtils.formatDecimalNumber(this.newResponses.size()))
.append(" client status files updated\n");
return sb.toString();
return String.format(
" %s client statistics processed from extra-info descriptors\n"
+ " %s client status files updated\n",
FormattingUtils.formatDecimalNumber(newIntervals / 2),
FormattingUtils.formatDecimalNumber(this.newResponses.size()));
}
}
......@@ -358,12 +358,11 @@ public class LookupService {
/** Returns a string with the number of addresses looked up and
* resolved. */
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
addressesLookedUp)).append(" addresses looked up\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
addressesResolved)).append(" addresses resolved\n");
return sb.toString();
return String.format(
" %s addresses looked up\n"
+ " %s addresses resolved\n",
FormattingUtils.formatDecimalNumber(addressesLookedUp),
FormattingUtils.formatDecimalNumber(addressesResolved));
}
}
......@@ -951,12 +951,10 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
@Override
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
relayConsensusesProcessed)).append(" relay consensuses processed\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
bridgeStatusesProcessed)).append(" bridge statuses processed\n");
return sb.toString();
return String.format(" %s relay consensuses processed\n"
+ " %s bridge statuses processed\n",
FormattingUtils.formatDecimalNumber(relayConsensusesProcessed),
FormattingUtils.formatDecimalNumber(bridgeStatusesProcessed));
}
}
......@@ -176,17 +176,13 @@ public class UptimeStatusUpdater implements DescriptorListener,
@Override
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.newRelayStatuses.size())).append(" hours of relay uptimes ")
.append("processed\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.newBridgeStatuses.size())).append(" hours of bridge uptimes ")
.append("processed\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.newRunningRelays.size() + this.newRunningBridges.size()))
.append(" uptime status files updated\n");
return sb.toString();
return String.format(" %s hours of relay uptimes processed\n"
+ " %s hours of bridge uptimes processed\n"
+ " %s uptime status files updated\n",
FormattingUtils.formatDecimalNumber(this.newRelayStatuses.size()),
FormattingUtils.formatDecimalNumber(this.newBridgeStatuses.size()),
FormattingUtils.formatDecimalNumber(
this.newRunningRelays.size() + this.newRunningBridges.size()));
}
}
......@@ -113,10 +113,8 @@ public class ClientsDocumentWriter implements DocumentWriter {
@Override
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.writtenDocuments)).append(" clients document files updated\n");
return sb.toString();
return String.format(" %s clients document files updated\n",
FormattingUtils.formatDecimalNumber(this.writtenDocuments));
}
}
......@@ -113,12 +113,10 @@ public class SummaryDocumentWriter implements DocumentWriter {
@Override
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.writtenDocuments)).append(" summary document files written\n");
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.deletedDocuments)).append(" summary document files deleted\n");
return sb.toString();
return String.format(" %s summary document files written\n"
+ " %s summary document files deleted\n",
FormattingUtils.formatDecimalNumber(this.writtenDocuments),
FormattingUtils.formatDecimalNumber(this.deletedDocuments));
}
}
......@@ -238,10 +238,8 @@ public class UptimeDocumentWriter implements DocumentWriter {
@Override
public String getStatsString() {
StringBuilder sb = new StringBuilder();
sb.append(" ").append(FormattingUtils.formatDecimalNumber(
this.writtenDocuments)).append(" uptime document files written\n");
return sb.toString();
return String.format(" %s uptime document files written\n",
FormattingUtils.formatDecimalNumber(this.writtenDocuments));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment