sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rzh...@apache.org
Subject sqoop git commit: SQOOP-2395: Sqoop2: Signature of method getConnectorIdFromIdentifier in HandlerUtils is inconsistent with other methods
Date Tue, 23 Jun 2015 08:03:28 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 d16566ace -> 87855a376


SQOOP-2395: Sqoop2: Signature of method getConnectorIdFromIdentifier in HandlerUtils is inconsistent
with other methods

(Dian Fu via Richard Zhou)


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

Branch: refs/heads/sqoop2
Commit: 87855a37681cd21cd26c06878465ba024ded425b
Parents: d16566a
Author: Richard Zhou <rzhou1@apache.org>
Authored: Tue Jun 23 15:51:06 2015 +0800
Committer: Richard Zhou <rzhou1@apache.org>
Committed: Tue Jun 23 15:51:50 2015 +0800

----------------------------------------------------------------------
 .../apache/sqoop/connector/ConnectorManager.java   |  6 ------
 .../org/apache/sqoop/handler/HandlerUtils.java     | 15 ++++++++++-----
 .../apache/sqoop/handler/JobRequestHandler.java    | 17 +++++++----------
 .../apache/sqoop/handler/LinkRequestHandler.java   |  8 ++++----
 .../sqoop/handler/SubmissionRequestHandler.java    |  4 +---
 5 files changed, 22 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/87855a37/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index d1537bf..a16fceb 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -189,12 +189,6 @@ public class ConnectorManager implements Reconfigurable {
     }
   }
 
