Java Code Examples for org.apache.commons.io.FileUtils#copyDirectoryToDirectory()

The following examples show how to use org.apache.commons.io.FileUtils#copyDirectoryToDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccumuloInstanceDriver.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Copies the HADOOP_HOME bin directory to the {@link MiniAccumuloCluster} temp directory.
 * {@link MiniAccumuloCluster} expects to find bin/winutils.exe in the MAC temp
 * directory instead of HADOOP_HOME for some reason.
 * @throws IOException
 */
private void copyHadoopHomeToTemp() throws IOException {
    if (IS_COPY_HADOOP_HOME_ENABLED && SystemUtils.IS_OS_WINDOWS) {
        final String hadoopHomeEnv = PathUtils.clean(System.getenv("HADOOP_HOME"));
        if (hadoopHomeEnv != null) {
            final File hadoopHomeDir = new File(hadoopHomeEnv);
            if (hadoopHomeDir.exists()) {
                final File binDir = Paths.get(hadoopHomeDir.getAbsolutePath(), "/bin").toFile();
                if (binDir.exists()) {
                    FileUtils.copyDirectoryToDirectory(binDir, tempDir);
                } else {
                    log.warn("The specified path for the Hadoop bin directory does not exist: " + binDir.getAbsolutePath());
                }
            } else {
                log.warn("The specified path for HADOOP_HOME does not exist: " + hadoopHomeDir.getAbsolutePath());
            }
        } else {
            log.warn("The HADOOP_HOME environment variable was not found.");
        }
    }
}
 
Example 2
Source File: HtrModel.java    From TranskribusCore with GNU General Public License v3.0 6 votes vote down vote up
public void persistFiles() throws IOException{
	final File modelDir = new File(HtrUtils.MODEL_PATH + modelName);
	if(baseDir.getAbsolutePath().equals(modelDir.getAbsolutePath())){
		logger.info("Model is already stored...");
		return;
	}
	logger.info("Storing model at: " + modelDir.getAbsolutePath());
	FileUtils.copyFileToDirectory(dict, modelDir);
	FileUtils.copyFileToDirectory(hmmList, modelDir);
	FileUtils.copyFileToDirectory(netSlfFile, modelDir);
	FileUtils.copyFileToDirectory(projMat, modelDir);
	FileUtils.copyFileToDirectory(trainInfo, modelDir);
	FileUtils.copyFileToDirectory(labelsMlf, modelDir);
	FileUtils.copyFileToDirectory(trainText, modelDir);
	FileUtils.copyDirectoryToDirectory(hmmDir, modelDir);
	this.baseDir = modelDir;
	this.baseDirPath = this.baseDir.getAbsolutePath();
	loadModel(modelDir);
}
 
Example 3
Source File: FTPArtifactHandlerImpl.java    From azure-gradle-plugins with MIT License 6 votes vote down vote up
private void doCopyResourceToStageDirectory(final FTPResource resource) {
    File file  = new File(resource.getSourcePath());
    if (!file.exists()) {
        logger.quiet(resource.getSourcePath() + " configured in deployment.resources does not exist.");
        return;
    }
    File destination = new File(Paths.get(getDeploymentStageDirectory(), resource.getTargetPath()).toString());
    try {
        if (file.isFile()) {
            FileUtils.copyFileToDirectory(file, destination);
        } else if (file.isDirectory()) {
            FileUtils.copyDirectoryToDirectory(file, destination);
        }
    } catch (IOException e) {
        logger.quiet("exception when copy resource: " + e.getLocalizedMessage());
    }
}
 
Example 4
Source File: AccumuloInstanceDriver.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Copies the HADOOP_HOME bin directory to the {@link MiniAccumuloCluster} temp directory.
 * {@link MiniAccumuloCluster} expects to find bin/winutils.exe in the MAC temp
 * directory instead of HADOOP_HOME for some reason.
 * @throws IOException
 */
