sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-1028: Remove poll timeout parameter from Sqoop shell synchronous submission
Date Wed, 05 Jun 2013 21:57:58 GMT
Updated Branches:
  refs/heads/sqoop2 5d641ad6e -> 8122d4ca9


SQOOP-1028: Remove poll timeout parameter from Sqoop shell synchronous submission

(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/8122d4ca
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/8122d4ca
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/8122d4ca

Branch: refs/heads/sqoop2
Commit: 8122d4ca937cd8258f4e775dd40d3d52259c6e53
Parents: 5d641ad
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Jun 5 14:56:57 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Wed Jun 5 14:56:57 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |    4 +-
 .../sqoop/client/shell/SetOptionFunction.java      |   17 ++++++++++++++-
 .../sqoop/client/shell/ShellEnvironment.java       |   11 +++++++++
 .../sqoop/client/shell/ShowOptionFunction.java     |   13 +++++++++++
 .../client/shell/SubmissionStartFunction.java      |   12 +--------
 .../src/main/resources/client-resource.properties  |    1 +
 docs/src/site/sphinx/CommandLineClient.rst         |    6 ++--
 7 files changed, 48 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/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 979b892..866f3b8 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
@@ -206,6 +206,8 @@ public class Constants {
       "set.prompt_opt_value";
   public static final String RES_SET_VERBOSE_CHANGED =
       "set.verbose_changed";
+  public static final String RES_SET_POLL_TIMEOUT_CHANGED =
+      "set.poll_timeout_changed";
   public static final String RES_SET_UNKNOWN_OPT_IGNORED =
       "set.unknown_opt_ignored";
   public static final String RES_SET_HOST_DESCRIPTION =
@@ -306,8 +308,6 @@ public class Constants {
       "submission.usage";
   public static final String RES_PROMPT_SYNCHRONOUS =
       "submission.prompt_synchronous";
-  public static final String RES_PROMPT_POLL_TIMEOUT =
-      "submission.prompt_poll_timeout";
 
   public static final String RES_UPDATE_USAGE =
       "update.usage";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/client/src/main/java/org/apache/sqoop/client/shell/SetOptionFunction.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SetOptionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SetOptionFunction.java
index 9414b7d..e843ede 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SetOptionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SetOptionFunction.java
@@ -67,6 +67,21 @@ public class SetOptionFunction extends SqoopFunction {
       return;
     }
 
+    if (name.equals(Constants.OPT_POLL_TIMEOUT)) {
+      long newValue = 0;
+
+      try {
+        newValue = Long.parseLong(value);
+      } catch (NumberFormatException ex) {
+        // make the value stay the same
+        newValue = getPollTimeout();
+      }
+
+      setPollTimeout(newValue);
+      printlnResource(Constants.RES_SET_POLL_TIMEOUT_CHANGED, newValue);
+      return;
+    }
+
     printlnResource(Constants.RES_SET_UNKNOWN_OPT_IGNORED, name);
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/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
index 5dbcef5..79cd8b2 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShellEnvironment.java
@@ -35,12 +35,15 @@ public final class ShellEnvironment {
     // using static API.
   }
 
+  private static final long DEFAULT_POLL_TIMEOUT = 10000;
+
   private static String serverHost = getEnv(Constants.ENV_HOST, "localhost");
   private static String serverPort = getEnv(Constants.ENV_PORT, "12000");
   private static String serverWebapp = getEnv(Constants.ENV_WEBAPP, "sqoop");
 
   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());
@@ -114,6 +117,14 @@ public final class ShellEnvironment {
     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);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/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
index 246937c..81c5612 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/ShowOptionFunction.java
@@ -54,6 +54,10 @@ public class ShowOptionFunction extends SqoopFunction {
       if(optionName.equals(Constants.OPT_VERBOSE)) {
         printVerbose();
       }
+
+      if(optionName.equals(Constants.OPT_POLL_TIMEOUT)) {
+        printPollTimeout();
+      }
     }
 
     return null;
@@ -64,6 +68,7 @@ public class ShowOptionFunction extends SqoopFunction {
    */
   private void printAllOptions() {
     printVerbose();
+    printPollTimeout();
   }
 
   /**
@@ -73,4 +78,12 @@ public class ShowOptionFunction extends SqoopFunction {
     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/8122d4ca/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
index f04b1fd..04bcf45 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java
@@ -32,7 +32,6 @@ import static org.apache.sqoop.client.shell.ShellEnvironment.*;
  */
 public class SubmissionStartFunction extends SqoopFunction {
   public static final Logger LOG = Logger.getLogger(SubmissionStartFunction.class);
-  public static final long POLL_TIMEOUT = 10000;
 
   @SuppressWarnings("static-access")
   public SubmissionStartFunction() {
@@ -45,11 +44,6 @@ public class SubmissionStartFunction extends SqoopFunction {
       .withDescription(resourceString(Constants.RES_PROMPT_SYNCHRONOUS))
       .withLongOpt(Constants.OPT_SYNCHRONOUS)
       .create(Constants.OPT_SYNCHRONOUS_CHAR));
-    this.addOption(OptionBuilder
-      .withDescription(resourceString(Constants.RES_PROMPT_POLL_TIMEOUT))
-      .withLongOpt(Constants.OPT_POLL_TIMEOUT)
-      .hasArg()
-      .create(Constants.OPT_POLL_TIMEOUT_CHAR));
   }
 
   public Object executeFunction(CommandLine line) {
@@ -60,7 +54,7 @@ public class SubmissionStartFunction extends SqoopFunction {
 
     // Poll until finished
     if (line.hasOption(Constants.OPT_SYNCHRONOUS)) {
-      long pollTimeout = POLL_TIMEOUT;
+      long pollTimeout = getPollTimeout();
       SubmissionCallback callback = new SubmissionCallback() {
         @Override
         public void submitted(MSubmission submission) {
@@ -78,9 +72,7 @@ public class SubmissionStartFunction extends SqoopFunction {
           SubmissionDisplayer.displayFooter(submission);
         }
       };
-      if (line.hasOption(Constants.OPT_POLL_TIMEOUT)) {
-        pollTimeout = getLong(line,Constants.OPT_POLL_TIMEOUT);
-      }
+
       try {
         client.startSubmission(getLong(line, Constants.OPT_JID), callback, pollTimeout);
       } catch (InterruptedException e) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/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 e328f9a..bbc8313 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -107,6 +107,7 @@ set.usage = Usage: set {0}
 set.prompt_opt_name = Client option name
 set.prompt_opt_value = New option value
 set.verbose_changed = Verbose option was changed to {0}
+set.poll_timeout_changed = Poll timeout option has been changed to {0}
 set.unknown_opt_ignored = Unknown option {0}. Ignoring...
 set.host_description = Host name to invoke server resources
 set.port_description = Port number to invoke server resources

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8122d4ca/docs/src/site/sphinx/CommandLineClient.rst
----------------------------------------------------------------------
diff --git a/docs/src/site/sphinx/CommandLineClient.rst b/docs/src/site/sphinx/CommandLineClient.rst
index 33419b9..721a6c0 100644
--- a/docs/src/site/sphinx/CommandLineClient.rst
+++ b/docs/src/site/sphinx/CommandLineClient.rst
@@ -109,10 +109,13 @@ Configure Sqoop client related options. This function have two required
argument
 +===================+===============+=====================================================================+
 | ``verbose``       | false         | Client will print additional information if verbose
mode is enabled |
 +-------------------+---------------+---------------------------------------------------------------------+
+| ``poll-timeout``  | 10000         | Server poll timeout in milliseconds               
                 |
++-------------------+---------------+---------------------------------------------------------------------+
 
 Example: ::
 
   set option --name verbose --value true
+  set option --name poll-timeout --value 20000
 
 Show Command
 ------------
@@ -447,14 +450,11 @@ Start job (submit new submission). Starting already running job is considered
as
 +----------------------------+----------------------------+
 | ``-s``, ``--synchronous``  | Synchoronous job execution |
 +----------------------------+----------------------------+
-| ``-p``, ``--poll-timeout`` | Server poll timeout        |
-+----------------------------+----------------------------+
 
 Example: ::
 
   submission start --jid 1
   submission start --jid 1 --synchronous
-  submission start --jid 1 --synchronous --poll-timeout 10000
 
 
 Submission Stop Function


Mime
View raw message