1) File is present in the filesystem of the node and it can be served to client (ask scheduler for info of the current node/peer, check current connections with maxConnections).
2) Ask scheduler for a node which can serve the requested content, an available node is found, redirect client to the node and download file locally (asynchronously) on current node for future requests (so that next requests will fall in scenario 1).
3) File is not present on any nodes, download locally (asynchronously), redirect to upstream, notify scheduler.
scenarios:
1) File is present in the filesystem of the node and it can be served to client (ask scheduler for info of the current node/peer, check current connections with maxConnections). 2) Ask scheduler for a node which can serve the requested content, an available node is found, redirect client to the node and download file locally (asynchronously) on current node for future requests (so that next requests will fall in scenario 1). 3) File is not present on any nodes, download locally (asynchronously), redirect to upstream, notify scheduler.