diff --git a/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java b/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java index 4db9cfcf23..8ebb2ac500 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java +++ b/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java @@ -36,6 +36,7 @@ import javax.transaction.TransactionManager; import java.sql.Connection; import java.sql.Driver; import java.sql.SQLException; +import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -165,8 +166,8 @@ public class DBCPConnectionFactory implements ConnectionFactoryInterface { } pool.setFactory(factory); - mds = new ManagedDataSource(pool, xacf.getTransactionRegistry()); - //mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool + //mds = new ManagedDataSource(pool, xacf.getTransactionRegistry()); + mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool mds.setAccessToUnderlyingConnectionAllowed(true); // cache the pool @@ -180,4 +181,14 @@ public class DBCPConnectionFactory implements ConnectionFactoryInterface { // no methods on the pool to shutdown; so just clearing for GC dsCache.clear(); } + + public static Map getDataSourceInfo(String helperName) { + Map dataSourceInfo = new HashMap(); + ManagedDataSource mds = dsCache.get(helperName); + if (mds instanceof DebugManagedDataSource) { + dataSourceInfo = ((DebugManagedDataSource)mds).getInfo(); + } + return dataSourceInfo; + } + } diff --git a/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java b/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java index fbd8854c4e..4df5380684 100644 --- a/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java +++ b/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java @@ -23,10 +23,13 @@ import org.apache.commons.dbcp.managed.ManagedDataSource; import org.apache.commons.dbcp.managed.TransactionRegistry; import org.apache.commons.pool.ObjectPool; +import org.apache.commons.pool.impl.GenericObjectPool; import org.ofbiz.base.util.Debug; import java.sql.Connection; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; public class DebugManagedDataSource extends ManagedDataSource { @@ -41,7 +44,31 @@ public class DebugManagedDataSource extends ManagedDataSource { @Override public Connection getConnection() throws SQLException { - Debug.logInfo("Borrowing a connection from the pool; used/total: " + super._pool.getNumActive() + "/" + (super._pool.getNumActive() + super._pool.getNumIdle()), module); + if (Debug.verboseOn()) { + if (super._pool instanceof GenericObjectPool) { + GenericObjectPool objectPool = (GenericObjectPool)super._pool; + Debug.logVerbose("Borrowing a connection from the pool; used/total: " + objectPool.getNumActive() + "/" + objectPool.getNumActive() + objectPool.getNumIdle() + "; min idle/max idle/max total: " + objectPool.getMinIdle() + "/" + objectPool.getMaxIdle() + "/" + objectPool.getMaxActive(), module); + } else { + Debug.logVerbose("Borrowing a connection from the pool; used/total: " + super._pool.getNumActive() + "/" + (super._pool.getNumActive() + super._pool.getNumIdle()), module); + } + } return super.getConnection(); } + + public Map getInfo() { + Map dataSourceInfo = new HashMap(); + dataSourceInfo.put("poolNumActive", super._pool.getNumActive()); + dataSourceInfo.put("poolNumIdle", super._pool.getNumIdle()); + dataSourceInfo.put("poolNumTotal", (super._pool.getNumIdle() + super._pool.getNumActive())); + if (super._pool instanceof GenericObjectPool) { + GenericObjectPool objectPool = (GenericObjectPool)super._pool; + dataSourceInfo.put("poolMaxActive", objectPool.getMaxActive()); + dataSourceInfo.put("poolMaxIdle", objectPool.getMaxIdle()); + dataSourceInfo.put("poolMaxWait", objectPool.getMaxWait()); + dataSourceInfo.put("poolMinEvictableIdleTimeMillis", objectPool.getMinEvictableIdleTimeMillis()); + dataSourceInfo.put("poolMinIdle", objectPool.getMinIdle()); + } + return dataSourceInfo; + } + } diff --git a/framework/webtools/config/WebtoolsUiLabels.xml b/framework/webtools/config/WebtoolsUiLabels.xml index a0b93e7823..9cbdc34e89 100644 --- a/framework/webtools/config/WebtoolsUiLabels.xml +++ b/framework/webtools/config/WebtoolsUiLabels.xml @@ -19,6 +19,9 @@ under the License. --> + + Connection Pool Status + Deleting ${fileName} Stò cancellando il file ${fileName} diff --git a/framework/webtools/webapp/webtools/WEB-INF/controller.xml b/framework/webtools/webapp/webtools/WEB-INF/controller.xml index a1adc5701a..b6f1425851 100644 --- a/framework/webtools/webapp/webtools/WEB-INF/controller.xml +++ b/framework/webtools/webapp/webtools/WEB-INF/controller.xml @@ -359,6 +359,11 @@ under the License. + + + + + @@ -657,6 +662,7 @@ under the License. + diff --git a/framework/webtools/webapp/webtools/entity/ConnectionPoolStatus.ftl b/framework/webtools/webapp/webtools/entity/ConnectionPoolStatus.ftl new file mode 100644 index 0000000000..f80f45e362 --- /dev/null +++ b/framework/webtools/webapp/webtools/entity/ConnectionPoolStatus.ftl @@ -0,0 +1,56 @@ +<#-- +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. +--> +

