Skip to content

startup - avoid iterating over geOrchestra users during bootstrap #735

@pmauduit

Description

@pmauduit

Description

I am not sure this is a bug or an improvement, but considering the scenario where mapstore2-georchestra is deployed into a geOrchestra instance with several hundreds of users registered in the LDAP, the webapp can take a lot of time to bootstrap itself.

For instance, at Rennes-Métropole, one of their instances contains 8k+ users in the LDAP, and with the following code being run at startup:
https://github.com/geosolutions-it/geostore/blob/master/src/web/app/src/main/java/it/geosolutions/geostore/init/GeoStoreInit.java#L115-L172
will iterate over the 8k users, which can take from 7/8 to 15 minutes to perform into their infrastructure.

We came along with the following patch:

diff --git a/src/web/app/src/main/java/it/geosolutions/geostore/init/GeoStoreInit.java b/src/web/app/src/main/java/it/geosolutions/geostore/init/GeoStoreInit.java
index 409c820..194aa7f 100644
--- a/src/web/app/src/main/java/it/geosolutions/geostore/init/GeoStoreInit.java
+++ b/src/web/app/src/main/java/it/geosolutions/geostore/init/GeoStoreInit.java
@@ -71,44 +71,49 @@ public class GeoStoreInit implements InitializingBean {
 
         LOGGER.info("===== Starting GeoStore services =====");
         // initialize password encoding
-        initPasswordEncoding();
-        long catCnt = categoryService.getCount(null);
-        if (catCnt == 0) {
-            LOGGER.warn("No category found.");
-            if (categoryListInitFile != null) {
-                LOGGER.warn("Initializing categories from file " + categoryListInitFile);
-                initCategories(categoryListInitFile);
+        if (new Boolean(System.getProperty("it.geosolutions.geostore.init.skipInit", "false"))
+                == false) {
+            initPasswordEncoding();
+            long catCnt = categoryService.getCount(null);
+            if (catCnt == 0) {
+                LOGGER.warn("No category found.");
+                if (categoryListInitFile != null) {
+                    LOGGER.warn("Initializing categories from file " + categoryListInitFile);
+                    initCategories(categoryListInitFile);
+                } else {
+                    LOGGER.info("No category initializer defined.");
+                }
             } else {
-                LOGGER.info("No category initializer defined.");
+                LOGGER.info("Categories already in db: " + catCnt);
             }
-        } else {
-            LOGGER.info("Categories already in db: " + catCnt);
-        }
 
-        long userGroupCnt = userGroupService.getAll(null, null).size();
-        if (userGroupCnt == 0) {
-            LOGGER.warn("No usersgroup found.");
-            if (userGroupListInitFile != null) {
-                LOGGER.warn("Initializing users from file " + userGroupListInitFile);
-                initUsersGroup(userGroupListInitFile);
+            long userGroupCnt = userGroupService.getAll(null, null).size();
+            if (userGroupCnt == 0) {
+                LOGGER.warn("No usersgroup found.");
+                if (userGroupListInitFile != null) {
+                    LOGGER.warn("Initializing users from file " + userGroupListInitFile);
+                    initUsersGroup(userGroupListInitFile);
+                } else {
+                    LOGGER.info("No usersgroup initializer defined.");
+                }
             } else {
-                LOGGER.info("No usersgroup initializer defined.");
+                LOGGER.info("UsersGroup already in db: " + userGroupCnt);
             }
-        } else {
-            LOGGER.info("UsersGroup already in db: " + userGroupCnt);
-        }
 
-        long userCnt = userService.getCount(null);
-        if (userCnt == 0) {
-            LOGGER.warn("No user found.");
-            if (userListInitFile != null) {
-                LOGGER.warn("Initializing users from file " + userListInitFile);
-                initUsers(userListInitFile);
+            long userCnt = userService.getCount(null);
+            if (userCnt == 0) {
+                LOGGER.warn("No user found.");
+                if (userListInitFile != null) {
+                    LOGGER.warn("Initializing users from file " + userListInitFile);
+                    initUsers(userListInitFile);
+                } else {
+                    LOGGER.info("No user initializer defined.");
+                }
             } else {
-                LOGGER.info("No user initializer defined.");
+                LOGGER.info("Users already in db: " + userCnt);
             }
         } else {
-            LOGGER.info("Users already in db: " + userCnt);
+            LOGGER.info("it.geosolutions.geostore.init.skipInit = true. Skipping init procedure.");
         }
     }

so that we could skip the password encoding logic which is outside the scope of mapstore2 or any other geOrchestra webapps, in a geOrchestra context.

What kind of improvement you want to add? (check one with "x", remove the others)

  • Minor changes to existing features
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Mapstore2georchestra improvement
  • Mapstore2 improvement
  • Other... Please describe:

Other useful information

The provided patch above targets geostore, but since this looks like being very geOrchestra-specific, I preferred to report it on this repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions