Parallel Aggregator
Challenge on lesson: Checkpoint: Async & HTTP
CHALLENGE
Difficulty: intermediate+25 XP
Build Solution:
- interface Shard { int fetch(String key); } — a data shard.
- static int totalFromAll(List<Shard> shards, String key) — call every
shard (sequentially is fine), treating a shard that throws
RuntimeException as contributing 0 (fault isolation).
- static CompletableFuture<Integer> asyncTotal(List<Shard> shards,
String key) — same semantics via completedFuture/thenApply chains with
one exceptionally per shard, joined with allOf + sum.
Failures in one shard must not poison the others — that's the contract.
Press Submit to check your solution.
Back to lesson: Checkpoint: Async & HTTP