You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by hs...@apache.org on 2013/08/07 01:20:09 UTC
[2/3] SQOOP-921. Sqoop2: Create standalone shell package
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/SetServerFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SetServerFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SetServerFunction.java
deleted file mode 100644
index 41fc17a..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SetServerFunction.java
+++ /dev/null
@@ -1,78 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-@SuppressWarnings("serial")
-public class SetServerFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected SetServerFunction() {
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_HOST)
- .withDescription(resourceString(Constants.RES_SET_HOST_DESCRIPTION))
- .withLongOpt(Constants.OPT_HOST)
- .create(Constants.OPT_HOST_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_PORT)
- .withDescription(resourceString(Constants.RES_SET_PORT_DESCRIPTION))
- .withLongOpt(Constants.OPT_PORT)
- .create(Constants.OPT_PORT_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_WEBAPP)
- .withDescription(resourceString(Constants.RES_WEBAPP_DESCRIPTION))
- .withLongOpt(Constants.OPT_WEBAPP)
- .create(Constants.OPT_WEBAPP_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_URL)
- .withDescription(resourceString(Constants.RES_URL_DESCRIPTION))
- .withLongOpt(Constants.OPT_URL)
- .create(Constants.OPT_URL_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.getArgs().length == 1) {
- printlnResource(Constants.RES_SET_SERVER_USAGE);
- return null;
- }
-
- if (line.hasOption(Constants.OPT_URL)) {
- setServerUrl(line.getOptionValue(Constants.OPT_URL));
-
- // ignore --host, --port and --webapp option
- if (line.hasOption(Constants.OPT_HOST)
- || line.hasOption(Constants.OPT_PORT)
- || line.hasOption(Constants.OPT_WEBAPP)) {
- printlnResource(Constants.RES_SET_SERVER_IGNORED);
- }
- } else {
- if (line.hasOption(Constants.OPT_HOST)) {
- setServerHost(line.getOptionValue(Constants.OPT_HOST));
- }
- if (line.hasOption(Constants.OPT_PORT)) {
- setServerPort(line.getOptionValue(Constants.OPT_PORT));
- }
- if (line.hasOption(Constants.OPT_WEBAPP)) {
- setServerWebapp(line.getOptionValue(Constants.OPT_WEBAPP));
- }
- }
-
- printlnResource(Constants.RES_SET_SERVER_SUCCESSFUL);
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
deleted file mode 100644
index 41a8cd3..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
+++ /dev/null
@@ -1,208 +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.sqoop.client.shell;
-
-import org.apache.sqoop.client.SqoopClient;
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.common.SqoopException;
-import org.codehaus.groovy.tools.shell.IO;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-/**
- * Static internal environment of the shell shared across all commands and
- * functions.
- */
-public final class ShellEnvironment {
- private ShellEnvironment() {
- // Direct instantiation is prohibited as entire functionality is exposed
- // using static API.
- }
-
- private static final long DEFAULT_POLL_TIMEOUT = 10000;
-
- private static String DEFAULT_SERVER_HOST = getEnv(Constants.ENV_HOST, "localhost");
- private static String DEFAULT_SERVER_PORT = getEnv(Constants.ENV_PORT, "12000");
- private static String DEFAULT_SERVER_WEBAPP = getEnv(Constants.ENV_WEBAPP, "sqoop");
-
- private static String serverHost = DEFAULT_SERVER_HOST;
- private static String serverPort = DEFAULT_SERVER_PORT;
- private static String serverWebapp = DEFAULT_SERVER_WEBAPP;
-
- private static boolean verbose = false;
- private static boolean interactive = false;
- private static long pollTimeout = DEFAULT_POLL_TIMEOUT;
-
- static ResourceBundle resource = ResourceBundle.getBundle(Constants.RESOURCE_NAME, Locale.getDefault());
- static SqoopClient client = new SqoopClient(getServerUrl());
- static IO io;
-
- public static String getEnv(String variable, String defaultValue) {
- String value = System.getenv(variable);
- return value != null ? value : defaultValue;
- }
-
- public static SqoopClient getClient() {
- return client;
- }
-
- public static void setIo(IO ioObject) {
- io = ioObject;
- }
-
- public static IO getIo() {
- return io;
- }
-
- public static void setServerHost(String host) {
- serverHost = host;
- client.setServerUrl(getServerUrl());
- }
-
- public static String getServerHost() {
- return serverHost;
- }
-
- public static void setServerPort(String port) {
- serverPort = port;
- client.setServerUrl(getServerUrl());
- }
-
- public static String getServerPort() {
- return serverPort;
- }
-
- public static void setServerWebapp(String webapp) {
- serverWebapp = webapp;
- client.setServerUrl(getServerUrl());
- }
-
- public static String getServerWebapp() {
- return serverWebapp;
- }
-
- public static void setServerUrl(String ustr){
- try {
- URL url = new URL(ustr);
-
- String host = url.getHost();
- if (host.length() > 0) {
- serverHost = host;
- }
-
- int port = url.getPort();
- if (port != -1) {
- serverPort = Integer.toString(port);
- } else {
- // use default port number
- serverPort = DEFAULT_SERVER_PORT;
- }
-
- String webapp = url.getFile();
- if (webapp.length() > 1) {
- // get rid of the first slash
- serverWebapp = webapp.substring(1);
- } else {
- // use default webapp name
- serverWebapp = DEFAULT_SERVER_WEBAPP;
- }
-
- client.setServerUrl(getServerUrl());
- } catch (MalformedURLException ex) {
- throw new SqoopException(ClientError.CLIENT_0003, ex);
- }
- }
-
- public static String getServerUrl() {
- return "http://" + serverHost + ":" + serverPort + "/" + serverWebapp + "/";
- }
-
- public static ResourceBundle getResourceBundle() {
- return resource;
- }
-
- public static void setVerbose(boolean newValue) {
- verbose = newValue;
- }
-
- public static boolean isVerbose() {
- return verbose;
- }
-
- public static void setInteractive(boolean newValue) {
- interactive = newValue;
- }
-
- public static boolean isInteractive() {
- return interactive;
- }
-
- public static void setPollTimeout(long timeout) {
- pollTimeout = timeout;
- }
-
- public static long getPollTimeout() {
- return pollTimeout;
- }
-
- public static String resourceString(String resourceName) {
- return resource.getString(resourceName);
- }
-
- public static void printlnResource(String resourceName) {
- io.out.println(resource.getString(resourceName));
- }
-
- public static void printlnResource(String resourceName, Object... values) {
- io.out.println(MessageFormat.format(resourceString(resourceName), values));
- }
-
- public static void println(String str, Object ... values) {
- io.out.println(MessageFormat.format(str, values));
- }
-
- public static void println(String str) {
- io.out.println(str);
- }
-
- public static void println(Object obj) {
- io.out.println(obj);
- }
-
- public static void println() {
- io.out.println();
- }
-
- public static void print(String str) {
- io.out.print(str);
- }
-
- public static void print(Object obj) {
- io.out.print(obj);
- }
-
- public static void print(String format, Object... args) {
- io.out.printf(format, args);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
deleted file mode 100644
index 4245717..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowCommand.java
+++ /dev/null
@@ -1,105 +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.sqoop.client.shell;
-
-import java.util.List;
-import org.apache.sqoop.client.core.Constants;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-public class ShowCommand extends SqoopCommand
-{
- private ShowServerFunction serverFunction;
- private ShowVersionFunction versionFunction;
- private ShowConnectorFunction connectorFunction;
- private ShowJobFunction jobFunction;
- private ShowSubmissionFunction submissionFunction;
- private ShowFrameworkFunction frameworkFunction;
- private ShowConnectionFunction connectionFunction;
- private ShowOptionFunction optionFunction;
-
-
- protected ShowCommand(Shell shell) {
- super(shell, Constants.CMD_SHOW, Constants.CMD_SHOW_SC,
- new String[] {Constants.FN_SERVER, Constants.FN_VERSION,
- Constants.FN_CONNECTOR, Constants.FN_FRAMEWORK,
- Constants.FN_CONNECTION, Constants.FN_JOB, Constants.FN_SUBMISSION, Constants.FN_OPTION },
- Constants.PRE_SHOW, Constants.SUF_INFO);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public Object executeCommand(List args) {
- if (args.size() == 0) {
- printlnResource(Constants.RES_SHOW_USAGE, getUsage());
- return null;
- }
-
- String func = (String)args.get(0);
- if (func.equals(Constants.FN_SERVER)) {
- if (serverFunction == null) {
- serverFunction = new ShowServerFunction();
- }
- return serverFunction.execute(args);
-
- } else if (func.equals(Constants.FN_VERSION)) {
- if (versionFunction == null) {
- versionFunction = new ShowVersionFunction();
- }
- return versionFunction.execute(args);
-
- } else if (func.equals(Constants.FN_CONNECTOR)) {
- if (connectorFunction == null) {
- connectorFunction = new ShowConnectorFunction();
- }
- return connectorFunction.execute(args);
-
- } else if (func.equals(Constants.FN_FRAMEWORK)) {
- if (frameworkFunction == null) {
- frameworkFunction = new ShowFrameworkFunction();
- }
- return frameworkFunction.execute(args);
-
- } else if (func.equals(Constants.FN_CONNECTION)) {
- if (connectionFunction == null) {
- connectionFunction = new ShowConnectionFunction();
- }
- return connectionFunction.execute(args);
-
- } else if (func.equals(Constants.FN_JOB)) {
- if (jobFunction == null) {
- jobFunction = new ShowJobFunction();
- }
- return jobFunction.execute(args);
- } else if (func.equals(Constants.FN_SUBMISSION)) {
- if (submissionFunction == null) {
- submissionFunction = new ShowSubmissionFunction();
- }
- return submissionFunction.execute(args);
- } else if (func.equals(Constants.FN_OPTION)) {
- if (optionFunction == null) {
- optionFunction = new ShowOptionFunction();
- }
- return optionFunction.execute(args);
- } else {
- printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
deleted file mode 100644
index 94f92b3..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectionFunction.java
+++ /dev/null
@@ -1,123 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.TableDisplayer;
-import org.apache.sqoop.model.MConnection;
-
-import java.text.DateFormat;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-import static org.apache.sqoop.client.utils.FormDisplayer.*;
-
-/**
- *
- */
-public class ShowConnectionFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowConnectionFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNS))
- .withLongOpt(Constants.OPT_ALL)
- .create(Constants.OPT_ALL_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_XID)
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_CONN_XID))
- .withLongOpt(Constants.OPT_XID)
- .create(Constants.OPT_XID_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_ALL)) {
- showConnections();
- } else if (line.hasOption(Constants.OPT_XID)) {
- showConnection(getLong(line, Constants.OPT_XID));
- } else {
- showSummary();
- }
-
- return null;
- }
-
- private void showSummary() {
- List<MConnection> connections = client.getConnections();
-
- List<String> header = new LinkedList<String>();
- header.add(resourceString(Constants.RES_TABLE_HEADER_ID));
- header.add(resourceString(Constants.RES_TABLE_HEADER_NAME));
- header.add(resourceString(Constants.RES_TABLE_HEADER_CONNECTOR));
- header.add(resourceString(Constants.RES_TABLE_HEADER_ENABLED));
-
- List<String> ids = new LinkedList<String>();
- List<String> names = new LinkedList<String>();
- List<String> connectors = new LinkedList<String>();
- List<String> availabilities = new LinkedList<String>();
-
- for(MConnection connection : connections) {
- ids.add(String.valueOf(connection.getPersistenceId()));
- names.add(connection.getName());
- connectors.add(String.valueOf(connection.getConnectorId()));
- availabilities.add(String.valueOf(connection.getEnabled()));
- }
-
- TableDisplayer.display(header, ids, names, connectors, availabilities);
- }
-
- private void showConnections() {
- List<MConnection> connections = client.getConnections();
-
- printlnResource(Constants.RES_SHOW_PROMPT_CONNS_TO_SHOW, connections.size());
-
- for (MConnection connection : connections) {
- displayConnection(connection);
- }
- }
-
- private void showConnection(Long xid) {
- MConnection connection = client.getConnection(xid);
-
- printlnResource(Constants.RES_SHOW_PROMPT_CONNS_TO_SHOW, 1);
-
- displayConnection(connection);
- }
-
- private void displayConnection(MConnection connection) {
- DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
-
- printlnResource(Constants.RES_SHOW_PROMPT_CONN_INFO,
- connection.getPersistenceId(),
- connection.getName(),
- connection.getEnabled(),
- formatter.format(connection.getCreationDate()),
- formatter.format(connection.getLastUpdateDate())
- );
-
- long connectorId = connection.getConnectorId();
- printlnResource(Constants.RES_SHOW_PROMPT_CONN_CID_INFO, connectorId);
-
- // Display connector part
- displayForms(connection.getConnectorPart().getForms(),
- client.getResourceBundle(connectorId));
- displayForms(connection.getFrameworkPart().getForms(),
- client.getFrameworkResourceBundle());
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
deleted file mode 100644
index b053339..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowConnectorFunction.java
+++ /dev/null
@@ -1,110 +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.sqoop.client.shell;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.TableDisplayer;
-import org.apache.sqoop.model.MConnector;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-import static org.apache.sqoop.client.utils.FormDisplayer.*;
-
-@SuppressWarnings("serial")
-public class ShowConnectorFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowConnectorFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_CONNECTORS))
- .withLongOpt(Constants.OPT_ALL)
- .create(Constants.OPT_ALL_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName("cid")
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_CONNECTOR_CID))
- .withLongOpt(Constants.OPT_CID)
- .create(Constants.OPT_CID_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_ALL)) {
- showConnectors();
- } else if (line.hasOption(Constants.OPT_CID)) {
- showConnector(getLong(line, Constants.OPT_CID));
- } else {
- showSummary();
- }
-
- return null;
- }
-
- private void showSummary() {
- Collection<MConnector> connectors = client.getConnectors();
-
- List<String> header = new LinkedList<String>();
- header.add(resourceString(Constants.RES_TABLE_HEADER_ID));
- header.add(resourceString(Constants.RES_TABLE_HEADER_NAME));
- header.add(resourceString(Constants.RES_TABLE_HEADER_VERSION));
- header.add(resourceString(Constants.RES_TABLE_HEADER_CLASS));
-
- List<String> ids = new LinkedList<String>();
- List<String> uniqueNames = new LinkedList<String>();
- List<String> versions = new LinkedList<String>();
- List<String> classes = new LinkedList<String>();
-
- for(MConnector connector : connectors) {
- ids.add(String.valueOf(connector.getPersistenceId()));
- uniqueNames.add(connector.getUniqueName());
- versions.add(connector.getVersion());
- classes.add(connector.getClassName());
- }
-
- TableDisplayer.display(header, ids, uniqueNames, versions, classes);
- }
-
- private void showConnectors() {
- Collection<MConnector> connectors = client.getConnectors();
-
- printlnResource(Constants.RES_SHOW_PROMPT_CONNECTORS_TO_SHOW, connectors.size());
-
- for (MConnector connector : connectors) {
- displayConnector(connector);
- }
- }
-
- private void showConnector(Long cid) {
- MConnector connector = client.getConnector(cid);
-
- printlnResource(Constants.RES_SHOW_PROMPT_CONNECTORS_TO_SHOW, 1);
-
- displayConnector(connector);
- }
-
- private void displayConnector(MConnector connector) {
- printlnResource(Constants.RES_SHOW_PROMPT_CONNECTOR_INFO,
- connector.getPersistenceId(),
- connector.getUniqueName(),
- connector.getClassName(),
- connector.getVersion()
- );
- displayFormMetadataDetails(connector, client.getResourceBundle(connector.getPersistenceId()));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowFrameworkFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowFrameworkFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowFrameworkFunction.java
deleted file mode 100644
index 58b2c6e..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowFrameworkFunction.java
+++ /dev/null
@@ -1,55 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.model.MFramework;
-
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-import static org.apache.sqoop.client.utils.FormDisplayer.*;
-
-/**
- *
- */
-public class ShowFrameworkFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowFrameworkFunction() {
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.getArgs().length != 0) {
- printlnResource(Constants.RES_SHOW_FRAMEWORK_USAGE);
- return null;
- }
-
- showFramework();
-
- return null;
- }
-
- private void showFramework() {
- MFramework framework = client.getFramework();
- ResourceBundle bundle = client.getFrameworkResourceBundle();
-
- printlnResource(Constants.RES_SHOW_PROMPT_FRAMEWORK_OPTS, framework.getPersistenceId());
- displayFormMetadataDetails(framework, bundle);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
deleted file mode 100644
index 97a240b..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowJobFunction.java
+++ /dev/null
@@ -1,125 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.TableDisplayer;
-import org.apache.sqoop.model.MJob;
-
-import java.text.DateFormat;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-import static org.apache.sqoop.client.utils.FormDisplayer.*;
-
-/**
- *
- */
-public class ShowJobFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowJobFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_JOBS))
- .withLongOpt(Constants.OPT_ALL)
- .create(Constants.OPT_ALL_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOB_JID))
- .withLongOpt(Constants.OPT_JID)
- .create(Constants.OPT_JID_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_ALL)) {
- showJobs();
- } else if (line.hasOption(Constants.OPT_JID)) {
- showJob(getLong(line, Constants.OPT_JID));
- } else {
- showSummary();
- }
-
- return null;
- }
-
- private void showSummary() {
- List<MJob> jobs = client.getJobs();
-
- List<String> header = new LinkedList<String>();
- header.add(resourceString(Constants.RES_TABLE_HEADER_ID));
- header.add(resourceString(Constants.RES_TABLE_HEADER_NAME));
- header.add(resourceString(Constants.RES_TABLE_HEADER_TYPE));
- header.add(resourceString(Constants.RES_TABLE_HEADER_CONNECTOR));
- header.add(resourceString(Constants.RES_TABLE_HEADER_ENABLED));
-
- List<String> ids = new LinkedList<String>();
- List<String> names = new LinkedList<String>();
- List<String> types = new LinkedList<String>();
- List<String> connectors = new LinkedList<String>();
- List<String> availabilities = new LinkedList<String>();
-
- for(MJob job : jobs) {
- ids.add(String.valueOf(job.getPersistenceId()));
- names.add(job.getName());
- types.add(job.getType().toString());
- connectors.add(String.valueOf(job.getConnectorId()));
- availabilities.add(String.valueOf(job.getEnabled()));
- }
-
- TableDisplayer.display(header, ids, names, types, connectors, availabilities);
- }
-
- private void showJobs() {
- List<MJob> jobs = client.getJobs();
- printlnResource(Constants.RES_SHOW_PROMPT_JOBS_TO_SHOW, jobs.size());
-
- for (MJob job : jobs) {
- displayJob(job);
- }
- }
-
- private void showJob(Long jid) {
- MJob job = client.getJob(jid);
- printlnResource(Constants.RES_SHOW_PROMPT_JOBS_TO_SHOW, 1);
-
- displayJob(job);
- }
-
- private void displayJob(MJob job) {
- DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
-
- printlnResource(
- Constants.RES_SHOW_PROMPT_JOB_INFO,
- job.getPersistenceId(),
- job.getName(),
- job.getEnabled(),
- formatter.format(job.getCreationDate()),
- formatter.format(job.getLastUpdateDate())
- );
- printlnResource(Constants.RES_SHOW_PROMPT_JOB_XID_CID_INFO,
- job.getConnectionId(),
- job.getConnectorId());
-
- // Display connector part
- displayForms(job.getConnectorPart().getForms(),
- client.getResourceBundle(job.getConnectorId()));
- displayForms(job.getFrameworkPart().getForms(),
- client.getFrameworkResourceBundle());
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java
deleted file mode 100644
index 81c5612..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java
+++ /dev/null
@@ -1,89 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- * Show client internal options
- */
-public class ShowOptionFunction extends SqoopFunction {
- /**
- * Construct new object.
- */
- @SuppressWarnings("static-access")
- protected ShowOptionFunction() {
- this.addOption(OptionBuilder
- .hasArg().withArgName(Constants.OPT_NAME)
- .withDescription(resource.getString(Constants.RES_SET_PROMPT_OPT_NAME))
- .withLongOpt(Constants.OPT_NAME)
- .create(Constants.OPT_NAME_CHAR));
- }
-
- /**
- * Execute this function from parsed command line.
- */
- public Object executeFunction(CommandLine line) {
- if (line.getArgs().length == 1) {
- printAllOptions();
- return null;
- }
-
- if (line.hasOption(Constants.OPT_NAME)) {
- String optionName = line.getOptionValue(Constants.OPT_NAME);
-
- if(optionName.equals(Constants.OPT_VERBOSE)) {
- printVerbose();
- }
-
- if(optionName.equals(Constants.OPT_POLL_TIMEOUT)) {
- printPollTimeout();
- }
- }
-
- return null;
- }
-
- /**
- * Print all known client options.
- */
- private void printAllOptions() {
- printVerbose();
- printPollTimeout();
- }
-
- /**
- * Print verbose option.
- */
- private void printVerbose() {
- print("Verbose = ");
- println(String.valueOf(isVerbose()));
- }
-
- /**
- * Print poll-timeout option.
- */
- private void printPollTimeout() {
- print("Poll-timeout = ");
- println(String.valueOf(getPollTimeout()));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java
deleted file mode 100644
index 110f67e..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowServerFunction.java
+++ /dev/null
@@ -1,88 +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.sqoop.client.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-@SuppressWarnings("serial")
-public class ShowServerFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowServerFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SERVERS))
- .withLongOpt(Constants.OPT_ALL)
- .create(Constants.OPT_ALL_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_SERVER_HOST))
- .withLongOpt(Constants.OPT_HOST)
- .create(Constants.OPT_HOST_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_SERVER_PORT))
- .withLongOpt(Constants.OPT_PORT)
- .create(Constants.OPT_PORT_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_SERVER_WEBAPP))
- .withLongOpt(Constants.OPT_WEBAPP)
- .create(Constants.OPT_WEBAPP_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.getArgs().length == 1) {
- printlnResource(Constants.RES_SHOW_SERVER_USAGE);
- return null;
- }
-
- if (line.hasOption(Constants.OPT_ALL)) {
- showServer(true, true, true, true);
-
- } else {
- boolean host = false, port = false, webapp = false, version = false;
- if (line.hasOption(Constants.OPT_HOST)) {
- host = true;
- }
- if (line.hasOption(Constants.OPT_PORT)) {
- port = true;
- }
- if (line.hasOption(Constants.OPT_WEBAPP)) {
- webapp = true;
- }
-
- showServer(host, port, webapp, version);
- }
-
- return null;
- }
-
- private void showServer(boolean host, boolean port, boolean webapp, boolean version) {
- if (host) {
- printlnResource(Constants.RES_SHOW_PROMPT_SERVER_HOST, getServerHost());
- }
-
- if (port) {
- printlnResource(Constants.RES_SHOW_PROMPT_SERVER_PORT, getServerPort());
- }
-
- if (webapp) {
- printlnResource(Constants.RES_SHOW_PROMPT_SERVER_WEBAPP, getServerWebapp());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowSubmissionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowSubmissionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowSubmissionFunction.java
deleted file mode 100644
index 666eb7a..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowSubmissionFunction.java
+++ /dev/null
@@ -1,106 +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.sqoop.client.shell;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.SubmissionDisplayer;
-import org.apache.sqoop.client.utils.TableDisplayer;
-import org.apache.sqoop.model.MSubmission;
-import org.apache.sqoop.submission.SubmissionStatus;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-public class ShowSubmissionFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- protected ShowSubmissionFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS))
- .withLongOpt(Constants.OPT_DETAIL)
- .create(Constants.OPT_DETAIL_CHAR));
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_SUBMISSIONS_JOB_ID))
- .withLongOpt(Constants.OPT_JID)
- .create(Constants.OPT_JID_CHAR));
- }
-
- @Override
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_DETAIL)) {
- if (line.hasOption(Constants.OPT_JID)) {
- showSubmissions(getLong(line, Constants.OPT_JID));
- } else {
- showSubmissions(null);
- }
- } else {
- if (line.hasOption(Constants.OPT_JID)) {
- showSummary(getLong(line, Constants.OPT_JID));
- } else {
- showSummary(null);
- }
- }
-
- return null;
- }
-
- private void showSummary(Long jid) {
- List<MSubmission> submissions;
- if (jid == null) {
- submissions = client.getSubmissions();
- } else {
- submissions = client.getSubmissionsForJob(jid);
- }
-
- List<String> header = new LinkedList<String>();
- header.add(resourceString(Constants.RES_TABLE_HEADER_JOB_ID));
- header.add(resourceString(Constants.RES_TABLE_HEADER_EXTERNAL_ID));
- header.add(resourceString(Constants.RES_TABLE_HEADER_STATUS));
- header.add(resourceString(Constants.RES_TABLE_HEADER_DATE));
-
- List<String> jids = new LinkedList<String>();
- List<String> eids = new LinkedList<String>();
- List<String> status = new LinkedList<String>();
- List<String> dates = new LinkedList<String>();
-
- for (MSubmission submission : submissions) {
- jids.add(String.valueOf(submission.getJobId()));
- eids.add(String.valueOf(submission.getExternalId()));
- status.add(submission.getStatus().toString());
- dates.add(submission.getLastUpdateDate().toString());
- }
-
- TableDisplayer.display(header, jids, eids, status, dates);
- }
-
- private void showSubmissions(Long jid) {
- List<MSubmission> submissions;
- if (jid == null) {
- submissions = client.getSubmissions();
- } else {
- submissions = client.getSubmissionsForJob(jid);
- }
-
- for (MSubmission submission : submissions) {
- SubmissionDisplayer.displaySubmission(submission);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
deleted file mode 100644
index 8e17f67..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowVersionFunction.java
+++ /dev/null
@@ -1,127 +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.sqoop.client.shell;
-
-import java.util.Arrays;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.request.VersionRequest;
-import org.apache.sqoop.common.VersionInfo;
-import org.apache.sqoop.json.VersionBean;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-@SuppressWarnings("serial")
-public class ShowVersionFunction extends SqoopFunction {
- private VersionRequest versionRequest;
-
-
- @SuppressWarnings("static-access")
- protected ShowVersionFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_VERSIONS))
- .withLongOpt(Constants.OPT_ALL)
- .create(Constants.OPT_ALL_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_VERSION_SERVER))
- .withLongOpt(Constants.OPT_SERVER)
- .create(Constants.OPT_SERVER_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_VERSION_CLIENT))
- .withLongOpt(Constants.OPT_CLIENT)
- .create(Constants.OPT_CLIENT_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_VERSION_PROTOCOL))
- .withLongOpt(Constants.OPT_PROTOCOL)
- .create(Constants.OPT_PROTOCOL_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (line.getArgs().length == 1) {
- printlnResource(Constants.RES_SHOW_VERSION_USAGE);
- return null;
- }
-
- if (line.hasOption(Constants.OPT_ALL)) {
- showVersion(true, true, true);
-
- } else {
- boolean server = false, client = false, protocol = false;
- if (line.hasOption(Constants.OPT_SERVER)) {
- server = true;
- }
- if (line.hasOption(Constants.OPT_CLIENT)) {
- client = true;
- }
- if (line.hasOption(Constants.OPT_PROTOCOL)) {
- protocol = true;
- }
-
- showVersion(server, client, protocol);
- }
-
- return null;
- }
-
- private void showVersion(boolean server, boolean client, boolean protocol) {
-
- // If no option has been given, print out client version as default
- if (!client && !server && !protocol) {
- client = true;
- }
-
- // Print out client string if needed
- if (client) {
- printlnResource(Constants.RES_SHOW_PROMPT_VERSION_CLIENT_SERVER,
- Constants.OPT_CLIENT,
- VersionInfo.getVersion(),
- VersionInfo.getRevision(),
- VersionInfo.getUser(),
- VersionInfo.getDate()
- );
- }
-
- // If only client version was required we do not need to continue
- if(!server && !protocol) {
- return;
- }
-
- if (versionRequest == null) {
- versionRequest = new VersionRequest();
- }
- VersionBean versionBean = versionRequest.doGet(getServerUrl());
-
- if (server) {
- printlnResource(Constants.RES_SHOW_PROMPT_VERSION_CLIENT_SERVER,
- Constants.OPT_SERVER,
- versionBean.getVersion(),
- versionBean.getRevision(),
- versionBean.getUser(),
- versionBean.getDate()
- );
- }
-
- if (protocol) {
- printlnResource(Constants.RES_SHOW_PROMPT_VERSION_PROTOCOL,
- Arrays.toString(versionBean.getProtocols())
- );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
deleted file mode 100644
index 2188482..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
+++ /dev/null
@@ -1,152 +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.sqoop.client.shell;
-
-import groovy.lang.GroovyShell;
-import groovy.lang.MissingPropertyException;
-import groovy.lang.Script;
-
-import java.util.*;
-
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.common.SqoopException;
-import org.codehaus.groovy.tools.shell.ComplexCommandSupport;
-import org.codehaus.groovy.tools.shell.Shell;
-
-public abstract class SqoopCommand extends ComplexCommandSupport
-{
- private String descriptionPrefix;
- private String descriptionPostfix;
-
- private String description;
- private String usage;
- private String help;
-
- @SuppressWarnings("unchecked")
- protected SqoopCommand(Shell shell, String name, String shortcut,
- String[] funcs, String descriptionPrefix, String descriptionPostfix) {
- super(shell, name, shortcut);
-
- this.functions = new LinkedList<String>();
- for (String func : funcs) {
- this.functions.add(func);
- }
-
- this.descriptionPrefix = descriptionPrefix;
- this.descriptionPostfix = descriptionPostfix;
- }
-
- @Override
- public String getDescription() {
- if (description == null) {
- StringBuilder sb = new StringBuilder();
-
- if (descriptionPrefix != null) {
- sb.append(descriptionPrefix);
- sb.append(" ");
- }
-
- @SuppressWarnings("unchecked")
- Iterator<String> iterator = functions.iterator();
- int size = functions.size();
- sb.append(iterator.next());
- if (size > 1) {
- for (int i = 1; i < (size - 1); i++) {
- sb.append(", ");
- sb.append(iterator.next());
- }
- sb.append(" or ");
- sb.append(iterator.next());
- }
-
- if (descriptionPostfix != null) {
- sb.append(" ");
- sb.append(descriptionPostfix);
- }
-
- description = sb.toString();
- }
-
- return description;
- }
-
- @Override
- public String getUsage() {
- if (usage == null) {
- StringBuilder sb = new StringBuilder();
-
- sb.append("[");
-
- @SuppressWarnings("unchecked")
- Iterator<String> iterator = functions.iterator();
- int size = functions.size();
- sb.append(iterator.next());
- for (int i = 1; i < size; i++) {
- sb.append("|");
- sb.append(iterator.next());
- }
-
- sb.append("]");
-
- usage = sb.toString();
- }
-
- return usage;
- }
-
- @Override
- public String getHelp() {
- if (help == null) {
- help = getDescription() + ".";
- }
-
- return help;
- }
-
- /**
- * Override execute method
- */
- @Override
- public Object execute(List args) {
- resolveVariables(args);
- return executeCommand(args);
- }
-
- /**
- * Abstract executeCommand
- * @param args list
- * @return Object
- */
- public abstract Object executeCommand(List args);
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- protected void resolveVariables(List arg) {
- List temp = new ArrayList();
- GroovyShell gs = new GroovyShell(getBinding());
- for(Object obj:arg) {
- Script scr = gs.parse("\""+(String)obj+"\"");
- try {
- temp.add(scr.run().toString());
- }
- catch(MissingPropertyException e) {
- throw new SqoopException(ClientError.CLIENT_0004, e.getMessage(), e);
- }
- }
- Collections.copy(arg, temp);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java
deleted file mode 100644
index bf26761..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SqoopFunction.java
+++ /dev/null
@@ -1,74 +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.sqoop.client.shell;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.common.SqoopException;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-@SuppressWarnings("serial")
-abstract public class SqoopFunction extends Options {
-
- public void printHelp() {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printOptions(getIo().out, formatter.getWidth(), this, 0, 4);
- }
-
- public abstract Object executeFunction(CommandLine line);
-
- public Object execute(List<String> args) {
- CommandLine line = parseOptions(this, 1, args);
- return executeFunction(line);
- }
-
- protected CommandLine parseOptions(Options options, int start, List<String> arglist) {
- Iterator<String> iterator = arglist.iterator();
- int i = 0;
- for (; i < start; i ++) {
- iterator.next();
- }
-
- String[] args = new String[arglist.size() - start];
- for (; i < arglist.size(); i ++) {
- args[i - start] = iterator.next();
- }
-
- CommandLineParser parser = new GnuParser();
- CommandLine line;
- try {
- line = parser.parse(options, args);
- } catch (ParseException e) {
- throw new SqoopException(ClientError.CLIENT_0003, e.getMessage(), e);
- }
- return line;
- }
-
- protected long getLong(CommandLine line, String parameterName) {
- return Long.parseLong(line.getOptionValue(parameterName));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java b/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
deleted file mode 100644
index f4ea3be..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
+++ /dev/null
@@ -1,176 +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.sqoop.client.shell;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.ThrowableDisplayer;
-import org.codehaus.groovy.runtime.MethodClosure;
-import org.codehaus.groovy.tools.shell.Command;
-import org.codehaus.groovy.tools.shell.CommandRegistry;
-import org.codehaus.groovy.tools.shell.Groovysh;
-import org.codehaus.groovy.tools.shell.IO.Verbosity;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- * Main entry point to Sqoop client.
- *
- * Sqoop shell is implemented on top of Groovy shell.
- */
-public final class SqoopShell {
-
- /**
- * Location of resource file that can contain few initial commands that will
- * be loaded during each client execution.
- */
- private static final String RC_FILE = ".sqoop2rc";
-
- /**
- * Banner message that is displayed in interactive mode after client start.
- */
-
- /**
- * Hash of commands that we want to have in history in all cases.
- */
- public final static HashSet<String> commandsToKeep;
-
- static {
- commandsToKeep = new HashSet<String>();
- commandsToKeep.add("exit");
- commandsToKeep.add("history");
- }
-
- /**
- * Main entry point to the client execution.
- *
- * @param args Command line arguments
- * @throws Exception
- */
- public static void main (String[] args) throws Exception {
- System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
- Groovysh shell = new Groovysh();
-
- // Install our error hook (exception handling)
- shell.setErrorHook(new MethodClosure(ThrowableDisplayer.class, "errorHook"));
-
- CommandRegistry registry = shell.getRegistry();
- @SuppressWarnings("unchecked")
- Iterator<Command> iterator = registry.iterator();
- while (iterator.hasNext()) {
- Command command = iterator.next();
- if (!commandsToKeep.contains(command.getName())) {
- iterator.remove();
- // remove from "names" set to avoid duplicate error.
- registry.remove(command);
- }
- }
-
- shell.register(new HelpCommand(shell));
- shell.register(new SetCommand(shell));
- shell.register(new ShowCommand(shell));
- shell.register(new CreateCommand(shell));
- shell.register(new DeleteCommand(shell));
- shell.register(new UpdateCommand(shell));
- shell.register(new CloneCommand(shell));
- shell.register(new StartCommand(shell));
- shell.register(new StopCommand(shell));
- shell.register(new StatusCommand(shell));
- shell.register(new EnableCommand(shell));
- shell.register(new DisableCommand(shell));
-
- // Configure shared shell io object
- setIo(shell.getIo());
-
- // We're running in batch mode by default
- setInteractive(false);
-
- // Let's see if user do have resource file with initial commands that he
- // would like to apply.
- String homeDir = System.getProperty(Constants.PROP_HOMEDIR);
- File rcFile = new File(homeDir, RC_FILE);
-
- if(rcFile.exists()) {
- printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADRC, RC_FILE);
- interpretFileContent(rcFile, shell);
- printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADEDRC);
- }
-
- if (args.length == 0) {
- // Interactive mode:
- getIo().setVerbosity(Verbosity.QUIET);
- printlnResource(Constants.RES_SQOOP_SHELL_BANNER);
- println();
-
- // Switch to interactive mode
- setInteractive(true);
- shell.run(args);
-
- } else {
- // Batch mode (with a script file):
- File script = new File(args[0]);
- if (!script.isAbsolute()) {
- String userDir = System.getProperty(Constants.PROP_CURDIR);
- script = new File(userDir, args[0]);
- }
-
- interpretFileContent(script, shell);
- }
- }
-
- /**
- * Interpret file content in given shell.
- *
- * @param script Script file that should be interpreted
- * @param shell Shell where the script should be interpreted
- * @throws IOException
- */
- private static void interpretFileContent(File script, Groovysh shell) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(script));
- String line;
-
- // Iterate over all lines and executed them one by one
- while ((line = in.readLine()) != null) {
-
- // Skip comments and empty lines as we don't need to interpret those
- if(line.isEmpty() || line.startsWith("#")) {
- continue;
- }
-
- // Render shell and command to get user perception that it was run as usual
- print(shell.renderPrompt());
- println(line);
-
- // Manually trigger command line parsing
- Object result = shell.execute(line);
- if (result != null) {
- println(result);
- }
- }
- }
-
- private SqoopShell() {
- // Instantiation of this class is prohibited
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StartCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StartCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/StartCommand.java
deleted file mode 100644
index 7293f56..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StartCommand.java
+++ /dev/null
@@ -1,58 +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.sqoop.client.shell;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.sqoop.client.core.Constants;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.printlnResource;
-
-public class StartCommand extends SqoopCommand {
- public static final Logger LOG = Logger.getLogger(StartCommand.class);
-
- private StartJobFunction startJobFunction;
-
- @SuppressWarnings("static-access")
- protected StartCommand(Shell shell) {
- super(shell, Constants.CMD_START, Constants.CMD_START_SC,
- new String[] {Constants.FN_JOB}, Constants.PRE_START, null);
- }
-
- @Override
- public Object executeCommand(List args) {
- if (args.size() == 0) {
- printlnResource(Constants.RES_START_USAGE, getUsage());
- return null;
- }
-
- String func = (String) args.get(0);
- if (func.equals(Constants.FN_JOB)) {
- if (startJobFunction == null) {
- startJobFunction = new StartJobFunction();
- }
- return startJobFunction.execute(args);
- } else {
- printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StartJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StartJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/StartJobFunction.java
deleted file mode 100644
index 2e1c8d3..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StartJobFunction.java
+++ /dev/null
@@ -1,89 +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.sqoop.client.shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.client;
-import static org.apache.sqoop.client.shell.ShellEnvironment.getPollTimeout;
-import static org.apache.sqoop.client.shell.ShellEnvironment.resourceString;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.log4j.Logger;
-import org.apache.sqoop.client.SubmissionCallback;
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.SubmissionDisplayer;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MSubmission;
-
-public class StartJobFunction extends SqoopFunction {
- public static final Logger LOG = Logger.getLogger(StartJobFunction.class);
-
- @SuppressWarnings("static-access")
- public StartJobFunction() {
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
- .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
- .withLongOpt(Constants.OPT_JID)
- .create(Constants.OPT_JID_CHAR));
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_PROMPT_SYNCHRONOUS))
- .withLongOpt(Constants.OPT_SYNCHRONOUS)
- .create(Constants.OPT_SYNCHRONOUS_CHAR));
- }
-
- @Override
- public Object executeFunction(CommandLine line) {
- // Poll until finished
- if (line.hasOption(Constants.OPT_SYNCHRONOUS) && line.hasOption(Constants.OPT_JID)) {
- long pollTimeout = getPollTimeout();
- SubmissionCallback callback = new SubmissionCallback() {
- @Override
- public void submitted(MSubmission submission) {
- SubmissionDisplayer.displayHeader(submission);
- SubmissionDisplayer.displayProgress(submission);
- }
-
- @Override
- public void updated(MSubmission submission) {
- SubmissionDisplayer.displayProgress(submission);
- }
-
- @Override
- public void finished(MSubmission submission) {
- SubmissionDisplayer.displayFooter(submission);
- }
- };
-
- try {
- client.startSubmission(getLong(line, Constants.OPT_JID), callback, pollTimeout);
- } catch (InterruptedException e) {
- throw new SqoopException(ClientError.CLIENT_0009, e);
- }
- } else if (line.hasOption(Constants.OPT_JID)) {
- MSubmission submission = client.startSubmission(getLong(line, Constants.OPT_JID));
- if(submission.getStatus().isFailure()) {
- SubmissionDisplayer.displayFooter(submission);
- } else {
- SubmissionDisplayer.displayHeader(submission);
- SubmissionDisplayer.displayProgress(submission);
- }
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StatusCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StatusCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/StatusCommand.java
deleted file mode 100644
index 5aab035..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StatusCommand.java
+++ /dev/null
@@ -1,56 +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.sqoop.client.shell;
-
-import java.util.List;
-
-import org.apache.sqoop.client.core.Constants;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.printlnResource;
-
-public class StatusCommand extends SqoopCommand {
-
- private StatusJobFunction statusJobFunction;
-
- @SuppressWarnings("static-access")
- protected StatusCommand(Shell shell) {
- super(shell, Constants.CMD_STATUS, Constants.CMD_STATUS_SC,
- new String[] { Constants.FN_JOB }, Constants.PRE_STATUS, null);
- }
-
- @Override
- public Object executeCommand(List args) {
- if (args.size() == 0) {
- printlnResource(Constants.RES_STATUS_USAGE, getUsage());
- return null;
- }
-
- String func = (String) args.get(0);
- if (func.equals(Constants.FN_JOB)) {
- if (statusJobFunction == null) {
- statusJobFunction = new StatusJobFunction();
- }
- return statusJobFunction.execute(args);
- } else {
- printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StatusJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StatusJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/StatusJobFunction.java
deleted file mode 100644
index b854a90..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StatusJobFunction.java
+++ /dev/null
@@ -1,55 +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.sqoop.client.shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.client;
-import static org.apache.sqoop.client.shell.ShellEnvironment.resourceString;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.SubmissionDisplayer;
-import org.apache.sqoop.model.MSubmission;
-import org.apache.sqoop.submission.SubmissionStatus;
-
-public class StatusJobFunction extends SqoopFunction{
-
- @SuppressWarnings("static-access")
- public StatusJobFunction() {
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
- .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
- .withLongOpt(Constants.OPT_JID)
- .create(Constants.OPT_JID_CHAR));
- }
-
- @Override
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_JID)) {
- MSubmission submission = client.getSubmissionStatus(getLong(line, Constants.OPT_JID));
- if(submission.getStatus().isFailure() || submission.getStatus().equals(SubmissionStatus.SUCCEEDED)) {
- SubmissionDisplayer.displayHeader(submission);
- SubmissionDisplayer.displayFooter(submission);
- } else {
- SubmissionDisplayer.displayHeader(submission);
- SubmissionDisplayer.displayProgress(submission);
- }
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StopCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StopCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/StopCommand.java
deleted file mode 100644
index 154c58e..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StopCommand.java
+++ /dev/null
@@ -1,54 +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.sqoop.client.shell;
-
-import java.util.List;
-
-import org.apache.sqoop.client.core.Constants;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.printlnResource;
-
-public class StopCommand extends SqoopCommand {
-
- private StopJobFunction stopJobFunction;
-
- @SuppressWarnings("static-access")
- protected StopCommand(Shell shell) {
- super(shell, Constants.CMD_STOP, Constants.CMD_STOP_SC,
- new String[] { Constants.FN_JOB }, Constants.PRE_STOP, null);
- }
- @Override
- public Object executeCommand(List args) {
- if (args.size() == 0) {
- printlnResource(Constants.RES_STOP_USAGE, getUsage());
- return null;
- }
-
- String func = (String) args.get(0);
- if (func.equals(Constants.FN_JOB)) {
- if (stopJobFunction == null) {
- stopJobFunction = new StopJobFunction();
- }
- return stopJobFunction.execute(args);
- } else {
- printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/StopJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/StopJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/StopJobFunction.java
deleted file mode 100644
index 49ab461..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/StopJobFunction.java
+++ /dev/null
@@ -1,53 +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.sqoop.client.shell;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.client;
-import static org.apache.sqoop.client.shell.ShellEnvironment.resourceString;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.SubmissionDisplayer;
-import org.apache.sqoop.model.MSubmission;
-
-public class StopJobFunction extends SqoopFunction {
-
- @SuppressWarnings("static-access")
- public StopJobFunction() {
- this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
- .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
- .withLongOpt(Constants.OPT_JID)
- .create(Constants.OPT_JID_CHAR));
- }
-
- @Override
- public Object executeFunction(CommandLine line) {
- if (line.hasOption(Constants.OPT_JID)) {
- MSubmission submission = client.stopSubmission(getLong(line, Constants.OPT_JID));
- if(submission.getStatus().isFailure()) {
- SubmissionDisplayer.displayFooter(submission);
- } else {
- SubmissionDisplayer.displayHeader(submission);
- SubmissionDisplayer.displayProgress(submission);
- }
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java
deleted file mode 100644
index f16745c..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java
+++ /dev/null
@@ -1,69 +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.sqoop.client.shell;
-
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.common.SqoopException;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import java.util.List;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- *
- */
-public class UpdateCommand extends SqoopCommand {
-
- private UpdateConnectionFunction connectionFunction;
- private UpdateJobFunction jobFunction;
-
- public UpdateCommand(Shell shell) {
- super(shell, Constants.CMD_UPDATE, Constants.CMD_UPDATE_SC,
- new String[] {Constants.FN_CONNECTION, Constants.FN_JOB},
- Constants.PRE_UPDATE, Constants.SUF_INFO);
- }
-
- public Object executeCommand(List args) {
- if(!isInteractive()) {
- throw new SqoopException(ClientError.CLIENT_0007, "update");
- }
-
- if (args.size() == 0) {
- printlnResource(Constants.RES_UPDATE_USAGE, getUsage());
- return null;
- }
-
- String func = (String)args.get(0);
- if (func.equals(Constants.FN_CONNECTION)) {
- if (connectionFunction == null) {
- connectionFunction = new UpdateConnectionFunction();
- }
- return connectionFunction.execute(args);
- } else if (func.equals(Constants.FN_JOB)) {
- if (jobFunction == null) {
- jobFunction = new UpdateJobFunction();
- }
- return jobFunction.execute(args);
- } else {
- printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
deleted file mode 100644
index 8556e2b..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java
+++ /dev/null
@@ -1,97 +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.sqoop.client.shell;
-
-import jline.ConsoleReader;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.FormDisplayer;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MConnection;
-import org.apache.sqoop.validation.Status;
-
-import java.io.IOException;
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.client.utils.FormFiller.*;
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- *
- */
-public class UpdateConnectionFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- public UpdateConnectionFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_PROMPT_CONN_ID))
- .withLongOpt(Constants.OPT_XID)
- .hasArg()
- .create(Constants.OPT_XID_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (!line.hasOption(Constants.OPT_XID)) {
- printlnResource(Constants.RES_ARGS_XID_MISSING);
- return null;
- }
-
- try {
- updateConnection(getLong(line, Constants.OPT_XID));
- } catch (IOException ex) {
- throw new SqoopException(ClientError.CLIENT_0005, ex);
- }
-
- return null;
- }
-
- private void updateConnection(Long connectionId) throws IOException {
- printlnResource(Constants.RES_UPDATE_UPDATING_CONN, connectionId);
-
- ConsoleReader reader = new ConsoleReader();
-
- MConnection connection = client.getConnection(connectionId);
-
- ResourceBundle connectorBundle = client.getResourceBundle(connection.getConnectorId());
- ResourceBundle frameworkBundle = client.getFrameworkResourceBundle();
-
- Status status = Status.FINE;
-
- printlnResource(Constants.RES_PROMPT_UPDATE_CONN_METADATA);
-
- do {
- // Print error introduction if needed
- if( !status.canProceed() ) {
- errorIntroduction();
- }
-
- // Fill in data from user
- if(!fillConnection(reader, connection, connectorBundle, frameworkBundle)) {
- return;
- }
-
- // Try to create
- status = client.updateConnection(connection);
- } while(!status.canProceed());
- FormDisplayer.displayFormWarning(connection);
- printlnResource(Constants.RES_UPDATE_CONN_SUCCESSFUL, status.name());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0d4efda1/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
deleted file mode 100644
index 425a53f..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java
+++ /dev/null
@@ -1,95 +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.sqoop.client.shell;
-
-import jline.ConsoleReader;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.client.core.ClientError;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.FormDisplayer;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.validation.Status;
-
-import java.io.IOException;
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.client.utils.FormFiller.*;
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- *
- */
-public class UpdateJobFunction extends SqoopFunction {
- @SuppressWarnings("static-access")
- public UpdateJobFunction() {
- this.addOption(OptionBuilder
- .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
- .withLongOpt(Constants.OPT_JID)
- .hasArg()
- .create(Constants.OPT_JID_CHAR));
- }
-
- public Object executeFunction(CommandLine line) {
- if (!line.hasOption(Constants.OPT_JID)) {
- printlnResource(Constants.RES_ARGS_JID_MISSING);
- return null;
- }
-
- try {
- updateJob(getLong(line, Constants.OPT_JID));
- } catch (IOException ex) {
- throw new SqoopException(ClientError.CLIENT_0005, ex);
- }
-
- return null;
- }
-
- private void updateJob(Long jobId) throws IOException {
- printlnResource(Constants.RES_UPDATE_UPDATING_JOB, jobId);
-
- ConsoleReader reader = new ConsoleReader();
-
- MJob job = client.getJob(jobId);
-
- ResourceBundle connectorBundle = client.getResourceBundle(job.getConnectorId());
- ResourceBundle frameworkBundle = client.getFrameworkResourceBundle();
-
- Status status = Status.FINE;
-
- printlnResource(Constants.RES_PROMPT_UPDATE_JOB_METADATA);
-
- do {
- // Print error introduction if needed
- if( !status.canProceed() ) {
- errorIntroduction();
- }
-
- // Fill in data from user
- if(!fillJob(reader, job, connectorBundle, frameworkBundle)) {
- return;
- }
-
- // Try to create
- status = client.updateJob(job);
- } while(!status.canProceed());
- FormDisplayer.displayFormWarning(job);
- printlnResource(Constants.RES_UPDATE_JOB_SUCCESSFUL, status.name());
- }
-}