-  public synchronized Long getConnectorId(String connectorName) {
-    Repository repository = RepositoryManager.getInstance().getRepository();
-    return repository.findConnector(connectorName) != null ? repository
-        .findConnector(connectorName).getPersistenceId() : null;
-  }
-
   private synchronized void registerConnectors(boolean autoUpgrade) {
     Repository repository = RepositoryManager.getInstance().getRepository();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/87855a37/server/src/main/java/org/apache/sqoop/handler/HandlerUtils.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/HandlerUtils.java b/server/src/main/java/org/apache/sqoop/handler/HandlerUtils.java
index 718b9e6..68b1300 100644
--- a/server/src/main/java/org/apache/sqoop/handler/HandlerUtils.java
+++ b/server/src/main/java/org/apache/sqoop/handler/HandlerUtils.java
@@ -18,19 +18,21 @@
 package org.apache.sqoop.handler;
 
 import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.connector.ConnectorManager;
+import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.repository.Repository;
+import org.apache.sqoop.repository.RepositoryManager;
 import org.apache.sqoop.server.common.ServerError;
 
 public class HandlerUtils {
 
-  public static long getJobIdFromIdentifier(String identifier, Repository repository) {
+  public static long getJobIdFromIdentifier(String identifier) {
     // support jobName or jobId for the api
     // NOTE: jobId is a fallback for older sqoop clients if any, since we want
     // to primarily use unique jobNames
     long jobId;
+    Repository repository = RepositoryManager.getInstance().getRepository();
     MJob job = repository.findJob(identifier);
     if (job != null) {
       jobId = job.getPersistenceId();
@@ -47,11 +49,12 @@ public class HandlerUtils {
     return jobId;
   }
 
-  public static long getLinkIdFromIdentifier(String identifier, Repository repository) {
+  public static long getLinkIdFromIdentifier(String identifier) {
     // support linkName or linkId for the api
     // NOTE: linkId is a fallback for older sqoop clients if any, since we want
     // to primarily use unique linkNames
     long linkId;
+    Repository repository = RepositoryManager.getInstance().getRepository();
     MLink link = repository.findLink(identifier);
     if (link != null) {
       linkId = link.getPersistenceId();
@@ -70,8 +73,10 @@ public class HandlerUtils {
 
   public static long getConnectorIdFromIdentifier(String identifier) {
     long connectorId;
-    if (ConnectorManager.getInstance().getConnectorId(identifier) != null) {
-      connectorId = ConnectorManager.getInstance().getConnectorId(identifier);
+    Repository repository = RepositoryManager.getInstance().getRepository();
+    MConnector connector = repository.findConnector(identifier);
+    if (connector != null) {
+      connectorId = connector.getPersistenceId();
     } else {
       try {
         connectorId = Long.valueOf(identifier);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/87855a37/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 c96d66d..d1621d8 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -138,7 +138,7 @@ public class JobRequestHandler implements RequestHandler {
     Repository repository = RepositoryManager.getInstance().getRepository();
 
     String jobIdentifier = ctx.getLastURLElement();
-    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
 
     // Authorization check
     AuthorizationEngine.deleteJob(String.valueOf(jobId));
@@ -210,7 +210,7 @@ public class JobRequestHandler implements RequestHandler {
     if (!create) {
       String jobIdentifier = ctx.getLastURLElement();
       // support jobName or jobId for the api
-      long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+      long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
       if (postedJob.getPersistenceId() == MPersistableEntity.PERSISTANCE_ID_DEFAULT) {
         MJob existingJob = repository.findJob(jobId);
         postedJob.setPersistenceId(existingJob.getPersistenceId());
@@ -305,7 +305,7 @@ public class JobRequestHandler implements RequestHandler {
       AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
           ctx.getRequest().getRemoteAddr(), "get", "job", connectorIdentifier);
 
-      long jobId = HandlerUtils.getJobIdFromIdentifier(connectorIdentifier, repository);
+      long jobId = HandlerUtils.getJobIdFromIdentifier(connectorIdentifier);
       MJob job = repository.findJob(jobId);
 
       // Authorization check
@@ -349,7 +349,7 @@ public class JobRequestHandler implements RequestHandler {
     Repository repository = RepositoryManager.getInstance().getRepository();
     String[] elements = ctx.getUrlElements();
     String jobIdentifier = elements[elements.length - 2];
-    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
 
     // Authorization check
     AuthorizationEngine.enableDisableJob(String.valueOf(jobId));
@@ -359,10 +359,9 @@ public class JobRequestHandler implements RequestHandler {
   }
 
   private JsonBean startJob(RequestContext ctx) {
-    Repository repository = RepositoryManager.getInstance().getRepository();
     String[] elements = ctx.getUrlElements();
     String jobIdentifier = elements[elements.length - 2];
-    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
 
     // Authorization check
     AuthorizationEngine.startJob(String.valueOf(jobId));
@@ -383,10 +382,9 @@ public class JobRequestHandler implements RequestHandler {
   }
 
   private JsonBean stopJob(RequestContext ctx) {
-    Repository repository = RepositoryManager.getInstance().getRepository();
     String[] elements = ctx.getUrlElements();
     String jobIdentifier = elements[elements.length - 2];
-    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
 
     // Authorization check
     AuthorizationEngine.stopJob(String.valueOf(jobId));
@@ -398,10 +396,9 @@ public class JobRequestHandler implements RequestHandler {
   }
 
   private JsonBean getJobStatus(RequestContext ctx) {
-    Repository repository = RepositoryManager.getInstance().getRepository();
     String[] elements = ctx.getUrlElements();
     String jobIdentifier = elements[elements.length - 2];
-    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+    long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
 
     // Authorization check
     AuthorizationEngine.statusJob(String.valueOf(jobId));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/87855a37/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index bf3a42a..26a341b 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -92,7 +92,7 @@ public class LinkRequestHandler implements RequestHandler {
     Repository repository = RepositoryManager.getInstance().getRepository();
     String linkIdentifier = ctx.getLastURLElement();
     // support linkName or linkId for the api
-    long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier, repository);
+    long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
 
     // Authorization check
     AuthorizationEngine.deleteLink(String.valueOf(linkId));
@@ -152,7 +152,7 @@ public class LinkRequestHandler implements RequestHandler {
     if (!create) {
       String linkIdentifier = ctx.getLastURLElement();
       // support linkName or linkId for the api
-      long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier, repository);
+      long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
       if (postedLink.getPersistenceId() == MPersistableEntity.PERSISTANCE_ID_DEFAULT) {
         MLink existingLink = repository.findLink(linkId);
         postedLink.setPersistenceId(existingLink.getPersistenceId());
@@ -233,7 +233,7 @@ public class LinkRequestHandler implements RequestHandler {
       AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
           ctx.getRequest().getRemoteAddr(), "get", "link", identifier);
 
-      long linkId = HandlerUtils.getLinkIdFromIdentifier(identifier, repository);
+      long linkId = HandlerUtils.getLinkIdFromIdentifier(identifier);
       MLink link = repository.findLink(linkId);
 
       // Authorization check
@@ -271,7 +271,7 @@ public class LinkRequestHandler implements RequestHandler {
     Repository repository = RepositoryManager.getInstance().getRepository();
     String[] elements = ctx.getUrlElements();
     String linkIdentifier = elements[elements.length - 2];
-    long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier, repository);
+    long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
 
     // Authorization check
     AuthorizationEngine.enableDisableLink(String.valueOf(linkId));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/87855a37/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
index b4c16f1..5a1ab51 100644
--- a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
@@ -25,7 +25,6 @@ import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.json.JsonBean;
 import org.apache.sqoop.json.SubmissionsBean;
 import org.apache.sqoop.model.MSubmission;
-import org.apache.sqoop.repository.Repository;
 import org.apache.sqoop.repository.RepositoryManager;
 import org.apache.sqoop.security.authorization.AuthorizationEngine;
 import org.apache.sqoop.server.RequestContext;
@@ -50,14 +49,13 @@ public class SubmissionRequestHandler implements RequestHandler {
           + ctx.getMethod());
     }
     String jobIdentifier = ctx.getLastURLElement();
-    Repository repository = RepositoryManager.getInstance().getRepository();
     // submissions per job are ordered by update time
     // hence the latest submission is on the top
     if (ctx.getParameterValue(JOB_NAME_QUERY_PARAM) != null) {
       jobIdentifier = ctx.getParameterValue(JOB_NAME_QUERY_PARAM);
       AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
           ctx.getRequest().getRemoteAddr(), "get", "submissionsByJob", jobIdentifier);
-        long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier, repository);
+        long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
         return getSubmissionsForJob(jobId);
     } else {
       // all submissions in the system


Mime
View raw message