|
@@ -20,6 +20,8 @@ package org.apache.hadoop.mapreduce.v2.app.launcher;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.security.PrivilegedAction;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
@@ -71,6 +73,10 @@ public class ContainerLauncherImpl extends AbstractService implements
|
|
|
private BlockingQueue<ContainerLauncherEvent> eventQueue =
|
|
|
new LinkedBlockingQueue<ContainerLauncherEvent>();
|
|
|
private RecordFactory recordFactory;
|
|
|
+ //have a cache/map of UGIs so as to avoid creating too many RPC
|
|
|
+ //client connection objects to the same NodeManager
|
|
|
+ private Map<String, UserGroupInformation> ugiMap =
|
|
|
+ new HashMap<String, UserGroupInformation>();
|
|
|
|
|
|
public ContainerLauncherImpl(AppContext context) {
|
|
|
super(ContainerLauncherImpl.class.getName());
|
|
@@ -130,15 +136,23 @@ public class ContainerLauncherImpl extends AbstractService implements
|
|
|
final String containerManagerBindAddr, ContainerToken containerToken)
|
|
|
throws IOException {
|
|
|
|
|
|
- UserGroupInformation user = UserGroupInformation.getLoginUser();
|
|
|
+ UserGroupInformation user = UserGroupInformation.getCurrentUser();
|
|
|
+
|
|
|
if (UserGroupInformation.isSecurityEnabled()) {
|
|
|
- Token<ContainerTokenIdentifier> token =
|
|
|
+ if(!ugiMap.containsKey(containerManagerBindAddr)) {
|
|
|
+ Token<ContainerTokenIdentifier> token =
|
|
|
new Token<ContainerTokenIdentifier>(
|
|
|
containerToken.getIdentifier().array(),
|
|
|
containerToken.getPassword().array(), new Text(
|
|
|
containerToken.getKind()), new Text(
|
|
|
- containerToken.getService()));
|
|
|
- user.addToken(token);
|
|
|
+ containerToken.getService()));
|
|
|
+ //the user in createRemoteUser in this context is not important
|
|
|
+ user = UserGroupInformation.createRemoteUser(containerManagerBindAddr);
|
|
|
+ user.addToken(token);
|
|
|
+ ugiMap.put(containerManagerBindAddr, user);
|
|
|
+ } else {
|
|
|
+ user = ugiMap.get(containerManagerBindAddr);
|
|
|
+ }
|
|
|
}
|
|
|
ContainerManager proxy =
|
|
|
user.doAs(new PrivilegedAction<ContainerManager>() {
|