From 851a4dc2d90374dc8ea6c0ea1e319af4756e6727 Mon Sep 17 00:00:00 2001 From: 9uapaw Date: Mon, 7 Mar 2022 09:00:22 +0100 Subject: [PATCH] YARN-11049. MutableConfScheduler is referred as plain String instead of class name. Contributed by Szilard Nemeth --- .../resourcemanager/ResourceManager.java | 4 ++-- .../resourcemanager/webapp/RMWebServices.java | 19 ++++++++++--------- .../webapp/TestRMWebServices.java | 5 +++-- 3 files changed, 15 insertions(+), 13 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/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 357cbf3f15..3bd6a0fe43 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -1864,8 +1864,8 @@ static void deleteRMConfStore(Configuration conf) throws Exception { confStore.initialize(conf, conf, rmContext); confStore.format(); } else { - System.out.println("Scheduler Configuration format only " + - "supported by MutableConfScheduler."); + System.out.println(String.format("Scheduler Configuration format only " + + "supported by %s.", MutableConfScheduler.class.getSimpleName())); } } 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 1dac043ae1..26c921796b 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 @@ -2678,7 +2678,7 @@ public Response formatSchedulerConfiguration(@Context HttpServletRequest hsr) } else { return Response.status(Status.BAD_REQUEST) .entity("Scheduler Configuration format only supported by " + - "MutableConfScheduler.").build(); + MutableConfScheduler.class.getSimpleName()).build(); } } @@ -2727,8 +2727,8 @@ public synchronized Response validateAndGetSchedulerConfiguration( .build(); } } else { - String errorMsg = "Configuration change validation only supported by " + - "MutableConfScheduler."; + String errorMsg = String.format("Configuration change validation only supported by %s.", + MutableConfScheduler.class.getSimpleName()); LOG.warn(errorMsg); return Response.status(Status.BAD_REQUEST) .entity(errorMsg) @@ -2823,10 +2823,11 @@ public Response getSchedulerConfiguration(@Context HttpServletRequest hsr) .build(); } else { return Response.status(Status.BAD_REQUEST).entity( - "This API only supports to retrieve scheduler configuration" - + " from a mutable-conf scheduler, underneath scheduler " - + scheduler.getClass().getSimpleName() - + " is not an instance of MutableConfScheduler") + String.format("This API only supports to retrieve scheduler configuration" + + " from a mutable-conf scheduler, underneath scheduler %s" + + " is not an instance of %s", + scheduler.getClass().getSimpleName(), + MutableConfScheduler.class.getSimpleName())) .build(); } } @@ -2858,8 +2859,8 @@ public Response getSchedulerConfigurationVersion(@Context } } else { return Response.status(Status.BAD_REQUEST) - .entity("Configuration Version only supported by " - + "MutableConfScheduler.").build(); + .entity(String.format("Configuration Version only supported by %s.", + MutableConfScheduler.class.getSimpleName())).build(); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java index d5d534395b..ce9de64374 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServices.java @@ -75,6 +75,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics; +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.MutableConfScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; @@ -1003,8 +1004,8 @@ public void testValidateAndGetSchedulerConfigurationInvalidScheduler() Assert.assertEquals(Status.BAD_REQUEST .getStatusCode(), response.getStatus()); Assert.assertTrue(response.getEntity().toString() - .contains("Configuration change validation only supported by" - +" MutableConfScheduler.")); + .contains(String.format("Configuration change validation only supported by %s.", + MutableConfScheduler.class.getSimpleName()))); } @Test