sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-675: Sqoop2: Substitute submission command with top level commands start, stop and status
Date Mon, 01 Jul 2013 17:27:46 GMT
Updated Branches:
  refs/heads/sqoop2 aa8e1e779 -> 214cde024


SQOOP-675: Sqoop2: Substitute submission command with top level commands start, stop and status

(Mengwei Ding via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/214cde02
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/214cde02
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/214cde02

Branch: refs/heads/sqoop2
Commit: 214cde024a4110b0af39f5029dd260bdb6c420ec
Parents: aa8e1e7
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon Jul 1 10:24:42 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Jul 1 10:24:42 2013 -0700

----------------------------------------------------------------------
 .../apache/sqoop/client/core/ClientError.java   |  4 +
 .../org/apache/sqoop/client/core/Constants.java | 35 +++++---
 .../apache/sqoop/client/shell/SqoopShell.java   |  4 +-
 .../apache/sqoop/client/shell/StartCommand.java | 58 ++++++++++++
 .../sqoop/client/shell/StartJobFunction.java    | 89 +++++++++++++++++++
 .../sqoop/client/shell/StatusCommand.java       | 56 ++++++++++++
 .../sqoop/client/shell/StatusJobFunction.java   | 55 ++++++++++++
 .../apache/sqoop/client/shell/StopCommand.java  | 54 ++++++++++++
 .../sqoop/client/shell/StopJobFunction.java     | 53 +++++++++++
 .../sqoop/client/shell/SubmissionCommand.java   | 72 ---------------
 .../client/shell/SubmissionStartFunction.java   | 92 --------------------
 .../client/shell/SubmissionStatusFunction.java  | 53 -----------
 .../client/shell/SubmissionStopFunction.java    | 56 ------------
 .../main/resources/client-resource.properties   |  8 +-
 docs/src/site/sphinx/CommandLineClient.rst      | 48 +++++-----
 15 files changed, 423 insertions(+), 314 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/ClientError.java b/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
index 944fb49..d96f44e 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
@@ -47,6 +47,10 @@ public enum ClientError implements ErrorCode {
 
   /** Polling time of submission status cannot be negative */
   CLIENT_0008("Polling time of submission status cannot be negative"),
+
+  /** Job Submission : Cannot sleep */
+  CLIENT_0009("Cannot sleep"),
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
index 085fcdb..b7b0436 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Constants.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -91,12 +91,18 @@ public class Constants {
   public static final String CMD_SHOW = "show";
   public static final String CMD_SHOW_SC = "\\sh";
 
-  public static final String CMD_SUBMISSION = "submission";
-  public static final String CMD_SUBMISSION_SC = "\\sub";
-
   public static final String CMD_UPDATE = "update";
   public static final String CMD_UPDATE_SC = "\\up";
 
+  public static final String CMD_START = "start";
+  public static final String CMD_START_SC = "\\sta";
+
+  public static final String CMD_STOP = "stop";
+  public static final String CMD_STOP_SC = "\\stp";
+
+  public static final String CMD_STATUS = "status";
+  public static final String CMD_STATUS_SC = "\\stu";
+
   public static final String FN_CONNECTION = "connection";
   public static final String FN_JOB = "job";
   public static final String FN_SUBMISSION = "submission";
@@ -105,17 +111,16 @@ public class Constants {
   public static final String FN_CONNECTOR = "connector";
   public static final String FN_VERSION = "version";
   public static final String FN_FRAMEWORK = "framework";
-  public static final String FN_START = "start";
-  public static final String FN_STOP = "stop";
-  public static final String FN_STATUS = "status";
 
   public static final String PRE_CLONE = "Clone";
   public static final String PRE_CREATE = "Create";
   public static final String PRE_DELETE = "Delete";
   public static final String PRE_SET = "Set";
   public static final String PRE_SHOW = "Show";
-  public static final String PRE_SUBMISSION = "Submission";
   public static final String PRE_UPDATE = "Update";
+  public static final String PRE_START = "Start";
+  public static final String PRE_STATUS = "Status";
+  public static final String PRE_STOP = "Stop";
   public static final String SUF_INFO = "Info";
 
 
@@ -311,6 +316,17 @@ public class Constants {
   public static final String RES_SHOW_PROMPT_VERSION_PROTOCOL =
       "show.prompt_version_protocol";
 
+  public static final String RES_START_USAGE =
+      "start.usage";
+
+  public static final String RES_STATUS_USAGE =
+      "status.usage";
+  public static final String RES_PROMPT_SYNCHRONOUS =
+      "start.prompt_synchronous";
+
+  public static final String RES_STOP_USAGE =
+      "stop.usage";
+
   public static final String RES_SQOOP_SHELL_BANNER =
       "sqoop.shell_banner";
   public static final String RES_SQOOP_PROMPT_SHELL_LOADRC =
@@ -318,11 +334,6 @@ public class Constants {
   public static final String RES_SQOOP_PROMPT_SHELL_LOADEDRC =
       "sqoop.prompt_shell_loadedrc";
 
-  public static final String RES_SUBMISSION_USAGE =
-      "submission.usage";
-  public static final String RES_PROMPT_SYNCHRONOUS =
-      "submission.prompt_synchronous";
-
   public static final String RES_UPDATE_USAGE =
       "update.usage";
   public static final String RES_UPDATE_UPDATING_CONN =

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/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
index 83f1c4f..aa87f20 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SqoopShell.java
@@ -94,7 +94,9 @@ public final class SqoopShell {
     shell.register(new DeleteCommand(shell));
     shell.register(new UpdateCommand(shell));
     shell.register(new CloneCommand(shell));
-    shell.register(new SubmissionCommand(shell));
+    shell.register(new StartCommand(shell));
+    shell.register(new StopCommand(shell));
+    shell.register(new StatusCommand(shell));
 
     // Configure shared shell io object
     setIo(shell.getIo());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/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
new file mode 100644
index 0000000..7293f56
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StartCommand.java
@@ -0,0 +1,58 @@
+/**
+ * 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/214cde02/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
new file mode 100644
index 0000000..2e1c8d3
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StartJobFunction.java
@@ -0,0 +1,89 @@
+/**
+ * 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/214cde02/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
new file mode 100644
index 0000000..5aab035
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StatusCommand.java
@@ -0,0 +1,56 @@
+/**
+ * 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/214cde02/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
new file mode 100644
index 0000000..b854a90
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StatusJobFunction.java
@@ -0,0 +1,55 @@
+/**
+ * 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/214cde02/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
new file mode 100644
index 0000000..154c58e
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StopCommand.java
@@ -0,0 +1,54 @@
+/**
+ * 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/214cde02/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
new file mode 100644
index 0000000..49ab461
--- /dev/null
+++ b/client/src/main/java/org/apache/sqoop/client/shell/StopJobFunction.java
@@ -0,0 +1,53 @@
+/**
+ * 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/214cde02/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java
deleted file mode 100644
index 993bbde..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java
+++ /dev/null
@@ -1,72 +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.Constants;
-import org.codehaus.groovy.tools.shell.Shell;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- *
- */
-public class SubmissionCommand  extends SqoopCommand {
-
-  private SubmissionStartFunction startFunction;
-  private SubmissionStopFunction stopFunction;
-  private SubmissionStatusFunction statusFunction;
-
-  public SubmissionCommand(Shell shell) {
-    super(shell, Constants.CMD_SUBMISSION, Constants.CMD_SUBMISSION_SC,
-      new String[] {Constants.FN_START, Constants.FN_STOP,
-          Constants.FN_STATUS},
-      Constants.PRE_SUBMISSION, Constants.SUF_INFO);
-  }
-
-  public Object executeCommand(List args) {
-    String usageMsg = MessageFormat.format(resource.getString(Constants.RES_SUBMISSION_USAGE),
getUsage());
-    if (args.size() == 0) {
-      println(usageMsg);
-      return null;
-    }
-
-    String func = (String)args.get(0);
-    if (func.equals(Constants.FN_START)) {
-      if (startFunction == null) {
-        startFunction = new SubmissionStartFunction();
-      }
-      return startFunction.execute(args);
-    } else if (func.equals(Constants.FN_STOP)) {
-        if (stopFunction == null) {
-          stopFunction = new SubmissionStopFunction();
-        }
-        return stopFunction.execute(args);
-    } else if (func.equals(Constants.FN_STATUS)) {
-      if (statusFunction == null) {
-        statusFunction = new SubmissionStatusFunction();
-      }
-      return statusFunction.execute(args);
-    } else {
-      printlnResource(Constants.RES_FUNCTION_UNKNOWN, func);
-      return null;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
deleted file mode 100644
index 04bcf45..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
+++ /dev/null
@@ -1,92 +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.log4j.Logger;
-import org.apache.sqoop.client.SubmissionCallback;
-import org.apache.sqoop.client.core.Constants;
-import org.apache.sqoop.client.utils.SubmissionDisplayer;
-import org.apache.sqoop.model.MSubmission;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- * Class used to perform the submission start function
- */
-public class SubmissionStartFunction extends SqoopFunction {
-  public static final Logger LOG = Logger.getLogger(SubmissionStartFunction.class);
-
-  @SuppressWarnings("static-access")
-  public SubmissionStartFunction() {
-    this.addOption(OptionBuilder
-      .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
-      .withLongOpt(Constants.OPT_JID)
-      .hasArg()
-      .create(Constants.OPT_JID_CHAR));
-    this.addOption(OptionBuilder
-      .withDescription(resourceString(Constants.RES_PROMPT_SYNCHRONOUS))
-      .withLongOpt(Constants.OPT_SYNCHRONOUS)
-      .create(Constants.OPT_SYNCHRONOUS_CHAR));
-  }
-
-  public Object executeFunction(CommandLine line) {
-    if (!line.hasOption(Constants.OPT_JID)) {
-      printlnResource(Constants.RES_ARGS_JID_MISSING);
-      return null;
-    }
-
-    // Poll until finished
-    if (line.hasOption(Constants.OPT_SYNCHRONOUS)) {
-      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) {
-        LOG.error("Could not sleep");
-      }
-    } else {
-      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/214cde02/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
deleted file mode 100644
index 29144d1..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.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 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;
-
-import static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- * Class used to print submission status function
- */
-public class SubmissionStatusFunction extends  SqoopFunction {
-  @SuppressWarnings("static-access")
-  public SubmissionStatusFunction() {
-    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;
-    }
-
-    MSubmission submission = client.getSubmissionStatus(getLong(line, Constants.OPT_JID));
-    SubmissionDisplayer.displaySubmission(submission);
-
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
deleted file mode 100644
index c407d01..0000000
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.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 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 static org.apache.sqoop.client.shell.ShellEnvironment.*;
-
-/**
- * Class used to perform the submission stop function
- */
-public class SubmissionStopFunction extends SqoopFunction {
-  @SuppressWarnings("static-access")
-  public SubmissionStopFunction() {
-    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;
-    }
-
-    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/214cde02/client/src/main/resources/client-resource.properties
----------------------------------------------------------------------
diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties
index a27d246..5537a8e 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -169,8 +169,12 @@ sqoop.shell_banner = @|green Sqoop Shell:|@ Type '@|bold help|@' or '@|bold
\\h|
 sqoop.prompt_shell_loadrc = Loading resource file {0}
 sqoop.prompt_shell_loadedrc = Resource file loaded.
 
-submission.usage = Usage: submission {0}
-submission.prompt_synchronous = Wait for submission to finish
+start.usage = Usage: start {0}
+start.prompt_synchronous = Wait for submission to finish
+
+stop.usage = Usage: stop  {0}
+
+status.usage = Usage: status {0}
 
 # Various Table headers
 table.header.id = Id

http://git-wip-us.apache.org/repos/asf/sqoop/blob/214cde02/docs/src/site/sphinx/CommandLineClient.rst
----------------------------------------------------------------------
diff --git a/docs/src/site/sphinx/CommandLineClient.rst b/docs/src/site/sphinx/CommandLineClient.rst
index a14898f..22d6d47 100644
--- a/docs/src/site/sphinx/CommandLineClient.rst
+++ b/docs/src/site/sphinx/CommandLineClient.rst
@@ -447,26 +447,13 @@ Example: ::
 
   clone job --jid 1
 
+Start Command
+-------------
 
-Submission Command
-------------------
-
-Submission command is entry point for executing actual data transfers. It allows you to start,
stop and retrieve status of currently running jobs.
-
-Available functions:
-
-+----------------+-------------------------------------------------+
-| Function       | Description                                     |
-+================+=================================================+
-| ``start``      | Start job                                       |
-+----------------+-------------------------------------------------+
-| ``stop``       | Interrupt running job                           |
-+----------------+-------------------------------------------------+
-| ``status``     | Retrieve status for given job                   |
-+----------------+-------------------------------------------------+
+Start command will begin execution of an existing Sqoop job.
 
-Submission Start Function
-~~~~~~~~~~~~~~~~~~~~~~~~~
+Start Job Function
+~~~~~~~~~~~~~~~~~~
 
 Start job (submit new submission). Starting already running job is considered as invalid
operation.
 
@@ -480,12 +467,16 @@ Start job (submit new submission). Starting already running job is considered
as
 
 Example: ::
 
-  submission start --jid 1
-  submission start --jid 1 --synchronous
+  start job --jid 1
+  start job --jid 1 --synchronous
 
+Stop Command
+------------
 
-Submission Stop Function
-~~~~~~~~~~~~~~~~~~~~~~~~~
+Stop command will interrupt an job execution.
+
+Stop Job Function
+~~~~~~~~~~~~~~~~~
 
 Interrupt running job.
 
@@ -497,10 +488,15 @@ Interrupt running job.
 
 Example: ::
 
-  submission stop --jid 1
+  stop job --jid 1
 
-Submission Status Function
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+Status Command
+--------------
+
+Status command will retrieve the last status of a job.
+
+Status Job Function
+~~~~~~~~~~~~~~~~~~~
 
 Retrieve last status for given job.
 
@@ -512,5 +508,5 @@ Retrieve last status for given job.
 
 Example: ::
 
-  submission status --jid 1
+  status job --jid 1
 


Mime
View raw message