From b99dd5de748d89ae57da159426a098122de334f8 Mon Sep 17 00:00:00 2001 From: Karthik Kambatla Date: Fri, 27 Dec 2013 03:32:05 +0000 Subject: [PATCH] YARN-1523. Use StandbyException instead of RMNotYetReadyException (kasha) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1553620 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 2 ++ .../exceptions/RMNotYetActiveException.java | 36 ------------------- ...ResourceManagerAdministrationProtocol.java | 10 +++--- .../server/resourcemanager/AdminService.java | 25 ++++++++----- 4 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/RMNotYetActiveException.java diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 936d26b9978..12888378cc5 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -171,6 +171,8 @@ Release 2.4.0 - UNRELEASED YARN-1172. Convert SecretManagers in RM to services (Tsuyoshi OZAWA via kasha) + YARN-1523. Use StandbyException instead of RMNotYetReadyException (kasha) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/RMNotYetActiveException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/RMNotYetActiveException.java deleted file mode 100644 index 4aac61eaa93..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/RMNotYetActiveException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.yarn.exceptions; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; - -/** - * Exception to be thrown when an Active-Only operation is attempted on a - * ResourceManager that is not Active. - */ -@InterfaceAudience.Private -@InterfaceStability.Evolving -public class RMNotYetActiveException extends YarnException { - private static final long serialVersionUID = 1L; - - public RMNotYetActiveException() { - super("ResourceManager is not yet Active!"); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java index e768847e850..26415992ac0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/ResourceManagerAdministrationProtocol.java @@ -24,10 +24,10 @@ import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Stable; +import org.apache.hadoop.ipc.StandbyException; import org.apache.hadoop.tools.GetUserMappingsProtocol; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.ResourceOption; -import org.apache.hadoop.yarn.exceptions.RMNotYetActiveException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest; import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsResponse; @@ -51,25 +51,25 @@ public interface ResourceManagerAdministrationProtocol extends GetUserMappingsPr @Public @Stable public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) - throws RMNotYetActiveException, YarnException, IOException; + throws StandbyException, YarnException, IOException; @Public @Stable public RefreshNodesResponse refreshNodes(RefreshNodesRequest request) - throws RMNotYetActiveException, YarnException, IOException; + throws StandbyException, YarnException, IOException; @Public @Stable public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfiguration( RefreshSuperUserGroupsConfigurationRequest request) - throws RMNotYetActiveException, YarnException, IOException; + throws StandbyException, YarnException, IOException; @Public @Stable public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings( RefreshUserToGroupsMappingsRequest request) - throws RMNotYetActiveException, YarnException, IOException; + throws StandbyException, YarnException, IOException; @Public @Stable diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java index 0d0e5481be5..33230d86f9b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java @@ -40,6 +40,7 @@ import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RPC.Server; +import org.apache.hadoop.ipc.StandbyException; import org.apache.hadoop.security.Groups; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.AccessControlList; @@ -49,7 +50,6 @@ import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.ResourceOption; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.exceptions.RMNotYetActiveException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; @@ -82,6 +82,7 @@ public class AdminService extends AbstractService implements private final RMContext rmContext; private final ResourceManager rm; + private String rmId; private Server server; private InetSocketAddress masterServiceAddress; @@ -105,6 +106,7 @@ public synchronized void serviceInit(Configuration conf) throws Exception { adminAcl = new AccessControlList(conf.get( YarnConfiguration.YARN_ADMIN_ACL, YarnConfiguration.DEFAULT_YARN_ADMIN_ACL)); + rmId = conf.get(YarnConfiguration.RM_HA_ID); super.serviceInit(conf); } @@ -176,6 +178,10 @@ private synchronized boolean isRMActive() { return HAServiceState.ACTIVE == rmContext.getHAServiceState(); } + private void throwStandbyException() throws StandbyException { + throw new StandbyException("ResourceManager " + rmId + " is not Active!"); + } + @Override public synchronized void monitorHealth() throws IOException { @@ -239,14 +245,14 @@ public synchronized HAServiceStatus getServiceStatus() throws IOException { @Override public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) - throws YarnException { + throws YarnException, StandbyException { UserGroupInformation user = checkAcls("refreshQueues"); if (!isRMActive()) { RMAuditLogger.logFailure(user.getShortUserName(), "refreshQueues", adminAcl.toString(), "AdminService", "ResourceManager is not active. Can not refresh queues."); - throw new RMNotYetActiveException(); + throwStandbyException(); } try { @@ -265,14 +271,14 @@ public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) @Override public RefreshNodesResponse refreshNodes(RefreshNodesRequest request) - throws YarnException { + throws YarnException, StandbyException { UserGroupInformation user = checkAcls("refreshNodes"); if (!isRMActive()) { RMAuditLogger.logFailure(user.getShortUserName(), "refreshNodes", adminAcl.toString(), "AdminService", "ResourceManager is not active. Can not refresh nodes."); - throw new RMNotYetActiveException(); + throwStandbyException(); } try { @@ -291,7 +297,7 @@ public RefreshNodesResponse refreshNodes(RefreshNodesRequest request) @Override public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfiguration( RefreshSuperUserGroupsConfigurationRequest request) - throws YarnException { + throws YarnException, StandbyException { UserGroupInformation user = checkAcls("refreshSuperUserGroupsConfiguration"); // TODO (YARN-1459): Revisit handling super-user-groups on Standby RM @@ -300,7 +306,7 @@ public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfigu "refreshSuperUserGroupsConfiguration", adminAcl.toString(), "AdminService", "ResourceManager is not active. Can not refresh super-user-groups."); - throw new RMNotYetActiveException(); + throwStandbyException(); } ProxyUsers.refreshSuperUserGroupsConfiguration(new Configuration()); @@ -313,7 +319,8 @@ public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfigu @Override public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings( - RefreshUserToGroupsMappingsRequest request) throws YarnException { + RefreshUserToGroupsMappingsRequest request) + throws YarnException, StandbyException { UserGroupInformation user = checkAcls("refreshUserToGroupsMappings"); // TODO (YARN-1459): Revisit handling user-groups on Standby RM @@ -322,7 +329,7 @@ public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings( "refreshUserToGroupsMapping", adminAcl.toString(), "AdminService", "ResourceManager is not active. Can not refresh user-groups."); - throw new RMNotYetActiveException(); + throwStandbyException(); } Groups.getUserToGroupsMappingService().refresh();