class_docstr: Controls a stand-alone Spark cluster for integration tests.
  Tests can run forked, but not in parallel.
  Multiple controller instances would restart each other's masters.
class_docstr_tok: ["Controls","a","stand-alone","Spark","cluster","for","integration","tests",".","Tests","can","run","forked",",","but","not","in","parallel",".","Multiple","controller","instances","would","restart","each","other","'s","masters","."]
docstr: Makes the cluster provide the given hosts only.
  
  Any host currently provided that is not in the given hosts will be shut down.
  This does not allow for changes in the number of slots.
docstr_tok: ["Makes","the","cluster","provide","the","given","hosts","only",".","Any","host","currently","provided","that","is","not","in","the","given","hosts","will","be","shut","down",".","This","does","not","allow","for","changes","in","the","number","of","slots","."]
code: def provide_hosts(self, hosts):
      """Makes the cluster provide the given hosts only.
  
      Any host currently provided that is not in the given hosts will be shut down.
      This does not allow for changes in the number of slots.
      """
      logging.debug("make Spark cluster provide hosts %s", hosts)
  
      # shut down missing works first
      for host in self._host_worker.copy():
          if host not in hosts:
              in_thread(
                  self.stop_worker, args=(self._host_worker[host],)
              )
              del self._host_worker[host]
  
      # start new workers
      threads = []
      for host in hosts:
          if host not in self._host_worker:
              cores = int(host.split(":", 1)[1])
              instance = self._next_worker_instance
              threads.append(
                  in_thread(
                      self.start_or_restart_worker,
                      args=(instance, cores),
                  )
              )
              self._host_worker[host] = instance
              self._next_worker_instance += 1
      for thread in threads:
          thread.join(5)
  
imports: from __future__ import absolute_import
  import contextlib
  import json
  import logging
  import os
  import re
  import sys
  import threading
  import time
  import warnings
  import mock
  from parameterized import parameterized
  import pytest
  import unittest
  from horovod.runner.util.threads import in_thread
  from horovod.runner.common.util import safe_shell_exec, tiny_shell_exec
  from horovod.spark import conf, run_elastic
  from common import temppath
label_desc: Use image node_id 10 for calling the SparkClusterController obj's underlying member method code with example usage: obj.provide_hosts(hosts) without return types