Connection Pool Status

+ +<#assign groups = delegator.getModelGroupReader().getGroupNames(delegator.getDelegatorName())?if_exists/> + + + + + + + + + + + + + <#assign alt_row = false> + <#if (groups?has_content)> + <#list groups as group> + <#assign helper = delegator.getGroupHelperName(group)?if_exists/> + <#if (helper?has_content)> + <#assign dataSourceInfo = Static["org.ofbiz.entity.connection.DBCPConnectionFactory"].getDataSourceInfo(helper)?if_exists/> + <#if (dataSourceInfo?has_content)> + + + + + + + + + + + + + + + +
Helper NameNum ActiveNum IdleNum TotalMax ActiveMax IdleMin IdleMin Evictable Idle TimeMax Wait
${helper}${dataSourceInfo.poolNumActive?if_exists}${dataSourceInfo.poolNumIdle?if_exists}${dataSourceInfo.poolNumTotal?if_exists}${dataSourceInfo.poolMaxActive?if_exists}${dataSourceInfo.poolMaxIdle?if_exists}${dataSourceInfo.poolMinIdle?if_exists}${dataSourceInfo.poolMinEvictableIdleTimeMillis?if_exists}${dataSourceInfo.poolMaxWait?if_exists}
diff --git a/framework/webtools/webapp/webtools/main.ftl b/framework/webtools/webapp/webtools/main.ftl index 58675f427f..fdc284e179 100644 --- a/framework/webtools/webapp/webtools/main.ftl +++ b/framework/webtools/webapp/webtools/main.ftl @@ -60,6 +60,7 @@ under the License.
  • ${uiLabelMap.WebtoolsInduceModelXMLFromDatabase}
  • ${uiLabelMap.WebtoolsExportEntityEoModelBundle}
  • ${uiLabelMap.WebtoolsCheckUpdateDatabase}
  • +
  • ${uiLabelMap.ConnectionPoolStatus}
  • <#-- not using Minerva by default any more
  • Minerva Connection Info
  • --> <#-- want to leave these out because they are only working so-so, and cause people more problems that they solve, IMHO
  • Edit Entity Definitions
  • diff --git a/framework/webtools/widget/EntityScreens.xml b/framework/webtools/widget/EntityScreens.xml index 2540c035d2..45b1bc5e3c 100644 --- a/framework/webtools/widget/EntityScreens.xml +++ b/framework/webtools/widget/EntityScreens.xml @@ -454,4 +454,22 @@ under the License. + +
    + + + + + + + + + + + + + + +
    +
    diff --git a/framework/webtools/widget/Menus.xml b/framework/webtools/widget/Menus.xml index f06e00f1e2..46dd209ea4 100644 --- a/framework/webtools/widget/Menus.xml +++ b/framework/webtools/widget/Menus.xml @@ -195,6 +195,9 @@ under the License. + + +