One less Queue command line requirement: -tempDir now defaults to .queue/tmp.

Also moved queueScatterGather to .queue/scatterGather.
This commit is contained in:
Khalid Shakir 2012-08-27 12:04:50 -04:00
parent 68c5142d2d
commit 2d1ea7124b
3 changed files with 19 additions and 8 deletions

View File

@ -48,14 +48,23 @@ public class IOUtils {
* @param tempDir Temporary directory.
*/
public static void checkTempDir(File tempDir) {
if (isDefaultTempDir(tempDir))
throw new UserException.BadTmpDir("java.io.tmpdir must be explicitly set");
if (!tempDir.exists() && !tempDir.mkdirs())
throw new UserException.BadTmpDir("Could not create directory: " + tempDir.getAbsolutePath());
}
/**
* Returns true if the directory is a default temporary directory.
* @param tempDir the directory to check.
* @return true if the directory is a default temporary directory.
*/
public static boolean isDefaultTempDir(File tempDir) {
String tempDirPath = tempDir.getAbsolutePath();
// Keeps the user from leaving the temp directory as the default, and on Macs from having pluses
// in the path which can cause problems with the Google Reflections library.
// see also: http://benjchristensen.com/2009/09/22/mac-osx-10-6-java-java-io-tmpdir/
if (tempDirPath.startsWith("/var/folders/") || (tempDirPath.equals("/tmp")) || (tempDirPath.equals("/tmp/")))
throw new UserException.BadTmpDir("java.io.tmpdir must be explicitly set");
if (!tempDir.exists() && !tempDir.mkdirs())
throw new UserException.BadTmpDir("Could not create directory: " + tempDir.getAbsolutePath());
return (tempDirPath.startsWith("/var/folders/") || (tempDirPath.equals("/tmp")) || (tempDirPath.equals("/tmp/")));
}
/**

View File

@ -64,10 +64,10 @@ object QCommandLine extends Logging {
Runtime.getRuntime.removeShutdownHook(shutdownHook)
qCommandLine.shutdown()
} catch {
case _ => /* ignore, example 'java.lang.IllegalStateException: Shutdown in progress' */
case e: Exception => /* ignore, example 'java.lang.IllegalStateException: Shutdown in progress' */
}
if (CommandLineProgram.result != 0)
System.exit(CommandLineProgram.result);
System.exit(CommandLineProgram.result)
} catch {
case e: Exception => CommandLineProgram.exitSystemWithError(e)
}
@ -105,9 +105,11 @@ class QCommandLine extends CommandLineProgram with Logging {
def execute = {
if (settings.qSettings.runName == null)
settings.qSettings.runName = FilenameUtils.removeExtension(scripts.head.getName)
if (IOUtils.isDefaultTempDir(settings.qSettings.tempDirectory))
settings.qSettings.tempDirectory = IOUtils.absolute(settings.qSettings.runDirectory, ".queue/tmp")
qGraph.initializeWithSettings(settings)
val allQScripts = pluginManager.createAllTypes();
val allQScripts = pluginManager.createAllTypes()
for (script <- allQScripts) {
logger.info("Scripting " + pluginManager.getName(script.getClass.asSubclass(classOf[QScript])))
loadArgumentsIntoObject(script)

View File

@ -91,7 +91,7 @@ trait ScatterGatherableFunction extends CommandLineFunction {
if (qSettings.jobScatterGatherDirectory != null) {
this.scatterGatherDirectory = IOUtils.absolute(qSettings.jobScatterGatherDirectory)
} else {
this.scatterGatherDirectory = IOUtils.absolute(this.commandDirectory, "queueScatterGather")
this.scatterGatherDirectory = IOUtils.absolute(this.commandDirectory, ".queue/scatterGather")
}
}
}