From e18301d99c7e0bb9177c808ac740ccf6085ee85f Mon Sep 17 00:00:00 2001 From: Charles Allen Date: Wed, 23 Dec 2015 11:00:32 -0800 Subject: [PATCH] Make TaskConfig pull from java.io.tmpdir * Also makes paths built off of java.nio.file.Paths instead of String.format --- docs/content/configuration/indexing-service.md | 6 +++--- .../io/druid/indexing/common/config/TaskConfig.java | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/content/configuration/indexing-service.md b/docs/content/configuration/indexing-service.md index e69f7f3d643..a8c48cfd9e6 100644 --- a/docs/content/configuration/indexing-service.md +++ b/docs/content/configuration/indexing-service.md @@ -274,9 +274,9 @@ Additional peon configs include: |Property|Description|Default| |--------|-----------|-------| |`druid.peon.mode`|Choices are "local" and "remote". Setting this to local means you intend to run the peon as a standalone node (Not recommended).|remote| -|`druid.indexer.task.baseDir`|Base temporary working directory.|/tmp| -|`druid.indexer.task.baseTaskDir`|Base temporary working directory for tasks.|/tmp/persistent/tasks| -|`druid.indexer.task.hadoopWorkingPath`|Temporary working directory for Hadoop tasks.|/tmp/druid-indexing| +|`druid.indexer.task.baseDir`|Base temporary working directory.|`System.getProperty("java.io.tmpdir")`| +|`druid.indexer.task.baseTaskDir`|Base temporary working directory for tasks.|`${druid.indexer.task.baseDir}/persistent/tasks`| +|`druid.indexer.task.hadoopWorkingPath`|Temporary working directory for Hadoop tasks.|`/tmp/druid-indexing`| |`druid.indexer.task.defaultRowFlushBoundary`|Highest row count before persisting to disk. Used for indexing generating tasks.|50000| |`druid.indexer.task.defaultHadoopCoordinates`|Hadoop version to use with HadoopIndexTasks that do not request a particular version.|org.apache.hadoop:hadoop-client:2.3.0| |`druid.indexer.task.restoreTasksOnRestart`|If true, middleManagers will attempt to stop tasks gracefully on shutdown and restore them on restart.|false| diff --git a/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java b/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java index fefc6903922..7149d3d8166 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableList; import org.joda.time.Period; import java.io.File; +import java.nio.file.Paths; import java.util.List; public class TaskConfig @@ -73,9 +74,10 @@ public class TaskConfig @JsonProperty("directoryLockTimeout") Period directoryLockTimeout ) { - this.baseDir = baseDir == null ? "/tmp" : baseDir; + this.baseDir = baseDir == null ? System.getProperty("java.io.tmpdir") : baseDir; this.baseTaskDir = new File(defaultDir(baseTaskDir, "persistent/task")); - this.hadoopWorkingPath = defaultDir(hadoopWorkingPath, "druid-indexing"); + // This is usually on HDFS or similar, so we can't use java.io.tmpdir + this.hadoopWorkingPath = hadoopWorkingPath == null ? "/tmp/druid-indexing" : hadoopWorkingPath; this.defaultRowFlushBoundary = defaultRowFlushBoundary == null ? 500000 : defaultRowFlushBoundary; this.defaultHadoopCoordinates = defaultHadoopCoordinates == null ? DEFAULT_DEFAULT_HADOOP_COORDINATES @@ -85,8 +87,8 @@ public class TaskConfig ? DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT : gracefulShutdownTimeout; this.directoryLockTimeout = directoryLockTimeout == null - ? DEFAULT_DIRECTORY_LOCK_TIMEOUT - : directoryLockTimeout; + ? DEFAULT_DIRECTORY_LOCK_TIMEOUT + : directoryLockTimeout; } @JsonProperty @@ -155,7 +157,7 @@ public class TaskConfig private String defaultDir(String configParameter, final String defaultVal) { if (configParameter == null) { - return String.format("%s/%s", getBaseDir(), defaultVal); + return Paths.get(getBaseDir(), defaultVal).toString(); } return configParameter;