} catch (LogInitializationException e) { Options opts = createOptions(); CommandLine cli = new GnuParser().parse(opts, args); rootHDFSDir = HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIR); ClearDanglingScratchDir clearDanglingScratchDirMain = new ClearDanglingScratchDir(dryRun, verbose, true, rootHDFSDir, conf); clearDanglingScratchDirMain.run();
SessionState.LOCK_FILE_NAME; if (verbose) { consoleMessage(message); consoleMessage("Unexpected error:" + eCreate.getMessage()); consoleMessage("Unexpected error:" + eAppend.getMessage()); consoleMessage(message); consoleMessage("Cannot find any scratch directory to clear"); return; consoleMessage("Removing " + scratchDirToRemove.size() + " scratch directories"); for (Path scratchDir : scratchDirToRemove) { if (dryRun) { boolean succ = fs.delete(scratchDir, true); if (!succ) { consoleMessage("Cannot remove " + scratchDir); } else { String message = scratchDir + " removed"; if (verbose) { consoleMessage(message); consoleMessage("Unexpected exception " + e.getMessage());
@VisibleForTesting public static void scheduleClearDanglingScratchDir(HiveConf hiveConf, int initialWaitInSec) { if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern("cleardanglingscratchdir-%d") .daemon(true) .build()); executor.scheduleAtFixedRate(new ClearDanglingScratchDir(false, false, false, HiveConf.getVar(hiveConf, HiveConf.ConfVars.SCRATCHDIR), hiveConf), initialWaitInSec, HiveConf.getTimeVar(hiveConf, ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR_INTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } }
@VisibleForTesting public static void scheduleClearDanglingScratchDir(HiveConf hiveConf, int initialWaitInSec) { if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern("cleardanglingscratchdir-%d") .daemon(true) .build()); executor.scheduleAtFixedRate(new ClearDanglingScratchDir(false, false, false, HiveConf.getVar(hiveConf, HiveConf.ConfVars.SCRATCHDIR), hiveConf), initialWaitInSec, HiveConf.getTimeVar(hiveConf, ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR_INTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } }
} catch (LogInitializationException e) { Options opts = createOptions(); CommandLine cli = new GnuParser().parse(opts, args); rootHDFSDir = HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIR); ClearDanglingScratchDir clearDanglingScratchDirMain = new ClearDanglingScratchDir(dryRun, verbose, true, rootHDFSDir, conf); clearDanglingScratchDirMain.run();
SessionState.LOCK_FILE_NAME; if (verbose) { consoleMessage(message); consoleMessage("Unexpected error:" + eCreate.getMessage()); consoleMessage("Unexpected error:" + eAppend.getMessage()); consoleMessage(message); consoleMessage("Cannot find any scratch directory to clear"); return; consoleMessage("Removing " + scratchDirToRemove.size() + " scratch directories"); for (Path scratchDir : scratchDirToRemove) { if (dryRun) { boolean succ = fs.delete(scratchDir, true); if (!succ) { consoleMessage("Cannot remove " + scratchDir); } else { String message = scratchDir + " removed"; if (verbose) { consoleMessage(message); consoleMessage("Unexpected exception " + e.getMessage());