Skip to content

Commit

Permalink
Merge pull request #43 from hansbogert/noURI
Browse files Browse the repository at this point in the history
 If no mapred.mesos.executor.uri is set, rely on mapred.mesos.executor directory, if set
  • Loading branch information
tarnfeld committed Mar 5, 2015
2 parents bc8732f + fdbb4f2 commit eef6c53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/hadoop/mapred/MesosExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,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");
Expand All @@ -408,8 +414,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");
Expand Down

0 comments on commit eef6c53

Please sign in to comment.