Arsnael commented on code in PR #1707:
URL: https://github.com/apache/james-project/pull/1707#discussion_r1323885328
##########
mailbox/tools/quota-recompute/src/main/java/org/apache/james/mailbox/quota/task/RecomputeCurrentQuotasService.java:
##########
@@ -91,97 +86,95 @@ public List<QuotaComponent> getQuotaComponents() {
public static class Context {
static class Snapshot {
- private final long processedQuotaRootCount;
- private final ImmutableList<QuotaRoot> failedQuotaRoots;
-
- private Snapshot(long processedQuotaRootCount,
ImmutableList<QuotaRoot> failedQuotaRoots) {
- this.processedQuotaRootCount = processedQuotaRootCount;
- this.failedQuotaRoots = failedQuotaRoots;
- }
+ private final List<RecomputeSingleQuotaComponentResult>
recomputeSingleQuotaComponentResults;
- long getProcessedQuotaRootCount() {
- return processedQuotaRootCount;
+ private Snapshot(List<RecomputeSingleQuotaComponentResult>
results) {
+ this.recomputeSingleQuotaComponentResults = results;
}
- ImmutableList<QuotaRoot> getFailedQuotaRoots() {
- return failedQuotaRoots;
+ public List<RecomputeSingleQuotaComponentResult> getResults() {
+ return recomputeSingleQuotaComponentResults;
}
@Override
public final boolean equals(Object o) {
if (o instanceof Snapshot) {
Snapshot that = (Snapshot) o;
- return Objects.equals(this.processedQuotaRootCount,
that.processedQuotaRootCount)
- && Objects.equals(this.failedQuotaRoots,
that.failedQuotaRoots);
+ return
Objects.equals(this.recomputeSingleQuotaComponentResults,
that.recomputeSingleQuotaComponentResults);
}
return false;
}
@Override
public final int hashCode() {
- return Objects.hash(processedQuotaRootCount, failedQuotaRoots);
+ return Objects.hash(recomputeSingleQuotaComponentResults);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
- .add("processedQuotaRootCount", processedQuotaRootCount)
- .add("failedQuotaRoots", failedQuotaRoots)
+ .add("results", recomputeSingleQuotaComponentResults)
.toString();
}
}
- private final AtomicLong processedQuotaRootCount;
- private final ConcurrentLinkedDeque<QuotaRoot> failedQuotaRoots;
+ public static class Statistic {
+ private final AtomicLong processedIdentifierCount;
+ private final ConcurrentLinkedDeque<String> failedIdentifiers;
- public Context() {
- this.processedQuotaRootCount = new AtomicLong();
- this.failedQuotaRoots = new ConcurrentLinkedDeque<>();
+ public Statistic(AtomicLong processedIdentifierCount,
ConcurrentLinkedDeque<String> failedIdentifiers) {
+ this.processedIdentifierCount = processedIdentifierCount;
+ this.failedIdentifiers = failedIdentifiers;
+ }
+
+ public Statistic(long processedQuotaRootCount, Collection<String>
failedQuotaRoots) {
+ this.processedIdentifierCount = new
AtomicLong(processedQuotaRootCount);
+ this.failedIdentifiers = new
ConcurrentLinkedDeque<>(failedQuotaRoots);
+ }
+
+ void incrementProcessed() {
+ processedIdentifierCount.incrementAndGet();
+ }
+
+ void addToFailedIdentifiers(String identifier) {
+ failedIdentifiers.add(identifier);
+ }
}
- public Context(long processedQuotaRootCount, Collection<QuotaRoot>
failedQuotaRoots) {
- this.processedQuotaRootCount = new
AtomicLong(processedQuotaRootCount);
- this.failedQuotaRoots = new
ConcurrentLinkedDeque<>(failedQuotaRoots);
+ private Map<QuotaComponent, Statistic> map;
Review Comment:
maybe a better identifier than `map`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]