YARN-5953:Create CLI for changing YARN configurations. (Jonathan Hung via xgong)
This commit is contained in:
parent
e566fd8b58
commit
916bdbd6be
@ -142,6 +142,9 @@ function yarncmd_case
|
||||
HADOOP_SUBCMD_SUPPORTDAEMONIZATION="true"
|
||||
HADOOP_CLASSNAME='org.apache.hadoop.yarn.server.router.Router'
|
||||
;;
|
||||
schedconf)
|
||||
HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.cli.SchedConfCLI'
|
||||
;;
|
||||
scmadmin)
|
||||
HADOOP_CLASSNAME='org.apache.hadoop.yarn.client.SCMAdmin'
|
||||
;;
|
||||
|
@ -295,6 +295,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" (
|
||||
|
@ -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<QueueConfigInfo> 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<String> queuesToRemove = Arrays.asList(args.split(","));
|
||||
updateInfo.setRemoveQueueInfo(new ArrayList<>(queuesToRemove));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateQueues(String args, SchedConfUpdateInfo updateInfo) {
|
||||
if (args == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<QueueConfigInfo> 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<String, String> 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<String, String> queueConfigs = new HashMap<>();
|
||||
for (int i = 1; i < queueArgs.length; ++i) {
|
||||
putKeyValuePair(queueConfigs, queueArgs[i]);
|
||||
}
|
||||
return new QueueConfigInfo(queuePath, queueConfigs);
|
||||
}
|
||||
|
||||
private void putKeyValuePair(Map<String, String> 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]");
|
||||
}
|
||||
}
|
@ -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<String, String> 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<String, String> bParams = bAddInfo.getParams();
|
||||
assertEquals(1, bParams.size());
|
||||
assertEquals("bVal1", bParams.get("b1"));
|
||||
QueueConfigInfo cAddInfo = schedUpdateInfo.getAddQueueInfo().get(1);
|
||||
assertEquals("root.c", cAddInfo.getQueue());
|
||||
Map<String, String> 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<String> 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<String, String> 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<String, String> bParams = bUpdateInfo.getParams();
|
||||
assertEquals(1, bParams.size());
|
||||
assertEquals("bVal1", bParams.get("b1"));
|
||||
QueueConfigInfo cUpdateInfo = schedUpdateInfo.getUpdateQueueInfo().get(1);
|
||||
assertEquals("root.c", cUpdateInfo.getQueue());
|
||||
Map<String, String> 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<String, String> globalInfo = schedUpdateInfo.getGlobalParams();
|
||||
assertEquals(2, globalInfo.size());
|
||||
assertEquals("schedVal1", globalInfo.get("schedKey1"));
|
||||
assertEquals("schedVal2", globalInfo.get("schedKey2"));
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -23,9 +23,14 @@
|
||||
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 static JSONObject getNodeInfoFromRMWebService(Configuration conf,
|
||||
.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();
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
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.
|
||||
|
@ -22,7 +22,7 @@
|
||||
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.
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -137,11 +137,11 @@
|
||||
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;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
@ -31,8 +31,8 @@
|
||||
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;
|
||||
|
@ -27,8 +27,8 @@
|
||||
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;
|
||||
|
@ -199,6 +199,7 @@
|
||||
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;
|
||||
|
@ -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 HashMap<String, String> getParams() {
|
||||
return this.params;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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 ArrayList<QueueConfigInfo> getAddQueueInfo() {
|
||||
return addQueueInfo;
|
||||
}
|
||||
|
||||
public void setAddQueueInfo(ArrayList<QueueConfigInfo> addQueueInfo) {
|
||||
this.addQueueInfo = addQueueInfo;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRemoveQueueInfo() {
|
||||
return removeQueueInfo;
|
||||
}
|
||||
|
||||
public void setRemoveQueueInfo(ArrayList<String> removeQueueInfo) {
|
||||
this.removeQueueInfo = removeQueueInfo;
|
||||
}
|
||||
|
||||
public ArrayList<QueueConfigInfo> getUpdateQueueInfo() {
|
||||
return updateQueueInfo;
|
||||
}
|
||||
|
||||
public void setUpdateQueueInfo(ArrayList<QueueConfigInfo> updateQueueInfo) {
|
||||
this.updateQueueInfo = updateQueueInfo;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "global-updates")
|
||||
public HashMap<String, String> getGlobalParams() {
|
||||
return global;
|
||||
}
|
||||
|
||||
public void setGlobalParams(HashMap<String, String> globalInfo) {
|
||||
this.global = globalInfo;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
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;
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
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;
|
||||
|
||||
|
@ -22,8 +22,6 @@
|
||||
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;
|
||||
@ -35,11 +33,12 @@
|
||||
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.GuiceServletConfig;
|
||||
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;
|
||||
@ -50,7 +49,6 @@
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -183,8 +181,8 @@ public void testAddNestedQueue() throws Exception {
|
||||
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());
|
||||
@ -218,8 +216,8 @@ public void testAddWithUpdate() throws Exception {
|
||||
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());
|
||||
@ -244,8 +242,8 @@ public void testRemoveQueue() throws Exception {
|
||||
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());
|
||||
@ -269,8 +267,8 @@ public void testRemoveParentQueue() throws Exception {
|
||||
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());
|
||||
@ -300,8 +298,8 @@ public void testRemoveParentQueueWithCapacity() throws Exception {
|
||||
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());
|
||||
@ -332,8 +330,8 @@ public void testRemoveMultipleQueues() throws Exception {
|
||||
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());
|
||||
@ -360,8 +358,8 @@ private void stopQueue(String... queuePaths) throws Exception {
|
||||
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 =
|
||||
@ -395,8 +393,8 @@ public void testUpdateQueue() throws Exception {
|
||||
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();
|
||||
@ -413,8 +411,8 @@ public void testUpdateQueue() throws Exception {
|
||||
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();
|
||||
@ -443,8 +441,8 @@ public void testUpdateQueueCapacity() throws Exception {
|
||||
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 =
|
||||
@ -468,8 +466,8 @@ public void testGlobalConfChange() throws Exception {
|
||||
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 =
|
||||
@ -483,8 +481,8 @@ public void testGlobalConfChange() throws Exception {
|
||||
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 =
|
||||
@ -506,13 +504,4 @@ public void tearDown() throws Exception {
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user