presto-main/src/main/java/io/prestosql/execution/scheduler/TopologyAwareNodeSelectorFactory.java/TopologyAwareNodeSelectorFactory/createNodeSelector
class TopologyAwareNodeSelectorFactory:    @Override
    public NodeSelector createNodeSelector(Optional<CatalogName> catalogName)
    {
        requireNonNull(catalogName, "catalogName is null");

        // this supplier is thread-safe. TODO: this logic should probably move to the scheduler since the choice of which node to run in should be
        // done as close to when the the split is about to be scheduled
        Supplier<NodeMap> nodeMap = Suppliers.memoizeWithExpiration(
                () -> createNodeMap(catalogName),
                5, TimeUnit.SECONDS);

        return new TopologyAwareNodeSelector(
                nodeManager,
                nodeTaskMap,
                includeCoordinator,
                nodeMap,
                minCandidates,
                maxSplitsPerNode,
                maxPendingSplitsPerTask,
                placementCounters,
                networkTopology);
    }