sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2735: Sqoop2: Use job name in MSubmission
Date Wed, 16 Dec 2015 19:26:56 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 060be9049 -> 0ab7c05e1


SQOOP-2735: Sqoop2: Use job name in MSubmission

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

Branch: refs/heads/sqoop2
Commit: 0ab7c05e114d40903abe982ff9f2d59f1452d2f1
Parents: 060be90
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Dec 16 20:26:15 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Wed Dec 16 20:26:15 2015 +0100

----------------------------------------------------------------------
 .../org/apache/sqoop/json/SubmissionBean.java   | 13 ++-------
 .../org/apache/sqoop/model/MSubmission.java     | 30 ++++++++++----------
 .../apache/sqoop/json/TestSubmissionBean.java   | 12 ++++----
 .../org/apache/sqoop/driver/JobManager.java     | 21 +++-----------
 .../org/apache/sqoop/driver/TestJobManager.java | 12 ++++----
 .../common/CommonRepositoryHandler.java         | 23 +++++++++++++--
 ...RepositoryInsertUpdateDeleteSelectQuery.java | 24 ++++++++++++++--
 .../derby/TestSubmissionHandling.java           |  8 +++---
 .../repository/mysql/MySqlTestCase.java         |  2 +-
 .../mysql/TestSubmissionHandling.java           |  8 +++---
 .../postgresql/PostgresqlTestCase.java          |  2 +-
 .../postgresql/TestSubmissionHandling.java      |  8 +++---
 .../authorization/AuthorizationEngine.java      |  3 +-
 .../apache/sqoop/handler/JobRequestHandler.java |  2 +-
 .../sqoop/shell/ShowSubmissionFunction.java     |  4 +--
 .../org/apache/sqoop/shell/core/Constants.java  |  8 +++---
 .../sqoop/shell/utils/SubmissionDisplayer.java  |  4 +--
 .../main/resources/shell-resource.properties    |  4 +--
 .../org/apache/sqoop/shell/TestShowCommand.java | 12 ++++----
 19 files changed, 106 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/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 e6b300d..4040688 100644
