From 0cfb366dccb66fab5236f63e03be88755a906e9b Mon Sep 17 00:00:00 2001 From: Hans van den Bogert Date: Mon, 2 Mar 2015 22:09:31 +0100 Subject: [PATCH 1/2] Use MESOS_DIRECTORY in MesosExecutor process (not user.dir property) We shouldn't rely on working dir (user.dir) of MesosExecutor process, for setting the mapred.local.dir as it can point to a directory which is not in a mesos sandbox, nor strictly local in the first place. --- src/main/java/org/apache/hadoop/mapred/MesosExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/hadoop/mapred/MesosExecutor.java b/src/main/java/org/apache/hadoop/mapred/MesosExecutor.java index f54507c..79b8b28 100644 --- a/src/main/java/org/apache/hadoop/mapred/MesosExecutor.java +++ b/src/main/java/org/apache/hadoop/mapred/MesosExecutor.java @@ -51,7 +51,7 @@ private JobConf configure(final TaskInfo task) { // Set the mapred.local directory inside the executor sandbox, so that // different TaskTrackers on the same host do not step on each other. - conf.set("mapred.local.dir", System.getProperty("user.dir") + "/mapred"); + conf.set("mapred.local.dir", System.getenv("MESOS_DIRECTORY") + "/mapred"); return conf; } From fdbb4f27523e4acf20999092cae5908d069480d1 Mon Sep 17 00:00:00 2001 From: Hans van den Bogert Date: Mon, 2 Mar 2015 22:17:24 +0100 Subject: [PATCH 2/2] If no mapred.mesos.executor.uri is set, rely on mapred.mesos.executor.directory, if set Retrieving the URI for the hadoop distribution is not always necessary for every task submitted to Mesos, in clusters with shared storage, the distribution can be shared. --- .../apache/hadoop/mapred/ResourcePolicy.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java b/src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java index c2d4aff..82f7ae6 100644 --- a/src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java +++ b/src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java @@ -383,16 +383,22 @@ public void resourceOffers(SchedulerDriver schedulerDriver, } String uri = scheduler.conf.get("mapred.mesos.executor.uri"); - if (uri == null) { + String directory = scheduler.conf.get("mapred.mesos.executor.directory"); + boolean isUriSet = uri != null && !uri.equals(""); + boolean isDirectorySet = directory != null && !directory.equals(""); + + if (!isUriSet && !isDirectorySet) { throw new RuntimeException( "Expecting configuration property 'mapred.mesos.executor'"); - } - - String directory = scheduler.conf.get("mapred.mesos.executor.directory"); - if (directory == null || directory.equals("")) { + } else if (isUriSet && isDirectorySet) { + throw new RuntimeException( + "Conflicting properties 'mapred.mesos.executor.uri' and 'mapred.mesos.executor.directory', only one can be set"); + } else if (!isDirectorySet) { LOG.info("URI: " + uri + ", name: " + new File(uri).getName()); directory = new File(uri).getName().split("\\.")[0] + "*"; + } else if (!isUriSet) { + LOG.info("mapred.mesos.executor.uri is not set, relying on configured 'mapred.mesos.executor.directory' for working Hadoop distribution"); } String command = scheduler.conf.get("mapred.mesos.executor.command"); @@ -403,8 +409,10 @@ public void resourceOffers(SchedulerDriver schedulerDriver, CommandInfo.Builder commandInfo = CommandInfo.newBuilder(); commandInfo .setEnvironment(envBuilder) - .setValue(String.format("cd %s && %s", directory, command)) - .addUris(CommandInfo.URI.newBuilder().setValue(uri)); + .setValue(String.format("cd %s && %s", directory, command)); + if (uri != null) { + commandInfo.addUris(CommandInfo.URI.newBuilder().setValue(uri)); + } // Populate ContainerInfo if needed String containerImage = scheduler.conf.get("mapred.mesos.container.image");