private void copyHadoopHomeToTemp() throws IOException {
    if (IS_COPY_HADOOP_HOME_ENABLED && SystemUtils.IS_OS_WINDOWS) {
        final String hadoopHomeEnv = PathUtils.clean(System.getenv("HADOOP_HOME"));
        if (hadoopHomeEnv != null) {
            final File hadoopHomeDir = new File(hadoopHomeEnv);
            if (hadoopHomeDir.exists()) {
                final File binDir = Paths.get(hadoopHomeDir.getAbsolutePath(), "/bin").toFile();
                if (binDir.exists()) {
                    FileUtils.copyDirectoryToDirectory(binDir, tempDir);
                } else {
                    log.warn("The specified path for the Hadoop bin directory does not exist: " + binDir.getAbsolutePath());
                }
            } else {
                log.warn("The specified path for HADOOP_HOME does not exist: " + hadoopHomeDir.getAbsolutePath());
            }
        } else {
            log.warn("The HADOOP_HOME environment variable was not found.");
        }
    }
}
 
Example 5
Source File: FileOptions.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
public static void moveDirectory(String source, String destination) {
    File sourceFile = new File(source);
    File destFile = new File(destination);
    try {
        if (sourceFile.exists()) {
            FileUtils.copyDirectoryToDirectory(sourceFile, destFile.getParentFile());
            FileUtils.deleteDirectory(sourceFile);
        }
    } catch (IOException ex) {
        Logger.getLogger(FileOptions.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 6
Source File: DebugTomcat.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    setupDebugEnv();

    int port = 7070;
    if (args.length >= 1) {
        port = Integer.parseInt(args[0]);
    }

    File webBase = new File("../webapp/app");
    File webInfDir = new File(webBase, "WEB-INF");
    FileUtils.deleteDirectory(webInfDir);
    FileUtils.copyDirectoryToDirectory(new File("../server/src/main/webapp/WEB-INF"), webBase);

    Tomcat tomcat = new Tomcat();
    tomcat.setPort(port);
    tomcat.setBaseDir(".");

    // Add AprLifecycleListener
    StandardServer server = (StandardServer) tomcat.getServer();
    AprLifecycleListener listener = new AprLifecycleListener();
    server.addLifecycleListener(listener);

    Context webContext = tomcat.addWebapp("/kylin", webBase.getAbsolutePath());
    ErrorPage notFound = new ErrorPage();
    notFound.setErrorCode(404);
    notFound.setLocation("/index.html");
    webContext.addErrorPage(notFound);
    webContext.addWelcomeFile("index.html");

    // tomcat start
    tomcat.start();
    tomcat.getServer().await();
}
 
Example 7
Source File: ResumeGenerator.java    From jresume with MIT License 5 votes vote down vote up
public File writeResume(String json, String theme) throws Exception {
        if (json == null) {
            json = readJSONFromFile();
        }
        String html = generateResumeHTML(json, theme);
        File location = runtime.getOutputHtmlFile();
        if (!location.exists()) {
            location.getParentFile().mkdirs();
        }
        ;
        FileWriter writer = new FileWriter(location, false);
        writer.write(html);
        writer.close();
        //System.out.println(html);

        System.out.println("Success! You can find your resume at " + runtime.getOutputHtmlFile().getAbsolutePath());
//        createPDF(runtime.getOutputHtmlFile().getAbsolutePath());
        if (!newResourceFolder.getAbsolutePath().toString().equals(Paths.get(runtime.getOutputDirectory().getAbsolutePath().toString(), "resources").toString())) {
            FileUtils.copyDirectoryToDirectory(newResourceFolder, runtime.getOutputDirectory());
        }

        File outputFile;
        if (runtime.getWebRequestType() == WEBREQUEST_TYPE.PDF) {
            createPDF(runtime.getOutputHtmlFile().getAbsolutePath(), runtime);
            outputFile = runtime.getOutputHtmlFile("output.pdf");
        } else {
            createInlineHTML(runtime);
            outputFile = runtime.getOutputHtmlFile("resume_inline.html");
        }
        System.out.println("Output File: " + outputFile.getAbsolutePath());
        return outputFile;
    }
 
Example 8
Source File: IOHelper.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
public static void copyDirectoryToDirectory(File source, File target) {
    try {
        FileUtils.copyDirectoryToDirectory(source, target);
    } catch (Exception e) {
        logger.error("Problem occured while copying {} to {}", source, target, e);
    }
}
 
Example 9
Source File: DirectJsonQueryRequestFacetingEmbeddedTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  final String sourceHome = ExternalPaths.SOURCE_HOME;

  final File tempSolrHome = LuceneTestCase.createTempDir().toFile();
  FileUtils.copyFileToDirectory(new File(sourceHome, "server/solr/solr.xml"), tempSolrHome);
  final File collectionDir = new File(tempSolrHome, COLLECTION_NAME);
  FileUtils.forceMkdir(collectionDir);
  final File configSetDir = new File(sourceHome, "server/solr/configsets/sample_techproducts_configs/conf");
  FileUtils.copyDirectoryToDirectory(configSetDir, collectionDir);

  final Properties props = new Properties();
  props.setProperty("name", COLLECTION_NAME);

  try (Writer writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collectionDir, "core.properties")),
      "UTF-8");) {
    props.store(writer, null);
  }

  final String config = tempSolrHome.getAbsolutePath() + "/" + COLLECTION_NAME + "/conf/solrconfig.xml";
  final String schema = tempSolrHome.getAbsolutePath() + "/" + COLLECTION_NAME + "/conf/managed-schema";
  initCore(config, schema, tempSolrHome.getAbsolutePath(), COLLECTION_NAME);

  client = new EmbeddedSolrServer(h.getCoreContainer(), COLLECTION_NAME) {
    @Override
    public void close() {
      // do not close core container
    }
  };

  ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
  up.setParam("collection", COLLECTION_NAME);
  up.addFile(getFile("solrj/techproducts.xml"), "application/xml");
  up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
  UpdateResponse updateResponse = up.process(client);
  assertEquals(0, updateResponse.getStatus());
}
 
