sv2000 commented on a change in 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:
[email protected]
With regards,
Apache Git Services