--- a/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
@@ -44,9 +44,7 @@ import org.json.simple.JSONObject;
 public class SubmissionBean implements JsonBean {
 
   private static final String SUBMISSION = "submission";
-  @Deprecated
-  private static final String JOB = "job";
-  private static final String JOB_ID = "job-id";
+  private static final String JOB_NAME = "job-name";
   private static final String CREATION_USER = "creation-user";
   private static final String CREATION_DATE = "creation-date";
   private static final String LAST_UPDATE_USER = "last-udpate-user";
@@ -104,8 +102,7 @@ public class SubmissionBean implements JsonBean {
   private JSONObject extractSubmission(MSubmission submission) {
     JSONObject object = new JSONObject();
 
-    object.put(JOB, submission.getJobId());
-    object.put(JOB_ID, submission.getJobId());
+    object.put(JOB_NAME, submission.getJobName());
     object.put(STATUS, submission.getStatus().name());
     object.put(PROGRESS, submission.getProgress());
 
@@ -176,11 +173,7 @@ public class SubmissionBean implements JsonBean {
   private MSubmission restoreSubmission(Object obj) {
     JSONObject object = (JSONObject) obj;
     MSubmission submission = new MSubmission();
-    Long jobId = JSONUtils.getLong(object, JOB_ID);
-    if (jobId == null) {
-      jobId = JSONUtils.getLong(object, JOB);
-    }
-    submission.setJobId(jobId);
+    submission.setJobName(JSONUtils.getString(object, JOB_NAME));
     submission.setStatus(SubmissionStatus.valueOf(JSONUtils.getString(object, STATUS)));
     submission.setProgress(JSONUtils.getDouble(object, PROGRESS));
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/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 11110ae..44250c3 100644
--- a/common/src/main/java/org/apache/sqoop/model/MSubmission.java
+++ b/common/src/main/java/org/apache/sqoop/model/MSubmission.java
@@ -37,11 +37,11 @@ import java.util.Date;
 public class MSubmission extends MAccountableEntity {
 
   /**
-   * Job id that this submission object belongs.
+   * Job name that this submission object belongs.
    *
    * This property is required and will be always present.
    */
-  private long jobId;
+  private String jobName;
 
   /**
    * Last known submission status.
@@ -122,36 +122,36 @@ public class MSubmission extends MAccountableEntity {
     progress = -1;
   }
 
-  public MSubmission(long jobId, Date creationDate, SubmissionStatus status) {
+  public MSubmission(String jobName, Date creationDate, SubmissionStatus status) {
     this();
-    this.jobId = jobId;
+    this.jobName = jobName;
     this.status = status;
     setCreationDate(creationDate);
   }
 
-  public MSubmission(long jobId) {
-    this(jobId, new Date(), SubmissionStatus.BOOTING);
+  public MSubmission(String jobName) {
+    this(jobName, new Date(), SubmissionStatus.BOOTING);
   }
 
-  public MSubmission(long jobId, Date creationDate, SubmissionStatus status,
+  public MSubmission(String jobName, Date creationDate, SubmissionStatus status,
                      String externalId) {
-    this(jobId, creationDate, status);
+    this(jobName, creationDate, status);
     this.externalJobId = externalId;
   }
 
-  public MSubmission(long jobId, Date creationDate, SubmissionStatus status,
+  public MSubmission(String jobName, Date creationDate, SubmissionStatus status,
                      String externalId, String externalLink, Counters counters){
-    this(jobId, creationDate, status, externalId);
+    this(jobName, creationDate, status, externalId);
     this.externalLink = externalLink;
     this.counters = counters;
   }
 
-  public void setJobId(long jobId) {
-    this.jobId = jobId;
+  public String getJobName() {
+    return jobName;
   }
 
-  public long getJobId() {
-    return jobId;
+  public void setJobName(String jobName) {
+    this.jobName = jobName;
   }
 
   public void setStatus(SubmissionStatus status) {
@@ -247,7 +247,7 @@ public class MSubmission extends MAccountableEntity {
 
   @Override
   public String toString() {
-    return "MSubmission [jobId=" + jobId + ", status=" + status + ", externalId=" + externalJobId
+    return "MSubmission [jobName=" + jobName + ", status=" + status + ", externalId=" + externalJobId
         + ", progress=" + progress + ", counters=" + counters + ", externalLink=" + externalLink
         + ", error=" + error + ", fromSchema=" + fromSchema + ", toSchema=" + toSchema +
"]";
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/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 1fc2ae2..204c1de 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
@@ -54,24 +54,24 @@ public class TestSubmissionBean {
   @Test
   public void testTransferJobId() {
     MSubmission source = new MSubmission();
-    source.setJobId(666);
+    source.setJobName("jobName1");
 
     MSubmission target = transfer(source);
-    assertEquals(666, target.getJobId());
+    assertEquals("jobName1", target.getJobName());
 
     List<MSubmission> sources = new ArrayList<MSubmission>();
     MSubmission sourcex = new MSubmission();
-    sourcex.setJobId(777);
+    sourcex.setJobName("jobName2");
     sources.add(sourcex);
     MSubmission sourcey = new MSubmission();
-    sourcey.setJobId(888);
+    sourcey.setJobName("jobName3");
     sources.add(sourcey);
 
     List<MSubmission> targets = transfer(sources);
     assertNotNull(targets.get(0));
-    assertEquals(777, targets.get(0).getJobId());
+    assertEquals("jobName2", targets.get(0).getJobName());
     assertNotNull(targets.get(1));
-    assertEquals(888, targets.get(1).getJobId());
+    assertEquals("jobName3", targets.get(1).getJobName());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/core/src/main/java/org/apache/sqoop/driver/JobManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/JobManager.java b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
index 4f4b9d3..d3a750e 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -311,7 +311,7 @@ public class JobManager implements Reconfigurable {
     if (!job.getEnabled()) {
       throw new SqoopException(DriverError.DRIVER_0009, "Job: " + jobName);
     }
-    MSubmission mSubmission = createJobSubmission(ctx, job.getPersistenceId());
+    MSubmission mSubmission = createJobSubmission(ctx, job.getName());
     JobRequest jobRequest = createJobRequest(mSubmission, job);
     // Bootstrap job to execute in the configured execution engine
     prepareJob(jobRequest);
@@ -463,8 +463,8 @@ public class JobManager implements Reconfigurable {
     }
   }
 
-  MSubmission createJobSubmission(HttpEventContext ctx, long jobId) {
-    MSubmission summary = new MSubmission(jobId);
+  MSubmission createJobSubmission(HttpEventContext ctx, String jobName) {
+    MSubmission summary = new MSubmission(jobName);
     summary.setCreationUser(ctx.getUsername());
     summary.setLastUpdateUser(ctx.getUsername());
     return summary;
@@ -496,19 +496,6 @@ public class JobManager implements Reconfigurable {
     return link;
   }
 
-  // TODO: this method should be removed when MSubmission link job with jobName
-  MJob getJob(long jobId) {
-    MJob job = RepositoryManager.getInstance().getRepository().findJob(jobId);
-    if (job == null) {
-      throw new SqoopException(DriverError.DRIVER_0004, "Unknown job id: " + jobId);
-    }
-
-    if (!job.getEnabled()) {
-      throw new SqoopException(DriverError.DRIVER_0009, "Job: " + job.getName());
-    }
-    return job;
-  }
-
   MJob getJob(String jobName) {
     MJob job = RepositoryManager.getInstance().getRepository().findJob(jobName);
     if (job == null) {
@@ -580,7 +567,7 @@ public class JobManager implements Reconfigurable {
 
   void invokeDestroyerOnJobSuccess(MSubmission submission) {
     try {
-      MJob job = getJob(submission.getJobId());
+      MJob job = getJob(submission.getJobName());
 
       SqoopConnector fromConnector = getSqoopConnector(job.getFromConnectorName());
       SqoopConnector toConnector = getSqoopConnector(job.getToConnectorName());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
index 8da759e..ee88ddc 100644
--- a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
+++ b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
@@ -74,7 +74,7 @@ public class TestJobManager {
 
     HttpEventContext testCtx = new HttpEventContext();
     testCtx.setUsername("testUser");
-    MSubmission jobSubmission = jobManager.createJobSubmission(testCtx, 1234L);
+    MSubmission jobSubmission = jobManager.createJobSubmission(testCtx, "jobName");
     assertEquals(jobSubmission.getCreationUser(), "testUser");
     assertEquals(jobSubmission.getLastUpdateUser(), "testUser");
   }
@@ -173,17 +173,15 @@ public class TestJobManager {
 
   @Test
   public void testUnknownJob() {
-    long testJobId = 555l;
-    SqoopException exception = new SqoopException(DriverError.DRIVER_0004, "Unknown job id:
"
-        + testJobId);
+    SqoopException exception = new SqoopException(DriverError.DRIVER_0004, "Unknown job name:
testJobName");
     when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
-    when(jdbcRepoMock.findJob(testJobId)).thenReturn(null);
+    when(jdbcRepoMock.findJob("testJobName")).thenReturn(null);
     try {
-      jobManager.getJob(testJobId);
+      jobManager.getJob("testJobName");
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repositoryManagerMock, times(1)).getRepository();
-      verify(jdbcRepoMock, times(1)).findJob(testJobId);
+      verify(jdbcRepoMock, times(1)).findJob("testJobName");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
index 13d8242..efbd533 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
@@ -636,7 +636,23 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
       }
     } catch (SQLException ex) {
       logException(ex);
-      throw new SqoopException(CommonRepositoryError.COMMON_0036, ex);
+      throw new SqoopException(CommonRepositoryError.COMMON_0000, ex);
+    }
+  }
+
+  public Long findJobIdByName(String jobName, Connection conn) {
+    try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectJobIdByName()))
{
+      stmt.setString(1,jobName);
+      try (ResultSet rs = stmt.executeQuery()) {
+        if (rs.next()) {
+          return rs.getLong(1);
+        } else {
+          throw new SqoopException(CommonRepositoryError.COMMON_0028);
+        }
+      }
+    } catch (SQLException ex) {
+      logException(ex);
+      throw new SqoopException(CommonRepositoryError.COMMON_0000, ex);
     }
   }
 
@@ -888,9 +904,10 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
   @Override
   public void createSubmission(MSubmission submission, Connection conn) {
     int result;
+    Long jobId = findJobIdByName(submission.getJobName(), conn);
     try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtInsertSubmission(),
           Statement.RETURN_GENERATED_KEYS)) {
-      stmt.setLong(1, submission.getJobId());
+      stmt.setLong(1, jobId);
       stmt.setString(2, submission.getStatus().name());
       stmt.setString(3, submission.getCreationUser());
       stmt.setTimestamp(4, new Timestamp(submission.getCreationDate().getTime()));
@@ -1367,7 +1384,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
     MSubmission submission = new MSubmission();
 
     submission.setPersistenceId(rs.getLong(1));
-    submission.setJobId(rs.getLong(2));
+    submission.setJobName(rs.getString(12));
     submission.setStatus(SubmissionStatus.valueOf(rs.getString(3)));
     submission.setCreationUser(rs.getString(4));
     submission.setCreationDate(rs.getTimestamp(5));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
index fa5a1c1..e1e23e2 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
@@ -536,8 +536,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_ID) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_LINK) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_SUMMARY) + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS)
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS) + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME)
           + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
+          + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
+          + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
           + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_STATUS) + " = ?";
 
   // DML : Get all submissions
@@ -553,8 +556,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_ID) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_LINK) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_SUMMARY) + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS)
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS) + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME)
           + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
+          + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
+          + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
           + " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_UPDATE_DATE) + " DESC";
 
   // DML: Get submissions for a job
@@ -570,7 +576,8 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_ID) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_LINK) + ", "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_SUMMARY) + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS)
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS) + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME)
           + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
           + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
           + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
@@ -578,6 +585,13 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_UPDATE_DATE) + "DESC
,"
             + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID) + " DESC";
 
+  // DML Select link id by name
+  private static final String STMT_SELECT_JOB_ID_BY_NAME =
+      "SELECT "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
+          + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
+          + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?";
+
   // DML: Select context type
   private static final String STMT_SELECT_CONTEXT_TYPE =
       "SELECT "
@@ -811,6 +825,10 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
 
   public String getStmtSelectLinkIdByName() {return STMT_SELECT_LINK_ID_BY_NAME;}
 
+  public String getStmtSelectJobIdByName() {
+    return STMT_SELECT_JOB_ID_BY_NAME;
+  }
+
   public String getStmtSelectLinkAll() {
     return STMT_SELECT_LINK_ALL;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
index 621d4e1..e2c3eae 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
@@ -117,7 +117,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
     driverContext.setString("driver2", "value2");
 
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName("JA0");
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(creationDate);
     submission.setLastUpdateDate(updateDate);
@@ -141,7 +141,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
 
     submission = submissions.get(0);
 
-    assertEquals(1, submission.getJobId());
+    assertEquals("JA0", submission.getJobName());
     assertEquals(SubmissionStatus.RUNNING, submission.getStatus());
     assertEquals(creationDate.getTime(), submission.getCreationDate().getTime());
     assertEquals(updateDate.getTime(), submission.getLastUpdateDate().getTime());
@@ -188,7 +188,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
     assertEquals(submission.getDriverContext().getString("driver2"), "value2");
 
     // Let's create second (simpler) connection
-    submission = new MSubmission(1, new Date(), SubmissionStatus.SUCCEEDED, "job-x");
+    submission = new MSubmission("JA0", new Date(), SubmissionStatus.SUCCEEDED, "job-x");
     handler.createSubmission(submission, getDerbyDatabaseConnection());
 
     assertEquals(2, submission.getPersistenceId());
@@ -229,7 +229,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
         + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it happe"
         + "nsYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happens";
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName("JA0");
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(new Date());
     submission.setLastUpdateDate(new Date());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
index ede930f..1d4ceb7 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
@@ -117,7 +117,7 @@ abstract public class MySqlTestCase {
 
   protected MSubmission getSubmission(MJob job,
       SubmissionStatus submissionStatus) {
-    MSubmission submission = new MSubmission(job.getPersistenceId(),
+    MSubmission submission = new MSubmission(job.getName(),
         new Date(), submissionStatus);
     fillSubmission(submission);
     return submission;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
index b4f34b6..b9a1392 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
@@ -157,7 +157,7 @@ public class TestSubmissionHandling extends MySqlTestCase {
     driverContext.setString("driver2", "value2");
 
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName(JOB_A_NAME);
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(creationDate);
     submission.setLastUpdateDate(updateDate);
@@ -183,7 +183,7 @@ public class TestSubmissionHandling extends MySqlTestCase {
 
     submission = submissions.get(0);
 
-    assertEquals(1, submission.getJobId());
+    assertEquals(JOB_A_NAME, submission.getJobName());
     assertEquals(SubmissionStatus.RUNNING, submission.getStatus());
     long exceptedData = creationDate.getTime();
     long actualData = submission.getCreationDate().getTime();
@@ -240,7 +240,7 @@ public class TestSubmissionHandling extends MySqlTestCase {
     assertEquals(submission.getDriverContext().getString("driver2"), "value2");
 
     // Let's create second (simpler) connection
-    submission = new MSubmission(1, new Date(), SubmissionStatus.SUCCEEDED,
+    submission = new MSubmission(JOB_A_NAME, new Date(), SubmissionStatus.SUCCEEDED,
         "job-x");
     handler.createSubmission(submission, provider.getConnection());
 
@@ -285,7 +285,7 @@ public class TestSubmissionHandling extends MySqlTestCase {
         + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it happe"
         + "nsYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happens";
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName(JOB_A_NAME);
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(new Date());
     submission.setLastUpdateDate(new Date());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
index 1bab548..2311f8b 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
@@ -106,7 +106,7 @@ abstract public class PostgresqlTestCase {
   }
 
   protected MSubmission getSubmission(MJob job, SubmissionStatus submissionStatus) {
-    MSubmission submission = new MSubmission(job.getPersistenceId(), new Date(), submissionStatus);
+    MSubmission submission = new MSubmission(job.getName(), new Date(), submissionStatus);
     fillSubmission(submission);
     return submission;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
index cd3367e..5a5c70e 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
@@ -152,7 +152,7 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
     driverContext.setString("driver2", "value2");
 
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName(JOB_A_NAME);
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(creationDate);
     submission.setLastUpdateDate(updateDate);
@@ -177,7 +177,7 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
 
     submission = submissions.get(0);
 
-    assertEquals(1, submission.getJobId());
+    assertEquals(JOB_A_NAME, submission.getJobName());
     assertEquals(SubmissionStatus.RUNNING, submission.getStatus());
     assertEquals(creationDate, submission.getCreationDate());
     assertEquals(updateDate, submission.getLastUpdateDate());
@@ -224,7 +224,7 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
     assertEquals(submission.getDriverContext().getString("driver2"), "value2");
 
     // Let's create second (simpler) connection
-    submission = new MSubmission(1, new Date(), SubmissionStatus.SUCCEEDED, "job-x");
+    submission = new MSubmission(JOB_A_NAME, new Date(), SubmissionStatus.SUCCEEDED, "job-x");
     handler.createSubmission(submission, provider.getConnection());
 
     assertEquals(2, submission.getPersistenceId());
@@ -265,7 +265,7 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
         + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it happe"
         + "nsYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happens";
     MSubmission submission = new MSubmission();
-    submission.setJobId(1);
+    submission.setJobName(JOB_A_NAME);
     submission.setStatus(SubmissionStatus.RUNNING);
     submission.setCreationDate(new Date());
     submission.setLastUpdateDate(new Date());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
----------------------------------------------------------------------
diff --git a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
index e7b7dac..091d1c4 100644
--- a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
+++ b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
@@ -149,8 +149,7 @@ public class AuthorizationEngine {
       @Override
       public boolean apply(MSubmission input) {
         try {
-          String jobName = getResourceName(MResource.TYPE.JOB, input.getJobId());
-          checkPrivilege(doUserName, getPrivilege(MResource.TYPE.JOB, jobName, MPrivilege.ACTION.READ));
+          checkPrivilege(doUserName, getPrivilege(MResource.TYPE.JOB, input.getJobName(),
MPrivilege.ACTION.READ));
           // add valid submission
           return true;
         } catch (RuntimeException e) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index 01516ed..7fa6a3b 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -407,7 +407,7 @@ public class JobRequestHandler implements RequestHandler {
         ctx.getRequest().getRemoteAddr(), "status", "job", jobName);
     MSubmission submission = JobManager.getInstance().status(jobName);
     if (submission == null) {
-      submission = new MSubmission(job.getPersistenceId(), new Date(), SubmissionStatus.NEVER_EXECUTED);
+      submission = new MSubmission(job.getName(), new Date(), SubmissionStatus.NEVER_EXECUTED);
     }
 
     return new SubmissionBean(submission);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/shell/src/main/java/org/apache/sqoop/shell/ShowSubmissionFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowSubmissionFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowSubmissionFunction.java
index 45f3bdd..aeac76a 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowSubmissionFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowSubmissionFunction.java
@@ -74,7 +74,7 @@ public class ShowSubmissionFunction extends SqoopFunction {
     }
 
     List<String> header = new LinkedList<String>();
-    header.add(resourceString(Constants.RES_TABLE_HEADER_JOB_ID));
+    header.add(resourceString(Constants.RES_TABLE_HEADER_JOB_NAME));
     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));
@@ -85,7 +85,7 @@ public class ShowSubmissionFunction extends SqoopFunction {
     List<String> dates = new LinkedList<String>();
 
     for (MSubmission submission : submissions) {
-      jids.add(String.valueOf(submission.getJobId()));
+      jids.add(String.valueOf(submission.getJobName()));
       eids.add(String.valueOf(submission.getExternalJobId()));
       status.add(submission.getStatus().toString());
       dates.add(submission.getLastUpdateDate().toString());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
index c516ea7..9c57a2e 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
@@ -369,8 +369,8 @@ public class Constants {
       "table.header.connector.from";
   public static final String RES_TABLE_HEADER_TO_CONNECTOR =
       "table.header.connector.to";
-  public static final String RES_TABLE_HEADER_JOB_ID =
-      "table.header.jid";
+  public static final String RES_TABLE_HEADER_JOB_NAME =
+      "table.header.job.name";
   public static final String RES_TABLE_HEADER_EXTERNAL_ID =
       "table.header.eid";
   public static final String RES_TABLE_HEADER_STATUS =
@@ -430,8 +430,8 @@ public class Constants {
 
   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_JOB_NAME =
+      "submission.job_name";
   public static final String RES_SUBMISSION_CREATION_USER =
       "submission.creation_user";
   public static final String RES_SUBMISSION_CREATION_DATE =

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/shell/src/main/java/org/apache/sqoop/shell/utils/SubmissionDisplayer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/SubmissionDisplayer.java b/shell/src/main/java/org/apache/sqoop/shell/utils/SubmissionDisplayer.java
index 3a78371..8be3715 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/SubmissionDisplayer.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/SubmissionDisplayer.java
@@ -43,8 +43,8 @@ public final class SubmissionDisplayer {
     SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
     println("@|bold "+ resourceString(Constants.RES_SUBMISSION_SUBMISSION_DETAIL) +"|@");
 
-    print(resourceString(Constants.RES_SUBMISSION_JOB_ID)+": ");
-    println(submission.getJobId());
+    print(resourceString(Constants.RES_SUBMISSION_JOB_NAME)+": ");
+    println(submission.getJobName());
 
     print(resourceString(Constants.RES_SUBMISSION_SERVER_URL)+": ");
     println(getServerUrl());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/shell/src/main/resources/shell-resource.properties
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/shell-resource.properties b/shell/src/main/resources/shell-resource.properties
index df3e7f1..630c31d 100644
--- a/shell/src/main/resources/shell-resource.properties
+++ b/shell/src/main/resources/shell-resource.properties
@@ -216,7 +216,7 @@ table.header.supported_directions = Supported Directions
 table.header.connector.name = Connector Name
 table.header.connector.from = From Connector
 table.header.connector.to = To Connector
-table.header.jid = Job Id
+table.header.job.name = Job Name
 table.header.eid = External Id
 table.header.status = Status
 table.header.date = Last Update Date
@@ -249,7 +249,7 @@ config.displayer.input_sensitive = This input is sensitive
 config.displayer.warning_message = There were warnings while create or update, but saved
successfully.
 
 submission.submission_detail = Submission details
-submission.job_id = Job ID
+submission.job_name = Job Name
 submission.creation_user = Created by
 submission.creation_date = Creation date
 submission.update_user = Lastly updated by

http://git-wip-us.apache.org/repos/asf/sqoop/blob/0ab7c05e/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
index 000f518..8f8d3db 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
@@ -278,12 +278,12 @@ public class TestShowCommand {
 
   @Test
   public void testShowSubmission() {
-    when(client.getSubmissions()).thenReturn(Arrays.asList(new MSubmission(1L)));
-    when(client.getSubmissionsForJob(any(String.class))).thenReturn(Arrays.asList(new MSubmission(1L)));
+    when(client.getSubmissions()).thenReturn(Arrays.asList(new MSubmission("jobName")));
+    when(client.getSubmissionsForJob(any(String.class))).thenReturn(Arrays.asList(new MSubmission("jobName")));
 
-    // show submission -details -name jobName
+    // show submission -details -job jobName
     out.reset();
-    Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail",
"-name", "jobName"));
+    Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail",
"-job", "jobName"));
     Assert.assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
     Assert.assertTrue(str.contains("Submission details"));
@@ -300,7 +300,7 @@ public class TestShowCommand {
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-job", "jobName"));
     Assert.assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Job Id"));
+    Assert.assertTrue(str.contains("Job Name"));
     Assert.assertTrue(str.contains("External Id"));
     Assert.assertTrue(str.contains("Status"));
     Assert.assertTrue(str.contains("Last Update Date"));
@@ -310,7 +310,7 @@ public class TestShowCommand {
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION));
     Assert.assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Job Id"));
+    Assert.assertTrue(str.contains("Job Name"));
     Assert.assertTrue(str.contains("External Id"));
     Assert.assertTrue(str.contains("Status"));
     Assert.assertTrue(str.contains("Last Update Date"));


Mime
View raw message