merge MAPREDUCE-5286 from trunk. Change MapReduce to use ContainerTokenIdentifier instead of the entire Container in the startContainer call - YARN-684. Contributed by Vinod Kumar Vavilapalli.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1488088 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6a9c87a11
commit
36ef457902
|
@ -310,6 +310,10 @@ Release 2.0.5-beta - UNRELEASED
|
|||
MAPREDUCE-5282. Updating MR App to use immutable ApplicationID after
|
||||
YARN-716. (Siddharth Seth via vinodkv)
|
||||
|
||||
MAPREDUCE-5286. Change MapReduce to use ContainerTokenIdentifier instead
|
||||
of the entire Container in the startContainer call - YARN-684.
|
||||
(Vinod Kumar Vavilapalli via sseth)
|
||||
|
||||
BREAKDOWN OF HADOOP-8562 SUBTASKS
|
||||
|
||||
MAPREDUCE-4739. Some MapReduce tests fail to find winutils.
|
||||
|
|
|
@ -154,7 +154,7 @@ public class ContainerLauncherImpl extends AbstractService implements
|
|||
StartContainerRequest startRequest = Records
|
||||
.newRecord(StartContainerRequest.class);
|
||||
startRequest.setContainerLaunchContext(containerLaunchContext);
|
||||
startRequest.setContainer(event.getAllocatedContainer());
|
||||
startRequest.setContainerToken(event.getContainerToken());
|
||||
StartContainerResponse response = proxy.startContainer(startRequest);
|
||||
|
||||
ByteBuffer portInfo =
|
||||
|
|
|
@ -90,14 +90,17 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||
import org.apache.hadoop.yarn.api.records.Container;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerToken;
|
||||
import org.apache.hadoop.yarn.api.records.NodeId;
|
||||
import org.apache.hadoop.yarn.api.records.Resource;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
|
||||
import org.apache.hadoop.yarn.service.Service;
|
||||
import org.apache.hadoop.yarn.state.StateMachine;
|
||||
import org.apache.hadoop.yarn.state.StateMachineFactory;
|
||||
import org.apache.hadoop.yarn.util.BuilderUtils;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -512,12 +515,19 @@ public class MRApp extends MRAppMaster {
|
|||
|
||||
@Override
|
||||
public void handle(ContainerAllocatorEvent event) {
|
||||
ContainerId cId = recordFactory.newRecordInstance(ContainerId.class);
|
||||
cId.setApplicationAttemptId(getContext().getApplicationAttemptId());
|
||||
cId.setId(containerCount++);
|
||||
ContainerId cId =
|
||||
ContainerId.newInstance(getContext().getApplicationAttemptId(),
|
||||
containerCount++);
|
||||
NodeId nodeId = NodeId.newInstance(NM_HOST, NM_PORT);
|
||||
Resource resource = Resource.newInstance(1234, 2);
|
||||
ContainerTokenIdentifier containerTokenIdentifier =
|
||||
new ContainerTokenIdentifier(cId, nodeId.toString(), "user",
|
||||
resource, System.currentTimeMillis() + 10000, 42, 42);
|
||||
ContainerToken containerToken =
|
||||
BuilderUtils.newContainerToken(nodeId, "password".getBytes(),
|
||||
containerTokenIdentifier);
|
||||
Container container = Container.newInstance(cId, nodeId,
|
||||
NM_HOST + ":" + NM_HTTP_PORT, null, null, null);
|
||||
NM_HOST + ":" + NM_HTTP_PORT, resource, null, containerToken);
|
||||
JobID id = TypeConverter.fromYarn(applicationId);
|
||||
JobId jobId = TypeConverter.toYarn(id);
|
||||
getContext().getEventHandler().handle(new JobHistoryEvent(jobId,
|
||||
|
|
|
@ -67,6 +67,7 @@ import org.apache.hadoop.yarn.factories.RecordFactory;
|
|||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
|
||||
import org.apache.hadoop.yarn.ipc.YarnRPC;
|
||||
import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
|
||||
import org.apache.hadoop.yarn.util.BuilderUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -376,13 +377,12 @@ public class TestContainerLauncher {
|
|||
public StartContainerResponse startContainer(StartContainerRequest request)
|
||||
throws IOException {
|
||||
|
||||
ContainerTokenIdentifier containerTokenIdentifier =
|
||||
BuilderUtils.newContainerTokenIdentifier(request.getContainerToken());
|
||||
|
||||
// Validate that the container is what RM is giving.
|
||||
Assert.assertEquals(MRApp.NM_HOST, request.getContainer().getNodeId()
|
||||
.getHost());
|
||||
Assert.assertEquals(MRApp.NM_PORT, request.getContainer().getNodeId()
|
||||
.getPort());
|
||||
Assert.assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_HTTP_PORT, request
|
||||
.getContainer().getNodeHttpAddress());
|
||||
Assert.assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_PORT,
|
||||
containerTokenIdentifier.getNmHostAddress());
|
||||
|
||||
StartContainerResponse response = recordFactory
|
||||
.newRecordInstance(StartContainerResponse.class);
|
||||
|
@ -395,7 +395,7 @@ public class TestContainerLauncher {
|
|||
throw new UndeclaredThrowableException(e);
|
||||
}
|
||||
status.setState(ContainerState.RUNNING);
|
||||
status.setContainerId(request.getContainer().getId());
|
||||
status.setContainerId(containerTokenIdentifier.getContainerID());
|
||||
status.setExitStatus(0);
|
||||
return response;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue