in emr-dynamodb-hadoop/src/main/java/org/apache/hadoop/dynamodb/util/RoundRobinYarnContainerAllocator.java [26:64]
public int getMaxMappers(int nodes, int reducers, int nodeSlots, int appMasterSlots, int
mapSlots, int reduceSlots) {
// Initialize all nodes with fully available slots
int[] clusterNodeSlots = new int[nodes];
for (int k = 0; k < nodes; k++) {
clusterNodeSlots[k] = nodeSlots;
}
// Allocate the app master in the 1st node
clusterNodeSlots[0] -= appMasterSlots;
// Find slots for all reducers using round robin
int reducerIndex = 0;
int nodeIndex = 1;
for (; reducerIndex < reducers; reducerIndex++) {
if (nodeIndex >= nodes) {
nodeIndex = 0;
}
if (clusterNodeSlots[nodeIndex] >= reduceSlots) {
clusterNodeSlots[nodeIndex] -= reduceSlots;
} else {
break;
}
nodeIndex++;
}
if (reducerIndex < reducers) {
log.warn("All slots are used for the app master and reducers. No slots for mappers.");
return 0;
}
// Use all remaining slots for mappers
int mappers = 0;
for (nodeIndex = 0; nodeIndex < nodes; nodeIndex++) {
mappers += clusterNodeSlots[nodeIndex] / mapSlots;
}
return mappers;
}