Skip to main content

Checkpoint: timed fan-out aggregator

Challenge on lesson: Checkpoint: The Timed Fan-Out Aggregator

Implement static List<String> aggregate(int shards) returning shard reports "shard-<i>-ok" in shard order where every even shard succeeds and every odd shard throws. Requirements: 1. Each shard runs on its own VIRTUAL thread (newVirtualThreadPerTaskExecutor), sleeping 10ms of simulated work. 2. Compose with CompletableFuture.supplyAsync(executor, ...) per shard; failures map to "shard-<i>-failed" via exceptionally. 3. The whole pipeline must complete and the list must be in shard order 0..shards-1. 4. static String executorChoice() returns exactly: "virtual threads per task: blocking work scales, CPU work still capped by cores".

Difficulty: advanced

Back to lesson: Checkpoint: The Timed Fan-Out Aggregator