You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by zm...@apache.org on 2016/04/18 20:04:36 UTC

aurora git commit: Make MyBatis connection pool size configurable.

Repository: aurora
Updated Branches:
  refs/heads/master e543415d2 -> 96c990875


Make MyBatis connection pool size configurable.

This adds two arguments which enables operators to configure the internal
MyBatis connection pool size. Increasing the size will allow for greater
concurrency in larger clusters.

Reviewed at https://reviews.apache.org/r/46289/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/96c99087
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/96c99087
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/96c99087

Branch: refs/heads/master
Commit: 96c99087503599e2c686e83027be411b26ded8a5
Parents: e543415
Author: Zameer Manji <zm...@apache.org>
Authored: Mon Apr 18 11:04:03 2016 -0700
Committer: Zameer Manji <zm...@apache.org>
Committed: Mon Apr 18 11:04:03 2016 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/storage/db/DbModule.java   | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/96c99087/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
index 743993c..e7287ce 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
@@ -34,6 +34,7 @@ import com.google.inject.util.Modules;
 
 import org.apache.aurora.common.args.Arg;
 import org.apache.aurora.common.args.CmdLine;
+import org.apache.aurora.common.args.constraints.Positive;
 import org.apache.aurora.common.inject.Bindings.KeyFactory;
 import org.apache.aurora.common.quantity.Amount;
 import org.apache.aurora.common.quantity.Time;
@@ -87,6 +88,17 @@ public final class DbModule extends PrivateModule {
   private static final Arg<Amount<Long, Time>> H2_LOCK_TIMEOUT =
       Arg.create(Amount.of(1L, Time.MINUTES));
 
+  // Flags to configure the PooledDataSource from mybatis.
+  @Positive
+  @CmdLine(name = "db_max_active_connection_count",
+      help = "Max number of connections to use with database via MyBatis")
+  private static final Arg<Integer> MYBATIS_MAX_ACTIVE_CONNECTION_COUNT = Arg.create();
+
+  @Positive
+  @CmdLine(name = "db_max_idle_connection_count",
+      help = "Max number of idle connections to the database via MyBatis")
+  private static final Arg<Integer> MYBATIS_MAX_IDLE_CONNECTION_COUNT = Arg.create();
+
   private static final Set<Class<?>> MAPPER_CLASSES = ImmutableSet.<Class<?>>builder()
       .add(AttributeMapper.class)
       .add(CronJobMapper.class)
@@ -260,6 +272,16 @@ public final class DbModule extends PrivateModule {
         bindProperties(binder(), ImmutableMap.of("mybatis.pooled.pingEnabled", "true"));
         bindProperties(binder(), ImmutableMap.of("mybatis.pooled.pingQuery", "SELECT 1;"));
 
+        if (MYBATIS_MAX_ACTIVE_CONNECTION_COUNT.hasAppliedValue()) {
+          String val = MYBATIS_MAX_ACTIVE_CONNECTION_COUNT.get().toString();
+          bindProperties(binder(), ImmutableMap.of("mybatis.pooled.maximumActiveConnections", val));
+        }
+
+        if (MYBATIS_MAX_IDLE_CONNECTION_COUNT.hasAppliedValue()) {
+          String val = MYBATIS_MAX_IDLE_CONNECTION_COUNT.get().toString();
+          bindProperties(binder(), ImmutableMap.of("mybatis.pooled.maximumIdleConnections", val));
+        }
+
         // Exposed for unit tests.
         bind(TaskConfigManager.class);
         expose(TaskConfigManager.class);