leixm commented on code in PR #2819:
URL: https://github.com/apache/celeborn/pull/2819#discussion_r2000150463


##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/quota/QuotaManager.scala:
##########
@@ -16,96 +16,393 @@
  */
 package org.apache.celeborn.service.deploy.master.quota
 
+import java.util.{Map => JMap}
+import java.util.concurrent.TimeUnit
+import java.util.function.Predicate
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable
+
 import org.apache.celeborn.common.CelebornConf
 import org.apache.celeborn.common.identity.UserIdentifier
 import org.apache.celeborn.common.internal.Logging
-import org.apache.celeborn.common.quota.{Quota, ResourceConsumption}
-import org.apache.celeborn.common.util.Utils
+import org.apache.celeborn.common.metrics.source.ResourceConsumptionSource
+import org.apache.celeborn.common.metrics.source.ResourceConsumptionSource._
+import 
org.apache.celeborn.common.protocol.message.ControlMessages.CheckQuotaResponse
+import org.apache.celeborn.common.quota.{ResourceConsumption, StorageQuota}
+import org.apache.celeborn.common.util.{JavaUtils, ThreadUtils, Utils}
 import org.apache.celeborn.server.common.service.config.ConfigService
+import org.apache.celeborn.service.deploy.master.MasterSource
+import 
org.apache.celeborn.service.deploy.master.MasterSource.UPDATE_RESOURCE_CONSUMPTION_TIME
+import 
org.apache.celeborn.service.deploy.master.clustermeta.AbstractMetaManager
+import org.apache.celeborn.service.deploy.master.quota.QuotaStatus._
+
+class QuotaManager(
+    statusSystem: AbstractMetaManager,
+    masterSource: MasterSource,
+    resourceConsumptionSource: ResourceConsumptionSource,
+    celebornConf: CelebornConf,
+    configService: ConfigService) extends Logging {
 
-class QuotaManager(celebornConf: CelebornConf, configService: ConfigService) 
extends Logging {
-  private val DEFAULT_QUOTA = Quota(
-    celebornConf.get(CelebornConf.QUOTA_DISK_BYTES_WRITTEN),
-    celebornConf.get(CelebornConf.QUOTA_DISK_FILE_COUNT),
-    celebornConf.get(CelebornConf.QUOTA_HDFS_BYTES_WRITTEN),
-    celebornConf.get(CelebornConf.QUOTA_HDFS_FILE_COUNT))
-  def getQuota(userIdentifier: UserIdentifier): Quota = {
-    if (configService != null) {
-      val config =
-        configService.getTenantUserConfigFromCache(userIdentifier.tenantId, 
userIdentifier.name)
-      config.getQuota
+  val userQuotaStatus: JMap[UserIdentifier, QuotaStatus] = 
JavaUtils.newConcurrentHashMap()
+  val tenantQuotaStatus: JMap[String, QuotaStatus] = 
JavaUtils.newConcurrentHashMap()
+  val resourceConsumptionMetricsEnabled = 
celebornConf.masterResourceConsumptionMetricsEnabled
+  @volatile
+  var clusterQuotaStatus: QuotaStatus = new QuotaStatus()
+  val appQuotaStatus: JMap[String, QuotaStatus] = 
JavaUtils.newConcurrentHashMap()
+  private val quotaChecker =
+    ThreadUtils.newDaemonSingleThreadScheduledExecutor("master-quota-checker")
+  quotaChecker.scheduleWithFixedDelay(
+    new Runnable {
+      override def run(): Unit = {
+        try {
+          updateResourceConsumption()
+        } catch {
+          case t: Throwable => logError("Update user resource consumption 
failed.", t)
+        }
+      }
+    },
+    0L,
+    celebornConf.masterResourceConsumptionInterval,
+    TimeUnit.MILLISECONDS)
+
+  def handleAppLost(appId: String): Unit = {
+    appQuotaStatus.remove(appId)
+  }
+
+  def checkUserQuotaStatus(user: UserIdentifier): CheckQuotaResponse = {
+    val quotaEnabled =

Review Comment:
   Should we keep quotaEnabled?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to