Method getOpenConnections in Class DatasourceManagerImpl does not work in Lucee 6. With Lucee 5 works fine. Was this method deprecated on a version higher than 5? Any alternative in Lucee 6?
I call this function by
con=getPageContext().getDataSourceManager().getOpenConnections(getPageContext(),“dsn”,null,null);
The error:
“No matching method for lucee.runtime.db.DatasourceManagerImpl.getOpenConnections(lucee.runtime.PageContextImpl, string, string, string) found.”
When dump:
writeDump(var=getPageContext().getDataSourceManager());
I see the class DatasourceManagerImpl with getOpenConnections method inside:
Lucee 6 switches to apache commons pool2 for managing the datasource connections
The method error is because it’s expecting an object lucee.runtime.db.datasource, not just the datasource name (string)
try the hidden GetSystemMetrics() function as used in the admin
ConfigWebPro config = (ConfigWebPro) pc.getConfig();
CFMLFactoryImpl factory = (CFMLFactoryImpl) config.getFactory();
ScopeContext sc = factory.getScopeContext();
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
// threads/requests
sct.put("activeRequests", factory.getActiveRequests());
sct.put("activeThreads", factory.getActiveThreads());
sct.put("queueRequests", config.getThreadQueue().size());
// Datasource connections
{
// TODO provide more data
int idle = 0, active = 0, waiters = 0;
for (DatasourceConnPool pool: config.getDatasourceConnectionPools()) {
idle += pool.getNumIdle();
active += pool.getNumActive();
idle += pool.getNumWaiters();
if ((pool.getNumActive() + pool.getNumIdle() + pool.getNumWaiters()) == 0) {
continue;
}
Thanks @Zackster ! GetSystemMetrics() made the trick.