Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ default values.
Mesos reservations. Consult the Mesos documentation for details.
</description>
</property>
<property>
<name>mapred.mesos.role.strict</name>
<value>false</value>
<description>
Force the framework to only ever accept resource offers that are of the
role configured in "mapred.mesos.role".
</description>
</property>

<!-- If you're using a custom Mesos Containerizer -->
<property>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/apache/hadoop/mapred/ResourcePolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ public void resourceOffers(SchedulerDriver schedulerDriver,
}
}

// Verify the resource roles are what we need
if (scheduler.conf.getBoolean("mapred.mesos.role.strict", false)) {
String expectedRole = scheduler.conf.get("mapred.mesos.role", "*");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure about this... perhaps I could assign the role to a property on the scheduler and access that?

if (!cpuRole.equals(expectedRole) ||
!memRole.equals(expectedRole) ||
!diskRole.equals(expectedRole) ||
!portsRole.equals(expectedRole)) {
LOG.info("Declining offer with invalid role " + expectedRole);

schedulerDriver.declineOffer(offer.getId());
continue;
}
}

final boolean sufficient = computeSlots();

double taskCpus = (mapSlots + reduceSlots) * slotCpus + containerCpus;
Expand Down