Bläddra i källkod

[test] Skip cleanup of pseudo HDFS tmp dir if $MINI_CLUSTER_CLEANUP is `false'.

bc Wong 13 år sedan
förälder
incheckning
acec8dd1fb
1 ändrade filer med 9 tillägg och 2 borttagningar
  1. 9 2
      desktop/libs/hadoop/src/hadoop/pseudo_hdfs4.py

+ 9 - 2
desktop/libs/hadoop/src/hadoop/pseudo_hdfs4.py

@@ -32,6 +32,9 @@ TEST_USER_GROUP_MAPPING = {
 # How long we're willing to wait for the cluster to start
 STARTUP_DEADLINE = 60.0
 
+# Whether to cleanup afterwards
+CLEANUP_TMP_DIR = os.environ.get("MINI_CLUSTER_CLEANUP", 'true')
+
 
 class PseudoHdfs4(object):
   """This class runs HDFS (CDH4) locally, in pseudo-distributed mode"""
@@ -100,8 +103,12 @@ class PseudoHdfs4(object):
     self._nn_proc = None
     self._dn_proc = None
 
-    LOG.info('Cleaning up temp directory "%s"' % (self._tmpdir,))
-    shutil.rmtree(self._tmpdir)
+    if CLEANUP_TMP_DIR == 'false':
+      LOG.info('Skipping cleanup of temp directory "%s"' % (self._tmpdir,))
+    else:
+      LOG.info('Cleaning up temp directory "%s". '
+               'Use $MINI_CLUSTER_CLEANUP to avoid.' % (self._tmpdir,))
+      shutil.rmtree(self._tmpdir)
 
     if self.shutdown_hook is not None:
       self.shutdown_hook()