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/05/01 20:58:37 UTC

[GitHub] [incubator-gobblin] jack-moseley opened a new pull request #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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


   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
   - [x] 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-1137
   
   
   ### Description
   - [x] Here are some details about my PR, including screenshots (if applicable):
   
   Add API to azkaban client that gets list of current proxy users for a given azkaban project
   
   ### Tests
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   Tested with gaas locally
   
   ### Commits
   - [x] 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] jack-moseley commented on pull request #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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


   @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



[GitHub] [incubator-gobblin] jack-moseley commented on pull request #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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


   @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 #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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



##########
File path: gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanMultiCallables.java
##########
@@ -415,4 +415,42 @@ public AzkabanClientStatus call()
       }
     }
   }
+
+  /**
+   * A callable that will get the list of proxy users from a project on Azkaban.
+   */
+  @Builder
+  static class GetProxyUserCallable implements Callable<AzkabanClientStatus> {
+    private AzkabanClient client;
+    private String projectName;
+    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, "getProxyUsers"));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.SESSION_ID, client.sessionId));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.PROJECT, projectName));
+
+        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);
+        Map<String, String> map = AzkabanClient.handleResponse(response);
+        return new AzkabanGetProxyUsersStatus(new AzkabanGetProxyUsersStatus.ProxyUsers(map));
+      } catch (InvalidSessionException e) {
+        this.invalidSession = true;

Review comment:
       Look at the `AzkabanClient`, there is logic for retrying in case of invalid session.




----------------------------------------------------------------
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 #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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



##########
File path: gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanMultiCallables.java
##########
@@ -415,4 +415,42 @@ public AzkabanClientStatus call()
       }
     }
   }
+
+  /**
+   * A callable that will get the list of proxy users from a project on Azkaban.
+   */
+  @Builder
+  static class GetProxyUserCallable implements Callable<AzkabanClientStatus> {
+    private AzkabanClient client;
+    private String projectName;
+    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, "getProxyUsers"));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.SESSION_ID, client.sessionId));
+        nvps.add(new BasicNameValuePair(AzkabanClientParams.PROJECT, projectName));
+
+        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);
+        Map<String, String> map = AzkabanClient.handleResponse(response);
+        return new AzkabanGetProxyUsersStatus(new AzkabanGetProxyUsersStatus.ProxyUsers(map));
+      } catch (InvalidSessionException e) {
+        this.invalidSession = true;

Review comment:
       should not all Callables in this class call themselves at least one more time when they get InvalidSessionException ?




----------------------------------------------------------------
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 #2976: [GOBBLIN-1137] Add API for getting list of proxy users from an azkaban project

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


   +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