[ 
https://issues.apache.org/jira/browse/GOBBLIN-1073?focusedWorklogId=401697&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-401697
 ]

ASF GitHub Bot logged work on GOBBLIN-1073:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Mar/20 19:17
            Start Date: 11/Mar/20 19:17
    Worklog Time Spent: 10m 
      Work Description: sv2000 commented on pull request #2913: [GOBBLIN-1073] 
Add proxy user and requester quota to GaaS
URL: https://github.com/apache/incubator-gobblin/pull/2913#discussion_r391204237
 
 

 ##########
 File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java
 ##########
 @@ -747,6 +763,55 @@ private void submitJob(DagNode<JobExecutionPlan> dagNode) 
{
       }
     }
 
+    private void checkQuota(DagNode<JobExecutionPlan> dagNode) throws 
IOException {
+      String proxyUser = 
ConfigUtils.getString(dagNode.getValue().getJobSpec().getConfig(), 
AzkabanProjectConfig.USER_TO_PROXY, null);
+      String specExecutorUri = 
dagNode.getValue().getSpecExecutor().getUri().toString();
+      boolean proxyUserCheck = true;
+      if (proxyUser != null) {
+        proxyUserCheck = incrementMapAndCheckQuota(proxyUserToJobCount, 
proxyUser, dagNode);
+      }
+
+      String serializedRequesters = 
ConfigUtils.getString(dagNode.getValue().getJobSpec().getConfig(), 
RequesterService.REQUESTER_LIST, null);
+      boolean requesterCheck = true;
+      String requesterMessage = null;
+      if (serializedRequesters != null) {
+        for (ServiceRequester requester : 
RequesterService.deserialize(serializedRequesters)) {
+          requesterCheck &= incrementMapAndCheckQuota(requesterToJobCount, 
requester.toString(), dagNode);
+          if (!requesterCheck && requesterMessage == null) {
+            requesterMessage = "Quota exceeded for requester " + requester + " 
on executor " + specExecutorUri + ": quota="
+                + quota + ", runningJobs=" + 
requesterToJobCount.get(requester.toString() + "," + specExecutorUri);
+          }
+        }
+      }
+
+      // Throw errors for reach quota at the end to avoid inconsistent job 
counts
+      if (!proxyUserCheck) {
+        throw new IOException("Quota exceeded for proxy user " + proxyUser + " 
on executor " + specExecutorUri +
+            ": quota=" + quota + ", runningJobs=" + 
proxyUserToJobCount.get(proxyUser + "," + specExecutorUri));
+      }
+
+      if (!requesterCheck) {
+        throw new IOException(requesterMessage);
+      }
+    }
+
+    /**
+     * Increment quota by one for the given map and key.
+     * @return true if quota is not reached for this user or user is 
whitelisted, false otherwise.
+     */
+    private boolean incrementMapAndCheckQuota(Map<String, Integer> quotaMap, 
String user, DagNode<JobExecutionPlan> dagNode) {
+      String key = user + "," + 
dagNode.getValue().getSpecExecutor().getUri().toString();
 
 Review comment:
   Move this logic to a separate method. DagManagerUtils.getUserKey()?
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 401697)
    Time Spent: 1h 10m  (was: 1h)

> Add proxy user and requester quota to GaaS
> ------------------------------------------
>
>                 Key: GOBBLIN-1073
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1073
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Jack Moseley
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to