From 5b85af87f0edeaded5f91c1b3317ddbf67d11d36 Mon Sep 17 00:00:00 2001 From: 9uapaw Date: Fri, 9 Sep 2022 14:38:41 +0200 Subject: [PATCH] YARN-11278. Fixed Ambiguous error message in mutation API. Contributed by Ashutosh Gupta. --- .../resourcemanager/webapp/RMWebServices.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java index 26c921796b..6a6a2e1de1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java @@ -2748,26 +2748,26 @@ public synchronized Response updateSchedulerConfiguration(SchedConfUpdateInfo initForWritableEndpoints(callerUGI, true); ResourceScheduler scheduler = rm.getResourceScheduler(); - if (isConfigurationMutable(scheduler)) { + if (!(scheduler instanceof MutableConfScheduler)) { + return Response.status(Status.BAD_REQUEST) + .entity("Configuration change only supported by MutableConfScheduler.").build(); + } else if (!((MutableConfScheduler) scheduler).isConfigurationMutable()) { + return Response.status(Status.BAD_REQUEST) + .entity("Configuration change only supported by mutable configuration store.").build(); + } else { try { callerUGI.doAs((PrivilegedExceptionAction) () -> { - MutableConfigurationProvider provider = ((MutableConfScheduler) - scheduler).getMutableConfProvider(); + MutableConfigurationProvider provider = + ((MutableConfScheduler) scheduler).getMutableConfProvider(); LogMutation logMutation = applyMutation(provider, callerUGI, mutationInfo); return refreshQueues(provider, logMutation); }); } catch (IOException e) { LOG.error("Exception thrown when modifying configuration.", e); - return Response.status(Status.BAD_REQUEST).entity(e.getMessage()) - .build(); + return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); } return Response.status(Status.OK).entity("Configuration change successfully applied.") .build(); - } else { - return Response.status(Status.BAD_REQUEST) - .entity(String.format("Configuration change only supported by " + - "%s.", MutableConfScheduler.class.getSimpleName())) - .build(); } }