sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-1960: Sqoop2: Share auth token across ResourceRequest in SqoopClient
Date Fri, 09 Jan 2015 07:22:04 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 471e534ef -> f4fd668b3


SQOOP-1960: Sqoop2: Share auth token across ResourceRequest in SqoopClient

(Qian Xu via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: f4fd668b368598401aaa933a43f0f94cf385f62a
Parents: 471e534
Author: Abraham Elmahrek <abe@apache.org>
Authored: Thu Jan 8 23:01:23 2015 -0800
Committer: Abraham Elmahrek <abe@apache.org>
Committed: Thu Jan 8 23:01:49 2015 -0800

----------------------------------------------------------------------
 .../client/request/ConnectorResourceRequest.java    |  9 +++++++++
 .../sqoop/client/request/DriverResourceRequest.java |  9 +++++++++
 .../sqoop/client/request/JobResourceRequest.java    |  9 +++++++++
 .../sqoop/client/request/LinkResourceRequest.java   |  9 +++++++++
 .../sqoop/client/request/ResourceRequest.java       | 13 ++++++++++++-
 .../sqoop/client/request/SqoopResourceRequests.java | 16 +++++++++++-----
 .../client/request/SubmissionResourceRequest.java   |  9 +++++++++
 .../client/request/VersionResourceRequest.java      |  9 +++++++++
 8 files changed, 77 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
index c6232d0..f23c6e4 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.ConnectorBean;
 import org.apache.sqoop.json.ConnectorsBean;
 import org.apache.sqoop.json.JSONUtils;
@@ -30,6 +31,14 @@ import org.json.simple.JSONObject;
 public class ConnectorResourceRequest extends ResourceRequest {
   public static final String RESOURCE = "v1/connector/";
 
+  public ConnectorResourceRequest(){
+    super();
+  }
+
+  public ConnectorResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public ConnectorBean read(String serverUrl, Long cid) {
     String response;
     if (cid == null) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
index 95bb12c..80103e6 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/DriverResourceRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.DriverBean;
 import org.apache.sqoop.json.JSONUtils;
 import org.json.simple.JSONObject;
@@ -28,6 +29,14 @@ public class DriverResourceRequest extends ResourceRequest {
 
   public static final String RESOURCE = "v1/driver/";
 
+  public DriverResourceRequest(){
+    super();
+  }
+
+  public DriverResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public DriverBean read(String serverUrl) {
     String response = null;
     response = super.get(serverUrl + RESOURCE);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
index 167e8be..c95686d 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.JobsBean;
@@ -39,6 +40,14 @@ public class JobResourceRequest extends ResourceRequest {
   private static final String STOP = "/stop";
   private static final String STATUS = "/status";
 
+  public JobResourceRequest(){
+    super();
+  }
+
+  public JobResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public JobBean read(String serverUrl, Long jobId) {
     String response;
     if (jobId == null) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
index 9a4a134..0783002 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.LinkBean;
 import org.apache.sqoop.json.LinksBean;
@@ -35,6 +36,14 @@ public class LinkResourceRequest extends ResourceRequest {
   private static final String ENABLE = "/enable";
   private static final String DISABLE = "/disable";
 
+  public LinkResourceRequest(){
+    super();
+  }
+
+  public LinkResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public LinkBean read(String serverUrl, Long linkId) {
     String response;
     if (linkId == null) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
index e55ba36..ce6a9e5 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java
@@ -51,6 +51,14 @@ public class ResourceRequest {
   private DelegationTokenAuthenticatedURL.Token authToken;
   private String strURL;
 
+  public ResourceRequest() {
+    this.authToken = new DelegationTokenAuthenticatedURL.Token();
+  }
+
+  public ResourceRequest(DelegationTokenAuthenticatedURL.Token token) {
+    this.authToken = token == null ? new DelegationTokenAuthenticatedURL.Token() : token;
+  }
+
   protected String doHttpRequest(String strURL, String method) {
     return doHttpRequest(strURL, method, "");
   }
@@ -59,7 +67,6 @@ public class ResourceRequest {
     DataOutputStream wr = null;
     BufferedReader reader = null;
     try {
-      this.authToken = new DelegationTokenAuthenticatedURL.Token();
       this.strURL = strURL;
       URL url = new URL(strURL);
       HttpURLConnection conn = new DelegationTokenAuthenticatedURL().openConnection(url,
authToken);
@@ -212,4 +219,8 @@ public class ResourceRequest {
     Text dtService = SecurityUtil.buildTokenService(addr);
     return dtService;
   }
+
+  public DelegationTokenAuthenticatedURL.Token getAuthToken() {
+    return authToken;
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
index fe528f2..a74a56d 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.ConnectorBean;
 import org.apache.sqoop.json.DriverBean;
 import org.apache.sqoop.json.JobBean;
@@ -39,6 +40,11 @@ public class SqoopResourceRequests {
   private LinkResourceRequest linkRequest;
   private JobResourceRequest jobRequest;
   private SubmissionResourceRequest submissionRequest;
+  private DelegationTokenAuthenticatedURL.Token authToken;
+
+  public SqoopResourceRequests(){
+    authToken = new DelegationTokenAuthenticatedURL.Token();
+  }
 
   public void setServerUrl(String serverUrl) {
     this.serverUrl = serverUrl;
@@ -46,7 +52,7 @@ public class SqoopResourceRequests {
 
   public DriverResourceRequest getDriverResourceRequest() {
     if (driverRequest == null) {
-      driverRequest = new DriverResourceRequest();
+      driverRequest = new DriverResourceRequest(authToken);
     }
 
     return driverRequest;
@@ -54,7 +60,7 @@ public class SqoopResourceRequests {
 
   public ConnectorResourceRequest getConnectorResourceRequest() {
     if (connectorRequest == null) {
-      connectorRequest = new ConnectorResourceRequest();
+      connectorRequest = new ConnectorResourceRequest(authToken);
     }
 
     return connectorRequest;
@@ -62,7 +68,7 @@ public class SqoopResourceRequests {
 
   public LinkResourceRequest getLinkResourceRequest() {
     if (linkRequest == null) {
-      linkRequest = new LinkResourceRequest();
+      linkRequest = new LinkResourceRequest(authToken);
     }
 
     return linkRequest;
@@ -70,7 +76,7 @@ public class SqoopResourceRequests {
 
   public JobResourceRequest getJobResourceRequest() {
     if (jobRequest == null) {
-      jobRequest = new JobResourceRequest();
+      jobRequest = new JobResourceRequest(authToken);
     }
 
     return jobRequest;
@@ -78,7 +84,7 @@ public class SqoopResourceRequests {
 
   public SubmissionResourceRequest getSubmissionResourceRequest() {
     if (submissionRequest == null) {
-      submissionRequest = new SubmissionResourceRequest();
+      submissionRequest = new SubmissionResourceRequest(authToken);
     }
 
     return submissionRequest;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
index 47a0a94..7beea08 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.SubmissionsBean;
 import org.json.simple.JSONObject;
@@ -29,6 +30,14 @@ public class SubmissionResourceRequest extends  ResourceRequest {
 
   public static final String RESOURCE = "v1/submissions/";
 
+  public SubmissionResourceRequest(){
+    super();
+  }
+
+  public SubmissionResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public SubmissionsBean read(String serverUrl, Long jid) {
     String response;
     if (jid == null) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/f4fd668b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
index 7bd0dba..d10fe24 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java
@@ -17,12 +17,21 @@
  */
 package org.apache.sqoop.client.request;
 
+import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.VersionBean;
 import org.json.simple.JSONObject;
 
 public class VersionResourceRequest extends ResourceRequest
 {
+  public VersionResourceRequest(){
+    super();
+  }
+
+  public VersionResourceRequest(DelegationTokenAuthenticatedURL.Token token){
+    super(token);
+  }
+
   public VersionBean read(String serverUrl) {
     String response = super.get(serverUrl + "version");
     JSONObject jsonObject = JSONUtils.parse(response);


Mime
View raw message