sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-984: Sqoop2: Improve user experience on synchronous job submission
Date Mon, 27 May 2013 06:12:58 GMT
Updated Branches:
  refs/heads/sqoop2 277429ed1 -> c6f433228


SQOOP-984: Sqoop2: Improve user experience on synchronous job submission

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

Branch: refs/heads/sqoop2
Commit: c6f4332289cf53a9cd59ed8739242722226abcb2
Parents: 277429e
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Sun May 26 23:11:58 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Sun May 26 23:11:58 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |   17 +++
 .../client/shell/SubmissionStartFunction.java      |   16 ++-
 .../client/shell/SubmissionStatusFunction.java     |   11 ++-
 .../sqoop/client/shell/SubmissionStopFunction.java |    9 +-
 .../sqoop/client/utils/SubmissionDisplayer.java    |  112 +++++++++------
 .../src/main/resources/client-resource.properties  |    9 ++
 docs/src/site/sphinx/CommandLineClient.rst         |   16 ++-
 7 files changed, 129 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/c6f43322/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 8c3c6a4..979b892 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
@@ -367,6 +367,23 @@ public class Constants {
   public static final String RES_FORMDISPLAYER_FORM_WARNING =
       "formdisplayer.warning_message";
 
+  public static final String RES_SUBMISSION_SUBMISSION_DETAIL =
+      "submission.submission_detail";
+  public static final String RES_SUBMISSION_JOB_ID =
+      "submission.job_id";
+  public static final String RES_SUBMISSION_CREATION_DATE =
+      "submission.creation_date";
+  public static final String RES_SUBMISSION_EXTERNAL_ID =
+      "submission.external_id";
+  public static final String RES_SUBMISSION_PROGRESS_NOT_AVAIL =
+      "submission.progress_not_available";
+  public static final String RES_SUBMISSION_COUNTERS =
+      "submission.counters";
+  public static final String RES_SUBMISSION_EXECUTED_SUCCESS =
+      "submission.executed_success";
+  public static final String RES_SUBMISSION_SERVER_URL =
+      "submission.server_url";
+
   private Constants() {
     // Instantiation is prohibited
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c6f43322/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 7009da2..f04b1fd 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
@@ -28,7 +28,7 @@ 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);
@@ -64,17 +64,18 @@ public class SubmissionStartFunction extends SqoopFunction {
       SubmissionCallback callback = new SubmissionCallback() {
         @Override
         public void submitted(MSubmission submission) {
-          SubmissionDisplayer.display(submission);
+          SubmissionDisplayer.displayHeader(submission);
+          SubmissionDisplayer.displayProgress(submission);
         }
 
         @Override
         public void updated(MSubmission submission) {
-          SubmissionDisplayer.display(submission);
+          SubmissionDisplayer.displayProgress(submission);
         }
 
         @Override
         public void finished(MSubmission submission) {
-          SubmissionDisplayer.display(submission);
+          SubmissionDisplayer.displayFooter(submission);
         }
       };
       if (line.hasOption(Constants.OPT_POLL_TIMEOUT)) {
@@ -87,7 +88,12 @@ public class SubmissionStartFunction extends SqoopFunction {
       }
     } else {
       MSubmission submission = client.startSubmission(getLong(line, Constants.OPT_JID));
-      SubmissionDisplayer.display(submission);
+      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/c6f43322/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
index 48db8ab..1a6d896 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java
@@ -22,11 +22,12 @@ 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")
@@ -45,7 +46,13 @@ public class SubmissionStatusFunction extends  SqoopFunction {
     }
 
     MSubmission submission = client.getSubmissionStatus(getLong(line, Constants.OPT_JID));
-    SubmissionDisplayer.display(submission);
+    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/c6f43322/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
index 8291a54..c407d01 100644
--- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
+++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java
@@ -26,7 +26,7 @@ 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")
@@ -45,7 +45,12 @@ public class SubmissionStopFunction extends SqoopFunction {
     }
 
     MSubmission submission = client.stopSubmission(getLong(line, Constants.OPT_JID));
-    SubmissionDisplayer.display(submission);
+    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/c6f43322/client/src/main/java/org/apache/sqoop/client/utils/SubmissionDisplayer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/utils/SubmissionDisplayer.java b/client/src/main/java/org/apache/sqoop/client/utils/SubmissionDisplayer.java
index c56cefd..e789e21 100644
--- a/client/src/main/java/org/apache/sqoop/client/utils/SubmissionDisplayer.java
+++ b/client/src/main/java/org/apache/sqoop/client/utils/SubmissionDisplayer.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.utils;
 
+import org.apache.sqoop.client.core.Constants;
 import org.apache.sqoop.model.MSubmission;
 import org.apache.sqoop.submission.SubmissionStatus;
 import org.apache.sqoop.submission.counter.Counter;
@@ -28,31 +29,31 @@ import java.text.SimpleDateFormat;
 import static org.apache.sqoop.client.shell.ShellEnvironment.*;
 
 /**
- *
+ * Class used for displaying or printing the submission details
  */
 public final class SubmissionDisplayer {
 
-  public static void display(MSubmission submission) {
+  private final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss
z");
 
-    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
-    println("@|bold Submission details|@");
+  /**
+   * On job submission, displays the initial job info
+   * @param submission
+   */
+  public static void displayHeader(MSubmission submission) {
+    println("@|bold "+ resourceString(Constants.RES_SUBMISSION_SUBMISSION_DETAIL) +"|@");
 
-    print("Job id: ");
+    print(resourceString(Constants.RES_SUBMISSION_JOB_ID)+": ");
     println(submission.getJobId());
 
-    print("Status: ");
-    printColoredStatus(submission.getStatus());
-    println();
+    print(resourceString(Constants.RES_SUBMISSION_SERVER_URL)+": ");
+    println(getServerUrl());
 
-    print("Creation date: ");
+    print(resourceString(Constants.RES_SUBMISSION_CREATION_DATE)+": ");
     println(dateFormat.format(submission.getCreationDate()));
 
-    print("Last update date: ");
-    println(dateFormat.format(submission.getLastUpdateDate()));
-
     String externalId = submission.getExternalId();
     if(externalId != null) {
-      print("External Id: ");
+      print(resourceString(Constants.RES_SUBMISSION_EXTERNAL_ID)+": ");
       println(externalId);
 
       String externalLink = submission.getExternalLink();
@@ -60,51 +61,68 @@ public final class SubmissionDisplayer {
         println("\t" + externalLink);
       }
     }
+  }
 
+  /**
+   * Displays the progress of the executing job
+   * @param submission
+   */
+  public static void displayProgress(MSubmission submission) {
+    StringBuilder sb = new StringBuilder();
     if(submission.getStatus().isRunning()) {
+      sb.append(dateFormat.format(submission.getLastUpdateDate())+": @|green "+submission.getStatus()+
" |@");
       double progress = submission.getProgress();
-      print("Progress: ");
+      sb.append(" - ");
       if(progress == -1) {
-        println("Progress is not available");
+        sb.append(resourceString(Constants.RES_SUBMISSION_PROGRESS_NOT_AVAIL));
       } else {
-        println(String.format("%.2f %%", progress * 100));
-      }
-    }
-
-    Counters counters = submission.getCounters();
-    if(counters != null) {
-      println("Counters:");
-      for(CounterGroup group : counters) {
-        print("\t");
-        println(group.getName());
-        for(Counter counter : group) {
-          print("\t\t");
-          print(counter.getName());
-          print(": ");
-          println(counter.getValue());
-        }
+        sb.append(String.format("%.2f %%", progress * 100));
       }
+    } else {
+      sb.append(dateFormat.format(submission.getLastUpdateDate())+": "+submission.getStatus());
     }
 
-    // Exception handling
-    if(submission.getExceptionInfo() != null) {
-      print("@|red Exception: |@");
-      println(submission.getExceptionInfo());
-
-      if(isVerboose() && submission.getExceptionStackTrace() != null) {
-        print("@|bold Stack trace: |@");
-        println(submission.getExceptionStackTrace());
-      }
-    }
+    println(sb.toString());
   }
 
-  public static void printColoredStatus(SubmissionStatus status) {
-    if(status.isRunning()) {
-      print("@|green " + status.toString() + " |@");
-    } else if(status.isFailure()) {
-      print("@|red " + status.toString() + " |@");
+  /**
+   * On successfull or error, method is invoked
+   * @param submission
+   */
+  public static void displayFooter(MSubmission submission) {
+    if (submission.getStatus().toString().equals(SubmissionStatus.SUCCEEDED.toString()))
{
+      println(dateFormat.format(submission.getLastUpdateDate())+": @|green "+submission.getStatus()+
" |@");
+      Counters counters = submission.getCounters();
+      if (counters != null) {
+        println(resourceString(Constants.RES_SUBMISSION_COUNTERS) + ":");
+        for (CounterGroup group : counters) {
+          print("\t");
+          println(group.getName());
+          for (Counter counter : group) {
+            print("\t\t");
+            print(counter.getName());
+            print(": ");
+            println(counter.getValue());
+          }
+        }
+        println(resourceString(Constants.RES_SUBMISSION_EXECUTED_SUCCESS));
+      }
     } else {
-      print(status.toString());
+      if (submission.getStatus().isFailure()) {
+        println(dateFormat.format(submission.getLastUpdateDate())+": @|red "+submission.getStatus()+
" |@");
+      } else {
+        println(dateFormat.format(submission.getLastUpdateDate())+": "+submission.getStatus());
+      }
+      // Exception handling
+      if (submission.getExceptionInfo() != null) {
+        print("@|red Exception: |@");
+        println(submission.getExceptionInfo());
+
+        if (isVerboose() && submission.getExceptionStackTrace() != null) {
+          print("@|bold Stack trace: |@");
+          println(submission.getExceptionStackTrace());
+        }
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c6f43322/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 c7a4cb3..e328f9a 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -193,3 +193,12 @@ formdisplayer.unsupported_datatype = Unsupported data type
 formdisplayer.input_sensitive = This input is sensitive
 
 formdisplayer.warning_message = There were warnings while create or update, but saved successfully.
+
+submission.submission_detail = Submission details
+submission.job_id = Job ID
+submission.creation_date = Creation date
+submission.external_id = External ID
+submission.progress_not_available = Progress is not available
+submission.counters = Counters
+submission.executed_success = Job executed successfully
+submission.server_url = Server URL
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c6f43322/docs/src/site/sphinx/CommandLineClient.rst
----------------------------------------------------------------------
diff --git a/docs/src/site/sphinx/CommandLineClient.rst b/docs/src/site/sphinx/CommandLineClient.rst
index 1b9676f..33419b9 100644
--- a/docs/src/site/sphinx/CommandLineClient.rst
+++ b/docs/src/site/sphinx/CommandLineClient.rst
@@ -440,15 +440,21 @@ Submission Start Function
 
 Start job (submit new submission). Starting already running job is considered as invalid
operation.
 
-+-----------------------+---------------------------+
-| Argument              |  Description              |
-+=======================+===========================+
-| ``-j``, ``--jid <x>`` | Start job with id ``<x>`` |
-+-----------------------+---------------------------+
++----------------------------+----------------------------+
+| Argument                   |  Description               |
++============================+============================+
+| ``-j``, ``--jid <x>``      | Start job with id ``<x>``  |
++----------------------------+----------------------------+
+| ``-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