geoserver / geoserver-cloud

Cloud Native GeoServer is GeoServer ready to use in the cloud through dockerized microservices.
http://geoserver.org/geoserver-cloud
Other
244 stars 73 forks source link

Make LayerGroupContainmentCache available only on required services #469

Closed groldan closed 3 months ago

groldan commented 3 months ago

LayerGroupContainmentCache can incur in quite a performance penalty during startup, as it'll get all layer groups and the layers/groups they're linked to.

LayerGroupContainmentCache is a securtity subsystem aid only used by WMS.

This patch contributes a no-op implementation or a customized one depending on the value of the geoserver.security.layergroup-containmentcache boolean config property, which is set to true in the default config's geoserver.yml for the wms, gwc, and webui services.

Additionally, the customized LayerGroupContainmentCache implementation avoids re-creating the cache multiple times during startup. The original implementation does it at the class constructor and on a ContextRefreshedEvent event. Now, this event is triggered on any ApplicationContext refreshed, which for our spring boot services was being triggered three times: for the app context itself, the servlet context, and the actuator context.

Now we make sure the cache is built only when the root application context is refreshed.