def shared_cluster(conf=False):
 cluster = shared_cluster_internal()
 closers = []
 if conf:
  closers.extend([hadoop.conf.HDFS_CLUSTERS['default'].NN_HOST.set_for_testing('localhost'), hadoop.conf.HDFS_CLUSTERS['default'].NN_HDFS_PORT.set_for_testing(cluster.namenode_port), hadoop.conf.MR_CLUSTERS['default'].HOST.set_for_testing('localhost'), hadoop.conf.MR_CLUSTERS['default'].JT_THRIFT_PORT.set_for_testing(cluster.jt.thrift_port)])
  old_caches = clear_sys_caches()
 def finish():
  if conf:
   restore_sys_caches(old_caches)
  for x in closers:
   x()
 cluster.shutdown = finish
 return cluster

def shared_cluster ( conf = False ) : cluster = shared_cluster_internal ( ) closers = [ ] if conf : closers . extend ( [ hadoop . conf . HDFS_CLUSTERS [ 'default' ] . NN_HOST . set_for_testing ( 'localhost' ) , hadoop . conf . HDFS_CLUSTERS [ 'default' ] . NN_HDFS_PORT . set_for_testing ( cluster . namenode_port ) , hadoop . conf . MR_CLUSTERS [ 'default' ] . HOST . set_for_testing ( 'localhost' ) , hadoop . conf . MR_CLUSTERS [ 'default' ] . JT_THRIFT_PORT . set_for_testing ( cluster . jt . thrift_port ) ] ) old_caches = clear_sys_caches ( ) def finish ( ) : if conf : restore_sys_caches ( old_caches ) for x in closers : x ( ) cluster . shutdown = finish return cluster
use a shared cluster that is initialized on demand .