perun
perun copied to clipboard
ExtSourceSql with pooling connections
Changed implementation of ExtSourceSql and ExtSourcesManagerImpl to use database connections obtained from pooling DataSources instead of keeping a special connection open for each one.
- changed parsing of XML file perun-extSources.xml in ExtSourcesManagerImpl
- replaced parsing library DOM with DOM4J, it is much easier to use
- replaced project dependency on JDOM, which was not used, with dependency on DOM4J
- parsing of perun-extSources.xml detects new tags <dbpool> and creates a read-only Hikari pool for each one (special mark <main/> is available for referencing the main pool instead of creating a new one)
- extSources of type ExtSourceSql now support a new attribute dbpool referencing a db pool
- for backward compatibility, extSources of type ExtSourceSql with legacy attributes url, driver, user and password are detected and dbpools are created for them
- added method destroy() to PerunBlImpl, ExtSourcesManagerBl, ExtSourcesManagerBlImpl, ExtSourcesManagerImplApi and ExtSourcesManagerImpl which closes created DataSources on shutdown
- changed implementation of methods querySource() and groupQuery() to be faster by pre-processing result set metadata outside of the reading loop and reading only available columns, thus avoiding throwing-and-catching exceptions just to detect missing columns on each row
- rewrote ExtSourcesManagerBlImpl to cache instances of ExtSources in memory to avoid a lot of database queries
- replaced injection of PerunBl instance into static variable in ExtSource* classes from perun-core.xml with all ExtSource descendants implementing a new class EtxSourceImpl that has a setter for PerunBl, and this is called right after creation of a new instance in EXTSOURCE_MAPPER
- replaced usages of EXT_SOURCES_EXTRACTOR with EXTSOURCE_MAPPER in ExtSourcesManagerImpl and changed SQL queries to spare useless extracting and immediate throwing away of attribute values when reading just ExtSources
- in AuthzResolverIntegrationTest added refreshing ExtSources before every test
deleted branch by mistake
Please rebase this PR. Thank you.
done as #3895