You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by GitBox <gi...@apache.org> on 2020/04/27 20:18:52 UTC

[GitHub] [incubator-gobblin] jack-moseley opened a new pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

jack-moseley opened a new pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971


   Dear Gobblin maintainers,
   
   Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
   
   
   ### JIRA
   - [ ] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-1130
   
   
   ### Description
   - [ ] Here are some details about my PR, including screenshots (if applicable):
   
   Add method in `AzkabanClient` that adds given user as a proxy user in given azkaban project
   
   ### Tests
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   
   ### Commits
   - [ ] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-gobblin] arjun4084346 commented on a change in pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

Posted by GitBox <gi...@apache.org>.
arjun4084346 commented on a change in pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971#discussion_r416126824



##########
File path: gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanMultiCallables.java
##########
@@ -375,4 +375,44 @@ public AzkabanClientStatus call()
       }
     }
   }
+
+  /**
+   * A callable that will add a proxy user to a project on Azkaban
+   */
+  @Builder
+  static class addProxyUserCallable implements Callable<AzkabanClientStatus> {
+    private AzkabanClient client;
+    private String projectName;
+    private String proxyUserName;
+    private boolean invalidSession = false;
+
+    @Override
+    public AzkabanClientStatus call()
+        throws AzkabanClientException {
+      try (Closer closer = Closer.create()) {
+        client.refreshSession(this.invalidSession);
+        List<NameValuePair> nvps = new ArrayList<>();
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.AJAX, "addProxyUser"));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.SESSION_ID, client.sessionId));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.PROJECT, projectName));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.NAME, proxyUserName));
+
+        Header contentType = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        Header requestType = new BasicHeader("X-Requested-With", "XMLHttpRequest");
+
+        HttpGet httpGet = new HttpGet(client.url + "/manager?" + URLEncodedUtils.format(nvps, "UTF-8"));
+        httpGet.setHeaders(new Header[]{contentType, requestType});
+
+        CloseableHttpResponse response = client.httpClient.execute(httpGet);
+        closer.register(response);
+        client.handleResponse(response);

Review comment:
       this can be called as AzkabanClient.handleResponse()
   intellij shows codestyle issue




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-gobblin] arjun4084346 commented on pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

Posted by GitBox <gi...@apache.org>.
arjun4084346 commented on pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971#issuecomment-620217933


   +1 LGTM


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-gobblin] jack-moseley commented on pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

Posted by GitBox <gi...@apache.org>.
jack-moseley commented on pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971#issuecomment-620211198


   @arjun4084346 please review


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-gobblin] jack-moseley commented on a change in pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

Posted by GitBox <gi...@apache.org>.
jack-moseley commented on a change in pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971#discussion_r416143398



##########
File path: gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanMultiCallables.java
##########
@@ -375,4 +375,44 @@ public AzkabanClientStatus call()
       }
     }
   }
+
+  /**
+   * A callable that will add a proxy user to a project on Azkaban
+   */
+  @Builder
+  static class addProxyUserCallable implements Callable<AzkabanClientStatus> {
+    private AzkabanClient client;
+    private String projectName;
+    private String proxyUserName;
+    private boolean invalidSession = false;
+
+    @Override
+    public AzkabanClientStatus call()
+        throws AzkabanClientException {
+      try (Closer closer = Closer.create()) {
+        client.refreshSession(this.invalidSession);
+        List<NameValuePair> nvps = new ArrayList<>();
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.AJAX, "addProxyUser"));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.SESSION_ID, client.sessionId));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.PROJECT, projectName));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.NAME, proxyUserName));
+
+        Header contentType = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        Header requestType = new BasicHeader("X-Requested-With", "XMLHttpRequest");
+
+        HttpGet httpGet = new HttpGet(client.url + "/manager?" + URLEncodedUtils.format(nvps, "UTF-8"));
+        httpGet.setHeaders(new Header[]{contentType, requestType});
+
+        CloseableHttpResponse response = client.httpClient.execute(httpGet);
+        closer.register(response);
+        client.handleResponse(response);

Review comment:
       I was just copying how the other methods did it, I'll change it at those places as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-gobblin] jack-moseley commented on pull request #2971: [GOBBLIN-1130] Add API for adding proxy user to azkaban project

Posted by GitBox <gi...@apache.org>.
jack-moseley commented on pull request #2971:
URL: https://github.com/apache/incubator-gobblin/pull/2971#issuecomment-621415515


   @sv2000 please merge


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org