diff --git a/hadoop-yarn-project/hadoop-yarn/bin/yarn b/hadoop-yarn-project/hadoop-yarn/bin/yarn index d476cc605bc..46d0e542027 100644 --- a/hadoop-yarn-project/hadoop-yarn/bin/yarn +++ b/hadoop-yarn-project/hadoop-yarn/bin/yarn @@ -301,6 +301,9 @@ elif [ "$COMMAND" = "daemonlog" ] ; then elif [ "$COMMAND" = "cluster" ] ; then CLASS=org.apache.hadoop.yarn.client.cli.ClusterCLI YARN_OPTS="$YARN_OPTS $YARN_CLIENT_OPTS" +elif [ "$COMMAND" = "schedconf" ] ; then + CLASS=org.apache.hadoop.yarn.client.cli.SchedConfCLI + YARN_OPTS="$YARN_OPTS $YARN_CLIENT_OPTS" elif [ "$COMMAND" = "top" ]; then CLASS=org.apache.hadoop.yarn.client.cli.TopCLI YARN_OPTS="$YARN_OPTS $YARN_CLIENT_OPTS" diff --git a/hadoop-yarn-project/hadoop-yarn/bin/yarn.cmd b/hadoop-yarn-project/hadoop-yarn/bin/yarn.cmd index 230e88c5a26..1da15961ac0 100644 --- a/hadoop-yarn-project/hadoop-yarn/bin/yarn.cmd +++ b/hadoop-yarn-project/hadoop-yarn/bin/yarn.cmd @@ -289,6 +289,11 @@ goto :eof set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS% goto :eof +:schedconf + set CLASS=org.apache.hadoop.yarn.client.cli.SchedConfCLI + set YARN_OPTS=%YARN_OPTS% %YARN_CLIENT_OPTS% + goto :eof + @rem This changes %1, %2 etc. Hence those cannot be used after calling this. :make_command_arguments if "%1" == "--config" ( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/SchedConfCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/SchedConfCLI.java new file mode 100644 index 00000000000..e17062e5f17 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/SchedConfCLI.java @@ -0,0 +1,238 @@ +/** +* 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.client.cli; + +import com.google.common.annotations.VisibleForTesting; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.MissingArgumentException; +import org.apache.commons.cli.Options; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Evolving; +import org.apache.hadoop.conf.Configured; +import org.apache.hadoop.util.Tool; +import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.util.WebAppUtils; +import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response.Status; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * CLI for modifying scheduler configuration. + */ +@Public +@Evolving +public class SchedConfCLI extends Configured implements Tool { + + private static final String ADD_QUEUES_OPTION = "addQueues"; + private static final String REMOVE_QUEUES_OPTION = "removeQueues"; + private static final String UPDATE_QUEUES_OPTION = "updateQueues"; + private static final String GLOBAL_OPTIONS = "globalUpdates"; + private static final String HELP_CMD = "help"; + + private static final String CONF_ERR_MSG = "Specify configuration key " + + "value as confKey=confVal."; + + public SchedConfCLI() { + super(new YarnConfiguration()); + } + + public static void main(String[] args) throws Exception { + SchedConfCLI cli = new SchedConfCLI(); + int exitCode = cli.run(args); + System.exit(exitCode); + } + + @Override + public int run(String[] args) throws Exception { + Options opts = new Options(); + + opts.addOption("add", ADD_QUEUES_OPTION, true, + "Add queues with configurations"); + opts.addOption("remove", REMOVE_QUEUES_OPTION, true, + "Remove queues"); + opts.addOption("update", UPDATE_QUEUES_OPTION, true, + "Update queue configurations"); + opts.addOption("global", GLOBAL_OPTIONS, true, + "Update global scheduler configurations"); + opts.addOption("h", HELP_CMD, false, "Displays help for all commands."); + + int exitCode = -1; + CommandLine parsedCli = null; + try { + parsedCli = new GnuParser().parse(opts, args); + } catch (MissingArgumentException ex) { + System.err.println("Missing argument for options"); + printUsage(); + return exitCode; + } + + if (parsedCli.hasOption(HELP_CMD)) { + printUsage(); + return 0; + } + + boolean hasOption = false; + SchedConfUpdateInfo updateInfo = new SchedConfUpdateInfo(); + try { + if (parsedCli.hasOption(ADD_QUEUES_OPTION)) { + hasOption = true; + addQueues(parsedCli.getOptionValue(ADD_QUEUES_OPTION), updateInfo); + } + if (parsedCli.hasOption(REMOVE_QUEUES_OPTION)) { + hasOption = true; + removeQueues(parsedCli.getOptionValue(REMOVE_QUEUES_OPTION), + updateInfo); + } + if (parsedCli.hasOption(UPDATE_QUEUES_OPTION)) { + hasOption = true; + updateQueues(parsedCli.getOptionValue(UPDATE_QUEUES_OPTION), + updateInfo); + } + if (parsedCli.hasOption(GLOBAL_OPTIONS)) { + hasOption = true; + globalUpdates(parsedCli.getOptionValue(GLOBAL_OPTIONS), updateInfo); + } + } catch (IllegalArgumentException e) { + System.err.println(e.getMessage()); + return -1; + } + + if (!hasOption) { + System.err.println("Invalid Command Usage: "); + printUsage(); + return -1; + } + + Client webServiceClient = Client.create(); + WebResource webResource = webServiceClient.resource(WebAppUtils. + getRMWebAppURLWithScheme(getConf())); + ClientResponse response = webResource.path("ws").path("v1").path("cluster") + .path("sched-conf").accept(MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) + .put(ClientResponse.class); + if (response != null) { + if (response.getStatus() == Status.OK.getStatusCode()) { + System.out.println("Configuration changed successfully."); + return 0; + } else { + System.err.println("Configuration change unsuccessful: " + + response.getEntity(String.class)); + } + } else { + System.err.println("Configuration change unsuccessful: null response"); + } + return -1; + } + + @VisibleForTesting + void addQueues(String args, SchedConfUpdateInfo updateInfo) { + if (args == null) { + return; + } + ArrayList queueConfigInfos = new ArrayList<>(); + for (String arg : args.split(";")) { + queueConfigInfos.add(getQueueConfigInfo(arg)); + } + updateInfo.setAddQueueInfo(queueConfigInfos); + } + + @VisibleForTesting + void removeQueues(String args, SchedConfUpdateInfo updateInfo) { + if (args == null) { + return; + } + List queuesToRemove = Arrays.asList(args.split(",")); + updateInfo.setRemoveQueueInfo(new ArrayList<>(queuesToRemove)); + } + + @VisibleForTesting + void updateQueues(String args, SchedConfUpdateInfo updateInfo) { + if (args == null) { + return; + } + ArrayList queueConfigInfos = new ArrayList<>(); + for (String arg : args.split(";")) { + queueConfigInfos.add(getQueueConfigInfo(arg)); + } + updateInfo.setUpdateQueueInfo(queueConfigInfos); + } + + @VisibleForTesting + void globalUpdates(String args, SchedConfUpdateInfo updateInfo) { + if (args == null) { + return; + } + HashMap globalUpdates = new HashMap<>(); + for (String globalUpdate : args.split(",")) { + putKeyValuePair(globalUpdates, globalUpdate); + } + updateInfo.setGlobalParams(globalUpdates); + } + + private QueueConfigInfo getQueueConfigInfo(String arg) { + String[] queueArgs = arg.split(","); + String queuePath = queueArgs[0]; + Map queueConfigs = new HashMap<>(); + for (int i = 1; i < queueArgs.length; ++i) { + putKeyValuePair(queueConfigs, queueArgs[i]); + } + return new QueueConfigInfo(queuePath, queueConfigs); + } + + private void putKeyValuePair(Map kv, String args) { + String[] argParts = args.split("="); + if (argParts.length == 1) { + if (argParts[0].isEmpty() || !args.contains("=")) { + throw new IllegalArgumentException(CONF_ERR_MSG); + } else { + // key specified, but no value e.g. "confKey=" + kv.put(argParts[0], null); + } + } else if (argParts.length > 2) { + throw new IllegalArgumentException(CONF_ERR_MSG); + } else { + if (argParts[0].isEmpty()) { + throw new IllegalArgumentException(CONF_ERR_MSG); + } + kv.put(argParts[0], argParts[1]); + } + } + + private void printUsage() { + System.out.println("yarn schedconf [-add queueAddPath1,confKey1=confVal1," + + "confKey2=confVal2;queueAddPath2,confKey3=confVal3] " + + "[-remove queueRemovePath1,queueRemovePath2] " + + "[-update queueUpdatePath1,confKey1=confVal1] " + + "[-global globalConfKey1=globalConfVal1," + + "globalConfKey2=globalConfVal2]"); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestSchedConfCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestSchedConfCLI.java new file mode 100644 index 00000000000..d2f063920d9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestSchedConfCLI.java @@ -0,0 +1,160 @@ +/** +* 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.client.cli; + +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.List; +import java.util.Map; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +/** + * Class for testing {@link SchedConfCLI}. + */ +public class TestSchedConfCLI { + + private ByteArrayOutputStream sysOutStream; + private PrintStream sysOut; + + private ByteArrayOutputStream sysErrStream; + private PrintStream sysErr; + + private SchedConfCLI cli; + + @Before + public void setUp() { + sysOutStream = new ByteArrayOutputStream(); + sysOut = new PrintStream(sysOutStream); + System.setOut(sysOut); + + sysErrStream = new ByteArrayOutputStream(); + sysErr = new PrintStream(sysErrStream); + System.setErr(sysErr); + + cli = new SchedConfCLI(); + } + + @Test(timeout = 10000) + public void testInvalidConf() throws Exception { + // conf pair with no key should be invalid + int exitCode = cli.run(new String[] {"-add", "root.a,=confVal"}); + assertTrue("Should return an error code", exitCode != 0); + assertTrue(sysErrStream.toString().contains("Specify configuration key " + + "value as confKey=confVal.")); + exitCode = cli.run(new String[] {"-update", "root.a,=confVal"}); + assertTrue("Should return an error code", exitCode != 0); + assertTrue(sysErrStream.toString().contains("Specify configuration key " + + "value as confKey=confVal.")); + + exitCode = cli.run(new String[] {"-add", "root.a,confKey=confVal=conf"}); + assertTrue("Should return an error code", exitCode != 0); + assertTrue(sysErrStream.toString().contains("Specify configuration key " + + "value as confKey=confVal.")); + exitCode = cli.run(new String[] {"-update", "root.a,confKey=confVal=c"}); + assertTrue("Should return an error code", exitCode != 0); + assertTrue(sysErrStream.toString().contains("Specify configuration key " + + "value as confKey=confVal.")); + } + + @Test(timeout = 10000) + public void testAddQueues() { + SchedConfUpdateInfo schedUpdateInfo = new SchedConfUpdateInfo(); + cli.addQueues("root.a,a1=aVal1,a2=aVal2," + + "a3=", schedUpdateInfo); + QueueConfigInfo addInfo = schedUpdateInfo.getAddQueueInfo().get(0); + assertEquals("root.a", addInfo.getQueue()); + Map params = addInfo.getParams(); + assertEquals(3, params.size()); + assertEquals("aVal1", params.get("a1")); + assertEquals("aVal2", params.get("a2")); + assertNull(params.get("a3")); + + schedUpdateInfo = new SchedConfUpdateInfo(); + cli.addQueues("root.b,b1=bVal1;root.c,c1=cVal1", schedUpdateInfo); + assertEquals(2, schedUpdateInfo.getAddQueueInfo().size()); + QueueConfigInfo bAddInfo = schedUpdateInfo.getAddQueueInfo().get(0); + assertEquals("root.b", bAddInfo.getQueue()); + Map bParams = bAddInfo.getParams(); + assertEquals(1, bParams.size()); + assertEquals("bVal1", bParams.get("b1")); + QueueConfigInfo cAddInfo = schedUpdateInfo.getAddQueueInfo().get(1); + assertEquals("root.c", cAddInfo.getQueue()); + Map cParams = cAddInfo.getParams(); + assertEquals(1, cParams.size()); + assertEquals("cVal1", cParams.get("c1")); + } + + @Test(timeout = 10000) + public void testRemoveQueues() { + SchedConfUpdateInfo schedUpdateInfo = new SchedConfUpdateInfo(); + cli.removeQueues("root.a,root.b,root.c.c1", schedUpdateInfo); + List removeInfo = schedUpdateInfo.getRemoveQueueInfo(); + assertEquals(3, removeInfo.size()); + assertEquals("root.a", removeInfo.get(0)); + assertEquals("root.b", removeInfo.get(1)); + assertEquals("root.c.c1", removeInfo.get(2)); + } + + @Test(timeout = 10000) + public void testUpdateQueues() { + SchedConfUpdateInfo schedUpdateInfo = new SchedConfUpdateInfo(); + cli.updateQueues("root.a,a1=aVal1,a2=aVal2," + + "a3=", schedUpdateInfo); + QueueConfigInfo updateInfo = schedUpdateInfo.getUpdateQueueInfo().get(0); + assertEquals("root.a", updateInfo.getQueue()); + Map params = updateInfo.getParams(); + assertEquals(3, params.size()); + assertEquals("aVal1", params.get("a1")); + assertEquals("aVal2", params.get("a2")); + assertNull(params.get("a3")); + + schedUpdateInfo = new SchedConfUpdateInfo(); + cli.updateQueues("root.b,b1=bVal1;root.c,c1=cVal1", schedUpdateInfo); + assertEquals(2, schedUpdateInfo.getUpdateQueueInfo().size()); + QueueConfigInfo bUpdateInfo = schedUpdateInfo.getUpdateQueueInfo().get(0); + assertEquals("root.b", bUpdateInfo.getQueue()); + Map bParams = bUpdateInfo.getParams(); + assertEquals(1, bParams.size()); + assertEquals("bVal1", bParams.get("b1")); + QueueConfigInfo cUpdateInfo = schedUpdateInfo.getUpdateQueueInfo().get(1); + assertEquals("root.c", cUpdateInfo.getQueue()); + Map cParams = cUpdateInfo.getParams(); + assertEquals(1, cParams.size()); + assertEquals("cVal1", cParams.get("c1")); + } + + @Test(timeout = 10000) + public void testGlobalUpdate() { + SchedConfUpdateInfo schedUpdateInfo = new SchedConfUpdateInfo(); + cli.globalUpdates("schedKey1=schedVal1,schedKey2=schedVal2", + schedUpdateInfo); + Map globalInfo = schedUpdateInfo.getGlobalParams(); + assertEquals(2, globalInfo.size()); + assertEquals("schedVal1", globalInfo.get("schedKey1")); + assertEquals("schedVal2", globalInfo.get("schedKey2")); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/dao/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/dao/package-info.java new file mode 100644 index 00000000000..aec67627729 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/dao/package-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +/** + * Data structures for scheduler configuration mutation info. + */ +@InterfaceAudience.Private +@InterfaceStability.Unstable +package org.apache.hadoop.yarn.webapp.dao; +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceStability; + diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/YarnWebServiceUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/YarnWebServiceUtils.java index 4167e21f51d..1cf1e9717e4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/YarnWebServiceUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/YarnWebServiceUtils.java @@ -23,9 +23,14 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import javax.ws.rs.core.MediaType; + +import com.sun.jersey.api.json.JSONJAXBContext; +import com.sun.jersey.api.json.JSONMarshaller; import org.apache.hadoop.conf.Configuration; import org.codehaus.jettison.json.JSONObject; +import java.io.StringWriter; + /** * This class contains several utility function which could be used to generate * Restful calls to RM/NM/AHS. @@ -59,4 +64,13 @@ public final class YarnWebServiceUtils { .get(ClientResponse.class); return response.getEntity(JSONObject.class); } + + @SuppressWarnings("rawtypes") + public static String toJson(Object nsli, Class klass) throws Exception { + StringWriter sw = new StringWriter(); + JSONJAXBContext ctx = new JSONJAXBContext(klass); + JSONMarshaller jm = ctx.createJSONMarshaller(); + jm.marshallToJSON(nsli, sw); + return sw.toString(); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ConfigurationMutationACLPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ConfigurationMutationACLPolicy.java index 3a388feb612..5bc5874ae39 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ConfigurationMutationACLPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/ConfigurationMutationACLPolicy.java @@ -21,7 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; /** * Interface for determining whether configuration mutations are allowed. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/DefaultConfigurationMutationACLPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/DefaultConfigurationMutationACLPolicy.java index 6648668d9e7..1de6f6b0724 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/DefaultConfigurationMutationACLPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/DefaultConfigurationMutationACLPolicy.java @@ -22,7 +22,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.security.YarnAuthorizationProvider; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; /** * Default configuration mutation ACL policy. Checks if user is YARN admin. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfScheduler.java index 027d9441b57..007dc29af7d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfScheduler.java @@ -19,7 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import java.io.IOException; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfigurationProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfigurationProvider.java index 6b8306c80ce..86be7c378a1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfigurationProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/MutableConfigurationProvider.java @@ -19,7 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import java.io.IOException; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index 1ac9aa35856..4151fe7b884 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -142,11 +142,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.Placeme import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimplePlacementSet; import org.apache.hadoop.yarn.server.resourcemanager.security.AppPriorityACLsManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; import org.apache.hadoop.yarn.server.utils.Lock; import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; import org.apache.hadoop.yarn.util.resource.ResourceCalculator; import org.apache.hadoop.yarn.util.resource.Resources; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; @LimitedPrivate("yarn") @Evolving diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java index b9e42e4297c..4a3088ca224 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/MutableCSConfigurationProvider.java @@ -31,8 +31,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.YarnConfigurationStore.LogMutation; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import java.io.IOException; import java.util.ArrayList; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/QueueAdminConfigurationMutationACLPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/QueueAdminConfigurationMutationACLPolicy.java index 0a82d50cfe5..ee53fd18b2b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/QueueAdminConfigurationMutationACLPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/QueueAdminConfigurationMutationACLPolicy.java @@ -27,8 +27,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ConfigurationMutationACLPolicy; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.MutableConfScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import java.io.IOException; import java.util.HashSet; 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 65bee0e0826..2409ccd116a 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 @@ -198,6 +198,7 @@ import org.apache.hadoop.yarn.webapp.BadRequestException; import org.apache.hadoop.yarn.webapp.ForbiddenException; import org.apache.hadoop.yarn.webapp.NotFoundException; import org.apache.hadoop.yarn.webapp.util.WebAppUtils; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import com.google.common.annotations.VisibleForTesting; import com.google.inject.Inject; 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/dao/QueueConfigInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/QueueConfigInfo.java index b20eda6a136..d1d91c2be0c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/QueueConfigInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/QueueConfigInfo.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; +package org.apache.hadoop.yarn.webapp.dao; import java.util.HashMap; import java.util.Map; @@ -54,4 +54,4 @@ public class QueueConfigInfo { return this.params; } -} \ No newline at end of file +} 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/dao/SchedConfUpdateInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedConfUpdateInfo.java index b7c585e733c..bb84096a545 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedConfUpdateInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedConfUpdateInfo.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; +package org.apache.hadoop.yarn.webapp.dao; import java.util.ArrayList; import java.util.HashMap; @@ -54,16 +54,32 @@ public class SchedConfUpdateInfo { return addQueueInfo; } + public void setAddQueueInfo(ArrayList addQueueInfo) { + this.addQueueInfo = addQueueInfo; + } + public ArrayList getRemoveQueueInfo() { return removeQueueInfo; } + public void setRemoveQueueInfo(ArrayList removeQueueInfo) { + this.removeQueueInfo = removeQueueInfo; + } + public ArrayList getUpdateQueueInfo() { return updateQueueInfo; } + public void setUpdateQueueInfo(ArrayList updateQueueInfo) { + this.updateQueueInfo = updateQueueInfo; + } + @XmlElementWrapper(name = "global-updates") public HashMap getGlobalParams() { return global; } + + public void setGlobalParams(HashMap globalInfo) { + this.global = globalInfo; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java index 0f5a3d82c54..398e90921e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestConfigurationMutationACLPolicies.java @@ -25,8 +25,8 @@ import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.conf.QueueAdminConfigurationMutationACLPolicy; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import org.junit.Before; import org.junit.Test; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java index 32167815a65..9104f1635e0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/TestMutableCSConfigurationProvider.java @@ -23,8 +23,8 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; import org.junit.Before; import org.junit.Test; 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/TestRMWebServicesConfigurationMutation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java index 2e32a0fe2ec..59236889fa7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesConfigurationMutation.java @@ -24,8 +24,6 @@ import com.google.inject.servlet.GuiceServletContextListener; import com.google.inject.servlet.ServletModule; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.json.JSONJAXBContext; -import com.sun.jersey.api.json.JSONMarshaller; import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; import com.sun.jersey.test.framework.WebAppDescriptor; import org.apache.hadoop.conf.Configuration; @@ -37,10 +35,11 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; import org.apache.hadoop.yarn.webapp.JerseyTestBase; +import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo; +import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo; +import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -51,7 +50,6 @@ import javax.ws.rs.core.Response.Status; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.StringWriter; import java.util.HashMap; import java.util.Map; @@ -189,8 +187,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -224,8 +222,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -250,8 +248,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -275,8 +273,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -306,8 +304,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -338,8 +336,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); @@ -366,8 +364,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = @@ -401,8 +399,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = cs.getConfiguration(); @@ -419,8 +417,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); newCSConf = cs.getConfiguration(); @@ -449,8 +447,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = @@ -474,8 +472,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); CapacitySchedulerConfiguration newCSConf = @@ -489,8 +487,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { r.path("ws").path("v1").path("cluster") .path("sched-conf").queryParam("user.name", userName) .accept(MediaType.APPLICATION_JSON) - .entity(toJson(updateInfo, SchedConfUpdateInfo.class), - MediaType.APPLICATION_JSON) + .entity(YarnWebServiceUtils.toJson(updateInfo, + SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON) .put(ClientResponse.class); assertEquals(Status.OK.getStatusCode(), response.getStatus()); newCSConf = @@ -512,13 +510,4 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase { } super.tearDown(); } - - @SuppressWarnings("rawtypes") - private String toJson(Object nsli, Class klass) throws Exception { - StringWriter sw = new StringWriter(); - JSONJAXBContext ctx = new JSONJAXBContext(klass); - JSONMarshaller jm = ctx.createJSONMarshaller(); - jm.marshallToJSON(nsli, sw); - return sw.toString(); - } }