[
https://issues.apache.org/jira/browse/GOBBLIN-1691?focusedWorklogId=803800&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-803800
]
ASF GitHub Bot logged work on GOBBLIN-1691:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 25/Aug/22 22:24
Start Date: 25/Aug/22 22:24
Worklog Time Spent: 10m
Work Description: arjun4084346 commented on code in PR #3545:
URL: https://github.com/apache/gobblin/pull/3545#discussion_r955468477
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/InMemoryUserQuotaManager.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.service.modules.orchestration;
+
+import com.google.inject.Inject;
+import com.typesafe.config.Config;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+
+
+/**
+ * An implementation of {@link UserQuotaManager} that stores quota usage in
memory.
+ */
+@Slf4j
+@Singleton
+public class InMemoryUserQuotaManager extends AbstractUserQuotaManager {
+ private final Map<String, Integer> proxyUserToJobCount = new
ConcurrentHashMap<>();
+ private final Map<String, Integer> flowGroupToJobCount = new
ConcurrentHashMap<>();
+ private final Map<String, Integer> requesterToJobCount = new
ConcurrentHashMap<>();
+
+ @Inject
+ public InMemoryUserQuotaManager(Config config) {
+ super(config);
+ }
+
+ private int incrementJobCount(String key, Map<String, Integer> quotaMap) {
+ Integer currentCount;
+ // Modifications must be thread safe since DAGs on DagManagerThreads may
update the quota for the same user
+ do {
+ currentCount = quotaMap.get(key);
+ } while (currentCount == null ? quotaMap.putIfAbsent(key, 1) != null :
!quotaMap.replace(key, currentCount, currentCount + 1));
+
+ if (currentCount == null) {
+ currentCount = 0;
+ }
+
+ return currentCount;
+ }
+
+ private void decrementJobCount(String key, Map<String, Integer> quotaMap) {
+ Integer currentCount;
+ if (key == null) {
+ return;
+ }
+ do {
+ currentCount = quotaMap.get(key);
+ } while (currentCount != null && currentCount > 0 &&
!quotaMap.replace(key, currentCount, currentCount - 1));
Review Comment:
added
Issue Time Tracking
-------------------
Worklog Id: (was: 803800)
Time Spent: 1h 10m (was: 1h)
> add a mysql based user quota manager
> ------------------------------------
>
> Key: GOBBLIN-1691
> URL: https://issues.apache.org/jira/browse/GOBBLIN-1691
> Project: Apache Gobblin
> Issue Type: Improvement
> Reporter: Arjun Singh Bora
> Priority: Major
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> mysql based user quota manager can share the usage data with other instances
> of Gobblin Service
--
This message was sent by Atlassian Jira
(v8.20.10#820010)