sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject [1/2] git commit: SQOOP-676 Add lastUpdateDate to MSubmission (Jarek Jarcec Cecho)
Date Wed, 07 Nov 2012 00:32:20 GMT
Updated Branches:
  refs/heads/sqoop2 6c20aa4e6 -> 379451fe3


SQOOP-676 Add lastUpdateDate to MSubmission
(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/379451fe
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/379451fe
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/379451fe

Branch: refs/heads/sqoop2
Commit: 379451fe3c8d555e9c175daf733689e841d29c12
Parents: 71f4044
Author: Bilung Lee <blee@apache.org>
Authored: Tue Nov 6 16:25:39 2012 -0800
Committer: Bilung Lee <blee@apache.org>
Committed: Tue Nov 6 16:25:39 2012 -0800

----------------------------------------------------------------------
 .../sqoop/client/utils/SubmissionDisplayer.java    |   10 +++
 .../java/org/apache/sqoop/json/SubmissionBean.java |   17 ++++--
 .../java/org/apache/sqoop/model/MSubmission.java   |   44 ++++++++++----
 .../org/apache/sqoop/json/TestSubmissionBean.java  |   15 ++++-
 .../apache/sqoop/framework/FrameworkManager.java   |    1 +
 .../repository/derby/DerbyRepositoryHandler.java   |    4 +-
 6 files changed, 68 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/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 a7b4bca..8e0dda8 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
@@ -24,12 +24,16 @@ import org.apache.sqoop.submission.counter.CounterGroup;
 import org.apache.sqoop.submission.counter.Counters;
 import org.codehaus.groovy.tools.shell.IO;
 
+import java.text.SimpleDateFormat;
+
 /**
  *
  */
 public final class SubmissionDisplayer {
 
   public static void display(IO io, MSubmission submission) {
+
+    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss z");
     io.out.println("@|bold Submission details|@");
 
     io.out.print("Job id: ");
@@ -39,6 +43,12 @@ public final class SubmissionDisplayer {
     printColoredStatus(io, submission.getStatus());
     io.out.println();
 
+    io.out.print("Creation date: ");
+    io.out.println(dateFormat.format(submission.getCreationDate()));
+
+    io.out.print("Last update date: ");
+    io.out.println(dateFormat.format(submission.getLastUpdateDate()));
+
     String externalId = submission.getExternalId();
     if(externalId != null) {
       io.out.print("External Id: ");

http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
index 0880418..9d8011b 100644
--- a/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
@@ -34,7 +34,8 @@ import java.util.Set;
 public class SubmissionBean implements JsonBean {
 
   private static final String JOB = "job";
-  private static final String DATE = "date";
+  private static final String CREATION_DATE = "creation-date";
+  private static final String LAST_UPDATE_DATE = "last-update-date";
   private static final String STATUS = "status";
   private static final String EXTERNAL_ID = "external-id";
   private static final String EXTERNAL_LINK = "external-link";
@@ -67,8 +68,11 @@ public class SubmissionBean implements JsonBean {
     ret.put(STATUS, submission.getStatus().name());
     ret.put(PROGRESS, submission.getProgress());
 
-    if(submission.getDate() != null) {
-      ret.put(DATE, submission.getDate().getTime());
+    if(submission.getCreationDate() != null) {
+      ret.put(CREATION_DATE, submission.getCreationDate().getTime());
+    }
+    if(submission.getLastUpdateDate() != null) {
+      ret.put(LAST_UPDATE_DATE, submission.getLastUpdateDate().getTime());
     }
     if(submission.getExternalId() != null) {
       ret.put(EXTERNAL_ID, submission.getExternalId());
@@ -112,8 +116,11 @@ public class SubmissionBean implements JsonBean {
     submission.setStatus(SubmissionStatus.valueOf((String) json.get(STATUS)));
     submission.setProgress((Double) json.get(PROGRESS));
 
-    if(json.containsKey(DATE)) {
-      submission.setDate(new Date((Long) json.get(DATE)));
+    if(json.containsKey(CREATION_DATE)) {
+      submission.setCreationDate(new Date((Long) json.get(CREATION_DATE)));
+    }
+    if(json.containsKey(LAST_UPDATE_DATE)) {
+      submission.setLastUpdateDate(new Date((Long) json.get(LAST_UPDATE_DATE)));
     }
     if(json.containsKey(EXTERNAL_ID)) {
       submission.setExternalId((String) json.get(EXTERNAL_ID));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/common/src/main/java/org/apache/sqoop/model/MSubmission.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MSubmission.java b/common/src/main/java/org/apache/sqoop/model/MSubmission.java
index c8ba0e2..24f175b 100644
--- a/common/src/main/java/org/apache/sqoop/model/MSubmission.java
+++ b/common/src/main/java/org/apache/sqoop/model/MSubmission.java
@@ -47,7 +47,14 @@ public class MSubmission extends MPersistableEntity {
    *
    * This property is required and will be always present.
    */
-  private Date date;
+  private Date creationDate;
+
+  /**
+   * Date of last update to this submission instance
+   *
+   * This property is required and will be always present.
+   */
+  private Date lastUpdateDate;
 
   /**
    * Last known submission status.
@@ -101,13 +108,15 @@ public class MSubmission extends MPersistableEntity {
   public MSubmission() {
     status = SubmissionStatus.UNKNOWN;
     progress = -1;
-    date = new Date();
+    creationDate = new Date();
+    lastUpdateDate = creationDate;
   }
 
-  public MSubmission(long jobId, Date date, SubmissionStatus status) {
+  public MSubmission(long jobId, Date creationDate, SubmissionStatus status) {
     this();
     this.jobId = jobId;
-    this.date = date;
+    this.creationDate = creationDate;
+    this.lastUpdateDate = creationDate;
     this.status = status;
   }
 
@@ -115,15 +124,15 @@ public class MSubmission extends MPersistableEntity {
     this(jobId, new Date(), SubmissionStatus.BOOTING);
   }
 
-  public MSubmission(long jobId, Date date, SubmissionStatus status,
+  public MSubmission(long jobId, Date creationDate, SubmissionStatus status,
                      String externalId) {
-    this(jobId, date, status);
+    this(jobId, creationDate, status);
     this.externalId = externalId;
   }
 
-  public MSubmission(long jobId, Date date, SubmissionStatus status,
+  public MSubmission(long jobId, Date creationDate, SubmissionStatus status,
                      String externalId, String externalLink, Counters counters){
-    this(jobId, date, status, externalId);
+    this(jobId, creationDate, status, externalId);
     this.externalLink = externalLink;
     this.counters = counters;
   }
@@ -136,12 +145,20 @@ public class MSubmission extends MPersistableEntity {
     return jobId;
   }
 
-  public void setDate(Date submissionDate) {
-    this.date = submissionDate;
+  public void setCreationDate(Date submissionDate) {
+    this.creationDate = submissionDate;
+  }
+
+  public Date getCreationDate() {
+    return creationDate;
+  }
+
+  public void setLastUpdateDate(Date date) {
+    this.lastUpdateDate = date;
   }
 
-  public Date getDate() {
-    return date;
+  public Date getLastUpdateDate() {
+    return lastUpdateDate;
   }
 
   public void setStatus(SubmissionStatus status) {
@@ -215,7 +232,8 @@ public class MSubmission extends MPersistableEntity {
   public String toString() {
     return "MSubmission{" +
       "jobId=" + jobId +
-      ", date=" + date +
+      ", creationDate=" + creationDate +
+      ", lastUpdateDate=" + lastUpdateDate +
       ", status=" + status +
       ", externalId='" + externalId + '\'' +
       ", progress=" + progress +

http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
index 9732fa1..7c77db6 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
@@ -45,13 +45,22 @@ public class TestSubmissionBean extends TestCase {
     assertEquals(666, target.getJobId());
   }
 
-  public void testTransferDate() {
+  public void testTransferCreationDate() {
     Date date = new Date();
     MSubmission source = new MSubmission();
-    source.setDate(date);
+    source.setCreationDate(date);
 
     MSubmission target = transfer(source);
-    assertEquals(date, target.getDate());
+    assertEquals(date, target.getCreationDate());
+  }
+
+  public void testTransferLastUpdateDate() {
+    Date date = new Date();
+    MSubmission source = new MSubmission();
+    source.setLastUpdateDate(date);
+
+    MSubmission target = transfer(source);
+    assertEquals(date, target.getLastUpdateDate());
   }
 
   public void testTransferStatus() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
index 7e10ddc..f4be639 100644
--- a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
@@ -478,6 +478,7 @@ public final class FrameworkManager {
     submission.setProgress(progress);
     submission.setCounters(counters);
     submission.setExternalLink(externalLink);
+    submission.setLastUpdateDate(new Date());
 
     RepositoryManager.getRepository().updateSubmission(submission);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/379451fe/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 9db1a4b..7006273 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -793,7 +793,7 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
         Statement.RETURN_GENERATED_KEYS);
       stmt.setLong(1, submission.getJobId());
       stmt.setString(2, submission.getStatus().name());
-      stmt.setTimestamp(3, new Timestamp(submission.getDate().getTime()));
+      stmt.setTimestamp(3, new Timestamp(submission.getCreationDate().getTime()));
       stmt.setString(4, submission.getExternalId());
 
       result = stmt.executeUpdate();
@@ -852,7 +852,7 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler {
       stmt = conn.prepareStatement(STMT_UPDATE_SUBMISSION);
       stmt.setLong(1, submission.getJobId());
       stmt.setString(2, submission.getStatus().name());
-      stmt.setTimestamp(3, new Timestamp(submission.getDate().getTime()));
+      stmt.setTimestamp(3, new Timestamp(submission.getCreationDate().getTime()));
       stmt.setString(4, submission.getExternalId());
 
       stmt.setLong(5, submission.getPersistenceId());


Mime
View raw message