|
19 | 19 | package org.apache.hadoop.yarn.server.router; |
20 | 20 |
|
21 | 21 | import java.io.IOException; |
| 22 | +import java.net.InetAddress; |
| 23 | +import java.net.UnknownHostException; |
22 | 24 | import java.util.concurrent.atomic.AtomicBoolean; |
23 | 25 |
|
24 | 26 | import org.apache.hadoop.classification.InterfaceAudience.Private; |
25 | 27 | import org.apache.hadoop.conf.Configuration; |
26 | 28 | import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; |
27 | 29 | import org.apache.hadoop.metrics2.source.JvmMetrics; |
| 30 | +import org.apache.hadoop.security.SecurityUtil; |
28 | 31 | import org.apache.hadoop.service.CompositeService; |
29 | 32 | import org.apache.hadoop.util.JvmPauseMonitor; |
30 | 33 | import org.apache.hadoop.util.ShutdownHookManager; |
@@ -88,7 +91,8 @@ public Router() { |
88 | 91 | } |
89 | 92 |
|
90 | 93 | protected void doSecureLogin() throws IOException { |
91 | | - // TODO YARN-6539 Create SecureLogin inside Router |
| 94 | + SecurityUtil.login(this.conf, YarnConfiguration.ROUTER_KEYTAB, |
| 95 | + YarnConfiguration.ROUTER_PRINCIPAL, getHostName(this.conf)); |
92 | 96 | } |
93 | 97 |
|
94 | 98 | @Override |
@@ -195,4 +199,31 @@ public static void main(String[] argv) { |
195 | 199 | System.exit(-1); |
196 | 200 | } |
197 | 201 | } |
| 202 | + |
| 203 | + @VisibleForTesting |
| 204 | + public RouterClientRMService getClientRMProxyService() { |
| 205 | + return clientRMProxyService; |
| 206 | + } |
| 207 | + |
| 208 | + @VisibleForTesting |
| 209 | + public RouterRMAdminService getRmAdminProxyService() { |
| 210 | + return rmAdminProxyService; |
| 211 | + } |
| 212 | + |
| 213 | + /** |
| 214 | + * Returns the hostname for this Router. If the hostname is not |
| 215 | + * explicitly configured in the given config, then it is determined. |
| 216 | + * |
| 217 | + * @param config configuration |
| 218 | + * @return the hostname (NB: may not be a FQDN) |
| 219 | + * @throws UnknownHostException if the hostname cannot be determined |
| 220 | + */ |
| 221 | + private String getHostName(Configuration config) |
| 222 | + throws UnknownHostException { |
| 223 | + String name = config.get(YarnConfiguration.ROUTER_KERBEROS_PRINCIPAL_HOSTNAME_KEY); |
| 224 | + if (name == null) { |
| 225 | + name = InetAddress.getLocalHost().getHostName(); |
| 226 | + } |
| 227 | + return name; |
| 228 | + } |
198 | 229 | } |
0 commit comments