MAPREDUCE-3682 Tracker URL says AM tasks run on localhost. (Ravi Prakash via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1309440 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Graves 2012-04-04 15:08:39 +00:00
parent b518a98169
commit 4e44259cbd
3 changed files with 20 additions and 7 deletions

View File

@ -245,6 +245,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-3672. Killed maps shouldn't be counted towards MAPREDUCE-3672. Killed maps shouldn't be counted towards
JobCounter.NUM_FAILED_MAPS. (Anupam Seth via tgraves) JobCounter.NUM_FAILED_MAPS. (Anupam Seth via tgraves)
MAPREDUCE-3682 Tracker URL says AM tasks run on localhost.
(Ravi Prakash via tgraves)
Release 0.23.2 - UNRELEASED Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -643,7 +643,8 @@ private final class ContainerAllocatorRouter extends AbstractService
public synchronized void start() { public synchronized void start() {
if (job.isUber()) { if (job.isUber()) {
this.containerAllocator = new LocalContainerAllocator( this.containerAllocator = new LocalContainerAllocator(
this.clientService, this.context); this.clientService, this.context, nmHost, nmPort, nmHttpPort
, containerID);
} else { } else {
this.containerAllocator = new RMContainerAllocator( this.containerAllocator = new RMContainerAllocator(
this.clientService, this.context); this.clientService, this.context);

View File

@ -65,14 +65,23 @@ public class LocalContainerAllocator extends RMCommunicator
private AtomicInteger containerCount = new AtomicInteger(); private AtomicInteger containerCount = new AtomicInteger();
private long retryInterval; private long retryInterval;
private long retrystartTime; private long retrystartTime;
private String nmHost;
private int nmPort;
private int nmHttpPort;
private ContainerId containerId;
private final RecordFactory recordFactory = private final RecordFactory recordFactory =
RecordFactoryProvider.getRecordFactory(null); RecordFactoryProvider.getRecordFactory(null);
public LocalContainerAllocator(ClientService clientService, public LocalContainerAllocator(ClientService clientService,
AppContext context) { AppContext context, String nmHost, int nmPort, int nmHttpPort
, ContainerId cId) {
super(clientService, context); super(clientService, context);
this.eventHandler = context.getEventHandler(); this.eventHandler = context.getEventHandler();
this.nmHost = nmHost;
this.nmPort = nmPort;
this.nmHttpPort = nmHttpPort;
this.containerId = cId;
} }
@Override @Override
@ -131,17 +140,17 @@ public void handle(ContainerAllocatorEvent event) {
LOG.info("Processing the event " + event.toString()); LOG.info("Processing the event " + event.toString());
ContainerId cID = recordFactory.newRecordInstance(ContainerId.class); ContainerId cID = recordFactory.newRecordInstance(ContainerId.class);
cID.setApplicationAttemptId(applicationAttemptId); cID.setApplicationAttemptId(applicationAttemptId);
// use negative ids to denote that these are local. Need a better way ?? // Assign the same container ID as the AM
cID.setId((-1) * containerCount.getAndIncrement()); cID.setId(this.containerId.getId());
Container container = recordFactory.newRecordInstance(Container.class); Container container = recordFactory.newRecordInstance(Container.class);
container.setId(cID); container.setId(cID);
NodeId nodeId = Records.newRecord(NodeId.class); NodeId nodeId = Records.newRecord(NodeId.class);
nodeId.setHost("localhost"); nodeId.setHost(this.nmHost);
nodeId.setPort(1234); nodeId.setPort(this.nmPort);
container.setNodeId(nodeId); container.setNodeId(nodeId);
container.setContainerToken(null); container.setContainerToken(null);
container.setNodeHttpAddress("localhost:8042"); container.setNodeHttpAddress(this.nmHost + ":" + this.nmHttpPort);
// send the container-assigned event to task attempt // send the container-assigned event to task attempt
if (event.getAttemptID().getTaskId().getTaskType() == TaskType.MAP) { if (event.getAttemptID().getTaskId().getTaskType() == TaskType.MAP) {