Will-Lo commented on code in PR #3545:
URL: https://github.com/apache/gobblin/pull/3545#discussion_r959860630


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/MysqlUserQuotaManager.java:
##########
@@ -0,0 +1,259 @@
+/*
+ * 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 java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+
+import org.apache.commons.dbcp.BasicDataSource;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.inject.Inject;
+import com.typesafe.config.Config;
+
+import javax.inject.Singleton;
+import javax.sql.DataSource;
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.metastore.MysqlStateStore;
+import org.apache.gobblin.service.modules.flowgraph.Dag;
+import org.apache.gobblin.service.modules.spec.JobExecutionPlan;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * An implementation of {@link UserQuotaManager} that stores quota usage in 
mysql.
+ */
+@Slf4j
+@Singleton
+public class MysqlUserQuotaManager extends AbstractUserQuotaManager {
+  private final MysqlQuotaStore mysqlStore;
+
+  @Inject
+  public MysqlUserQuotaManager(Config config) throws IOException {
+    super(config);
+    this.mysqlStore = createQuotaStore(config);
+  }
+
+  // This implementation does not need to update quota usage when the service 
restarts or it's leadership status changes
+  public void init(Collection<Dag<JobExecutionPlan>> dags) {

Review Comment:
   Ah I think if the DagManagers are sharded and they each manage their own 
dagstatestores, then it'll be fine. The only concern then would be that there 
could be a race condition when decrementing quota for jobs that have already 
completed versus incoming jobs, but that shouldn't be captured in the PR 
anyways.
   
   I'm thinking of the scenario where DagManager A manages job A, DagManager A 
goes down, and job A completes. Then job B is picked up once DagManager A goes 
back up. If job B is picked up before the dag manager processes that A is 
complete, then we'd run into a quota issue even though the job is technically 
already finished. This can lead to spiky behavior, but I think this would be 
managed in the dagmanager anyways instead of the quota manager.



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