Skip to content

Commit

Permalink
changed way to count suites for aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
plutasnyy committed Aug 28, 2018
1 parent 47acf66 commit c1e494b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ public class SuiteAggregationCounter {

public static final String NAME_KEY = "suiteAggregationCounter";

private int suitesToAggregate;
private final int suitesToAggregate;

public SuiteAggregationCounter() {
this.suitesToAggregate = 0;
public SuiteAggregationCounter(int suitesToAggregate) {
this.suitesToAggregate = suitesToAggregate;
}

public int getSuitesToAggregate() {
return suitesToAggregate;
}

public void addSuitesToAggregate(int suitesToAggregate) {
this.suitesToAggregate += suitesToAggregate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public AllSuiteVersionsMessageBody apply(Map.Entry<String, Collection<Suite>> in
}).toList();

exchange.getOut().setBody(body);
exchange.getOut().setHeader(SuiteAggregationCounter.NAME_KEY, new SuiteAggregationCounter());
exchange.getOut().setHeader(SuiteAggregationCounter.NAME_KEY,
new SuiteAggregationCounter(allProjectSuites.size()));
exchange.getOut().setHeader(CleanerContext.KEY_NAME, cleanerContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public void process(Exchange exchange) throws Exception {
final Collection<Suite> suiteVersions = allSuiteVersions.getAllVersions();
final DBKey dbKey = allSuiteVersions.getDbKey();

SuiteAggregationCounter suiteAggregationCounter = exchange.getIn()
.getHeader(SuiteAggregationCounter.NAME_KEY, SuiteAggregationCounter.class);
suiteAggregationCounter.addSuitesToAggregate(suiteVersions.size());

LOGGER.info("Processing suite `{}` with {} version(s) in {}", allSuiteVersions.getData(),
suiteVersions.size(), dbKey);

Expand All @@ -68,8 +64,8 @@ public SuiteMessageBody apply(Suite suite) {
}).toList();

exchange.getOut().setBody(body);
exchange.getOut().setHeader(SuiteAggregationCounter.NAME_KEY,
suiteAggregationCounter);
exchange.getOut().setHeader(SuiteAggregationCounter.NAME_KEY, exchange.getIn()
.getHeader(SuiteAggregationCounter.NAME_KEY, SuiteAggregationCounter.class));
exchange.getOut().setHeader(CleanerContext.KEY_NAME, cleanerContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ private boolean isFirstAggregation(Exchange oldExchange) {
public void onCompletion(Exchange exchange) {
ReferencedArtifactsMessageBody body = exchange.getIn()
.getBody(ReferencedArtifactsMessageBody.class);
LOGGER.debug("Finished aggregating {}", body.getData());
LOGGER.debug("Finished aggregating {}", body.getDbKey());
}
}

0 comments on commit c1e494b

Please sign in to comment.