1

I use thousands of H2 databases via TCP using Hikari Connection Pools. In a period of 1-30min a lot of queries will be performed on about five of the databases. There will be some queries to some of the other databases too but it is not predictable which and how many databases are affected by those side queries.

I store the already used HikariDataSources in a HashMap for the subsequent queries but I fear that the HashMap (contained objects) is getting too large and therefore I want to create a cleanup thread that closes HikariDataSources and removes them from the HashMap after they weren't used for a certain period of time.

To remove the right connection pools I need to know if a pool was not used for a defined period of time. How do I get that information?

And is there a better way to handle the number of Connection Pools? Maybe there is something that is made for Connection Pools similar as HikariCP is made for Connections. Is there a Pool for Connection Pools? :D

Ironori
  • 540
  • 1
  • 5
  • 19
  • You have a getter for those Datasource in the map ? just update the timestamp for a the Datasource selected (store in an other map or using a class to wrap the timestamp and the Datasource) during this call. I don't know those API so can't tell if there is something existing. – AxelH Dec 07 '16 at 07:49
  • There is a getter for the DataSource object. This solution would probably be a first approach. However, a DataSource can still be used long after the getter has been executed. An already open connection can be used, or new connections can be obtained directly from the DataSource. – Ironori Dec 07 '16 at 08:04
  • I found [Intercepting DataSource](https://gist.github.com/brettwooldridge/dfd21934416fc2a3c865) here: [Detailed pool and connection information?](https://groups.google.com/forum/#!searchin/hikari-cp/time|sort:relevance/hikari-cp/zVsBhsQ633o/QZ8e9k9s0yIJ). This approach might be useful but we have to be careful to not influence negatively the performance. – Ironori Dec 07 '16 at 08:48

0 Answers0