You are going to asynchronously precompute some statistics about product sets. Whenever a product set is scheduled for precomputation, it produces a new PrecomputationTask
which is inserted into the queue.
There are several precomputation nodes which should endlessly poll queue for new tasks and consume them by running a given precomputation task.
-
Finish implementation of
PrecomputationNode
andPrecomputationNodeManager
. Precomputation should be done in the background on severalPrecomputationNodes
. Exact amount of nodes is defined bynodesAmount
parameter in thestartPrecomputationNodes
method. -
Finish implementation of the
PrecomputationQueue
class. Precomputation tasks should be always processed in order, prioritized by cause:ProductSet
which was computed at least onceProductSet
which was never computed
If both product sets have the same cause, you should break ties by:
- Importance of a product set - lower value means that a product set should be processed earlier.
- If importance is also equal, you should follow the order of scheduling (First In, First Out).
- Consider thread safety.
- Producer and consumer share queue as a buffer, but you don't have to worry about the buffer size, because you can assume that consuming can be scaled-up to be fast enough, as the number of consumers is configurable.