|
@@ -20,6 +20,7 @@ package org.apache.hadoop.mapreduce.v2.hs.server;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.net.InetSocketAddress;
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -52,6 +53,7 @@ import org.apache.hadoop.mapreduce.v2.hs.JobHistory;
|
|
|
import org.apache.hadoop.mapreduce.v2.hs.proto.HSAdminRefreshProtocolProtos.HSAdminRefreshProtocolService;
|
|
|
import org.apache.hadoop.mapreduce.v2.hs.protocolPB.HSAdminRefreshProtocolServerSideTranslatorPB;
|
|
|
|
|
|
+import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.protobuf.BlockingService;
|
|
|
|
|
|
@Private
|
|
@@ -67,6 +69,8 @@ public class HSAdminServer extends AbstractService implements HSAdminProtocol {
|
|
|
private static final String HISTORY_ADMIN_SERVER = "HSAdminServer";
|
|
|
private JobHistory jobHistoryService = null;
|
|
|
|
|
|
+ private UserGroupInformation loginUGI;
|
|
|
+
|
|
|
public HSAdminServer(AggregatedLogDeletionService aggLogDelService,
|
|
|
JobHistory jobHistoryService) {
|
|
|
super(HSAdminServer.class.getName());
|
|
@@ -125,9 +129,24 @@ public class HSAdminServer extends AbstractService implements HSAdminProtocol {
|
|
|
|
|
|
@Override
|
|
|
protected void serviceStart() throws Exception {
|
|
|
+ if (UserGroupInformation.isSecurityEnabled()) {
|
|
|
+ loginUGI = UserGroupInformation.getLoginUser();
|
|
|
+ } else {
|
|
|
+ loginUGI = UserGroupInformation.getCurrentUser();
|
|
|
+ }
|
|
|
clientRpcServer.start();
|
|
|
}
|
|
|
|
|
|
+ @VisibleForTesting
|
|
|
+ UserGroupInformation getLoginUGI() {
|
|
|
+ return loginUGI;
|
|
|
+ }
|
|
|
+
|
|
|
+ @VisibleForTesting
|
|
|
+ void setLoginUGI(UserGroupInformation ugi) {
|
|
|
+ loginUGI = ugi;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void serviceStop() throws Exception {
|
|
|
if (clientRpcServer != null) {
|
|
@@ -233,7 +252,17 @@ public class HSAdminServer extends AbstractService implements HSAdminProtocol {
|
|
|
public void refreshLogRetentionSettings() throws IOException {
|
|
|
UserGroupInformation user = checkAcls("refreshLogRetentionSettings");
|
|
|
|
|
|
- aggLogDelService.refreshLogRetentionSettings();
|
|
|
+ try {
|
|
|
+ loginUGI.doAs(new PrivilegedExceptionAction<Void>() {
|
|
|
+ @Override
|
|
|
+ public Void run() throws IOException {
|
|
|
+ aggLogDelService.refreshLogRetentionSettings();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new IOException(e);
|
|
|
+ }
|
|
|
|
|
|
HSAuditLogger.logSuccess(user.getShortUserName(),
|
|
|
"refreshLogRetentionSettings", "HSAdminServer");
|
|
@@ -243,7 +272,17 @@ public class HSAdminServer extends AbstractService implements HSAdminProtocol {
|
|
|
public void refreshJobRetentionSettings() throws IOException {
|
|
|
UserGroupInformation user = checkAcls("refreshJobRetentionSettings");
|
|
|
|
|
|
- jobHistoryService.refreshJobRetentionSettings();
|
|
|
+ try {
|
|
|
+ loginUGI.doAs(new PrivilegedExceptionAction<Void>() {
|
|
|
+ @Override
|
|
|
+ public Void run() throws IOException {
|
|
|
+ jobHistoryService.refreshJobRetentionSettings();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new IOException(e);
|
|
|
+ }
|
|
|
|
|
|
HSAuditLogger.logSuccess(user.getShortUserName(),
|
|
|
"refreshJobRetentionSettings", HISTORY_ADMIN_SERVER);
|