KeyManagerImpl#listStatus and the sortDatanodeInPipeline helper method sort datanodes using individual RPC call for each key location info.
Problems, possible improvements:
- All location versions are processed. Would it be enough to process only the "latest" version, which is used for read?
- Each key location is queried separately, even if the same pipeline was already updated in a previous request. Could be improved by keeping track of processed pipelines.
- Further improvement may be possible by sending a single sortDatanodes request for all datanodes in all relevant pipelines, then creating the per-pipeline lists locally.