Example 10
Source File: FileHelper.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
/**
 * 拷贝一个目录
 *
 * @param dir
 * @param copy
 * @param includeDir    是否包含dir目录
 * @return
 */
public static boolean copyDir(File dir, File copy, boolean includeDir) {
    try {
        if(includeDir){
            FileUtils.copyDirectoryToDirectory(dir,copy);
        }else{
            FileUtils.copyDirectory(dir,copy);
        }
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return copy.exists();
}
 
Example 11
Source File: FileOptions.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
public static void copyDirectory(String source, String destination) {
    File sourceFile = new File(source);
    File destFile = new File(destination);
    try {
        if (sourceFile.exists()) {
            FileUtils.copyDirectoryToDirectory(sourceFile, destFile);
        }
    } catch (IOException ex) {
        Logger.getLogger(FileOptions.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 12
Source File: ImportWorker.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
/**
 * If imported version does not have an existing "themes" folder then
 * copies any existing "*_theme" folders or files from "mods" to "themes".
 */
private void migrateModThemes() throws IOException {
    final Path targetPath = MagicFileSystem.getDataPath(MagicFileSystem.DataPath.THEMES);
    File[] modThemes = importDataPath.resolve("mods").toFile().listFiles(MODS_THEME_FILE_FILTER);
    for (File themeFile : modThemes) {
        if (themeFile.isDirectory()) {
            FileUtils.copyDirectoryToDirectory(themeFile, targetPath.toFile());
        } else {
            FileUtils.copyFileToDirectory(themeFile, targetPath.toFile());
        }
    }
}
 
Example 13
Source File: ResumeGenerator.java    From jresume with MIT License 5 votes vote down vote up
public File writeResume(String json, String theme) throws Exception {
        if (json == null) {
            json = readJSONFromFile();
        }
        String html = generateResumeHTML(json, theme);
        File location = runtime.getOutputHtmlFile();
        if (!location.exists()) {
            location.getParentFile().mkdirs();
        }
        ;
        FileWriter writer = new FileWriter(location, false);
        writer.write(html);
        writer.close();
        //System.out.println(html);

        System.out.println("Success! You can find your resume at " + runtime.getOutputHtmlFile().getAbsolutePath());
//        createPDF(runtime.getOutputHtmlFile().getAbsolutePath());
        if (!newResourceFolder.getAbsolutePath().toString().equals(Paths.get(runtime.getOutputDirectory().getAbsolutePath().toString(), "resources").toString())) {
            FileUtils.copyDirectoryToDirectory(newResourceFolder, runtime.getOutputDirectory());
        }

        File outputFile;
        if (runtime.getWebRequestType() == WEBREQUEST_TYPE.PDF) {
            createPDF(runtime.getOutputHtmlFile().getAbsolutePath(), runtime);
            outputFile = runtime.getOutputHtmlFile("output.pdf");
        } else {
            createInlineHTML(runtime);
            outputFile = runtime.getOutputHtmlFile("resume_inline.html");
        }
        System.out.println("Output File: " + outputFile.getAbsolutePath());
        return outputFile;
    }
 
Example 14
Source File: NativeBinaryExportOperation.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void execute(IProgressMonitor monitor) throws CoreException,
		InvocationTargetException, InterruptedException {
	SubMonitor sm = SubMonitor.convert(monitor);
	sm.setWorkRemaining(delegates.size()*10);
	for (AbstractNativeBinaryBuildDelegate delegate : delegates) {
		if(monitor.isCanceled()){ 
			break; 
		}
		delegate.setRelease(true);
		delegate.buildNow(sm.newChild(10));
		try {
			File buildArtifact = delegate.getBuildArtifact();
			File destinationFile = new File(destinationDir, buildArtifact.getName());
			if(destinationFile.exists()){
				String callback = overwriteQuery.queryOverwrite(destinationFile.toString());
				if(IOverwriteQuery.NO.equals(callback)){
					continue;
				}
				if(IOverwriteQuery.CANCEL.equals(callback)){
					break;
				}
			}
			File artifact = delegate.getBuildArtifact();
			if(artifact.isDirectory()){
				FileUtils.copyDirectoryToDirectory(artifact, destinationDir);
			}else{
				FileUtils.copyFileToDirectory(artifact, destinationDir);
			}
			sm.done();
		} catch (IOException e) {
			HybridCore.log(IStatus.ERROR, "Error on NativeBinaryExportOperation", e);
		}
	}
	monitor.done(); 
}
 
Example 15
Source File: FileUtil.java    From bbs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**  
   * 复制目录
   *  
   * @param resDirPath 源目录路径  
   * @param distFolder  目标文件夹  
   * @IOException 当操作发生异常时抛出  
   */   
  public static void copyDirectory(String resDirPath, String distFolder) throws IOException {  
  	
      File copyDir = new File(PathUtil.path()+File.separator+resDirPath);   
      File distFile = new File(PathUtil.path()+File.separator+(distFolder == null || "".equals(distFolder.trim()) ? "" :distFolder+File.separator)); 
 
if (copyDir.isDirectory()) { 
	FileUtils.copyDirectoryToDirectory(copyDir, distFile);   
      }

  }
 
Example 16
Source File: Environment.java    From desktop with GNU General Public License v3.0 5 votes vote down vote up
public void copyResourcesRecursively(URL originUrl, File destination) throws Exception {
    URLConnection urlConnection = originUrl.openConnection();
    if (urlConnection instanceof JarURLConnection) {
        copyResourcesFromJar((JarURLConnection) urlConnection, destination);
    } else if (urlConnection instanceof FileURLConnection) {
        // I know that this is not so beatiful... I'll try to change in a future...
        if (operatingSystem == OperatingSystem.Mac || operatingSystem == OperatingSystem.Linux) {
            destination = defaultUserConfDir;
        }
        FileUtils.copyDirectoryToDirectory(new File(originUrl.getPath()), destination);
    } else {
        throw new Exception("URLConnection[" + urlConnection.getClass().getSimpleName() +
                "] is not a recognized/implemented connection type.");
    }
}
 
Example 17
Source File: YarnTestBase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@AfterClass
public static void teardown() throws Exception {

	LOG.info("Stopping MiniYarn Cluster");
	yarnCluster.stop();

	// Unset FLINK_CONF_DIR, as it might change the behavior of other tests
	Map<String, String> map = new HashMap<>(System.getenv());
	map.remove(ConfigConstants.ENV_FLINK_CONF_DIR);
	map.remove("YARN_CONF_DIR");
	map.remove("IN_TESTS");
	TestBaseUtils.setEnv(map);

	if (tempConfPathForSecureRun != null) {
		FileUtil.fullyDelete(tempConfPathForSecureRun);
		tempConfPathForSecureRun = null;
	}

	// When we are on travis, we copy the temp files of JUnit (containing the MiniYARNCluster log files)
	// to <flinkRoot>/target/flink-yarn-tests-*.
	// The files from there are picked up by the ./tools/travis_watchdog.sh script
	// to upload them to Amazon S3.
	if (isOnTravis()) {
		File target = new File("../target" + YARN_CONFIGURATION.get(TEST_CLUSTER_NAME_KEY));
		if (!target.mkdirs()) {
			LOG.warn("Error creating dirs to {}", target);
		}
		File src = tmp.getRoot();
		LOG.info("copying the final files from {} to {}", src.getAbsolutePath(), target.getAbsolutePath());
		try {
			FileUtils.copyDirectoryToDirectory(src, target);
		} catch (IOException e) {
			LOG.warn("Error copying the final files from {} to {}: msg: {}", src.getAbsolutePath(), target.getAbsolutePath(), e.getMessage(), e);
		}
	}

}
 
Example 18
Source File: DirectoryWatcherOnDiskTest.java    From directory-watcher with Apache License 2.0 4 votes vote down vote up
private void copyAndVerifyEvents(List<Path> structure) throws IOException {
  try {
    FileUtils.copyDirectoryToDirectory(structure.get(0).toFile(), tmpDir.toFile());
    await()
        .atMost(5, TimeUnit.SECONDS)
        .untilAsserted(
            () ->
                assertTrue(
                    "Create event for the parent directory was notified",
                    existsMatch(
                        e ->
                            e.eventType() == DirectoryChangeEvent.EventType.CREATE
                                && e.path()
                                    .getFileName()
                                    .equals(structure.get(0).getFileName()))));

    await()
        .atMost(5, TimeUnit.SECONDS)
        .untilAsserted(
            () ->
                assertTrue(
                    "Create event for the child file was notified",
                    existsMatch(
                        e ->
                            e.eventType() == DirectoryChangeEvent.EventType.CREATE
                                && e.path()
                                    .getFileName()
                                    .equals(structure.get(1).getFileName()))));

    await()
        .atMost(5, TimeUnit.SECONDS)
        .untilAsserted(
            () ->
                assertTrue(
                    "Create event for the child file was notified",
                    existsMatch(
                        e ->
                            e.eventType() == DirectoryChangeEvent.EventType.CREATE
                                && e.path()
                                    .getFileName()
                                    .equals(structure.get(2).getFileName()))));
  } finally {
    /* unfortunately this deletion does not simulate 'real' deletion by the user, as it
     * deletes all the files underneath. You can stop the execution of the test here and
     * delete the folder by hand and then continue with the test.
     */
    FileUtils.deleteDirectory(tmpDir.toFile().listFiles()[0]);
  }
}
 
Example 19
Source File: SolrCLI.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
protected void runImpl(CommandLine cli) throws Exception {
  String solrUrl = cli.getOptionValue("solrUrl", DEFAULT_SOLR_URL);
  if (!solrUrl.endsWith("/"))
    solrUrl += "/";

  File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
  if (!configsetsDir.isDirectory())
    throw new FileNotFoundException(configsetsDir.getAbsolutePath() + " not found!");

  String configSet = cli.getOptionValue("confdir", DEFAULT_CONFIG_SET);
  File configSetDir = new File(configsetsDir, configSet);
  if (!configSetDir.isDirectory()) {
    // we allow them to pass a directory instead of a configset name
    File possibleConfigDir = new File(configSet);
    if (possibleConfigDir.isDirectory()) {
      configSetDir = possibleConfigDir;
    } else {
      throw new FileNotFoundException("Specified config directory " + configSet +
          " not found in " + configsetsDir.getAbsolutePath());
    }
  }

  String coreName = cli.getOptionValue(NAME);

  String systemInfoUrl = solrUrl+"admin/info/system";
  CloseableHttpClient httpClient = getHttpClient();
  String solrHome = null;
  try {
    Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2, true);
    if ("solrcloud".equals(systemInfo.get("mode"))) {
      throw new IllegalStateException("Solr at "+solrUrl+
          " is running in SolrCloud mode, please use create_collection command instead.");
    }

    // convert raw JSON into user-friendly output
    solrHome = (String)systemInfo.get("solr_home");
    if (solrHome == null)
      solrHome = configsetsDir.getParentFile().getAbsolutePath();

  } finally {
    closeHttpClient(httpClient);
  }

  String coreStatusUrl = solrUrl+"admin/cores?action=STATUS&core="+coreName;
  if (safeCheckCoreExists(coreStatusUrl, coreName)) {
    throw new IllegalArgumentException("\nCore '"+coreName+
        "' already exists!\nChecked core existence using Core API command:\n"+coreStatusUrl);
  }

  File coreInstanceDir = new File(solrHome, coreName);
  File confDir = new File(configSetDir,"conf");
  if (!coreInstanceDir.isDirectory()) {
    coreInstanceDir.mkdirs();
    if (!coreInstanceDir.isDirectory())
      throw new IOException("Failed to create new core instance directory: "+coreInstanceDir.getAbsolutePath());

    if (confDir.isDirectory()) {
      FileUtils.copyDirectoryToDirectory(confDir, coreInstanceDir);
    } else {
      // hmmm ... the configset we're cloning doesn't have a conf sub-directory,
      // we'll just assume it is OK if it has solrconfig.xml
      if ((new File(configSetDir, "solrconfig.xml")).isFile()) {
        FileUtils.copyDirectory(configSetDir, new File(coreInstanceDir, "conf"));
      } else {
        throw new IllegalArgumentException("\n"+configSetDir.getAbsolutePath()+" doesn't contain a conf subdirectory or solrconfig.xml\n");
      }
    }
    echoIfVerbose("\nCopying configuration to new core instance directory:\n" + coreInstanceDir.getAbsolutePath(), cli);
  }

  String createCoreUrl =
      String.format(Locale.ROOT,
          "%sadmin/cores?action=CREATE&name=%s&instanceDir=%s",
          solrUrl,
          coreName,
          coreName);

  echoIfVerbose("\nCreating new core '" + coreName + "' using command:\n" + createCoreUrl + "\n", cli);

  try {
    Map<String,Object> json = getJson(createCoreUrl);
    if (cli.hasOption("verbose")) {
      CharArr arr = new CharArr();
      new JSONWriter(arr, 2).write(json);
      echo(arr.toString());
      echo("\n");
    } else {
      echo(String.format(Locale.ROOT, "\nCreated new core '%s'", coreName));
    }
  } catch (Exception e) {
    /* create-core failed, cleanup the copied configset before propagating the error. */
    FileUtils.deleteDirectory(coreInstanceDir);
    throw e;
  }
}
 
Example 20
Source File: YarnTestBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void teardown() throws Exception {

	if (yarnCluster != null) {
		LOG.info("Stopping MiniYarn Cluster");
		yarnCluster.stop();
		yarnCluster = null;
	}

	if (miniDFSCluster != null) {
		LOG.info("Stopping MiniDFS Cluster");
		miniDFSCluster.shutdown();
		miniDFSCluster = null;
	}

	// Unset FLINK_CONF_DIR, as it might change the behavior of other tests
	Map<String, String> map = new HashMap<>(System.getenv());
	map.remove(ConfigConstants.ENV_FLINK_CONF_DIR);
	map.remove("YARN_CONF_DIR");
	map.remove("IN_TESTS");
	TestBaseUtils.setEnv(map);

	if (tempConfPathForSecureRun != null) {
		FileUtil.fullyDelete(tempConfPathForSecureRun);
		tempConfPathForSecureRun = null;
	}

	if (yarnSiteXML != null) {
		yarnSiteXML.delete();
	}

	if (hdfsSiteXML != null) {
		hdfsSiteXML.delete();
	}

	// When we are on CI, we copy the temp files of JUnit (containing the MiniYARNCluster log files)
	// to <flinkRoot>/target/flink-yarn-tests-*.
	// The files from there are picked up by the tools/ci/* scripts to upload them.
	if (isOnCI()) {
		File target = new File("../target" + YARN_CONFIGURATION.get(TEST_CLUSTER_NAME_KEY));
		if (!target.mkdirs()) {
			LOG.warn("Error creating dirs to {}", target);
		}
		File src = tmp.getRoot();
		LOG.info("copying the final files from {} to {}", src.getAbsolutePath(), target.getAbsolutePath());
		try {
			FileUtils.copyDirectoryToDirectory(src, target);
		} catch (IOException e) {
			LOG.warn("Error copying the final files from {} to {}: msg: {}", src.getAbsolutePath(), target.getAbsolutePath(), e.getMessage(), e);
		}
	}

}