From aaab2d6cbcfa937f207c1b4c731831f9080a9a6c Mon Sep 17 00:00:00 2001 From: Adrien LAUER Date: Thu, 1 Jul 2021 12:37:17 +0200 Subject: [PATCH] Ensure indexes and caps at startup only --- .travis.yml | 9 +- CHANGELOG.md | 22 +++-- checkstyle.xml | 2 +- core/pom.xml | 2 +- .../org/seedstack/mongodb/MongoDbConfig.java | 2 +- .../internal/AbstractMongoDbManager.java | 2 +- .../mongodb/internal/AsyncMongoDbManager.java | 2 +- .../mongodb/internal/MongoDbErrorCode.java | 2 +- .../mongodb/internal/MongoDbManager.java | 2 +- .../mongodb/internal/MongoDbModule.java | 2 +- .../mongodb/internal/MongoDbPlugin.java | 2 +- .../mongodb/internal/SyncMongoDbManager.java | 2 +- .../mongodb/MongoDbConfig.properties | 2 +- .../internal/MongoDbErrorCode.properties | 2 +- .../org/seedstack/mongodb/MongoDbAsyncIT.java | 2 +- .../java/org/seedstack/mongodb/MongoDbIT.java | 2 +- core/src/test/resources/application.yaml | 2 +- gpg.asc | 91 +++++++++++++++++++ morphia/pom.xml | 2 +- .../morphia/BaseMorphiaRepository.java | 2 +- .../seedstack/mongodb/morphia/Morphia.java | 2 +- .../mongodb/morphia/MorphiaConfig.java | 34 +++++++ .../mongodb/morphia/MorphiaDatastore.java | 2 +- .../morphia/internal/DatastoreFactory.java | 21 +++-- .../morphia/internal/DatastoreImpl.java | 2 +- .../morphia/internal/DatastoreProvider.java | 2 +- .../internal/DefaultMorphiaRepository.java | 2 +- .../morphia/internal/MorphiaErrorCode.java | 2 +- .../morphia/internal/MorphiaModule.java | 2 +- .../morphia/internal/MorphiaPlugin.java | 25 ++++- .../morphia/internal/MorphiaPredicates.java | 2 +- .../morphia/internal/MorphiaUtils.java | 2 +- .../internal/ValidatingEntityInterceptor.java | 2 +- .../specification/MorphiaAndConverter.java | 2 +- .../MorphiaAttributeConverter.java | 2 +- .../specification/MorphiaEqualConverter.java | 2 +- .../specification/MorphiaFalseConverter.java | 2 +- .../MorphiaGreaterThanConverter.java | 2 +- .../MorphiaIdentityConverter.java | 2 +- .../MorphiaLessThanConverter.java | 2 +- .../specification/MorphiaNotConverter.java | 2 +- .../specification/MorphiaOrConverter.java | 2 +- .../MorphiaSpecificationTranslator.java | 2 +- .../specification/MorphiaStringConverter.java | 2 +- .../MorphiaStringEqualConverter.java | 2 +- .../MorphiaStringMatchingConverter.java | 2 +- .../MorphiaTranslationContext.java | 2 +- .../specification/MorphiaTrueConverter.java | 2 +- .../internal/MorphiaErrorCode.properties | 2 +- .../seedstack/mongodb/morphia/MorphiaIT.java | 2 +- .../mongodb/morphia/MorphiaRepositoryIT.java | 2 +- .../mongodb/morphia/SpecificationIT.java | 2 +- .../morphia/fixtures/dummyobject/Dummy1.java | 2 +- .../morphia/fixtures/dummyobject/Dummy2.java | 2 +- .../morphia/fixtures/dummyobject/Dummy3.java | 2 +- .../morphia/fixtures/dummyobject/Dummy4.java | 2 +- .../morphia/fixtures/dummyobject/Dummy5.java | 2 +- .../morphia/fixtures/dummyobject/Dummy6.java | 2 +- .../morphia/fixtures/product/Picture.java | 2 +- .../morphia/fixtures/product/PictureURL.java | 2 +- .../morphia/fixtures/product/Product.java | 2 +- .../morphia/fixtures/user/Address.java | 2 +- .../mongodb/morphia/fixtures/user/User.java | 2 +- morphia/src/test/resources/application.yaml | 2 +- pom.xml | 57 +++--------- 65 files changed, 252 insertions(+), 123 deletions(-) create mode 100644 gpg.asc create mode 100644 morphia/src/main/java/org/seedstack/mongodb/morphia/MorphiaConfig.java diff --git a/.travis.yml b/.travis.yml index 283d06b..f41db62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,14 @@ cache: directories: - "$HOME/.m2/repository" +before_install: + - gpg --fast-import gpg.asc + install: - - echo "bintray\${env.BINTRAY_USER}\${env.BINTRAY_KEY}" > ~/.m2/settings.xml + - echo "ossrh\${env.SONATYPE_USER}\${env.SONATYPE_PASSWORD}" > ~/.m2/settings.xml - if [[ $TRAVIS_PULL_REQUEST = false ]] && [[ $TRAVIS_BRANCH = master || $TRAVIS_BRANCH = dev-* ]] || [[ $TRAVIS_TAG = v* ]]; then GOAL=deploy; else GOAL=install; fi - - if [[ $TRAVIS_TAG = v* ]]; then ADDITIONAL_PROFILES=release; mvn -q -U org.seedstack:seedstack-maven-plugin:release; else ADDITIONAL_PROFILES=snapshots; fi + - if [[ $TRAVIS_TAG = v* ]]; then ADDITIONAL_PROFILES=release; mvn -q -U org.seedstack:seedstack-maven-plugin:release; fi -script: mvn -U -Pbuild-number,compatibility,bintray,quality,javadoc,$ADDITIONAL_PROFILES $GOAL jacoco:report +script: mvn -U -Pbuild-number,compatibility,javadoc,quality,$ADDITIONAL_PROFILES $GOAL after_success: mvn -q coveralls:report -DrepoToken=$COVERALLS_TOKEN diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a29453..a0a20c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 3.1.3 (2021-07-31) + +* [fix] Avoid calling `ensureIndexes()` and `ensureCaps()` for each datastore instantiation which adds a considerable + overhead in some circumstances. It is now done at application startup and can be controlled with + `mongoDb.morphia.ensureCapsAtStartup` and `mongoDb.morphia.ensureIndexesAtStartup` config options. + # Version 3.1.2 (2020-08-05) * [chg] Updated for seed 3.10+ @@ -8,21 +14,24 @@ # Version 3.1.0 (2020-01-31) -* [new] Morphia repository now has the ability to stream results from the database as consumed (using a cursor instead of a list behind the scenes). +* [new] Morphia repository now has the ability to stream results from the database as consumed (using a cursor instead + of a list behind the scenes). * [chg] Update the Morphia module to work with business framework 4.3.0+. -* [chg] Updated Morphia to 1.5.8 (its package has changed to `dev.morphia`, update project code accordingly if necessary). +* [chg] Updated Morphia to 1.5.8 (its package has changed to `dev.morphia`, update project code accordingly if + necessary). # Version 3.0.2 (2019-01-10) -* [fix] Fix issue #11: an exception occurred at startup because the way of accessing the ValidationFactory changed. +* [fix] Fix issue #11: an exception occurred at startup because the way of accessing the ValidationFactory changed. # Version 3.0.1 (2019-01-10) -* [fix] During translation of composite specifications (or, and), set the field for each member (avoid "No field has been set" exception). +* [fix] During translation of composite specifications (or, and), set the field for each member (avoid "No field has + been set" exception). # Version 3.0.0 (2017-11-30) -* [new] Implements automatic translation of business specifications to Morphia queries. +* [new] Implements automatic translation of business specifications to Morphia queries. # Version 2.0.0 (2017-01-13) @@ -31,7 +40,8 @@ # Version 1.1.0 (2016-04-26) * [new] Automatically build indexes -* [new] Add Bean Validation support to Morphia (at pre-persist) when SeedStack validation add-on is present in the classpath. +* [new] Add Bean Validation support to Morphia (at pre-persist) when SeedStack validation add-on is present in the + classpath. * [new] Add `exists()` and `count()` in `BaseMorphiaRepository` according to change in business framework. * [chg] Update for SeedStack 16.4. * [brk] Remove `do*()` methods in `BaseMorphiaRepository` according to change in business framework. diff --git a/checkstyle.xml b/checkstyle.xml index 1fe5bc0..1636763 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,7 +1,7 @@