SLIDER-408 slider getconf command should be removed (yu liu)
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/e3757269 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/e3757269 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/e3757269 Branch: refs/heads/feature/SLIDER-149_Support_a_YARN_service_registry Commit: e37572697cb3018a9065099ca13f0032dfa70ce4 Parents: 6b19cb8 Author: Steve Loughran <[email protected]> Authored: Wed Oct 8 11:39:15 2014 -0700 Committer: Steve Loughran <[email protected]> Committed: Wed Oct 8 11:39:15 2014 -0700 ---------------------------------------------------------------------- .../org/apache/slider/client/SliderClient.java | 97 -------------------- .../slider/common/params/ActionGetConfArgs.java | 51 ---------- .../apache/slider/common/params/ClientArgs.java | 9 -- .../slider/common/params/SliderActions.java | 1 - .../slider/client/TestCommonArgParsing.groovy | 31 ------- .../funtest/framework/CommandTestBase.groovy | 13 --- .../commands/UnknownClusterOperationsIT.groovy | 6 -- .../lifecycle/AgentClusterLifecycleIT.groovy | 2 - .../funtest/HBaseClusterLifecycleIT.groovy | 5 +- 9 files changed, 4 insertions(+), 211 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java index 2b76faf..8d2bcfd 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -58,7 +58,6 @@ import org.apache.slider.common.params.ActionCreateArgs; import org.apache.slider.common.params.ActionEchoArgs; import org.apache.slider.common.params.ActionFlexArgs; import org.apache.slider.common.params.ActionFreezeArgs; -import org.apache.slider.common.params.ActionGetConfArgs; import org.apache.slider.common.params.ActionKillContainerArgs; import org.apache.slider.common.params.ActionRegistryArgs; import org.apache.slider.common.params.ActionStatusArgs; @@ -325,8 +324,6 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe serviceArgs.getActionExistsArgs().live); } else if (ACTION_FLEX.equals(action)) { exitCode = actionFlex(clusterName, serviceArgs.getActionFlexArgs()); - } else if (ACTION_GETCONF.equals(action)) { - exitCode = actionGetConf(clusterName, serviceArgs.getActionGetConfArgs()); } else if (ACTION_HELP.equals(action) || ACTION_USAGE.equals(action)) { log.info(serviceArgs.usage()); @@ -1928,100 +1925,6 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe return EXIT_SUCCESS; } - /* - * Creates a site conf with entries from clientProperties of ClusterStatus - * @param desc ClusterDescription, can be null - * @param clustername, can be null - * @return site conf - */ - public Configuration getSiteConf(ClusterDescription desc, String clustername) - throws YarnException, IOException { - if (desc == null) { - desc = getClusterDescription(); - } - if (clustername == null) { - clustername = getDeployedClusterName(); - } - String description = "Slider Application Instance " + clustername; - - Configuration siteConf = new Configuration(false); - for (String key : desc.clientProperties.keySet()) { - siteConf.set(key, desc.clientProperties.get(key), description); - } - return siteConf; - } - - - /** - * get the cluster configuration - * @param clustername cluster name - * @return the cluster name - */ - - @SuppressWarnings( - {"UseOfSystemOutOrSystemErr", "IOResourceOpenedButNotSafelyClosed"}) - public int actionGetConf(String clustername, ActionGetConfArgs confArgs) throws - YarnException, - IOException { - File outfile = null; - - if (confArgs.getOutput() != null) { - outfile = new File(confArgs.getOutput()); - } - - String format = confArgs.getFormat(); - verifyBindingsDefined(); - SliderUtils.validateClusterName(clustername); - ClusterDescription status = getClusterDescription(clustername); - Writer writer; - boolean toPrint; - if (outfile != null) { - writer = new FileWriter(outfile); - toPrint = false; - } else { - writer = new StringWriter(); - toPrint = true; - } - try { - String description = "Slider Application Instance " + clustername; -// JDK7 -/* - switch (format) { - case Arguments.FORMAT_XML: - Configuration siteConf = getSiteConf(status, clustername); - siteConf.writeXml(writer); - break; - case Arguments.FORMAT_PROPERTIES: - Properties props = new Properties(); - props.putAll(status.clientProperties); - props.store(writer, description); - break; - default: - throw new BadCommandArgumentsException("Unknown format: " + format); - } -*/ - if (Arguments.FORMAT_XML.equals(format)) { - Configuration siteConf = getSiteConf(status, clustername); - siteConf.writeXml(writer); - } else if (Arguments.FORMAT_PROPERTIES.equals(format)) { - Properties props = new Properties(); - props.putAll(status.clientProperties); - props.store(writer, description); - } else { - throw new BadCommandArgumentsException("Unknown format: " + format); - } - } finally { - // data is written. - // close the file - writer.close(); - } - // then, if this is not a file write, print it - if (toPrint) { - // not logged - System.err.println(writer.toString()); - } - return EXIT_SUCCESS; - } /** * Restore a cluster http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-core/src/main/java/org/apache/slider/common/params/ActionGetConfArgs.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/params/ActionGetConfArgs.java b/slider-core/src/main/java/org/apache/slider/common/params/ActionGetConfArgs.java deleted file mode 100644 index b636a5e..0000000 --- a/slider-core/src/main/java/org/apache/slider/common/params/ActionGetConfArgs.java +++ /dev/null @@ -1,51 +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.slider.common.params; - -import com.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; - -@Parameters(commandNames = {SliderActions.ACTION_GETCONF}, - commandDescription = SliderActions.DESCRIBE_ACTION_GETCONF) - -public class ActionGetConfArgs extends AbstractActionArgs { - @Override - public String getActionName() { - return SliderActions.ACTION_GETCONF; - } - - //--format - @Parameter(names = ARG_FORMAT, - description = "Format for a response: [text|xml|json|properties]") - public String format = FORMAT_XML; - - - @Parameter(names = {ARG_OUTPUT, ARG_OUTPUT_SHORT}, - description = "Output file for the configuration data") - private String output; - - - public String getFormat() { - return format; - } - - public String getOutput() { - return output; - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-core/src/main/java/org/apache/slider/common/params/ClientArgs.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/params/ClientArgs.java b/slider-core/src/main/java/org/apache/slider/common/params/ClientArgs.java index cd981b1..50bf106 100644 --- a/slider-core/src/main/java/org/apache/slider/common/params/ClientArgs.java +++ b/slider-core/src/main/java/org/apache/slider/common/params/ClientArgs.java @@ -53,7 +53,6 @@ public class ClientArgs extends CommonArgs { private final ActionExistsArgs actionExistsArgs = new ActionExistsArgs(); private final ActionFlexArgs actionFlexArgs = new ActionFlexArgs(); private final ActionFreezeArgs actionFreezeArgs = new ActionFreezeArgs(); - private final ActionGetConfArgs actionGetConfArgs = new ActionGetConfArgs(); private final ActionKillContainerArgs actionKillContainerArgs = new ActionKillContainerArgs(); private final ActionListArgs actionListArgs = new ActionListArgs(); @@ -85,7 +84,6 @@ public class ClientArgs extends CommonArgs { actionExistsArgs, actionFlexArgs, actionFreezeArgs, - actionGetConfArgs, actionKillContainerArgs, actionListArgs, actionRegistryArgs, @@ -157,10 +155,6 @@ public class ClientArgs extends CommonArgs { return actionFreezeArgs; } - public ActionGetConfArgs getActionGetConfArgs() { - return actionGetConfArgs; - } - public ActionKillContainerArgs getActionKillContainerArgs() { return actionKillContainerArgs; } @@ -224,9 +218,6 @@ public class ClientArgs extends CommonArgs { } else if (SliderActions.ACTION_FLEX.equals(action)) { bindCoreAction(actionFlexArgs); - } else if (SliderActions.ACTION_GETCONF.equals(action)) { - bindCoreAction(actionGetConfArgs); - } else if (SliderActions.ACTION_HELP.equals(action) || SliderActions.ACTION_USAGE.equals(action)) { bindCoreAction(actionHelpArgs); http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-core/src/main/java/org/apache/slider/common/params/SliderActions.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/params/SliderActions.java b/slider-core/src/main/java/org/apache/slider/common/params/SliderActions.java index 29fd098..a711ca0 100644 --- a/slider-core/src/main/java/org/apache/slider/common/params/SliderActions.java +++ b/slider-core/src/main/java/org/apache/slider/common/params/SliderActions.java @@ -33,7 +33,6 @@ public interface SliderActions { String ACTION_EXISTS = "exists"; String ACTION_FLEX = "flex"; String ACTION_FREEZE = "stop"; - String ACTION_GETCONF = "getconf"; String ACTION_HELP = "help"; String ACTION_KILL_CONTAINER = "kill-container"; String ACTION_LIST = "list"; http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-core/src/test/groovy/org/apache/slider/client/TestCommonArgParsing.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/client/TestCommonArgParsing.groovy b/slider-core/src/test/groovy/org/apache/slider/client/TestCommonArgParsing.groovy index ea44489..95d3483 100644 --- a/slider-core/src/test/groovy/org/apache/slider/client/TestCommonArgParsing.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/client/TestCommonArgParsing.groovy @@ -234,37 +234,6 @@ class TestCommonArgParsing implements SliderActions, Arguments { } @Test - public void testGetConfFailsNoArg() throws Throwable { - assertParseFails([ - ACTION_GETCONF, - ]) - } - - @Test - public void testGetConfWorks1Arg() throws Throwable { - ClientArgs ca = createClientArgs([ - ACTION_GETCONF, - CLUSTERNAME, - ]) - assert ca.clusterName == CLUSTERNAME - assert ca.coreAction instanceof ActionGetConfArgs - } - - @Test - public void testGetConfWorksOut() throws Throwable { - ClientArgs ca = createClientArgs([ - ACTION_GETCONF, - CLUSTERNAME, - ARG_FORMAT,"xml", - ARG_OUTPUT,"file.xml" - ]) - assert ca.clusterName == CLUSTERNAME - assert ca.coreAction instanceof ActionGetConfArgs - assert ca.actionGetConfArgs.format == "xml" - assert ca.actionGetConfArgs.output == "file.xml" - } - - @Test public void testGetStatusWorks1Arg() throws Throwable { ClientArgs ca = createClientArgs([ ACTION_STATUS, http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy index 216b68d..d780ac7 100644 --- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy +++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy @@ -238,19 +238,6 @@ abstract class CommandTestBase extends SliderTestUtils { freeze(name, [ARG_FORCE]) } - static SliderShell getConf(String name) { - slider([ - ACTION_GETCONF, name - ]) - } - - static SliderShell getConf(int result, String name) { - slider(result, - [ - ACTION_GETCONF, name - ]) - } - static SliderShell killContainer(String name, String containerID) { slider(0, [ http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy index 39ae4dd..6eaf54a 100644 --- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy +++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/commands/UnknownClusterOperationsIT.groovy @@ -26,7 +26,6 @@ import org.apache.slider.common.params.Arguments import org.apache.slider.common.params.SliderActions import org.apache.slider.funtest.framework.CommandTestBase import org.apache.slider.funtest.framework.SliderShell -import org.junit.BeforeClass import org.junit.Test /** @@ -92,9 +91,4 @@ public class UnknownClusterOperationsIT extends CommandTestBase { assertUnknownCluster(status(UNKNOWN)) } - @Test - public void testGetConfUnknownCluster() throws Throwable { - assertUnknownCluster(getConf(UNKNOWN)) - } - } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy ---------------------------------------------------------------------- diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy index 73ca275..48ae266 100644 --- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy +++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentClusterLifecycleIT.groovy @@ -115,8 +115,6 @@ public class AgentClusterLifecycleIT extends AgentCommandTestBase log.info(cd.toJsonString()) - getConf(0, CLUSTER) - //get a slider client against the cluster SliderClient sliderClient = bondToCluster(SLIDER_CONFIG, CLUSTER) ClusterDescription cd2 = sliderClient.clusterDescription http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e3757269/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/HBaseClusterLifecycleIT.groovy ---------------------------------------------------------------------- diff --git a/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/HBaseClusterLifecycleIT.groovy b/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/HBaseClusterLifecycleIT.groovy index c65593f..7943464 100644 --- a/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/HBaseClusterLifecycleIT.groovy +++ b/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/HBaseClusterLifecycleIT.groovy @@ -20,6 +20,7 @@ package org.apache.slider.providers.hbase.funtest import groovy.transform.CompileStatic import groovy.util.logging.Slf4j +import org.apache.slider.server.appmaster.PublishedArtifacts import org.apache.slider.api.ClusterDescription import org.apache.slider.api.StatusKeys import org.apache.slider.client.SliderClient @@ -108,7 +109,9 @@ public class HBaseClusterLifecycleIT extends HBaseCommandTestBase log.info(cd.toJsonString()) - getConf(0, CLUSTER) + def yarn_site_config = PublishedArtifacts.COMPLETE_CONFIG + registry([ARG_GETCONF, yarn_site_config, + ARG_NAME, CLUSTER]) //get a slider client against the cluster SliderClient sliderClient = bondToCluster(SLIDER_CONFIG, CLUSTER)
