├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── Jenkinsfile ├── Jenkinsfile-release ├── LICENSE ├── README.adoc ├── docs ├── _config.yml └── index.md ├── documentation └── asciidoc │ ├── stories │ ├── assembly_application_properties.adoc │ ├── assembly_getting_started.adoc │ ├── assembly_running_embedded.adoc │ ├── assembly_running_server.adoc │ ├── assembly_setting_up_project.adoc │ └── assembly_using_spring_session.adoc │ ├── titles │ ├── spring_boot_starter.asciidoc │ └── stories.adoc │ └── topics │ ├── attributes │ ├── community-attributes.adoc │ └── product-attributes.adoc │ ├── code_examples │ ├── AutowiredEmbeddedCacheManager.java │ ├── AutowiredRemoteCacheManager.java │ ├── CacheConfigurationBean.java │ ├── CacheManagerGetCache.java │ ├── CacheMetricsRegistrar.java │ ├── ConfigurationCustomizerBean.java │ ├── EnableJmxStatisticsSpringBoot.java │ ├── HotRodConfigurationBean.java │ ├── InfinispanCacheConfigurer.java │ ├── InfinispanRemoteCacheCustomizer.java │ └── InfinispanRemoteConfigurer.java │ ├── con_sb_starter.adoc │ ├── config_examples │ ├── application.properties │ ├── hotrod-client.properties │ └── jmx_statistics.xml │ ├── dependencies_maven │ ├── sb_actuator.xml │ ├── sb_bom.xml │ ├── sb_embedded.xml │ └── sb_remote.xml │ ├── proc_adding_dependencies.adoc │ ├── proc_clone_repo.adoc │ ├── proc_embedded_enabling_spring_cache.adoc │ ├── proc_enabling_spring_session.adoc │ ├── proc_enforcing_versions.adoc │ ├── proc_exposing_statistics.adoc │ ├── proc_marshalling.adoc │ ├── proc_running_embedded.adoc │ ├── proc_running_server.adoc │ ├── proc_server_enabling_spring_cache.adoc │ ├── ref_config_properties.adoc │ ├── ref_embedded_custom_beans.adoc │ └── ref_server_custom_beans.adoc ├── infinispan-spring-boot-starter-embedded ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── infinispan │ │ │ └── spring │ │ │ └── starter │ │ │ └── embedded │ │ │ ├── InfinispanCacheConfigurer.java │ │ │ ├── InfinispanConfigurationCustomizer.java │ │ │ ├── InfinispanEmbeddedAutoConfiguration.java │ │ │ ├── InfinispanEmbeddedCacheManagerAutoConfiguration.java │ │ │ ├── InfinispanEmbeddedCacheManagerChecker.java │ │ │ ├── InfinispanEmbeddedConfigurationProperties.java │ │ │ ├── InfinispanGlobalConfigurationCustomizer.java │ │ │ ├── InfinispanGlobalConfigurer.java │ │ │ └── actuator │ │ │ ├── InfinispanCacheMeterBinder.java │ │ │ └── InfinispanCacheMeterBinderProvider.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── test │ │ └── org │ │ └── infinispan │ │ └── spring │ │ └── starter │ │ └── embedded │ │ ├── InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.java │ │ ├── InfinispanEmbeddedAutoConfigurationIntegrationConfigurationTest.java │ │ ├── InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.java │ │ ├── InfinispanEmbeddedAutoConfigurationIntegrationTest.java │ │ ├── InfinispanEmbeddedAutoConfigurationPropertiesTest.java │ │ ├── InfinispanEmbeddedDisableTest.java │ │ ├── InfinispanEmbeddedEnableTest.java │ │ ├── actuator │ │ └── InfinispanCacheMetricBinderTest.java │ │ └── testconfiguration │ │ ├── GlobalConfigurerJmxDisabledConfiguration.java │ │ ├── InfinispanCacheConfigurationBaseTestConfiguration.java │ │ ├── InfinispanCacheConfigurationTestConfiguration.java │ │ └── InfinispanCacheTestConfiguration.java │ └── resources │ ├── infinispan-test-conf.xml │ └── logback.xml ├── infinispan-spring-boot-starter-remote ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── infinispan │ │ │ └── spring │ │ │ └── starter │ │ │ └── remote │ │ │ ├── InfinispanJmxConfiguration.java │ │ │ ├── InfinispanRemoteAutoConfiguration.java │ │ │ ├── InfinispanRemoteCacheCustomizer.java │ │ │ ├── InfinispanRemoteCacheManagerAutoConfiguration.java │ │ │ ├── InfinispanRemoteConfigurationProperties.java │ │ │ ├── InfinispanRemoteConfigurer.java │ │ │ └── actuator │ │ │ ├── RemoteInfinispanCacheMeterBinder.java │ │ │ └── RemoteInfinispanCacheMeterBinderProvider.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── test │ │ └── org │ │ └── infinispan │ │ └── spring │ │ └── starter │ │ └── remote │ │ ├── ApplicationPropertiesTest.java │ │ ├── CustomConfigurationTest.java │ │ ├── CustomConfigurerWithPropertyInjectionTest.java │ │ ├── CustomPropertiesTest.java │ │ ├── DisablingTest.java │ │ ├── EnablingTest.java │ │ ├── InfinispanJmxConfigurationTest.java │ │ ├── IntegrationTest.java │ │ ├── PreventingAutoCreatingBeansTest.java │ │ ├── actuator │ │ └── RemoteCacheMetricBinderTest.java │ │ ├── extension │ │ └── InfinispanServerExtension.java │ │ └── testconfiguration │ │ └── InfinispanCacheTestConfiguration.java │ └── resources │ ├── custom-test-hotrod-client.properties │ ├── logback.xml │ ├── test-application.properties │ └── test-hotrod-client.properties ├── infinispan-spring-boot-starter ├── pom.xml └── src │ └── test │ ├── java │ └── test │ │ └── infinispan │ │ └── autoconfigure │ │ ├── CacheDisabledTest.java │ │ └── CacheManagerTest.java │ └── resources │ ├── application.properties │ └── logback.xml └── pom.xml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: karesti 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for Infinispan and Spring-Boot 4 | title: '' 5 | labels: enhancement 6 | assignees: karesti 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Maven ### 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | pom.xml.next 7 | release.properties 8 | dependency-reduced-pom.xml 9 | buildNumber.properties 10 | .mvn/timing.properties 11 | 12 | 13 | ### Java ### 14 | *.class 15 | 16 | # Mobile Tools for Java (J2ME) 17 | .mtj.tmp/ 18 | 19 | # Package Files # 20 | *.jar 21 | *.war 22 | *.ear 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | ## File-based project format: 28 | *.iws 29 | *.iml 30 | 31 | ## Plugin-specific files: 32 | 33 | # IntelliJ 34 | /out/ 35 | 36 | # mpeltonen/sbt-idea plugin 37 | .idea_modules/ 38 | 39 | # JIRA plugin 40 | atlassian-ide-plugin.xml 41 | 42 | # Crashlytics plugin (for Android Studio and IntelliJ) 43 | com_crashlytics_export_strings.xml 44 | crashlytics.properties 45 | crashlytics-build.properties 46 | fabric.properties 47 | 48 | .idea/ 49 | /infinispan-spring-boot-starter-embedded/___global.state 50 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | 3 | pipeline { 4 | agent any 5 | stages { 6 | stage('SCM Checkout') { 7 | steps { 8 | checkout scm 9 | } 10 | } 11 | 12 | stage('Build') { 13 | steps { 14 | script { 15 | def mvnHome = tool 'Maven' 16 | sh "${mvnHome}/bin/mvn clean install -Pinfinispan-itests -T2.0C -Dmaven.test.failure.ignore=true" 17 | junit '**/target/*-reports/*.xml' 18 | } 19 | } 20 | } 21 | 22 | 23 | stage('Deploy SNAPSHOT') { 24 | when { 25 | branch 'master' 26 | } 27 | steps { 28 | configFileProvider([configFile(fileId: 'maven-settings-with-deploy-snapshot', variable: 'MAVEN_SETTINGS')]) { 29 | script { 30 | def mvnHome = tool 'Maven' 31 | sh "${mvnHome}/bin/mvn deploy -s $MAVEN_SETTINGS -DskipTests" 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Jenkinsfile-release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | 3 | pipeline { 4 | agent { 5 | label 'slave-group-release' 6 | } 7 | 8 | parameters { 9 | string(name: 'version', defaultValue: '0.0.0.Qualifier', description: 'Release version') 10 | string(name: 'nextVersion', defaultValue: '', description: 'Next release (blank to stay on current SNAPSHOT)') 11 | gitParameter(name: 'branch', defaultValue: 'origin/master', branchFilter: 'origin/(.*)', type: 'PT_BRANCH', description: 'Branch to release from') 12 | } 13 | 14 | options { 15 | timeout(time: 3, unit: 'HOURS') 16 | timestamps() 17 | buildDiscarder(logRotator(numToKeepStr: '100', daysToKeepStr: '61')) 18 | } 19 | 20 | stages { 21 | stage('Prepare') { 22 | steps { 23 | script { 24 | env.MAVEN_HOME = tool('Maven') 25 | env.MAVEN_OPTS = "-Xmx1g -XX:+HeapDumpOnOutOfMemoryError" 26 | env.JAVA_HOME = tool('JDK 11') 27 | } 28 | 29 | sh returnStdout: true, script: 'cleanup.sh' 30 | } 31 | } 32 | 33 | stage('Checkout') { 34 | steps { 35 | checkout scm 36 | } 37 | } 38 | 39 | stage('Commit version for documentation') { 40 | steps { 41 | script { 42 | sh "sed -i \"s/^:sb_starter:.*\$/:sb_starter: ${version}/\" documentation/asciidoc/topics/attributes/community-attributes.adoc" 43 | sh "git add 'documentation/asciidoc/topics/attributes/community-attributes.adoc'" 44 | sh "git diff-index --quiet HEAD || git commit -m 'Committing ${version} to doc attribute file'" 45 | } 46 | } 47 | } 48 | 49 | stage('Version') { 50 | steps { 51 | sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${version} -DprocessAllModules=true" 52 | sh "$MAVEN_HOME/bin/mvn -B -V versions:set-property -Dproperty=version.infinispan -DnewVersion=${version}" 53 | } 54 | } 55 | 56 | stage('Create Staging repository') { 57 | steps { 58 | // Create a staging repository on Nexus 59 | script { 60 | STAGING_REPO_ID = sh(returnStdout: true, script: "$MAVEN_HOME/bin/mvn -B -V org.sonatype.plugins:nexus-staging-maven-plugin:rc-open -pl .|grep 'Opened '|grep -oE '[^ ]+\$'").trim() 61 | } 62 | echo "Staging repository: $STAGING_REPO_ID" 63 | } 64 | } 65 | 66 | stage('Deploy') { 67 | steps { 68 | sh "$MAVEN_HOME/bin/mvn -B -V -Pdistribution -DskipTests clean deploy -DstagingRepositoryId=$STAGING_REPO_ID" 69 | } 70 | } 71 | 72 | stage('Close Staging repository') { 73 | steps { 74 | // This ensures that Nexus validates the repository for correctness 75 | sh "$MAVEN_HOME/bin/mvn -B -V org.sonatype.plugins:nexus-staging-maven-plugin:rc-close -pl . -DstagingRepositoryId=$STAGING_REPO_ID" 76 | } 77 | } 78 | 79 | stage('Tag') { 80 | steps { 81 | // Commit and tag once everything is good 82 | sh "$MAVEN_HOME/bin/mvn -B -V scm:checkin -Dmessage=\"Releasing version ${version}\" -DpushChanges=false" 83 | sh "$MAVEN_HOME/bin/mvn -B -V scm:tag -Dtag=${version}" 84 | } 85 | } 86 | 87 | stage('Next version') { 88 | when { 89 | expression { params.nextVersion != '' } 90 | } 91 | steps { 92 | sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${nextVersion} -DprocessAllModules=true" 93 | sh "$MAVEN_HOME/bin/mvn -B -V versions:set-property -Dproperty=version.infinispan -DnewVersion=${nextVersion}" 94 | sh "$MAVEN_HOME/bin/mvn -B -V -Dmessage='next version ${nextVersion}' -DscmVersion=${branch} -DscmVersionType=branch scm:checkin" 95 | } 96 | } 97 | } 98 | 99 | post { 100 | always { 101 | // Clean 102 | sh 'git clean -fdx -e "*.hprof" || echo "git clean failed, exit code $?"' 103 | } 104 | failure { 105 | echo "post build status: failure" 106 | emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}' 107 | } 108 | 109 | success { 110 | echo "post build status: success" 111 | emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}' 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | ### This repository will be kept opened for Infinispan 11 corrections until Infinispan 12 is released. 2 | 3 | From Infinispan 12, the Infinispan Spring-Boot starter is shipped with https://github.com/infinispan/infinispan/tree/master/spring/spring-boot[Infinispan] 4 | 5 | # Infinispan Spring Boot Starter 6 | 7 | link:https://infinispan.org/infinispan-spring-boot/master/spring_boot_starter.html[Infinispan Spring Boot Starter Documentation] is available on our site. 8 | 9 | Alternatively, you can build the docs locally with Asciidoctor: 10 | 11 | ---- 12 | $ asciidoctor documentation/asciidoc/titles/spring_boot_starter.asciidoc 13 | ---- 14 | 15 | Code Examples and Tutorials:: 16 | + 17 | * link:https://github.com/infinispan/infinispan-simple-tutorials/tree/master/spring-integration/spring-boot[Infinispan Spring Boot Tutorial] 18 | * link:https://github.com/infinispan-demos/infinispan-near-cache[infinispan-near-cache] showcases Infinispan near caching with Spring Boot. 19 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | Infinispan Spring Boot 2 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_application_properties.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_properties'] 2 | :context: starter_properties 3 | = Application Properties 4 | 5 | include::{topics}/ref_config_properties.adoc[leveloffset=+1] 6 | 7 | // Restore the parent context. 8 | ifdef::parent-context[:context: {parent-context}] 9 | ifndef::parent-context[:!context:] 10 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_getting_started.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_intro'] 2 | :context: starter_intro 3 | 4 | include::{topics}/con_sb_starter.adoc[leveloffset=+1] 5 | //Community Only 6 | ifndef::productized[] 7 | include::{topics}/proc_clone_repo.adoc[leveloffset=+1] 8 | endif::productized[] 9 | 10 | // Restore the parent context. 11 | ifdef::parent-context[:context: {parent-context}] 12 | ifndef::parent-context[:!context:] 13 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_running_embedded.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_embedded'] 2 | :context: starter_embedded 3 | = Running in Embedded Mode 4 | 5 | Embed the {brandname} library in your project for in-memory data storage. 6 | 7 | include::{topics}/proc_running_embedded.adoc[leveloffset=+1] 8 | include::{topics}/ref_embedded_custom_beans.adoc[leveloffset=+1] 9 | include::{topics}/proc_embedded_enabling_spring_cache.adoc[leveloffset=+1] 10 | 11 | // Restore the parent context. 12 | ifdef::parent-context[:context: {parent-context}] 13 | ifndef::parent-context[:!context:] 14 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_running_server.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_server'] 2 | :context: starter_server 3 | = Running in Server Mode 4 | 5 | Store and retrieve data from remote {brandname} clusters using Hot Rod, a 6 | custom TCP binary wire protocol. 7 | 8 | include::{topics}/proc_running_server.adoc[leveloffset=+1] 9 | include::{topics}/proc_marshalling.adoc[leveloffset=+1] 10 | include::{topics}/ref_server_custom_beans.adoc[leveloffset=+1] 11 | include::{topics}/proc_server_enabling_spring_cache.adoc[leveloffset=+1] 12 | include::{topics}/proc_exposing_statistics.adoc[leveloffset=+1] 13 | 14 | // Restore the parent context. 15 | ifdef::parent-context[:context: {parent-context}] 16 | ifndef::parent-context[:!context:] 17 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_setting_up_project.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_project'] 2 | :context: starter_project 3 | = Setting Up Your Project 4 | 5 | Add dependencies for the {brandname} Spring Boot Starter to your project. 6 | 7 | include::{topics}/proc_enforcing_versions.adoc[leveloffset=+1] 8 | include::{topics}/proc_adding_dependencies.adoc[leveloffset=+1] 9 | 10 | // Restore the parent context. 11 | ifdef::parent-context[:context: {parent-context}] 12 | ifndef::parent-context[:!context:] 13 | -------------------------------------------------------------------------------- /documentation/asciidoc/stories/assembly_using_spring_session.adoc: -------------------------------------------------------------------------------- 1 | [id='sb_starter_session'] 2 | :context: spring_session 3 | = Using Spring Session 4 | 5 | include::{topics}/proc_enabling_spring_session.adoc[leveloffset=+1] 6 | 7 | // Restore the parent context. 8 | ifdef::parent-context[:context: {parent-context}] 9 | ifndef::parent-context[:!context:] 10 | -------------------------------------------------------------------------------- /documentation/asciidoc/titles/spring_boot_starter.asciidoc: -------------------------------------------------------------------------------- 1 | //Title attributes 2 | :toc2: 3 | :icons: font 4 | :toclevels: 3 5 | :numbered: 6 | 7 | //Avoid symlinks in community docs 8 | :topics: ../topics 9 | :stories: ../stories 10 | 11 | //Include community attributes 12 | include::{topics}/attributes/community-attributes.adoc[] 13 | 14 | [id='sb_starter'] 15 | = {brandname} Spring Boot Starter 16 | 17 | include::stories.adoc[] 18 | -------------------------------------------------------------------------------- /documentation/asciidoc/titles/stories.adoc: -------------------------------------------------------------------------------- 1 | include::{stories}/assembly_getting_started.adoc[leveloffset=+1] 2 | include::{stories}/assembly_setting_up_project.adoc[leveloffset=+1] 3 | include::{stories}/assembly_running_embedded.adoc[leveloffset=+1] 4 | include::{stories}/assembly_running_server.adoc[leveloffset=+1] 5 | include::{stories}/assembly_using_spring_session.adoc[leveloffset=+1] 6 | include::{stories}/assembly_application_properties.adoc[leveloffset=+1] 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/attributes/community-attributes.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // This file contains attributes for building community documentation. 3 | // 4 | 5 | // 6 | // Spring Boot attributes 7 | // 8 | :sb_repo: git@github.com:infinispan/infinispan-spring-boot.git 9 | :sb_version: ${version.infinispan.starter} 10 | 11 | :brandname: Infinispan 12 | 13 | :javadocroot: https://docs.jboss.org/infinispan/11.0/apidocs 14 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/attributes/product-attributes.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Attributes for building Red Hat Data Grid documentation. 3 | // 4 | 5 | // 6 | // Conditional statements 7 | // 8 | :productized: 9 | 10 | :brandname: Data Grid 11 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/AutowiredEmbeddedCacheManager.java: -------------------------------------------------------------------------------- 1 | private final EmbeddedCacheManager cacheManager; 2 | 3 | @Autowired 4 | public YourClassName(EmbeddedCacheManager cacheManager) { 5 | this.cacheManager = cacheManager; 6 | } 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/AutowiredRemoteCacheManager.java: -------------------------------------------------------------------------------- 1 | private final RemoteCacheManager cacheManager; 2 | 3 | @Autowired 4 | public YourClassName(RemoteCacheManager cacheManager) { 5 | this.cacheManager = cacheManager; 6 | } 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/CacheConfigurationBean.java: -------------------------------------------------------------------------------- 1 | @Bean(name = "small-cache") 2 | public org.infinispan.configuration.cache.Configuration smallCache() { 3 | return new ConfigurationBuilder() 4 | .read(baseCache) 5 | .memory().size(1000L) 6 | .memory().evictionType(EvictionType.COUNT) 7 | .build(); 8 | } 9 | 10 | @Bean(name = "large-cache") 11 | public org.infinispan.configuration.cache.Configuration largeCache() { 12 | return new ConfigurationBuilder() 13 | .read(baseCache) 14 | .memory().size(2000L) 15 | .build(); 16 | } 17 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/CacheManagerGetCache.java: -------------------------------------------------------------------------------- 1 | cacheManager.getCache("testCache").put("testKey", "testValue"); 2 | System.out.println("Received value from cache: " + cacheManager.getCache("testCache").get("testKey")); 3 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/CacheMetricsRegistrar.java: -------------------------------------------------------------------------------- 1 | @Autowire 2 | CacheMetricsRegistrar cacheMetricsRegistrar; 3 | 4 | @Autowire 5 | CacheManager cacheManager; 6 | ... 7 | 8 | cacheMetricsRegistrar.bindCacheToRegistry(cacheManager.getCache("my-cache")); 9 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/ConfigurationCustomizerBean.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public InfinispanGlobalConfigurationCustomizer globalCustomizer() { 3 | return builder -> builder.transport().clusterName(CLUSTER_NAME); 4 | } 5 | 6 | @Bean 7 | public InfinispanConfigurationCustomizer configurationCustomizer() { 8 | return builder -> builder.memory().evictionType(EvictionType.COUNT); 9 | } 10 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/EnableJmxStatisticsSpringBoot.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public InfinispanCacheConfigurer cacheConfigurer() { 3 | return cacheManager -> { 4 | final org.infinispan.configuration.cache.Configuration config = 5 | new ConfigurationBuilder() 6 | .jmxStatistics().enable() 7 | .build(); 8 | 9 | cacheManager.defineConfiguration("my-cache", config); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/HotRodConfigurationBean.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public org.infinispan.client.hotrod.configuration.Configuration customConfiguration() { 3 | new ConfigurationBuilder() 4 | .addServer() 5 | .host("127.0.0.1") 6 | .port(12345) 7 | .build(); 8 | } 9 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/InfinispanCacheConfigurer.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public InfinispanCacheConfigurer cacheConfigurer() { 3 | return manager -> { 4 | final Configuration ispnConfig = new ConfigurationBuilder() 5 | .clustering() 6 | .cacheMode(CacheMode.LOCAL) 7 | .build(); 8 | 9 | manager.defineConfiguration("local-sync-config", ispnConfig); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/InfinispanRemoteCacheCustomizer.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public InfinispanRemoteCacheCustomizer customizer() { 3 | return b -> b.tcpKeepAlive(false); 4 | } 5 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/code_examples/InfinispanRemoteConfigurer.java: -------------------------------------------------------------------------------- 1 | @Bean 2 | public InfinispanRemoteConfigurer infinispanRemoteConfigurer() { 3 | return () -> new ConfigurationBuilder() 4 | .addServer() 5 | .host("127.0.0.1") 6 | .port(12345) 7 | .build(); 8 | } 9 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/con_sb_starter.adoc: -------------------------------------------------------------------------------- 1 | The {brandname} starter provides a set of managed transitive dependencies that include everything your Spring Boot project needs to seamlessly interact with {brandname}. 2 | 3 | [TIP] 4 | ==== 5 | The {brandname} Spring Boot starter gives you a convenient way to get started with Spring Boot but is optional. To use {brandname} with Spring Boot you can simply add the dependencies you want. 6 | ==== 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/config_examples/application.properties: -------------------------------------------------------------------------------- 1 | # List Infinispan or Data Grid servers by IP address or hostname at port 11222. 2 | infinispan.remote.server-list=127.0.0.1:11222 3 | 4 | # 5 | # Embedded Properties - Uncomment properties to use them. 6 | # 7 | 8 | # Enables embedded capabilities in your application. 9 | # Values are true (default) or false. 10 | #infinispan.embedded.enabled = 11 | 12 | # Sets the Spring state machine ID. 13 | #infinispan.embedded.machineId = 14 | 15 | # Sets the name of the embedded cluster. 16 | #infinispan.embedded.clusterName = 17 | 18 | # Specifies a XML configuration file that takes priority over the global 19 | # configuration bean or any configuration customizer. 20 | #infinispan.embedded.configXml = 21 | 22 | # 23 | # Server Properties - Uncomment properties to use them. 24 | # 25 | 26 | # Specifies a custom filename for Hot Rod client properties. 27 | #infinispan.remote.clientProperties = 28 | 29 | # Enables remote server connections. 30 | # Values are true (default) or false. 31 | #infinispan.remote.enabled = 32 | 33 | # Defines a comma-separated list of servers in this format: 34 | # `host1[:port],host2[:port]`. 35 | #infinispan.remote.serverList = 36 | 37 | # Sets a timeout value, in milliseconds, for socket connections. 38 | #infinispan.remote.socketTimeout = 39 | 40 | # Sets a timeout value for initializing connections with servers. 41 | #infinispan.remote.connectTimeout = 42 | 43 | # Sets the maximum number of attempts to connect to servers. 44 | #infinispan.remote.maxRetries = 45 | 46 | # Specifies the marshaller to use. 47 | #infinispan.remote.marshaller = 48 | 49 | # Adds your classes to the serialization whitelist. 50 | #infinispan.remote.java-serial-whitelist= 51 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/config_examples/hotrod-client.properties: -------------------------------------------------------------------------------- 1 | # List Infinispan or Data Grid servers by IP address or hostname at port 11222. 2 | infinispan.client.hotrod.server_list=127.0.0.1:6667 3 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/config_examples/jmx_statistics.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/dependencies_maven/sb_actuator.xml: -------------------------------------------------------------------------------- 1 | 2 | org.springframework.boot 3 | spring-boot-starter-actuator 4 | ${version.spring.boot} 5 | 6 | 7 | 8 | org.springframework.boot 9 | spring-boot-starter-web 10 | ${version.spring.boot} 11 | 12 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/dependencies_maven/sb_bom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.infinispan 5 | infinispan-bom 6 | ${version.infinispan} 7 | pom 8 | import 9 | 10 | 11 | org.springframework.boot 12 | spring-boot-starter-parent 13 | ${version.spring.boot} 14 | pom 15 | import 16 | 17 | 18 | org.infinispan 19 | infinispan-spring-boot-starter 20 | {sb_version} 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/dependencies_maven/sb_embedded.xml: -------------------------------------------------------------------------------- 1 | 2 | org.infinispan 3 | infinispan-spring-boot-starter-embedded 4 | {sb_version} 5 | 6 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/dependencies_maven/sb_remote.xml: -------------------------------------------------------------------------------- 1 | 2 | org.infinispan 3 | infinispan-spring-boot-starter-remote 4 | {sb_version} 5 | 6 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_adding_dependencies.adoc: -------------------------------------------------------------------------------- 1 | = Adding Dependencies for Usage Modes 2 | 3 | {brandname} provides different dependencies for each usage mode. Add one of the following to your `pom.xml` file: 4 | 5 | .Embedded Mode 6 | [source,xml,options="nowrap",subs=attributes+] 7 | ---- 8 | include::dependencies_maven/sb_embedded.xml[] 9 | ---- 10 | 11 | .Remote Client/Server Mode 12 | [source,xml,options="nowrap",subs=attributes+] 13 | ---- 14 | include::dependencies_maven/sb_remote.xml[] 15 | ---- 16 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_clone_repo.adoc: -------------------------------------------------------------------------------- 1 | Getting the Code:: 2 | + 3 | [source,options="nowrap",subs=attributes+] 4 | ---- 5 | $ git clone {sb_repo} 6 | ---- 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_embedded_enabling_spring_cache.adoc: -------------------------------------------------------------------------------- 1 | = Enabling Spring Cache Support 2 | 3 | Add the `@EnableCaching` annotation to your application to enable Spring Cache support. 4 | 5 | When this starter detects the `EmbeddedCacheManager` bean, it instantiates a new `SpringEmbeddedCacheManager`, which provides an implementation of 6 | https://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html[Spring Cache]. 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_enabling_spring_session.adoc: -------------------------------------------------------------------------------- 1 | = Enabling Spring Session Support 2 | 3 | {brandname} Spring Session support is built on 4 | `SpringRemoteCacheManager` and `SpringEmbeddedCacheManager`. This starter produces those beans by default. 5 | 6 | To use Spring Session in your project, do the following: 7 | 8 | . Add this starter to your project. 9 | . Add Spring Session to the classpath. 10 | . Add the following annotations to your configuration: 11 | - `@EnableCaching` 12 | - `@EnableInfinispanRemoteHttpSession` 13 | - `@EnableInfinispanEmbeddedHttpSession` 14 | 15 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_enforcing_versions.adoc: -------------------------------------------------------------------------------- 1 | = Enforcing {brandname} Versions 2 | 3 | This starter uses a high-level API to ensure compatibility between major versions of {brandname}. However you can enforce a specific version of {brandname} with the `infinispan-bom` module. 4 | 5 | Add `infinispan-bom` to your `pom.xml` file before the starter dependencies, as follows: 6 | 7 | [source,xml,options="nowrap",subs=attributes+] 8 | ---- 9 | include::dependencies_maven/sb_bom.xml[] 10 | ---- 11 | 12 | [IMPORTANT] 13 | ==== 14 | The {brandname} Spring Boot starter uses different Spring Boot versions to other projects such as Red Hat OpenShift Application Runtimes. If you want to use a specific Spring Boot version for compatibility with other projects, you must add the correct dependency to your project. 15 | ==== 16 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_exposing_statistics.adoc: -------------------------------------------------------------------------------- 1 | = Exposing {brandname} Statistics 2 | 3 | {brandname} supports the Spring Boot Actuator to expose cache statistics as metrics. 4 | 5 | To use the Actuator, add the following to your `pom.xml` file: 6 | 7 | [source,xml,options="nowrap",subs=attributes+] 8 | ---- 9 | include::dependencies_maven/sb_actuator.xml[] 10 | ---- 11 | 12 | You must then activate statistics for the appropriate cache instances, either programmatically or declaratively. 13 | 14 | .Programmatically 15 | [source,java,options="nowrap"] 16 | ---- 17 | include::code_examples/EnableJmxStatisticsSpringBoot.java[] 18 | ---- 19 | 20 | .Declaratively 21 | [source,xml,options="nowrap",subs=attributes+] 22 | ---- 23 | include::config_examples/jmx_statistics.xml[] 24 | ---- 25 | 26 | The Spring Boot Actuator registry binds cache instances when your application starts. If you create caches dynamically, you should use the `CacheMetricsRegistrar` bean to bind caches to the Actuator registry, as follows: 27 | 28 | [source,java,options="nowrap"] 29 | ---- 30 | include::code_examples/CacheMetricsRegistrar.java[] 31 | ---- 32 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_marshalling.adoc: -------------------------------------------------------------------------------- 1 | = Configuring Marshalling 2 | Configure {brandname} servers to use Java serialization to marshall objects. 3 | 4 | By default {brandname} server uses a ProtoStream serialization library as the 5 | default marshaller. However, the ProtoStream marshaller is not supported for 6 | Spring integration. For this reason you should use the Java Serialization Marshaller. 7 | 8 | * Specify the following properties in your `application.properties`: 9 | + 10 | ---- 11 | infinispan.remote.marshaller=org.infinispan.commons.marshall.JavaSerializationMarshaller <1> 12 | infinispan.remote.java-serial-whitelist=your_marshalled_beans_package.* <2> 13 | ---- 14 | 15 | <1> Use the Java Serialization Marshaller. 16 | <2> Adds your classes to the serialization whitelist so {brandname} marshalls your objects. You can specify a comma-separated list of fully qualified class names or a regular expression to match classes. 17 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_running_embedded.adoc: -------------------------------------------------------------------------------- 1 | = Adding the EmbeddedCacheManager Bean 2 | 3 | . Add `infinispan-spring-boot-starter-embedded` to your project's classpath to enable Embedded mode. 4 | + 5 | This starter operates in Remote Client/Server mode with `infinispan-spring-boot-starter-remote` on the classpath by default. 6 | + 7 | . Use the Spring `@Autowired` annotation to include an `EmbeddedCacheManager` bean in your Java configuration classes, as in the following example: 8 | + 9 | [source,java,options="nowrap"] 10 | ---- 11 | include::code_examples/AutowiredEmbeddedCacheManager.java[] 12 | ---- 13 | + 14 | You are now ready to use {brandname} in Embedded Mode. Here is a simple example: 15 | + 16 | [source,java,options="nowrap"] 17 | ---- 18 | include::code_examples/CacheManagerGetCache.java[] 19 | ---- 20 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_running_server.adoc: -------------------------------------------------------------------------------- 1 | = Setting Up the RemoteCacheManager 2 | 3 | . Provide the location for the {brandname} server so the starter can create the `RemoteCacheManager` bean. 4 | + 5 | The starter first tries to find the server location in 6 | `hotrod-client.properties` and then from `application.properties`. 7 | + 8 | . Use the Spring `@Autowired` annotation to include your own custom cache manager class in your application: 9 | + 10 | [source,java,options="nowrap"] 11 | ---- 12 | include::code_examples/AutowiredRemoteCacheManager.java[] 13 | ---- 14 | 15 | .Hot Rod client properties 16 | 17 | Specify client configuration in `hotrod-client.properties` on your classpath, 18 | for example: 19 | 20 | [source,text,options=nowrap] 21 | ---- 22 | include::config_examples/hotrod-client.properties[] 23 | ---- 24 | 25 | For more information, see link:{javadocroot}/org/infinispan/client/hotrod/configuration/package-summary.html[org.infinispan.client.hotrod.configuration]. 26 | 27 | .Application properties 28 | 29 | Configure your project with `application.properties`. See link:#sb_starter_properties[Application Properties] for more information. 30 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/proc_server_enabling_spring_cache.adoc: -------------------------------------------------------------------------------- 1 | = Enabling Spring Cache Support 2 | 3 | Add the `@EnableCaching` annotation to your application to enable Spring Cache support. 4 | 5 | When the {brandname} starter detects the `RemoteCacheManager` bean, it instantiates a new `SpringRemoteCacheManager`, which provides an implementation of 6 | https://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html[Spring Cache]. 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/ref_config_properties.adoc: -------------------------------------------------------------------------------- 1 | Configure your project with `application.properties` or `application.yaml`. 2 | 3 | [source,text,options="nowrap"] 4 | ---- 5 | include::config_examples/application.properties[] 6 | ---- 7 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/ref_embedded_custom_beans.adoc: -------------------------------------------------------------------------------- 1 | = Cache Manager Configuration Beans 2 | 3 | You can customize the cache manager with the following configuration beans: 4 | 5 | * `InfinispanGlobalConfigurer` 6 | * `InfinispanCacheConfigurer` 7 | * `Configuration` 8 | * `InfinispanConfigurationCustomizer` 9 | * `InfinispanGlobalConfigurationCustomizer` 10 | + 11 | [NOTE] 12 | ==== 13 | You can create one `InfinispanGlobalConfigurer` bean only. However you can create multiple configurations with the other beans. 14 | ==== 15 | 16 | .InfinispanCacheConfigurer Bean 17 | [source,java,options="nowrap"] 18 | ---- 19 | include::code_examples/InfinispanCacheConfigurer.java[] 20 | ---- 21 | 22 | .Configuration Bean 23 | Link the bean name to the cache that it configures, as follows: 24 | [source,java,options="nowrap"] 25 | ---- 26 | include::code_examples/CacheConfigurationBean.java[] 27 | ---- 28 | 29 | .Customizer Beans 30 | [source,java,options="nowrap"] 31 | ---- 32 | include::code_examples/ConfigurationCustomizerBean.java[] 33 | ---- 34 | -------------------------------------------------------------------------------- /documentation/asciidoc/topics/ref_server_custom_beans.adoc: -------------------------------------------------------------------------------- 1 | = Cache Manager Configuration Beans 2 | 3 | Customize the cache manager with the following configuration beans: 4 | 5 | * `InfinispanRemoteConfigurer` 6 | * `Configuration` 7 | * `InfinispanRemoteCacheCustomizer` 8 | + 9 | [NOTE] 10 | ==== 11 | You can create one `InfinispanRemoteConfigurer` bean only. However you can create multiple configurations with the other beans. 12 | ==== 13 | 14 | .InfinispanRemoteConfigurer Bean 15 | [source,java,options="nowrap"] 16 | ---- 17 | include::code_examples/InfinispanRemoteConfigurer.java[] 18 | ---- 19 | 20 | .Configuration Bean 21 | [source,java,options="nowrap"] 22 | ---- 23 | include::code_examples/HotRodConfigurationBean.java[] 24 | ---- 25 | 26 | .InfinispanRemoteCacheCustomizer Bean 27 | [source,java,options="nowrap"] 28 | ---- 29 | include::code_examples/InfinispanRemoteCacheCustomizer.java[] 30 | ---- 31 | 32 | [TIP] 33 | ==== 34 | Use the `@Ordered` annotation to apply customizers in a specific order. 35 | ==== 36 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | infinispan-spring-boot-starter-parent 5 | org.infinispan 6 | 2.3.7-SNAPSHOT 7 | 8 | 4.0.0 9 | Infinispan Spring Boot Starter Embedded 10 | infinispan-spring-boot-starter-embedded 11 | 12 | 13 | 14 | org.infinispan 15 | infinispan-core 16 | 17 | 18 | 19 | javax.cache 20 | cache-api 21 | 22 | 23 | 24 | org.infinispan 25 | infinispan-spring5-embedded 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-actuator 36 | true 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-configuration-processor 42 | true 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-autoconfigure-processor 48 | true 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | 58 | org.assertj 59 | assertj-core 60 | test 61 | 62 | 63 | 64 | io.micrometer 65 | micrometer-test 66 | test 67 | 68 | 69 | 70 | org.junit.jupiter 71 | junit-jupiter-api 72 | test 73 | 74 | 75 | 76 | org.junit.jupiter 77 | junit-jupiter-engine 78 | test 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanCacheConfigurer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.manager.EmbeddedCacheManager; 4 | 5 | @FunctionalInterface 6 | public interface InfinispanCacheConfigurer { 7 | /** 8 | * Configure an Infinispan cache. 9 | * 10 | * @param manager The {@link EmbeddedCacheManager}. 11 | */ 12 | void configureCache(final EmbeddedCacheManager manager); 13 | } 14 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanConfigurationCustomizer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.configuration.cache.ConfigurationBuilder; 4 | 5 | @Deprecated 6 | // Will be removed in future releases 7 | @FunctionalInterface 8 | public interface InfinispanConfigurationCustomizer { 9 | void customize(ConfigurationBuilder builder); 10 | } 11 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.commons.api.CacheContainerAdmin; 4 | import org.infinispan.commons.marshall.JavaSerializationMarshaller; 5 | import org.infinispan.configuration.cache.ConfigurationBuilder; 6 | import org.infinispan.configuration.global.GlobalConfigurationBuilder; 7 | import org.infinispan.manager.DefaultCacheManager; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.beans.factory.annotation.Qualifier; 10 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 11 | import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 15 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 16 | import org.springframework.context.annotation.Bean; 17 | import org.springframework.context.annotation.ComponentScan; 18 | import org.springframework.context.annotation.Conditional; 19 | import org.springframework.context.annotation.Configuration; 20 | 21 | import java.io.IOException; 22 | import java.util.Collections; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | @Configuration 27 | @ComponentScan 28 | @AutoConfigureBefore(CacheAutoConfiguration.class) 29 | //Since a jar with configuration might be missing (which would result in TypeNotPresentExceptionProxy), we need to 30 | //use String based methods. 31 | //See https://github.com/spring-projects/spring-boot/issues/1733 32 | @ConditionalOnClass(name = "org.infinispan.manager.EmbeddedCacheManager") 33 | @ConditionalOnProperty(value = "infinispan.embedded.enabled", havingValue = "true", matchIfMissing = true) 34 | @EnableConfigurationProperties(InfinispanEmbeddedConfigurationProperties.class) 35 | public class InfinispanEmbeddedAutoConfiguration { 36 | 37 | public static final String DEFAULT_CACHE_MANAGER_QUALIFIER = "defaultCacheManager"; 38 | 39 | @Autowired 40 | private InfinispanEmbeddedConfigurationProperties infinispanProperties; 41 | 42 | @Autowired(required = false) 43 | private List configurers = Collections.emptyList(); 44 | 45 | @Autowired(required = false) 46 | private List configurationCustomizers = Collections.emptyList(); 47 | 48 | @Autowired(required = false) 49 | private Map cacheConfigurations = Collections.emptyMap(); 50 | 51 | @Autowired(required = false) 52 | private InfinispanGlobalConfigurer infinispanGlobalConfigurer; 53 | 54 | @Autowired(required = false) 55 | private List globalConfigurationCustomizers = Collections.emptyList(); 56 | 57 | @Bean(destroyMethod = "stop") 58 | @Conditional(InfinispanEmbeddedCacheManagerChecker.class) 59 | @ConditionalOnMissingBean 60 | @Qualifier(DEFAULT_CACHE_MANAGER_QUALIFIER) 61 | public DefaultCacheManager defaultCacheManager() throws IOException { 62 | final String configXml = infinispanProperties.getConfigXml(); 63 | final DefaultCacheManager manager; 64 | GlobalConfigurationBuilder globalConfigurationBuilder = new GlobalConfigurationBuilder(); 65 | // spring session needs does not work with protostream right now, easy users to configure the marshaller 66 | // and the classes we need for spring embedded 67 | globalConfigurationBuilder.serialization().marshaller(new JavaSerializationMarshaller()); 68 | globalConfigurationBuilder.serialization().whiteList().addClass("org.springframework.session.MapSession"); 69 | globalConfigurationBuilder.serialization().whiteList().addRegexp("java.util.*"); 70 | 71 | ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); 72 | if (!configXml.isEmpty()) { 73 | manager = new DefaultCacheManager(configXml, false); 74 | } else { 75 | if (infinispanGlobalConfigurer != null) { 76 | globalConfigurationBuilder.read(infinispanGlobalConfigurer.getGlobalConfiguration()); 77 | } else { 78 | globalConfigurationBuilder.transport().clusterName(infinispanProperties.getClusterName()); 79 | globalConfigurationBuilder.jmx().enable(); 80 | } 81 | globalConfigurationCustomizers.forEach(customizer -> customizer.customize(globalConfigurationBuilder)); 82 | configurationCustomizers.forEach(customizer -> customizer.customize(configurationBuilder)); 83 | 84 | manager = new DefaultCacheManager(globalConfigurationBuilder.build(), false); 85 | } 86 | 87 | cacheConfigurations.forEach(manager::defineConfiguration); 88 | configurers.forEach(configurer -> configurer.configureCache(manager)); 89 | 90 | manager.start(); 91 | if (configXml.isEmpty()) { 92 | manager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE) 93 | .getOrCreateCache("default", configurationBuilder.build()); 94 | } 95 | return manager; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanEmbeddedCacheManagerAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.manager.EmbeddedCacheManager; 4 | import org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.ComponentScan; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | @Configuration 14 | @ComponentScan 15 | //Since a jar with configuration might be missing (which would result in TypeNotPresentExceptionProxy), we need to 16 | //use String based methods. 17 | //See https://github.com/spring-projects/spring-boot/issues/1733 18 | @ConditionalOnClass(name = "org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager") 19 | @ConditionalOnProperty(value = "infinispan.embedded.cache.enabled", havingValue = "true", matchIfMissing = true) 20 | public class InfinispanEmbeddedCacheManagerAutoConfiguration { 21 | 22 | @Bean 23 | @ConditionalOnMissingBean(type = {"org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager", "org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManagerFactoryBean"}) 24 | @ConditionalOnBean(type = "org.infinispan.manager.EmbeddedCacheManager") 25 | public SpringEmbeddedCacheManager springEmbeddedCacheManager(EmbeddedCacheManager embeddedCacheManager) { 26 | return new SpringEmbeddedCacheManager(embeddedCacheManager); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanEmbeddedCacheManagerChecker.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.springframework.boot.autoconfigure.cache.CacheType; 4 | import org.springframework.context.annotation.Condition; 5 | import org.springframework.context.annotation.ConditionContext; 6 | import org.springframework.core.type.AnnotatedTypeMetadata; 7 | 8 | public class InfinispanEmbeddedCacheManagerChecker implements Condition { 9 | @Override 10 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 11 | String cacheType = context.getEnvironment().getProperty("spring.cache.type"); 12 | 13 | return cacheType == null || CacheType.INFINISPAN.name().equalsIgnoreCase(cacheType); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanEmbeddedConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | @ConfigurationProperties("infinispan.embedded") 6 | public class InfinispanEmbeddedConfigurationProperties { 7 | public static final String DEFAULT_CLUSTER_NAME = "default-autoconfigure"; 8 | 9 | /** 10 | * Enable embedded cache. 11 | */ 12 | private boolean enabled = true; 13 | 14 | /** 15 | * The configuration file to use as a template for all caches created. 16 | */ 17 | private String configXml = ""; 18 | 19 | private String machineId = ""; 20 | 21 | /** 22 | * The name of the cluster. 23 | */ 24 | private String clusterName = DEFAULT_CLUSTER_NAME; 25 | 26 | public String getConfigXml() { 27 | return configXml; 28 | } 29 | 30 | public void setConfigXml(String configXml) { 31 | this.configXml = configXml; 32 | } 33 | 34 | public String getMachineId() { 35 | return machineId; 36 | } 37 | 38 | public void setMachineId(String machineId) { 39 | this.machineId = machineId; 40 | } 41 | 42 | public String getClusterName() { 43 | return clusterName; 44 | } 45 | 46 | public void setClusterName(String clusterName) { 47 | this.clusterName = clusterName; 48 | } 49 | 50 | public boolean isEnabled() { 51 | return enabled; 52 | } 53 | 54 | public void setEnabled(boolean enabled) { 55 | this.enabled = enabled; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanGlobalConfigurationCustomizer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.configuration.global.GlobalConfigurationBuilder; 4 | 5 | @FunctionalInterface 6 | public interface InfinispanGlobalConfigurationCustomizer { 7 | void customize(GlobalConfigurationBuilder builder); 8 | } 9 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/InfinispanGlobalConfigurer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.configuration.global.GlobalConfiguration; 4 | 5 | @FunctionalInterface 6 | public interface InfinispanGlobalConfigurer { 7 | GlobalConfiguration getGlobalConfiguration(); 8 | } 9 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/actuator/InfinispanCacheMeterBinder.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded.actuator; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import org.infinispan.Cache; 6 | 7 | import io.micrometer.core.instrument.Gauge; 8 | import io.micrometer.core.instrument.MeterRegistry; 9 | import io.micrometer.core.instrument.Tag; 10 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinder; 11 | 12 | /** 13 | * Implements {@link CacheMeterBinder} to expose Infinispan embedded metrics 14 | * 15 | * @author Katia Aresti, karesti@redhat.com 16 | * @since 2.1 17 | */ 18 | public class InfinispanCacheMeterBinder extends CacheMeterBinder { 19 | 20 | private final Cache cache; 21 | 22 | public InfinispanCacheMeterBinder(Cache cache, Iterable tags) { 23 | super(cache, cache.getName(), tags); 24 | this.cache = cache; 25 | } 26 | 27 | @Override 28 | protected Long size() { 29 | if (cache == null) return 0L; 30 | 31 | return cache.getAdvancedCache().getStats().getStores(); 32 | } 33 | 34 | @Override 35 | protected long hitCount() { 36 | if (cache == null) return 0L; 37 | 38 | return cache.getAdvancedCache().getStats().getHits(); 39 | } 40 | 41 | @Override 42 | protected Long missCount() { 43 | if (cache == null) return 0L; 44 | 45 | return cache.getAdvancedCache().getStats().getMisses(); 46 | } 47 | 48 | @Override 49 | protected Long evictionCount() { 50 | if (cache == null) return 0L; 51 | 52 | return cache.getAdvancedCache().getStats().getEvictions(); 53 | } 54 | 55 | @Override 56 | protected long putCount() { 57 | if (cache == null) return 0L; 58 | 59 | return cache.getAdvancedCache().getStats().getStores(); 60 | } 61 | 62 | @Override 63 | protected void bindImplementationSpecificMetrics(MeterRegistry registry) { 64 | if (cache == null) return; 65 | 66 | Gauge.builder("cache.start", cache, cache -> cache.getAdvancedCache().getStats().getTimeSinceStart()) 67 | .baseUnit(TimeUnit.SECONDS.name()) 68 | .tags(getTagsWithCacheName()) 69 | .description("Time elapsed since start") 70 | .register(registry); 71 | 72 | Gauge.builder("cache.reset", cache, cache -> cache.getAdvancedCache().getStats().getTimeSinceReset()) 73 | .baseUnit(TimeUnit.SECONDS.name()) 74 | .tags(getTagsWithCacheName()) 75 | .description("Time elapsed since the last statistics reset") 76 | .register(registry); 77 | 78 | memory(registry); 79 | averages(registry); 80 | } 81 | 82 | private void memory(MeterRegistry registry) { 83 | Gauge.builder("cache.memory.size", cache, cache -> cache.getAdvancedCache().getStats().getCurrentNumberOfEntriesInMemory()) 84 | .tags(getTagsWithCacheName()) 85 | .description("Number of entries currently in the cache, excluding passivated entries") 86 | .register(registry); 87 | 88 | if (cache.getCacheConfiguration().memory().evictionStrategy().isEnabled()) { 89 | Gauge.builder("cache.memory.used", cache, cache -> cache.getAdvancedCache().getStats().getDataMemoryUsed()) 90 | .tags(getTagsWithCacheName()) 91 | .description("Provides how much memory the current eviction algorithm estimates is in use for data") 92 | .register(registry); 93 | } 94 | 95 | Gauge.builder("cache.memory.offHeap", cache, cache -> cache.getAdvancedCache().getStats().getOffHeapMemoryUsed()) 96 | .tags(getTagsWithCacheName()) 97 | .description("The amount of off-heap memory used by this cache") 98 | .register(registry); 99 | } 100 | 101 | private void averages(MeterRegistry registry) { 102 | Gauge.builder("cache.puts.latency", cache, cache -> cache.getAdvancedCache().getStats().getAverageWriteTime()) 103 | .baseUnit(TimeUnit.MILLISECONDS.name()) 104 | .tags(getTagsWithCacheName()) 105 | .description("Cache puts") 106 | .register(registry); 107 | 108 | Gauge.builder("cache.gets.latency", cache, cache -> cache.getAdvancedCache().getStats().getAverageReadTime()) 109 | .baseUnit(TimeUnit.MILLISECONDS.name()) 110 | .tags(getTagsWithCacheName()) 111 | .description("Cache gets") 112 | .register(registry); 113 | 114 | Gauge.builder("cache.removes.latency", cache, cache -> cache.getAdvancedCache().getStats().getAverageRemoveTime()) 115 | .baseUnit(TimeUnit.MILLISECONDS.name()) 116 | .tags(getTagsWithCacheName()) 117 | .description("Cache removes") 118 | .register(registry); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/java/org/infinispan/spring/starter/embedded/actuator/InfinispanCacheMeterBinderProvider.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.embedded.actuator; 2 | 3 | import io.micrometer.core.instrument.binder.cache.JCacheMetrics; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.boot.actuate.metrics.cache.CacheMeterBinderProvider; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 8 | import org.springframework.cache.Cache; 9 | import org.springframework.stereotype.Component; 10 | 11 | import io.micrometer.core.instrument.Tag; 12 | import io.micrometer.core.instrument.binder.MeterBinder; 13 | 14 | /** 15 | * When actuate dependency is found in the classpath, this component links Infinispan cache metrics with Actuator 16 | * 17 | * @author Katia Aresti, karesti@redtat.com 18 | * @since 2.1 19 | */ 20 | @Component 21 | @Qualifier(InfinispanCacheMeterBinderProvider.NAME) 22 | @ConditionalOnClass(name = "org.springframework.boot.actuate.metrics.cache.CacheMeterBinderProvider") 23 | @ConditionalOnProperty(value = "infinispan.embedded.enabled", havingValue = "true", matchIfMissing = true) 24 | public class InfinispanCacheMeterBinderProvider implements CacheMeterBinderProvider { 25 | 26 | public static final String NAME = "infinispanCacheMeterBinderProvider"; 27 | 28 | @Override 29 | public MeterBinder getMeterBinder(Cache cache, Iterable tags) { 30 | Object nativeCache = cache.getNativeCache(); 31 | MeterBinder meterBinder = null; 32 | if (nativeCache instanceof org.infinispan.Cache) { 33 | meterBinder = new InfinispanCacheMeterBinder((org.infinispan.Cache) nativeCache, tags); 34 | } else { 35 | if (nativeCache instanceof javax.cache.Cache){ // for caches like org.infinispan.jcache.embedded.JCache 36 | meterBinder = new JCacheMetrics((javax.cache.Cache) nativeCache, tags); 37 | } 38 | } 39 | return meterBinder; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration,\ 3 | org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration 4 | 5 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.configuration.cache.ConfigurationBuilder; 4 | import org.infinispan.eviction.EvictionType; 5 | import org.infinispan.manager.EmbeddedCacheManager; 6 | import org.infinispan.notifications.Listener; 7 | import org.infinispan.notifications.cachemanagerlistener.annotation.CacheStarted; 8 | import org.infinispan.notifications.cachemanagerlistener.event.CacheStartedEvent; 9 | import org.infinispan.spring.starter.embedded.InfinispanCacheConfigurer; 10 | import org.infinispan.spring.starter.embedded.InfinispanConfigurationCustomizer; 11 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 12 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 13 | import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurationCustomizer; 14 | import org.junit.jupiter.api.Test; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.test.context.SpringBootTest; 17 | import org.springframework.context.annotation.Bean; 18 | import org.springframework.context.annotation.Configuration; 19 | 20 | import java.util.UUID; 21 | 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | 24 | @SpringBootTest( 25 | classes = { 26 | InfinispanEmbeddedAutoConfiguration.class, 27 | InfinispanEmbeddedCacheManagerAutoConfiguration.class, 28 | InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest.TestConfiguration.class, 29 | }, 30 | properties = { 31 | "spring.main.banner-mode=off" 32 | } 33 | ) 34 | public class InfinispanEmbeddedAutoConfigurationCustomizerIntegrationTest { 35 | private static final String CLUSTER_NAME = UUID.randomUUID().toString(); 36 | 37 | @Autowired 38 | EmbeddedCacheManager manager; 39 | 40 | static CacheStartedEvent startedEvent; 41 | 42 | @Test 43 | public void testConfiguration() { 44 | assertThat(manager.getCacheManagerConfiguration().transport().clusterName()).isEqualTo(CLUSTER_NAME); 45 | assertThat(manager.getDefaultCacheConfiguration()).isNull(); 46 | 47 | assertThat(manager.getCacheNames()).contains("small-cache"); 48 | assertThat(manager.getCacheConfiguration("small-cache").memory().size()).isEqualTo(1000L); 49 | assertThat(manager.getCacheConfiguration("small-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT); 50 | assertThat(startedEvent).isNotNull(); 51 | } 52 | 53 | @Configuration 54 | static class TestConfiguration { 55 | 56 | @Listener 57 | public class ExampleListener { 58 | @CacheStarted 59 | public void cacheStarted(CacheStartedEvent event) { 60 | startedEvent = event; 61 | } 62 | } 63 | 64 | @Bean(name = "small-cache") 65 | public org.infinispan.configuration.cache.Configuration smallCache() { 66 | return new ConfigurationBuilder() 67 | .simpleCache(true) 68 | .memory().size(1000L) 69 | .memory().evictionType(EvictionType.COUNT) 70 | .build(); 71 | } 72 | 73 | @Bean 74 | public InfinispanCacheConfigurer cacheConfigurer() { 75 | return manager -> manager.addListener(new ExampleListener()); 76 | } 77 | 78 | @Bean 79 | public InfinispanGlobalConfigurationCustomizer globalCustomizer() { 80 | return builder -> builder.transport().clusterName(CLUSTER_NAME).jmx().disable(); 81 | } 82 | 83 | @Bean 84 | public InfinispanConfigurationCustomizer configurationCustomizer() { 85 | return builder -> { 86 | builder.memory().evictionType(EvictionType.COUNT); 87 | }; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfigurationIntegrationConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.eviction.EvictionType; 4 | import org.infinispan.manager.EmbeddedCacheManager; 5 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 6 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 7 | import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurer; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import test.org.infinispan.spring.starter.embedded.testconfiguration.GlobalConfigurerJmxDisabledConfiguration; 12 | import test.org.infinispan.spring.starter.embedded.testconfiguration.InfinispanCacheConfigurationBaseTestConfiguration; 13 | import test.org.infinispan.spring.starter.embedded.testconfiguration.InfinispanCacheConfigurationTestConfiguration; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | @SpringBootTest( 18 | classes = { 19 | InfinispanEmbeddedAutoConfiguration.class, 20 | InfinispanEmbeddedCacheManagerAutoConfiguration.class, 21 | InfinispanCacheConfigurationBaseTestConfiguration.class, 22 | InfinispanCacheConfigurationTestConfiguration.class, 23 | InfinispanGlobalConfigurer.class, 24 | GlobalConfigurerJmxDisabledConfiguration.class 25 | }, 26 | properties = { 27 | "spring.main.banner-mode=off" 28 | } 29 | ) 30 | public class InfinispanEmbeddedAutoConfigurationIntegrationConfigurationTest { 31 | 32 | @Autowired 33 | EmbeddedCacheManager manager; 34 | 35 | @Test 36 | public void testConfiguration() { 37 | assertThat(manager.getCacheNames()).contains("base-cache", "small-cache", "large-cache"); 38 | assertThat(manager.getCacheConfiguration("base-cache").memory().size()).isEqualTo(500L); 39 | assertThat(manager.getCacheConfiguration("base-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT); 40 | assertThat(manager.getCacheConfiguration("small-cache").memory().size()).isEqualTo(1000L); 41 | assertThat(manager.getCacheConfiguration("small-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT); 42 | assertThat(manager.getCacheConfiguration("large-cache").memory().size()).isEqualTo(2000L); 43 | assertThat(manager.getCacheConfiguration("large-cache").memory().evictionType()).isEqualTo(EvictionType.COUNT); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import org.infinispan.configuration.cache.Configuration; 4 | import org.infinispan.configuration.cache.StorageType; 5 | import org.infinispan.configuration.global.GlobalConfiguration; 6 | import org.infinispan.eviction.EvictionStrategy; 7 | import org.infinispan.eviction.EvictionType; 8 | import org.infinispan.manager.EmbeddedCacheManager; 9 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 10 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 11 | import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurationCustomizer; 12 | import org.junit.jupiter.api.Test; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.context.annotation.Bean; 16 | import test.org.infinispan.spring.starter.embedded.testconfiguration.InfinispanCacheTestConfiguration; 17 | 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | 20 | @SpringBootTest( 21 | classes = { 22 | InfinispanEmbeddedAutoConfiguration.class, 23 | InfinispanEmbeddedCacheManagerAutoConfiguration.class, 24 | InfinispanCacheTestConfiguration.class, 25 | InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.TestConfiguration.class 26 | }, 27 | properties = { 28 | "spring.main.banner-mode=off" 29 | } 30 | ) 31 | public class InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest { 32 | 33 | private static final String JMX_TEST_DOMAIN = InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.class.getName(); 34 | 35 | @org.springframework.context.annotation.Configuration 36 | static class TestConfiguration { 37 | @Bean 38 | public InfinispanGlobalConfigurationCustomizer globalCustomizer() { 39 | return builder -> builder.jmx() 40 | .domain(JMX_TEST_DOMAIN); 41 | } 42 | } 43 | 44 | @Autowired 45 | EmbeddedCacheManager defaultCacheManager; 46 | 47 | @Test 48 | public void testWithCacheConfigurer() { 49 | assertThat(defaultCacheManager.getCacheNames()).containsExactlyInAnyOrder(InfinispanCacheTestConfiguration.TEST_CACHE_NAME, "default"); 50 | 51 | final Configuration testCacheConfiguration = defaultCacheManager.getCacheConfiguration(InfinispanCacheTestConfiguration.TEST_CACHE_NAME); 52 | assertThat(testCacheConfiguration.statistics().enabled()).isTrue(); 53 | assertThat(testCacheConfiguration.memory().storageType()).isEqualTo(StorageType.OBJECT); 54 | assertThat(testCacheConfiguration.memory().evictionType()).isEqualTo(EvictionType.COUNT); 55 | assertThat(testCacheConfiguration.memory().evictionStrategy()).isEqualTo(EvictionStrategy.MANUAL); 56 | } 57 | 58 | @Test 59 | public void testWithGlobalConfigurer() { 60 | final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); 61 | 62 | assertThat(globalConfiguration.jmx().enabled()).isTrue(); 63 | assertThat(globalConfiguration.jmx().domain()).isEqualTo(JMX_TEST_DOMAIN); 64 | assertThat(globalConfiguration.transport().clusterName()).isEqualTo(InfinispanCacheTestConfiguration.TEST_CLUSTER); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfigurationIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.configuration.cache.Configuration; 6 | import org.infinispan.configuration.global.GlobalConfiguration; 7 | import org.infinispan.manager.EmbeddedCacheManager; 8 | import org.infinispan.spring.embedded.provider.SpringEmbeddedCacheManager; 9 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 10 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 11 | import org.junit.jupiter.api.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | 15 | @SpringBootTest( 16 | classes = { 17 | InfinispanEmbeddedAutoConfiguration.class, 18 | InfinispanEmbeddedCacheManagerAutoConfiguration.class 19 | }, 20 | properties = { 21 | "spring.main.banner-mode=off" 22 | } 23 | ) 24 | public class InfinispanEmbeddedAutoConfigurationIntegrationTest { 25 | 26 | @Autowired 27 | EmbeddedCacheManager defaultCacheManager; 28 | 29 | @Autowired 30 | SpringEmbeddedCacheManager springEmbeddedCacheManager; 31 | 32 | @Test 33 | public void testAutowired() { 34 | assertThat(defaultCacheManager).isNotNull(); 35 | } 36 | 37 | @Test 38 | public void testDefaultConfigurations() { 39 | assertThat(defaultCacheManager.getClusterName()).isEqualTo("default-autoconfigure"); 40 | assertThat(defaultCacheManager.getCacheNames()).containsExactly("default"); 41 | 42 | final Configuration defaultCacheConfiguration = defaultCacheManager.getDefaultCacheConfiguration(); 43 | assertThat(defaultCacheConfiguration).isNull(); 44 | 45 | final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); 46 | assertThat(globalConfiguration.jmx().enabled()).isTrue(); 47 | assertThat(globalConfiguration.jmx().domain()).isEqualTo("org.infinispan"); 48 | } 49 | 50 | @Test 51 | public void testIfSpringCachingWasCreatedUsingProperEmbeddedCacheManager() throws Exception { 52 | assertThat(defaultCacheManager).isEqualTo(springEmbeddedCacheManager.getNativeCacheManager()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedAutoConfigurationPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.Collections; 6 | 7 | import org.infinispan.configuration.cache.Configuration; 8 | import org.infinispan.configuration.global.GlobalConfiguration; 9 | import org.infinispan.manager.EmbeddedCacheManager; 10 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 11 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 12 | import org.junit.jupiter.api.Test; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.test.context.TestPropertySource; 16 | 17 | @SpringBootTest( 18 | classes = { 19 | InfinispanEmbeddedAutoConfiguration.class, 20 | InfinispanEmbeddedCacheManagerAutoConfiguration.class 21 | }, 22 | properties = { 23 | "spring.main.banner-mode=off" 24 | } 25 | ) 26 | @TestPropertySource(properties = "infinispan.embedded.config-xml=infinispan-test-conf.xml") 27 | public class InfinispanEmbeddedAutoConfigurationPropertiesTest { 28 | 29 | @Autowired 30 | EmbeddedCacheManager defaultCacheManager; 31 | 32 | @Test 33 | public void testCacheManagerXmlConfig() { 34 | assertThat(defaultCacheManager.getCacheNames()).isEqualTo(Collections.singleton("default-local")); 35 | 36 | final GlobalConfiguration globalConfiguration = defaultCacheManager.getCacheManagerConfiguration(); 37 | assertThat(globalConfiguration.globalJmxStatistics().enabled()).isTrue(); 38 | assertThat(globalConfiguration.globalJmxStatistics().domain()).isEqualTo("properties.test.spring.infinispan"); 39 | 40 | final Configuration defaultCacheConfiguration = defaultCacheManager.getDefaultCacheConfiguration(); 41 | assertThat(defaultCacheConfiguration.memory().size()).isEqualTo(2000L); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedDisableTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration.DEFAULT_CACHE_MANAGER_QUALIFIER; 5 | 6 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 7 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 8 | import org.infinispan.spring.starter.embedded.actuator.InfinispanCacheMeterBinderProvider; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.ListableBeanFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | 14 | @SpringBootTest( 15 | classes = { 16 | InfinispanEmbeddedAutoConfiguration.class, 17 | InfinispanEmbeddedCacheManagerAutoConfiguration.class 18 | }, 19 | properties = { 20 | "spring.main.banner-mode=off", 21 | "infinispan.embedded.enabled=false", 22 | "infinispan.embedded.caching.enabled=true" 23 | } 24 | ) 25 | public class InfinispanEmbeddedDisableTest { 26 | 27 | @Autowired 28 | private ListableBeanFactory beanFactory; 29 | 30 | @Test 31 | public void testDefaultClient() { 32 | assertThat(beanFactory.containsBeanDefinition(DEFAULT_CACHE_MANAGER_QUALIFIER)).isFalse(); 33 | assertThat(beanFactory.containsBeanDefinition(InfinispanCacheMeterBinderProvider.NAME)).isFalse(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/InfinispanEmbeddedEnableTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration.DEFAULT_CACHE_MANAGER_QUALIFIER; 5 | 6 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 7 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 8 | import org.infinispan.spring.starter.embedded.actuator.InfinispanCacheMeterBinderProvider; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.ListableBeanFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import test.org.infinispan.spring.starter.embedded.testconfiguration.InfinispanCacheTestConfiguration; 14 | 15 | @SpringBootTest( 16 | classes = { 17 | InfinispanEmbeddedAutoConfiguration.class, 18 | InfinispanEmbeddedCacheManagerAutoConfiguration.class, 19 | InfinispanCacheTestConfiguration.class 20 | }, 21 | properties = { 22 | "spring.main.banner-mode=off", 23 | "infinispan.embedded.enabled=true", 24 | "infinispan.embedded.caching.enabled=true" 25 | } 26 | ) 27 | public class InfinispanEmbeddedEnableTest { 28 | 29 | @Autowired 30 | private ListableBeanFactory beanFactory; 31 | 32 | @Test 33 | public void testDefaultClient() { 34 | assertThat(beanFactory.containsBeanDefinition(DEFAULT_CACHE_MANAGER_QUALIFIER)).isTrue(); 35 | assertThat(beanFactory.containsBeanDefinition(InfinispanCacheMeterBinderProvider.NAME)).isTrue(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/actuator/InfinispanCacheMetricBinderTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded.actuator; 2 | 3 | import static java.util.Collections.emptyList; 4 | 5 | import org.infinispan.Cache; 6 | import org.infinispan.commons.api.CacheContainerAdmin; 7 | import org.infinispan.configuration.cache.ConfigurationBuilder; 8 | import org.infinispan.manager.DefaultCacheManager; 9 | import org.infinispan.manager.EmbeddedCacheManager; 10 | import org.infinispan.spring.starter.embedded.actuator.InfinispanCacheMeterBinder; 11 | import org.junit.jupiter.api.AfterAll; 12 | 13 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinder; 14 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinderCompatibilityKit; 15 | 16 | public class InfinispanCacheMetricBinderTest extends CacheMeterBinderCompatibilityKit { 17 | 18 | private static EmbeddedCacheManager cacheManager; 19 | private Cache cache; 20 | 21 | @AfterAll 22 | public static void cleanup() { 23 | cacheManager.stop(); 24 | } 25 | 26 | @Override 27 | public CacheMeterBinder binder() { 28 | cacheManager = new DefaultCacheManager(); 29 | cache = cacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("mycache", new ConfigurationBuilder().jmxStatistics().enable().build()); 30 | return new InfinispanCacheMeterBinder(cache, emptyList()); 31 | } 32 | 33 | @Override 34 | public void put(String key, String value) { 35 | cache.put(key, value); 36 | } 37 | 38 | @Override 39 | public String get(String key) { 40 | return cache.get(key); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/testconfiguration/GlobalConfigurerJmxDisabledConfiguration.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded.testconfiguration; 2 | 3 | import org.infinispan.configuration.global.GlobalConfiguration; 4 | import org.infinispan.configuration.global.GlobalConfigurationBuilder; 5 | import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurer; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import static test.org.infinispan.spring.starter.embedded.testconfiguration.InfinispanCacheTestConfiguration.TEST_CLUSTER; 10 | 11 | @Configuration 12 | public class GlobalConfigurerJmxDisabledConfiguration { 13 | 14 | @Bean 15 | public InfinispanGlobalConfigurer globalConfigurer() { 16 | return () -> { 17 | final GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder() 18 | .transport().clusterName(TEST_CLUSTER) 19 | .jmx().disable() 20 | .build(); 21 | 22 | return globalConfiguration; 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/testconfiguration/InfinispanCacheConfigurationBaseTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded.testconfiguration; 2 | 3 | import org.infinispan.configuration.cache.ConfigurationBuilder; 4 | import org.infinispan.eviction.EvictionType; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class InfinispanCacheConfigurationBaseTestConfiguration { 10 | 11 | @Bean(name = "base-cache") 12 | public org.infinispan.configuration.cache.Configuration smallCache() { 13 | return new ConfigurationBuilder() 14 | .simpleCache(true) 15 | .memory().size(500L) 16 | .memory().evictionType(EvictionType.COUNT) 17 | .build(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/testconfiguration/InfinispanCacheConfigurationTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded.testconfiguration; 2 | 3 | import org.infinispan.configuration.cache.ConfigurationBuilder; 4 | import org.infinispan.eviction.EvictionType; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Qualifier; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Configuration 11 | public class InfinispanCacheConfigurationTestConfiguration { 12 | @Autowired 13 | @Qualifier("base-cache") 14 | org.infinispan.configuration.cache.Configuration baseCache; 15 | 16 | @Bean(name = "small-cache") 17 | public org.infinispan.configuration.cache.Configuration smallCache() { 18 | return new ConfigurationBuilder() 19 | .read(baseCache) 20 | .memory().size(1000L) 21 | .memory().evictionType(EvictionType.COUNT) 22 | .build(); 23 | } 24 | 25 | @Bean(name = "large-cache") 26 | public org.infinispan.configuration.cache.Configuration largeCache() { 27 | return new ConfigurationBuilder() 28 | .read(baseCache) 29 | .memory().size(2000L) 30 | .memory().evictionType(EvictionType.COUNT) 31 | .build(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/java/test/org/infinispan/spring/starter/embedded/testconfiguration/InfinispanCacheTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.embedded.testconfiguration; 2 | 3 | import org.infinispan.configuration.cache.ConfigurationBuilder; 4 | import org.infinispan.configuration.cache.StorageType; 5 | import org.infinispan.configuration.global.GlobalConfiguration; 6 | import org.infinispan.configuration.global.GlobalConfigurationBuilder; 7 | import org.infinispan.eviction.EvictionStrategy; 8 | import org.infinispan.eviction.EvictionType; 9 | import org.infinispan.spring.starter.embedded.InfinispanCacheConfigurer; 10 | import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurer; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | @Configuration 15 | public class InfinispanCacheTestConfiguration { 16 | 17 | public static final String TEST_CLUSTER = "TEST_CLUSTER"; 18 | public static final String TEST_CACHE_NAME = "test-simple-cache"; 19 | public static final String TEST_GLOBAL_JMX_DOMAIN = "test.infinispan"; 20 | 21 | @Bean 22 | public InfinispanCacheConfigurer cacheConfigurer() { 23 | return cacheManager -> { 24 | final org.infinispan.configuration.cache.ConfigurationBuilder testCacheBuilder = new ConfigurationBuilder(); 25 | 26 | testCacheBuilder.simpleCache(true) 27 | .memory() 28 | .storageType(StorageType.OBJECT) 29 | .evictionType(EvictionType.COUNT) 30 | .evictionStrategy(EvictionStrategy.MANUAL); 31 | 32 | testCacheBuilder.statistics().enable(); 33 | 34 | cacheManager.defineConfiguration(TEST_CACHE_NAME, testCacheBuilder.build()); 35 | }; 36 | } 37 | 38 | @Bean 39 | public InfinispanGlobalConfigurer globalConfigurer() { 40 | return () -> { 41 | final GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder() 42 | .transport().clusterName(TEST_CLUSTER) 43 | .jmx().domain(TEST_GLOBAL_JMX_DOMAIN).enable() 44 | .build(); 45 | 46 | return globalConfiguration; 47 | }; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/resources/infinispan-test-conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-embedded/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 25 | 26 | 27 | 28 | 29 | 30 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 31 | 32 | target/infinispan-spring-boot-starter-test-embedded.log 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | infinispan-spring-boot-starter-parent 5 | org.infinispan 6 | 2.3.7-SNAPSHOT 7 | 8 | 4.0.0 9 | Infinispan Spring Boot Starter Remote 10 | infinispan-spring-boot-starter-remote 11 | 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-configuration-processor 21 | true 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-autoconfigure-processor 26 | true 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-actuator 32 | true 33 | 34 | 35 | 36 | org.infinispan 37 | infinispan-client-hotrod 38 | 39 | 40 | 41 | 42 | org.infinispan 43 | infinispan-query-dsl 44 | 45 | 46 | 47 | org.infinispan 48 | infinispan-spring5-remote 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | org.infinispan 58 | infinispan-server-hotrod 59 | ${infinispan.version} 60 | test 61 | 62 | 63 | org.infinispan 64 | infinispan-component-annotations 65 | ${infinispan.version} 66 | test 67 | 68 | 69 | org.infinispan 70 | infinispan-commons-test 71 | ${infinispan.version} 72 | test 73 | 74 | 75 | org.infinispan 76 | infinispan-core 77 | ${infinispan.version} 78 | test-jar 79 | test 80 | 81 | 82 | org.infinispan 83 | infinispan-server-hotrod 84 | ${infinispan.version} 85 | test-jar 86 | test 87 | 88 | 89 | com.fasterxml.jackson.core 90 | jackson-databind 91 | ${version.jackson.databind} 92 | test 93 | 94 | 95 | org.assertj 96 | assertj-core 97 | test 98 | 99 | 100 | org.junit.jupiter 101 | junit-jupiter-api 102 | test 103 | 104 | 105 | org.junit.jupiter 106 | junit-jupiter-engine 107 | test 108 | 109 | 110 | io.micrometer 111 | micrometer-test 112 | test 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanJmxConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import javax.annotation.PostConstruct; 4 | 5 | import org.springframework.beans.factory.ObjectProvider; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.jmx.export.MBeanExporter; 9 | 10 | /** 11 | * Spring and Infinispan register the same bean. Avoid an exception telling Spring not to export Infinispan's 12 | * bean 13 | * 14 | * @since 2.1.x 15 | */ 16 | @Configuration 17 | @ConditionalOnProperty(prefix = "infinispan.remote", name = "jmx", havingValue = "true") 18 | public class InfinispanJmxConfiguration { 19 | 20 | private final ObjectProvider mBeanExporter; 21 | 22 | InfinispanJmxConfiguration(ObjectProvider mBeanExporter) { 23 | this.mBeanExporter = mBeanExporter; 24 | } 25 | 26 | @PostConstruct 27 | public void excludeRemoteCacheManagerMBean() { 28 | this.mBeanExporter 29 | .ifUnique((exporter) -> exporter.addExcludedBean("remoteCacheManager")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanRemoteAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.lang.invoke.MethodHandles; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.Objects; 9 | import java.util.Properties; 10 | import java.util.logging.Logger; 11 | 12 | import org.infinispan.client.hotrod.RemoteCacheManager; 13 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 14 | import org.infinispan.commons.marshall.JavaSerializationMarshaller; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.beans.factory.annotation.Qualifier; 17 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 18 | import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; 19 | import org.springframework.boot.autoconfigure.cache.CacheType; 20 | import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 22 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 23 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 25 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 26 | import org.springframework.context.ApplicationContext; 27 | import org.springframework.context.annotation.Bean; 28 | import org.springframework.context.annotation.ComponentScan; 29 | import org.springframework.context.annotation.Condition; 30 | import org.springframework.context.annotation.ConditionContext; 31 | import org.springframework.context.annotation.Conditional; 32 | import org.springframework.context.annotation.Configuration; 33 | import org.springframework.context.annotation.ConfigurationCondition; 34 | import org.springframework.core.io.Resource; 35 | import org.springframework.core.type.AnnotatedTypeMetadata; 36 | import org.springframework.util.StringUtils; 37 | 38 | @Configuration 39 | @ComponentScan 40 | @AutoConfigureBefore(CacheAutoConfiguration.class) 41 | //Since a jar with configuration might be missing (which would result in TypeNotPresentExceptionProxy), we need to 42 | //use String based methods. 43 | //See https://github.com/spring-projects/spring-boot/issues/1733 44 | @ConditionalOnClass(name = "org.infinispan.client.hotrod.RemoteCacheManager") 45 | @ConditionalOnProperty(value = "infinispan.remote.enabled", havingValue = "true", matchIfMissing = true) 46 | @EnableConfigurationProperties(InfinispanRemoteConfigurationProperties.class) 47 | public class InfinispanRemoteAutoConfiguration { 48 | 49 | private static final Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass().getName()); 50 | 51 | public static final String REMOTE_CACHE_MANAGER_BEAN_QUALIFIER = "remoteCacheManager"; 52 | 53 | @Autowired 54 | private InfinispanRemoteConfigurationProperties infinispanProperties; 55 | 56 | @Autowired(required = false) 57 | private InfinispanRemoteConfigurer infinispanRemoteConfigurer; 58 | 59 | @Autowired(required = false) 60 | private org.infinispan.client.hotrod.configuration.Configuration infinispanConfiguration; 61 | 62 | @Autowired(required = false) 63 | private List cacheCustomizers = Collections.emptyList(); 64 | 65 | @Autowired 66 | private ApplicationContext ctx; 67 | 68 | @Bean 69 | @Conditional({ConditionalOnCacheType.class, ConditionalOnConfiguration.class}) 70 | @ConditionalOnMissingBean 71 | @Qualifier(REMOTE_CACHE_MANAGER_BEAN_QUALIFIER) 72 | public RemoteCacheManager remoteCacheManager() throws IOException { 73 | 74 | boolean hasHotRodPropertiesFile = ctx.getResource(infinispanProperties.getClientProperties()).exists(); 75 | boolean hasConfigurer = infinispanRemoteConfigurer != null; 76 | boolean hasProperties = StringUtils.hasText(infinispanProperties.getServerList()); 77 | ConfigurationBuilder builder = new ConfigurationBuilder(); 78 | //by default, add java white list and marshaller 79 | builder.addJavaSerialWhiteList("java.util.*", "java.time.*", "org.springframework.*", "org.infinispan.spring.common.*", "org.infinispan.spring.remote.*"); 80 | builder.marshaller(new JavaSerializationMarshaller()); 81 | 82 | if (hasConfigurer) { 83 | builder.read(Objects.requireNonNull(infinispanRemoteConfigurer.getRemoteConfiguration())); 84 | } else if (hasHotRodPropertiesFile) { 85 | String remoteClientPropertiesLocation = infinispanProperties.getClientProperties(); 86 | Resource hotRodClientPropertiesFile = ctx.getResource(remoteClientPropertiesLocation); 87 | try (InputStream stream = hotRodClientPropertiesFile.getURL().openStream()) { 88 | Properties hotrodClientProperties = new Properties(); 89 | hotrodClientProperties.load(stream); 90 | builder.withProperties(hotrodClientProperties); 91 | } 92 | } else if (hasProperties) { 93 | builder.withProperties(infinispanProperties.getProperties()); 94 | } else if (infinispanConfiguration != null) { 95 | builder.read(infinispanConfiguration); 96 | 97 | } else { 98 | throw new IllegalStateException("Not enough data to create RemoteCacheManager. Check InfinispanRemoteCacheManagerChecker" + 99 | "and update conditions."); 100 | } 101 | 102 | cacheCustomizers.forEach(c -> c.customize(builder)); 103 | return new RemoteCacheManager(builder.build()); 104 | } 105 | 106 | public static class ConditionalOnConfiguration extends AnyNestedCondition { 107 | public ConditionalOnConfiguration() { 108 | super(ConfigurationCondition.ConfigurationPhase.REGISTER_BEAN); 109 | } 110 | 111 | @Conditional(ConditionalOnConfigurationResources.class) 112 | static class OnConfigurationResources { 113 | } 114 | 115 | @ConditionalOnBean(InfinispanRemoteConfigurer.class) 116 | static class OnRemoteConfigurer { 117 | } 118 | 119 | @ConditionalOnBean(org.infinispan.client.hotrod.configuration.Configuration.class) 120 | static class OnConfiguration { 121 | } 122 | } 123 | 124 | public static class ConditionalOnCacheType implements Condition { 125 | @Override 126 | public boolean matches(ConditionContext ctx, AnnotatedTypeMetadata atm) { 127 | String cacheType = ctx.getEnvironment().getProperty("spring.cache.type"); 128 | return cacheType == null || CacheType.INFINISPAN.name().equalsIgnoreCase(cacheType); 129 | } 130 | } 131 | 132 | public static class ConditionalOnConfigurationResources implements Condition { 133 | @Override 134 | public boolean matches(ConditionContext ctx, AnnotatedTypeMetadata atm) { 135 | return hasHotRodClientPropertiesFile(ctx) || hasServersProperty(ctx); 136 | } 137 | 138 | private boolean hasServersProperty(ConditionContext conditionContext) { 139 | return conditionContext.getEnvironment().getProperty("infinispan.remote.server-list") != null; 140 | } 141 | 142 | private boolean hasHotRodClientPropertiesFile(ConditionContext conditionContext) { 143 | String hotRodPropertiesPath = conditionContext.getEnvironment().getProperty("infinispan.remote.client-properties"); 144 | if (hotRodPropertiesPath == null) { 145 | hotRodPropertiesPath = InfinispanRemoteConfigurationProperties.DEFAULT_CLIENT_PROPERTIES; 146 | } 147 | 148 | return conditionContext.getResourceLoader().getResource(hotRodPropertiesPath).exists(); 149 | } 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanRemoteCacheCustomizer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 4 | 5 | @FunctionalInterface 6 | public interface InfinispanRemoteCacheCustomizer { 7 | void customize(ConfigurationBuilder builder); 8 | } 9 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanRemoteCacheManagerAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import org.infinispan.client.hotrod.RemoteCacheManager; 4 | import org.infinispan.spring.remote.provider.SpringRemoteCacheManager; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.ComponentScan; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | @Configuration 14 | @ComponentScan 15 | //Since a jar with configuration might be missing (which would result in TypeNotPresentExceptionProxy), we need to 16 | //use String based methods. 17 | //See https://github.com/spring-projects/spring-boot/issues/1733 18 | @ConditionalOnClass(name = "org.infinispan.spring.remote.provider.SpringRemoteCacheManager") 19 | @ConditionalOnProperty(value = "infinispan.remote.cache.enabled", havingValue = "true", matchIfMissing = true) 20 | public class InfinispanRemoteCacheManagerAutoConfiguration { 21 | 22 | @Bean 23 | @ConditionalOnBean(RemoteCacheManager.class) 24 | @ConditionalOnMissingBean(type = {"org.infinispan.spring.remote.provider.SpringRemoteCacheManager", "org.infinispan.spring.remote.provider.SpringRemoteCacheManagerFactoryBean"}) 25 | public SpringRemoteCacheManager springRemoteCacheManager(RemoteCacheManager remoteCacheManager) { 26 | return new SpringRemoteCacheManager(remoteCacheManager); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanRemoteConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import java.util.Map; 4 | import java.util.Properties; 5 | 6 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | 9 | 10 | @ConfigurationProperties(value = "infinispan.remote", ignoreInvalidFields = true) 11 | public class InfinispanRemoteConfigurationProperties extends org.infinispan.client.hotrod.impl.ConfigurationProperties { 12 | public static final String DEFAULT_CLIENT_PROPERTIES = "classpath:hotrod-client.properties"; 13 | 14 | /** 15 | * Enable remote cache. 16 | */ 17 | private boolean enabled = true; 18 | 19 | /** 20 | * The hotrod client properties location. 21 | */ 22 | private String clientProperties = DEFAULT_CLIENT_PROPERTIES; 23 | 24 | public String getClientProperties() { 25 | return clientProperties; 26 | } 27 | 28 | public void setClientProperties(String clientProperties) { 29 | this.clientProperties = clientProperties; 30 | } 31 | 32 | public boolean isEnabled() { 33 | return enabled; 34 | } 35 | 36 | public void setEnabled(boolean enabled) { 37 | this.enabled = enabled; 38 | } 39 | 40 | 41 | public ConfigurationBuilder getConfigurationBuilder() { 42 | ConfigurationBuilder builder = new ConfigurationBuilder(); 43 | Properties properties = this.getProperties(); 44 | builder.withProperties(properties); 45 | return builder; 46 | } 47 | 48 | public void setSaslProperties(Map saslProperties) { 49 | saslProperties.forEach((k, v) -> this.getProperties().setProperty(SASL_PROPERTIES_PREFIX + "." + k, v)); 50 | } 51 | 52 | public void setCluster(Map cluster) { 53 | cluster.forEach((k, v) -> this.getProperties().setProperty(CLUSTER_PROPERTIES_PREFIX + "." + k, v)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/InfinispanRemoteConfigurer.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote; 2 | 3 | import org.infinispan.client.hotrod.configuration.Configuration; 4 | 5 | @FunctionalInterface 6 | public interface InfinispanRemoteConfigurer { 7 | Configuration getRemoteConfiguration(); 8 | } 9 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/actuator/RemoteInfinispanCacheMeterBinder.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote.actuator; 2 | 3 | import org.infinispan.client.hotrod.RemoteCache; 4 | 5 | import io.micrometer.core.instrument.Gauge; 6 | import io.micrometer.core.instrument.MeterRegistry; 7 | import io.micrometer.core.instrument.Tag; 8 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinder; 9 | 10 | /** 11 | * Implements {@link CacheMeterBinder} to expose Infinispan remote metrics 12 | * 13 | * @author Katia Aresti, karesti@redhat.com 14 | * @since 2.1 15 | */ 16 | public class RemoteInfinispanCacheMeterBinder extends CacheMeterBinder { 17 | 18 | private final RemoteCache cache; 19 | 20 | public RemoteInfinispanCacheMeterBinder(RemoteCache cache, Iterable tags) { 21 | super(cache, cache.getName(), tags); 22 | this.cache = cache; 23 | } 24 | 25 | @Override 26 | protected Long size() { 27 | if (cache == null) return 0L; 28 | 29 | /** 30 | * TODO implement this. Which is the equivalent to 31 | * {@code cache.getAdvancedCache().getStats().getTotalNumberOfEntries();} 32 | */ 33 | return Long.valueOf(cache.size()); 34 | } 35 | 36 | @Override 37 | protected long hitCount() { 38 | if (cache == null) return 0L; 39 | 40 | return cache.clientStatistics().getRemoteHits(); 41 | } 42 | 43 | @Override 44 | protected Long missCount() { 45 | if (cache == null) return 0L; 46 | 47 | return cache.clientStatistics().getRemoteMisses(); 48 | } 49 | 50 | @Override 51 | protected Long evictionCount() { 52 | if (cache == null) return 0L; 53 | 54 | return cache.clientStatistics().getRemoteRemoves(); 55 | } 56 | 57 | @Override 58 | protected long putCount() { 59 | if (cache == null) return 0L; 60 | 61 | return cache.clientStatistics().getRemoteStores(); 62 | } 63 | 64 | @Override 65 | protected void bindImplementationSpecificMetrics(MeterRegistry registry) { 66 | if (cache == null) return; 67 | 68 | Gauge.builder("cache.reset", cache, cache -> cache.clientStatistics().getTimeSinceReset()) 69 | .tags(getTagsWithCacheName()).tag("ownership", "backup") 70 | .description("Time elapsed in seconds since the last statistics reset") 71 | .register(registry); 72 | 73 | averages(registry); 74 | nearCacheMetrics(registry); 75 | } 76 | 77 | private void averages(MeterRegistry registry) { 78 | Gauge.builder("cache.puts.latency", cache, cache -> cache.clientStatistics().getAverageRemoteStoreTime()) 79 | .tags(getTagsWithCacheName()) 80 | .description("Cache puts") 81 | .register(registry); 82 | 83 | Gauge.builder("cache.gets.latency", cache, cache -> cache.clientStatistics().getAverageRemoteReadTime()) 84 | .tags(getTagsWithCacheName()) 85 | .description("Cache gets") 86 | .register(registry); 87 | 88 | Gauge.builder("cache.removes.latency", cache, cache -> cache.clientStatistics().getAverageRemoteRemovesTime()) 89 | .tags(getTagsWithCacheName()) 90 | .description("Cache removes") 91 | .register(registry); 92 | } 93 | 94 | private void nearCacheMetrics(MeterRegistry registry) { 95 | if (isNearCacheEnabled()) { 96 | Gauge.builder("cache.near.requests", cache, cache -> cache.clientStatistics().getNearCacheHits()) 97 | .tags(getTagsWithCacheName()).tag("result", "hit") 98 | .description("The number of hits (reads) of near cache entries owned by this client") 99 | .register(registry); 100 | 101 | Gauge.builder("cache.near.requests", cache, cache -> cache.clientStatistics().getNearCacheMisses()) 102 | .tags(getTagsWithCacheName()).tag("result", "miss") 103 | .description("The number of hits (reads) of near cache entries owned by this client") 104 | .register(registry); 105 | 106 | Gauge.builder("cache.near.invalidations", cache, cache -> cache.clientStatistics().getNearCacheInvalidations()) 107 | .tags(getTagsWithCacheName()) 108 | .description("The number of invalidations of near cache entries owned by this client") 109 | .register(registry); 110 | 111 | Gauge.builder("cache.near.size", cache, cache -> cache.clientStatistics().getNearCacheSize()) 112 | .tags(getTagsWithCacheName()) 113 | .description("The size of the near cache owned by this client") 114 | .register(registry); 115 | } 116 | } 117 | 118 | private boolean isNearCacheEnabled() { 119 | return cache.getRemoteCacheManager().getConfiguration().nearCache().mode().enabled(); 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/java/org/infinispan/spring/starter/remote/actuator/RemoteInfinispanCacheMeterBinderProvider.java: -------------------------------------------------------------------------------- 1 | package org.infinispan.spring.starter.remote.actuator; 2 | 3 | import org.infinispan.client.hotrod.RemoteCache; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.boot.actuate.metrics.cache.CacheMeterBinderProvider; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 8 | import org.springframework.cache.Cache; 9 | import org.springframework.stereotype.Component; 10 | 11 | import io.micrometer.core.instrument.Tag; 12 | import io.micrometer.core.instrument.binder.MeterBinder; 13 | 14 | /** 15 | * When actuate dependency is found in the classpath, this component links Infinispan cache metrics with Actuator 16 | * 17 | * @author Katia Aresti, karesti@redhat.com 18 | * @since 2.1 19 | */ 20 | @Component 21 | @Qualifier(RemoteInfinispanCacheMeterBinderProvider.NAME) 22 | @ConditionalOnClass(name = "org.springframework.boot.actuate.metrics.cache.CacheMeterBinderProvider") 23 | @ConditionalOnProperty(value = "infinispan.remote.enabled", havingValue = "true", matchIfMissing = true) 24 | public class RemoteInfinispanCacheMeterBinderProvider implements CacheMeterBinderProvider { 25 | 26 | public static final String NAME = "remoteInfinispanCacheMeterBinderProvider"; 27 | 28 | @Override 29 | public MeterBinder getMeterBinder(Cache cache, Iterable tags) { 30 | 31 | if (cache.getNativeCache() instanceof RemoteCache) { 32 | return new RemoteInfinispanCacheMeterBinder((RemoteCache) cache.getNativeCache(), tags); 33 | } else { 34 | return new RemoteInfinispanCacheMeterBinder(null, tags); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration,\ 3 | org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration 4 | 5 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/ApplicationPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import org.infinispan.client.hotrod.ProtocolVersion; 4 | import org.infinispan.client.hotrod.RemoteCacheManager; 5 | import org.infinispan.client.hotrod.configuration.ClientIntelligence; 6 | import org.infinispan.client.hotrod.configuration.ClusterConfiguration; 7 | import org.infinispan.client.hotrod.configuration.Configuration; 8 | import org.infinispan.client.hotrod.configuration.ExhaustedAction; 9 | import org.infinispan.client.hotrod.configuration.NearCacheMode; 10 | import org.infinispan.client.hotrod.configuration.TransactionMode; 11 | import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory; 12 | import org.infinispan.client.hotrod.security.BasicCallbackHandler; 13 | import org.infinispan.commons.marshall.JavaSerializationMarshaller; 14 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 15 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 16 | import org.junit.jupiter.api.Test; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | import org.springframework.test.context.TestPropertySource; 20 | 21 | import javax.security.auth.callback.Callback; 22 | import javax.security.auth.callback.NameCallback; 23 | import javax.security.auth.callback.PasswordCallback; 24 | import javax.security.sasl.RealmCallback; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | import static org.assertj.core.groups.Tuple.tuple; 28 | 29 | @SpringBootTest( 30 | classes = { 31 | InfinispanRemoteAutoConfiguration.class, 32 | InfinispanRemoteCacheManagerAutoConfiguration.class 33 | }, 34 | properties = { 35 | "spring.main.banner-mode=off" 36 | }) 37 | @TestPropertySource(locations = "classpath:test-application.properties") 38 | public class ApplicationPropertiesTest { 39 | 40 | @Autowired 41 | private RemoteCacheManager remoteCacheManager; 42 | 43 | @Test 44 | public void testDefaultClient() throws Exception { 45 | //when 46 | Configuration configuration = remoteCacheManager.getConfiguration(); 47 | String hostObtainedFromPropertiesFile = configuration.servers().get(0).host(); 48 | int portObtainedFromPropertiesFile = configuration.servers().get(0).port(); 49 | 50 | configuration.asyncExecutorFactory().factoryClass(); 51 | 52 | // properties 53 | assertThat(hostObtainedFromPropertiesFile).isEqualTo("180.567.112.333"); 54 | assertThat(portObtainedFromPropertiesFile).isEqualTo(6668); 55 | assertThat(configuration.tcpNoDelay()).isFalse(); 56 | assertThat(configuration.tcpKeepAlive()).isTrue(); 57 | assertThat(configuration.clientIntelligence()).isEqualTo(ClientIntelligence.TOPOLOGY_AWARE); 58 | assertThat(configuration.socketTimeout()).isEqualTo(500); 59 | assertThat(configuration.connectionTimeout()).isEqualTo(200); 60 | assertThat(configuration.maxRetries()).isEqualTo(30); 61 | assertThat(configuration.batchSize()).isEqualTo(91); 62 | assertThat(configuration.version()).isEqualTo(ProtocolVersion.PROTOCOL_VERSION_24); 63 | 64 | // pool 65 | assertThat(configuration.connectionPool().maxActive()).isEqualTo(90); 66 | assertThat(configuration.connectionPool().maxWait()).isEqualTo(20000); 67 | assertThat(configuration.connectionPool().minIdle()).isEqualTo(1000); 68 | assertThat(configuration.connectionPool().maxPendingRequests()).isEqualTo(845); 69 | assertThat(configuration.connectionPool().minEvictableIdleTime()).isEqualTo(9000); 70 | assertThat(configuration.connectionPool().exhaustedAction()).isEqualTo(ExhaustedAction.CREATE_NEW); 71 | 72 | // Thread pool properties 73 | assertThat(configuration.asyncExecutorFactory().factoryClass()).isEqualTo(DefaultAsyncExecutorFactory.class); 74 | // TODO: how to assert thread pool size ? default-executor-factory-pool-size 75 | 76 | // Marshalling properties 77 | assertThat(configuration.marshallerClass()).isEqualTo(JavaSerializationMarshaller.class); 78 | assertThat(configuration.keySizeEstimate()).isEqualTo(88889); 79 | assertThat(configuration.valueSizeEstimate()).isEqualTo(11112); 80 | assertThat(configuration.forceReturnValues()).isTrue(); 81 | assertThat(configuration.serialWhitelist()).contains("APP-KILLER1", "APP-KILLER2"); 82 | // TODO: Consistent Hash Impl ?? 83 | //assertThat(configuration.consistentHashImpl().getClass().toString()).isEqualTo(""); 84 | 85 | // Encryption properties 86 | assertThat(configuration.security().ssl().enabled()).isTrue(); 87 | assertThat(configuration.security().ssl().keyStoreFileName()).isEqualTo("superKeyStoreFile"); 88 | assertThat(configuration.security().ssl().keyStoreType()).isEqualTo("SKL"); 89 | assertThat(configuration.security().ssl().keyStorePassword().length).isEqualTo(17); 90 | assertThat(configuration.security().ssl().keyAlias()).isEqualTo("superAliasKey"); 91 | assertThat(configuration.security().ssl().keyStoreCertificatePassword()).hasSize(13); 92 | assertThat(configuration.security().ssl().trustStoreFileName()).isEqualTo("superTrustFileName"); 93 | assertThat(configuration.security().ssl().trustStorePath()).isNull(); 94 | assertThat(configuration.security().ssl().trustStoreType()).isEqualTo("CKO"); 95 | assertThat(configuration.security().ssl().trustStorePassword().length).isEqualTo(18); 96 | assertThat(configuration.security().ssl().sniHostName()).isEqualTo("elahost"); 97 | assertThat(configuration.security().ssl().protocol()).isEqualTo("TLSv1.4"); 98 | 99 | // authentication 100 | assertThat(configuration.security().authentication().enabled()).isTrue(); 101 | assertThat(configuration.security().authentication().callbackHandler().getClass()).isEqualTo(BasicCallbackHandler.class); 102 | assertThat(configuration.security().authentication().saslMechanism()).isEqualTo("my-sasl-mechanism"); 103 | assertThat(configuration.security().authentication().serverName()).isEqualTo("my-server-name"); 104 | BasicCallbackHandler basicCallbackHandler = (BasicCallbackHandler) configuration.security().authentication().callbackHandler(); 105 | NameCallback nameCallback = new NameCallback("test", "test"); 106 | PasswordCallback passwordCallback = new PasswordCallback("test", false); 107 | RealmCallback realmCallback = new RealmCallback("test", "test"); 108 | basicCallbackHandler.handle(new Callback[]{nameCallback, passwordCallback, realmCallback}); 109 | assertThat(nameCallback.getName()).isEqualTo("oihana"); 110 | assertThat(passwordCallback.getPassword()).isEqualTo("oipass".toCharArray()); 111 | assertThat(realmCallback.getText()).isEqualTo("oirealm"); 112 | assertThat(configuration.security().authentication().saslProperties()).hasSize(2); 113 | assertThat(configuration.security().authentication().saslProperties()).extracting("prop1", "prop2").containsExactly("value1", "value2"); 114 | 115 | // transactions 116 | assertThat(configuration.transaction().transactionMode()).isEqualTo(TransactionMode.NON_DURABLE_XA); 117 | assertThat(configuration.transaction().timeout()).isEqualTo(50000); 118 | 119 | // near cache 120 | assertThat(configuration.nearCache().mode()).isEqualTo(NearCacheMode.INVALIDATED); 121 | assertThat(configuration.nearCache().maxEntries()).isEqualTo(2000); 122 | assertThat(configuration.nearCache().cacheNamePattern().pattern()).isEqualTo("appCache*"); 123 | 124 | // xsite 125 | assertThat(configuration.clusters()).hasSize(1); 126 | ClusterConfiguration site = configuration.clusters().get(0); 127 | assertThat(site.getCluster()).extracting("host", "port").containsExactly(tuple("hostOi1", 21222), tuple("hostOi2", 21223)); 128 | 129 | // statistics 130 | assertThat(configuration.statistics().enabled()).isTrue(); 131 | assertThat(configuration.statistics().jmxEnabled()).isTrue(); 132 | assertThat(configuration.statistics().jmxName()).isEqualTo("oiJmx"); 133 | assertThat(configuration.statistics().jmxDomain()).isEqualTo("oiJmxDom"); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/CustomConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 8 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheCustomizer; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.springframework.core.Ordered; 15 | import org.springframework.core.annotation.Order; 16 | 17 | @SpringBootTest( 18 | classes = { 19 | CustomConfigurationTest.TestConfiguration.class, 20 | InfinispanRemoteAutoConfiguration.class 21 | }, 22 | properties = { 23 | "spring.main.banner-mode=off" 24 | } 25 | ) 26 | public class CustomConfigurationTest { 27 | @Autowired 28 | private RemoteCacheManager manager; 29 | 30 | @Test 31 | public void testConfiguredClient() { 32 | assertThat(manager.getConfiguration().servers().get(0).port()).isEqualTo(6667); 33 | assertThat(manager.getConfiguration().tcpNoDelay()).isFalse(); 34 | assertThat(manager.getConfiguration().tcpKeepAlive()).isFalse(); 35 | } 36 | 37 | @Configuration 38 | static class TestConfiguration { 39 | @Bean 40 | public org.infinispan.client.hotrod.configuration.Configuration customConfiguration() { 41 | return new ConfigurationBuilder() 42 | .addServers("127.0.0.1:6667") 43 | .tcpNoDelay(false) 44 | .tcpKeepAlive(true) 45 | .build(); 46 | } 47 | 48 | @Order(Ordered.HIGHEST_PRECEDENCE) 49 | @Bean 50 | public InfinispanRemoteCacheCustomizer customizer() { 51 | return b -> b.tcpKeepAlive(false); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/CustomConfigurerWithPropertyInjectionTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 8 | import org.infinispan.spring.starter.remote.InfinispanRemoteConfigurer; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | 16 | @SpringBootTest( 17 | classes = { 18 | CustomConfigurerWithPropertyInjectionTest.TestConfiguration.class, 19 | InfinispanRemoteAutoConfiguration.class 20 | }, 21 | properties = { 22 | "spring.main.banner-mode=off", 23 | "myServerList=localhost:6667" 24 | } 25 | ) 26 | public class CustomConfigurerWithPropertyInjectionTest { 27 | @Autowired 28 | private RemoteCacheManager manager; 29 | 30 | @Test 31 | public void testConfiguredClient() { 32 | assertThat(manager.getConfiguration().servers().get(0).port()).isEqualTo(6667); 33 | } 34 | 35 | @Configuration 36 | static class TestConfiguration { 37 | @Value("${myServerList}") 38 | private String serverList; 39 | 40 | @Bean 41 | public InfinispanRemoteConfigurer configuration() { 42 | return () -> new ConfigurationBuilder() 43 | .addServers(serverList) 44 | .build(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/CustomPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import org.infinispan.client.hotrod.ProtocolVersion; 4 | import org.infinispan.client.hotrod.RemoteCacheManager; 5 | import org.infinispan.client.hotrod.configuration.ClientIntelligence; 6 | import org.infinispan.client.hotrod.configuration.ClusterConfiguration; 7 | import org.infinispan.client.hotrod.configuration.Configuration; 8 | import org.infinispan.client.hotrod.configuration.ExhaustedAction; 9 | import org.infinispan.client.hotrod.configuration.NearCacheMode; 10 | import org.infinispan.client.hotrod.configuration.TransactionMode; 11 | import org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory; 12 | import org.infinispan.client.hotrod.security.BasicCallbackHandler; 13 | import org.infinispan.commons.marshall.JavaSerializationMarshaller; 14 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 15 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 16 | import org.junit.jupiter.api.Test; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.boot.test.context.SpringBootTest; 19 | 20 | import javax.security.auth.callback.Callback; 21 | import javax.security.auth.callback.NameCallback; 22 | import javax.security.auth.callback.PasswordCallback; 23 | import javax.security.sasl.RealmCallback; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | import static org.assertj.core.groups.Tuple.tuple; 27 | 28 | @SpringBootTest( 29 | classes = { 30 | InfinispanRemoteAutoConfiguration.class, 31 | InfinispanRemoteCacheManagerAutoConfiguration.class 32 | }, 33 | properties = { 34 | "spring.main.banner-mode=off", 35 | "infinispan.remote.client-properties=custom-test-hotrod-client.properties" 36 | } 37 | ) 38 | public class CustomPropertiesTest { 39 | 40 | @Autowired 41 | private RemoteCacheManager remoteCacheManager; 42 | 43 | @Test 44 | public void testDefaultClient() throws Exception { 45 | //when 46 | Configuration configuration = remoteCacheManager.getConfiguration(); 47 | String hostObtainedFromPropertiesFile = configuration.servers().get(0).host(); 48 | int portObtainedFromPropertiesFile = configuration.servers().get(0).port(); 49 | 50 | // Connection 51 | assertThat(hostObtainedFromPropertiesFile).isEqualTo("127.0.0.1"); 52 | assertThat(portObtainedFromPropertiesFile).isEqualTo(6667); 53 | assertThat(configuration.tcpNoDelay()).isFalse(); 54 | assertThat(configuration.tcpKeepAlive()).isTrue(); 55 | assertThat(configuration.clientIntelligence()).isEqualTo(ClientIntelligence.TOPOLOGY_AWARE); 56 | assertThat(configuration.socketTimeout()).isEqualTo(3000); 57 | assertThat(configuration.connectionTimeout()).isEqualTo(5000); 58 | assertThat(configuration.maxRetries()).isEqualTo(42); 59 | assertThat(configuration.batchSize()).isEqualTo(90); 60 | assertThat(configuration.version()).isEqualTo(ProtocolVersion.PROTOCOL_VERSION_28); 61 | 62 | // Connection pool properties 63 | assertThat(configuration.connectionPool().maxActive()).isEqualTo(91); 64 | assertThat(configuration.connectionPool().exhaustedAction()).isEqualTo(ExhaustedAction.EXCEPTION); 65 | assertThat(configuration.connectionPool().maxWait()).isEqualTo(20001); 66 | assertThat(configuration.connectionPool().minIdle()).isEqualTo(1001); 67 | assertThat(configuration.connectionPool().minEvictableIdleTime()).isEqualTo(9001); 68 | assertThat(configuration.connectionPool().maxPendingRequests()).isEqualTo(846); 69 | 70 | // Thread pool properties 71 | assertThat(configuration.asyncExecutorFactory().factoryClass()).isEqualTo(DefaultAsyncExecutorFactory.class); 72 | // TODO: how to assert thread pool size ? default_executor_factory.pool_size 73 | 74 | // Marshalling properties 75 | assertThat(configuration.marshallerClass()).isEqualTo(JavaSerializationMarshaller.class); 76 | assertThat(configuration.keySizeEstimate()).isEqualTo(123456); 77 | assertThat(configuration.valueSizeEstimate()).isEqualTo(789012); 78 | assertThat(configuration.forceReturnValues()).isTrue(); 79 | assertThat(configuration.serialWhitelist()).contains("SERIAL-KILLER"); 80 | // TODO: Consistent Hash Impl ?? 81 | //assertThat(configuration.consistentHashImpl().getClass().toString()).isEqualTo(""); 82 | 83 | // Encryption properties 84 | assertThat(configuration.security().ssl().enabled()).isTrue(); 85 | assertThat(configuration.security().ssl().keyStoreFileName()).isEqualTo("keyStoreFile"); 86 | assertThat(configuration.security().ssl().keyStoreType()).isEqualTo("JKS"); 87 | assertThat(configuration.security().ssl().keyStorePassword()).hasSize(12); 88 | assertThat(configuration.security().ssl().keyAlias()).isEqualTo("aliasKey"); 89 | assertThat(configuration.security().ssl().keyStoreCertificatePassword()).hasSize(9); 90 | assertThat(configuration.security().ssl().trustStoreFileName()).isEqualTo("trustFileName"); 91 | assertThat(configuration.security().ssl().trustStorePath()).isNull(); 92 | assertThat(configuration.security().ssl().trustStoreType()).isEqualTo("LOL"); 93 | assertThat(configuration.security().ssl().trustStorePassword().length).isEqualTo(13); 94 | assertThat(configuration.security().ssl().sniHostName()).isEqualTo("oihost"); 95 | assertThat(configuration.security().ssl().protocol()).isEqualTo("TLSv1.3"); 96 | 97 | // authentication 98 | assertThat(configuration.security().authentication().enabled()).isTrue(); 99 | assertThat(configuration.security().authentication().saslMechanism()).isEqualTo("DIGEST-MD5"); 100 | assertThat(configuration.security().authentication().callbackHandler()).isInstanceOf(BasicCallbackHandler.class); 101 | assertThat(configuration.security().authentication().serverName()).isEqualTo("my_ela_server_name"); 102 | BasicCallbackHandler basicCallbackHandler = (BasicCallbackHandler) configuration.security().authentication().callbackHandler(); 103 | NameCallback nameCallback = new NameCallback("test", "test"); 104 | PasswordCallback passwordCallback = new PasswordCallback("test", false); 105 | RealmCallback realmCallback = new RealmCallback("test", "test"); 106 | basicCallbackHandler.handle(new Callback[]{nameCallback, passwordCallback, realmCallback}); 107 | assertThat(nameCallback.getName()).isEqualTo("elaia"); 108 | assertThat(passwordCallback.getPassword()).isEqualTo("elapass".toCharArray()); 109 | assertThat(realmCallback.getText()).isEqualTo("elarealm"); 110 | assertThat(configuration.security().authentication().saslProperties()).hasSize(1); 111 | assertThat(configuration.security().authentication().saslProperties()).containsOnlyKeys("prop1"); 112 | assertThat(configuration.security().authentication().saslProperties()).containsValues("value1"); 113 | 114 | // Transaction properties 115 | // TODO: transaction_manager_lookup?? 116 | assertThat(configuration.transaction().transactionMode()).isEqualTo(TransactionMode.FULL_XA); 117 | assertThat(configuration.transaction().timeout()).isEqualTo(50001); 118 | 119 | // near cache 120 | assertThat(configuration.nearCache().mode()).isEqualTo(NearCacheMode.INVALIDATED); 121 | assertThat(configuration.nearCache().maxEntries()).isEqualTo(10000); 122 | assertThat(configuration.nearCache().cacheNamePattern().pattern()).isEqualTo("nearSuperCache*"); 123 | 124 | // xsite 125 | assertThat(configuration.clusters()).hasSize(2); 126 | ClusterConfiguration siteA = configuration.clusters().get(0); 127 | ClusterConfiguration siteB = configuration.clusters().get(1); 128 | assertThat(siteA.getClusterName()).isEqualTo("siteA"); 129 | assertThat(siteB.getClusterName()).isEqualTo("siteB"); 130 | assertThat(siteA.getCluster()).extracting("host", "port").containsExactly(tuple("hostA1", 11222), tuple("hostA2", 11223)); 131 | assertThat(siteB.getCluster()).extracting("host", "port").containsExactly(tuple("hostB1", 11224), tuple("hostB2", 11225)); 132 | 133 | // statistics 134 | assertThat(configuration.statistics().enabled()).isTrue(); 135 | assertThat(configuration.statistics().jmxEnabled()).isTrue(); 136 | assertThat(configuration.statistics().jmxName()).isEqualTo("elaJmx"); 137 | assertThat(configuration.statistics().jmxDomain()).isEqualTo("elaJmxDom2"); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/DisablingTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 6 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 7 | import org.infinispan.spring.starter.remote.actuator.RemoteInfinispanCacheMeterBinderProvider; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.beans.factory.ListableBeanFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | @SpringBootTest( 14 | classes = { 15 | InfinispanRemoteAutoConfiguration.class, 16 | InfinispanRemoteCacheManagerAutoConfiguration.class}, 17 | properties = { 18 | "spring.main.banner-mode=off", 19 | "infinispan.remote.client-properties=test-hotrod-client.properties", 20 | "infinispan.remote.enabled=false" 21 | } 22 | ) 23 | public class DisablingTest { 24 | 25 | @Autowired 26 | private ListableBeanFactory beanFactory; 27 | 28 | @Test 29 | public void testDefaultClient() { 30 | assertThat(beanFactory.containsBeanDefinition(InfinispanRemoteAutoConfiguration.REMOTE_CACHE_MANAGER_BEAN_QUALIFIER)).isFalse(); 31 | assertThat(beanFactory.containsBeanDefinition(RemoteInfinispanCacheMeterBinderProvider.NAME)).isFalse(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/EnablingTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 6 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 7 | import org.infinispan.spring.starter.remote.actuator.RemoteInfinispanCacheMeterBinderProvider; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.beans.factory.ListableBeanFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | @SpringBootTest( 14 | classes = { 15 | InfinispanRemoteAutoConfiguration.class, 16 | InfinispanRemoteCacheManagerAutoConfiguration.class}, 17 | properties = { 18 | "spring.main.banner-mode=off", 19 | "infinispan.remote.client-properties=test-hotrod-client.properties", 20 | "infinispan.remote.enabled=true" 21 | } 22 | ) 23 | public class EnablingTest { 24 | 25 | @Autowired 26 | private ListableBeanFactory beanFactory; 27 | 28 | @Test 29 | public void testDefaultClient() { 30 | assertThat(beanFactory.containsBeanDefinition(InfinispanRemoteAutoConfiguration.REMOTE_CACHE_MANAGER_BEAN_QUALIFIER)).isTrue(); 31 | assertThat(beanFactory.containsBeanDefinition(RemoteInfinispanCacheMeterBinderProvider.NAME)).isTrue(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/InfinispanJmxConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.spring.starter.remote.InfinispanJmxConfiguration; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 8 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.jmx.export.MBeanExporter; 13 | 14 | @SpringBootTest(classes = { 15 | InfinispanRemoteAutoConfiguration.class, 16 | InfinispanRemoteCacheManagerAutoConfiguration.class, 17 | InfinispanJmxConfiguration.class, 18 | MBeanExporter.class}, 19 | properties = { 20 | "spring.main.banner-mode=off", 21 | "infinispan.remote.server-list=180.567.112.333:6668", 22 | "infinispan.remote.jmx=true", 23 | "infinispan.remote.enabled=true"}) 24 | public class InfinispanJmxConfigurationTest { 25 | 26 | @Autowired 27 | RemoteCacheManager remoteCacheManager; 28 | 29 | @Test 30 | public void contextIsUp() { 31 | /** 32 | * When JMX is enabled in Spring and Infinispan, if {@link InfinispanJmxConfiguration} does not exclude 33 | * 'remoteCacheManager', this test will fail because context won't start 34 | */ 35 | assertThat(remoteCacheManager).isNotNull(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/IntegrationTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.spring.remote.provider.SpringRemoteCacheManager; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 8 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import test.org.infinispan.spring.starter.remote.testconfiguration.InfinispanCacheTestConfiguration; 13 | 14 | @SpringBootTest( 15 | classes = { 16 | InfinispanRemoteAutoConfiguration.class, 17 | InfinispanRemoteCacheManagerAutoConfiguration.class, 18 | InfinispanCacheTestConfiguration.class 19 | }, 20 | properties = { 21 | "spring.main.banner-mode=off", 22 | "infinispan.remote.client-properties=test-hotrod-client.properties" 23 | } 24 | ) 25 | public class IntegrationTest { 26 | 27 | @Autowired 28 | private RemoteCacheManager remoteCacheManager; 29 | 30 | @Autowired 31 | private SpringRemoteCacheManager springRemoteCacheManager; 32 | 33 | @Test 34 | public void testConfiguredClient() { 35 | int portObtainedFromPropertiesFile = remoteCacheManager.getConfiguration().servers().get(0).port(); 36 | 37 | assertThat(portObtainedFromPropertiesFile).isEqualTo(11555); 38 | } 39 | 40 | @Test 41 | public void testIfSpringCachingWasCreatedUsingProperEmbeddedCacheManager() throws Exception { 42 | assertThat(remoteCacheManager).isEqualTo(springRemoteCacheManager.getNativeCacheManager()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/PreventingAutoCreatingBeansTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.beans.factory.ListableBeanFactory; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | @SpringBootTest( 14 | classes = { 15 | InfinispanRemoteAutoConfiguration.class, 16 | InfinispanRemoteCacheManagerAutoConfiguration.class 17 | }, 18 | properties = { 19 | "spring.main.banner-mode=off", 20 | "infinispan.remote.client-properties=test-hotrod-client.properties", 21 | "infinispan.remote.enabled=false" 22 | } 23 | ) 24 | public class PreventingAutoCreatingBeansTest { 25 | 26 | @Autowired 27 | private ListableBeanFactory beanFactory; 28 | 29 | @Test 30 | public void testIfNoDefaultClientWasCreated() { 31 | assertThat(beanFactory.getBeansOfType(RemoteCacheManager.class)).isEmpty(); 32 | } 33 | 34 | @Test 35 | public void testIfNoEmbeddedCacheManagerWasCreated() { 36 | assertThat(beanFactory.containsBeanDefinition("defaultCacheManager")).isFalse(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/actuator/RemoteCacheMetricBinderTest.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote.actuator; 2 | 3 | import static java.util.Collections.emptyList; 4 | 5 | import org.infinispan.client.hotrod.RemoteCache; 6 | import org.infinispan.spring.common.provider.SpringCache; 7 | import org.infinispan.spring.starter.remote.actuator.RemoteInfinispanCacheMeterBinderProvider; 8 | import org.junit.jupiter.api.AfterAll; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeAll; 11 | 12 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinder; 13 | import io.micrometer.core.instrument.binder.cache.CacheMeterBinderCompatibilityKit; 14 | import test.org.infinispan.spring.starter.remote.extension.InfinispanServerExtension; 15 | 16 | public class RemoteCacheMetricBinderTest extends CacheMeterBinderCompatibilityKit { 17 | private static InfinispanServerExtension infinispanServerExtension = InfinispanServerExtension.builder() 18 | .withCaches("mycache").build(); 19 | 20 | private RemoteCache cache; 21 | 22 | @AfterEach 23 | public void cleanCache() { 24 | cache.clientStatistics().resetStatistics(); 25 | } 26 | 27 | @BeforeAll 28 | public static void start() { 29 | infinispanServerExtension.start(); 30 | } 31 | 32 | @AfterAll 33 | public static void stop() { 34 | infinispanServerExtension.stop(); 35 | } 36 | 37 | @Override 38 | public CacheMeterBinder binder() { 39 | cache = infinispanServerExtension.hotRodClient().getCache("mycache"); 40 | RemoteInfinispanCacheMeterBinderProvider remoteInfinispanCacheMeterBinderProvider = new RemoteInfinispanCacheMeterBinderProvider(); 41 | return (CacheMeterBinder) remoteInfinispanCacheMeterBinderProvider 42 | .getMeterBinder(new SpringCache(cache), emptyList()); 43 | } 44 | 45 | @Override 46 | public void put(String key, String value) { 47 | cache.put(key, value); 48 | } 49 | 50 | @Override 51 | public String get(String key) { 52 | return cache.get(key); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/extension/InfinispanServerExtension.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote.extension; 2 | 3 | import java.util.stream.Stream; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.configuration.cache.ConfigurationBuilder; 7 | import org.infinispan.configuration.global.GlobalConfigurationBuilder; 8 | import org.infinispan.manager.EmbeddedCacheManager; 9 | import org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler; 10 | import org.infinispan.server.hotrod.HotRodServer; 11 | import org.infinispan.server.hotrod.configuration.HotRodServerConfiguration; 12 | import org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder; 13 | import org.infinispan.server.hotrod.test.HotRodTestingUtil; 14 | import org.infinispan.test.fwk.TestCacheManagerFactory; 15 | import org.infinispan.commons.test.TestResourceTracker; 16 | import org.junit.jupiter.api.extension.AfterAllCallback; 17 | import org.junit.jupiter.api.extension.AfterEachCallback; 18 | import org.junit.jupiter.api.extension.BeforeAllCallback; 19 | import org.junit.jupiter.api.extension.BeforeEachCallback; 20 | import org.junit.jupiter.api.extension.ExtensionContext; 21 | import org.junit.jupiter.api.extension.TestTemplateInvocationContext; 22 | import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; 23 | 24 | /** 25 | * Junit 5 simple extension for the hotrod server 26 | * 27 | * @author Katia Aresti, karesti@redhat.com 28 | */ 29 | public class InfinispanServerExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, TestTemplateInvocationContextProvider { 30 | 31 | private HotRodServer hotRodServer; 32 | private RemoteCacheManager hotRodClient; 33 | private final String host; 34 | private final int port; 35 | private final String[] initialCaches; 36 | private final boolean startBeforeAll; 37 | private final boolean stopAfterAll; 38 | private final boolean startBeforeEach; 39 | private final boolean stopAfterEach; 40 | 41 | 42 | public InfinispanServerExtension(String host, int port, String[] initialCaches, boolean startBeforeAll, 43 | boolean stopAfterAll, boolean startBeforeEach, boolean stopAfterEach) { 44 | this.host = host; 45 | this.port = port; 46 | this.initialCaches = initialCaches; 47 | this.startBeforeAll = startBeforeAll; 48 | this.stopAfterAll = stopAfterAll; 49 | this.startBeforeEach = startBeforeEach; 50 | this.stopAfterEach = stopAfterEach; 51 | } 52 | 53 | public static final InfinispanServerExtensionBuilder builder() { 54 | return new InfinispanServerExtensionBuilder(); 55 | 56 | } 57 | 58 | @Override 59 | public boolean supportsTestTemplate(ExtensionContext extensionContext) { 60 | return true; 61 | } 62 | 63 | @Override 64 | public Stream provideTestTemplateInvocationContexts( 65 | ExtensionContext extensionContext) { 66 | return null; 67 | } 68 | 69 | @Override 70 | public void beforeAll(ExtensionContext context) throws Exception { 71 | if (startBeforeAll) 72 | start(); 73 | } 74 | 75 | @Override 76 | public void afterAll(ExtensionContext context) throws Exception { 77 | if (stopAfterAll) 78 | stop(); 79 | } 80 | 81 | @Override 82 | public void beforeEach(ExtensionContext context) throws Exception { 83 | if (startBeforeEach) 84 | start(); 85 | } 86 | 87 | @Override 88 | public void afterEach(ExtensionContext context) throws Exception { 89 | if (stopAfterEach) 90 | stop(); 91 | } 92 | 93 | public static class InfinispanServerExtensionBuilder { 94 | private String host = "localhost"; 95 | private int port = 11222; 96 | private String[] cacheNames = new String[0]; 97 | private boolean startBeforeAll = true; 98 | private boolean stopAfterAll = true; 99 | private boolean startBeforeEach; 100 | private boolean stopAfterEach; 101 | 102 | public InfinispanServerExtensionBuilder host(String host) { 103 | this.host = host; 104 | return this; 105 | } 106 | 107 | public InfinispanServerExtensionBuilder port(int port) { 108 | this.port = port; 109 | return this; 110 | } 111 | 112 | public InfinispanServerExtensionBuilder withCaches(String... cacheName) { 113 | this.cacheNames = cacheName; 114 | return this; 115 | } 116 | 117 | public InfinispanServerExtensionBuilder startBeforerEach(boolean stopBeforeEach) { 118 | this.startBeforeEach = stopBeforeEach; 119 | return this; 120 | } 121 | 122 | public InfinispanServerExtensionBuilder stopAfterEach(boolean stopAfterEach) { 123 | this.stopAfterEach = stopAfterEach; 124 | return this; 125 | } 126 | 127 | public InfinispanServerExtensionBuilder startBeforerAll(boolean stopBeforeAll) { 128 | this.startBeforeAll = stopBeforeAll; 129 | return this; 130 | } 131 | 132 | public InfinispanServerExtensionBuilder stopAfterAll(boolean stopAfterAll) { 133 | this.stopAfterAll = stopAfterAll; 134 | return this; 135 | } 136 | 137 | public InfinispanServerExtension build() { 138 | return new InfinispanServerExtension(host, port, cacheNames, startBeforeAll, stopAfterAll, startBeforeEach, stopAfterEach); 139 | } 140 | } 141 | 142 | public RemoteCacheManager hotRodClient() { 143 | if (hotRodServer != null && hotRodClient == null) { 144 | org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); 145 | HotRodServerConfiguration serverConfiguration = hotRodServer.getConfiguration(); 146 | builder.addServer().host(serverConfiguration.publicHost()) 147 | .port(serverConfiguration.publicPort()); 148 | builder.statistics().enable(); 149 | hotRodClient = new RemoteCacheManager(builder.build()); 150 | } 151 | return hotRodClient; 152 | } 153 | 154 | public void start() { 155 | if (hotRodServer == null) { 156 | TestResourceTracker.setThreadTestName("InfinispanServer"); 157 | ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); 158 | EmbeddedCacheManager ecm = TestCacheManagerFactory.createCacheManager( 159 | new GlobalConfigurationBuilder().nonClusteredDefault().defaultCacheName("default"), 160 | configurationBuilder); 161 | 162 | for (String cacheName : initialCaches) { 163 | ecm.createCache(cacheName, new ConfigurationBuilder().build()); 164 | } 165 | HotRodServerConfigurationBuilder serverBuilder = new HotRodServerConfigurationBuilder(); 166 | serverBuilder.adminOperationsHandler(new EmbeddedServerAdminOperationHandler()); 167 | hotRodServer = HotRodTestingUtil.startHotRodServer(ecm, host, port, serverBuilder); 168 | } 169 | } 170 | 171 | public void stop() { 172 | if (hotRodServer != null) { 173 | hotRodServer.stop(); 174 | } 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/java/test/org/infinispan/spring/starter/remote/testconfiguration/InfinispanCacheTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package test.org.infinispan.spring.starter.remote.testconfiguration; 2 | 3 | import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; 4 | import org.infinispan.spring.starter.remote.InfinispanRemoteConfigurer; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class InfinispanCacheTestConfiguration { 10 | 11 | public static final int PORT = 11555; 12 | 13 | @Bean 14 | public InfinispanRemoteConfigurer infinispanRemoteConfigurer() { 15 | return () -> new ConfigurationBuilder().statistics().disable().addServer().host("127.0.0.1").port(PORT).build(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/resources/custom-test-hotrod-client.properties: -------------------------------------------------------------------------------- 1 | # connection 2 | infinispan.client.hotrod.server_list=127.0.0.1:6667 3 | infinispan.client.hotrod.tcp_no_delay=false 4 | infinispan.client.hotrod.tcp_keep_alive=true 5 | infinispan.client.hotrod.client_intelligence=TOPOLOGY_AWARE 6 | infinispan.client.hotrod.socket_timeout=3000 7 | infinispan.client.hotrod.connect_timeout=5000 8 | infinispan.client.hotrod.max_retries=42 9 | infinispan.client.hotrod.batch_size=90 10 | infinispan.client.hotrod.protocol_version=2.8 11 | 12 | # connection pool 13 | infinispan.client.hotrod.connection_pool.max_active=91 14 | infinispan.client.hotrod.connection_pool.exhausted_action=EXCEPTION 15 | infinispan.client.hotrod.connection_pool.max_wait=20001 16 | infinispan.client.hotrod.connection_pool.min_idle=1001 17 | infinispan.client.hotrod.connection_pool.min_evictable_idle_time=9001 18 | infinispan.client.hotrod.connection_pool.max_pending_requests=846 19 | 20 | # thread pool 21 | infinispan.client.hotrod.async_executor_factory=org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory 22 | infinispan.client.hotrod.default_executor_factory.pool_size=88 23 | 24 | # marshalling 25 | #infinispan.client.hotrod.marshaller=org.infinispan.commons.marshall.jboss.GenericJBossMarshaller 26 | infinispan.client.hotrod.key_size_estimate=123456 27 | infinispan.client.hotrod.value_size_estimate=789012 28 | infinispan.client.hotrod.force_return_values=true 29 | infinispan.client.hotrod.java_serial_whitelist=SERIAL-KILLER 30 | 31 | # encryption 32 | infinispan.client.hotrod.use_ssl=true 33 | infinispan.client.hotrod.key_store_file_name=keyStoreFile 34 | infinispan.client.hotrod.key_store_type=JKS 35 | infinispan.client.hotrod.key_store_password=keyStorePass 36 | infinispan.client.hotrod.key_alias=aliasKey 37 | infinispan.client.hotrod.key_store_certificate_password=rococoyes 38 | infinispan.client.hotrod.trust_store_file_name=trustFileName 39 | # mutually exclusive with trust_store_file_name -> infinispan.client.hotrod.trust_store_path=/path/trust 40 | infinispan.client.hotrod.trust_store_type=LOL 41 | infinispan.client.hotrod.trust_store_password=trusStorePass 42 | infinispan.client.hotrod.sni_host_name=oihost 43 | infinispan.client.hotrod.ssl_protocol=TLSv1.3 44 | 45 | # authentication 46 | infinispan.client.hotrod.use_auth=true 47 | infinispan.client.hotrod.sasl_mechanism=DIGEST-MD5 48 | infinispan.client.hotrod.auth_username=elaia 49 | infinispan.client.hotrod.auth_password=elapass 50 | infinispan.client.hotrod.auth_realm=elarealm 51 | infinispan.client.hotrod.auth_server_name=my_ela_server_name 52 | infinispan.client.hotrod.sasl_properties.prop1=value1 53 | 54 | # transactions 55 | infinispan.client.hotrod.transaction.transaction_mode=FULL_XA 56 | infinispan.client.hotrod.transaction.timeout=50001 57 | 58 | # near cache 59 | infinispan.client.hotrod.near_cache.mode=INVALIDATED 60 | infinispan.client.hotrod.near_cache.max_entries=10000 61 | infinispan.client.hotrod.near_cache.name_pattern=nearSuperCache* 62 | 63 | #xsite 64 | infinispan.client.hotrod.cluster.siteA=hostA1:11222; hostA2:11223 65 | infinispan.client.hotrod.cluster.siteB=hostB1:11224; hostB2:11225 66 | 67 | # statistics 68 | infinispan.client.hotrod.statistics=true 69 | infinispan.client.hotrod.jmx=true 70 | infinispan.client.hotrod.jmx_name=elaJmx 71 | infinispan.client.hotrod.jmx_domain=elaJmxDom2 -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 25 | 26 | 27 | 28 | 29 | 30 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 31 | 32 | target/infinispan-spring-boot-starter-test-remote.log 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/resources/test-application.properties: -------------------------------------------------------------------------------- 1 | # Infinispan 2 | infinispan.remote.server-list=180.567.112.333:6668 3 | infinispan.remote.tcp-no-delay=false 4 | infinispan.remote.tcp-keep-alive=true 5 | infinispan.remote.client-intelligence=TOPOLOGY_AWARE 6 | infinispan.remote.socket-timeout=500 7 | infinispan.remote.connect-timeout=200 8 | infinispan.remote.max-retries=30 9 | infinispan.remote.batch-size=91 10 | infinispan.remote.protocol-version=2.4 11 | 12 | # pool 13 | infinispan.remote.connection-pool-max-active=90 14 | infinispan.remote.connection-pool-exhausted-action=CREATE_NEW 15 | infinispan.remote.connection-pool-max-wait=20000 16 | infinispan.remote.connection-pool-min-idle=1000 17 | infinispan.remote.connection-pool-min-evictable-idle-time=9000 18 | infinispan.remote.connection-pool-max-pending-requests=845 19 | 20 | # thread pool 21 | infinispan.remote.default-executor-factory-pool-size=89 22 | 23 | # marshalling 24 | #infinispan.client.hotrod.marshaller=org.infinispan.commons.marshall.jboss.GenericJBossMarshaller 25 | infinispan.remote.key-size-estimate=88889 26 | infinispan.remote.value-size-estimate=11112 27 | infinispan.remote.force-return-values=true 28 | infinispan.remote.java-serial-whitelist=APP-KILLER1,APP-KILLER2 29 | 30 | # encryption 31 | infinispan.remote.use-ssl=true 32 | infinispan.remote.key-store-file-name=superKeyStoreFile 33 | infinispan.remote.key-store-type=SKL 34 | infinispan.remote.key-store-password=superKeyStorePass 35 | infinispan.remote.key-alias=superAliasKey 36 | infinispan.remote.key-store-certificate-password=superYeahcool 37 | # mutually exclusive with trust-store-file-name -> infinispan.remote.trust-store-path=/path/trust 38 | infinispan.remote.trust-store-file-name=superTrustFileName 39 | infinispan.remote.trust-store-type=CKO 40 | infinispan.remote.trust-store-password=superTrusStorePass 41 | infinispan.remote.sni-host-name=elahost 42 | infinispan.remote.ssl-protocol=TLSv1.4 43 | 44 | # authentication 45 | infinispan.remote.use-auth=true 46 | infinispan.remote.sasl-mechanism=my-sasl-mechanism 47 | infinispan.remote.auth-user-name=oihana 48 | infinispan.remote.auth-password=oipass 49 | infinispan.remote.auth-realm=oirealm 50 | infinispan.remote.auth-server-name=my-server-name 51 | infinispan.remote.sasl-properties.prop1=value1 52 | infinispan.remote.sasl-properties.prop2=value2 53 | 54 | # transactions 55 | infinispan.remote.transaction-mode=NON_DURABLE_XA 56 | infinispan.remote.transaction-timeout=50000 57 | 58 | # near cache 59 | infinispan.remote.near-cache-mode=INVALIDATED 60 | infinispan.remote.near-cache-max-entries=2000 61 | infinispan.remote.near-cache-name-pattern=appCache* 62 | 63 | infinispan.remote.cluster.siteOi=hostOi1:21222; hostOi2:21223 64 | 65 | # statistics 66 | infinispan.remote.statistics=true 67 | infinispan.remote.jmx=true 68 | infinispan.remote.jmx-name=oiJmx 69 | infinispan.remote.jmx-domain=oiJmxDom -------------------------------------------------------------------------------- /infinispan-spring-boot-starter-remote/src/test/resources/test-hotrod-client.properties: -------------------------------------------------------------------------------- 1 | # connection 2 | infinispan.client.hotrod.server_list=127.0.0.1:6667 3 | infinispan.client.hotrod.tcp_no_delay=false 4 | infinispan.client.hotrod.tcp_keep_alive=true 5 | infinispan.client.hotrod.client_intelligence=TOPOLOGY_AWARE 6 | infinispan.client.hotrod.socket_timeout=3000 7 | infinispan.client.hotrod.connect_timeout=5000 8 | infinispan.client.hotrod.max_retries=42 9 | infinispan.client.hotrod.batch_size=90 10 | infinispan.client.hotrod.protocol_version=2.8 11 | 12 | # connection pool 13 | infinispan.client.hotrod.connection_pool.max_active=91 14 | infinispan.client.hotrod.connection_pool.exhausted_action=EXCEPTION 15 | infinispan.client.hotrod.connection_pool.max_wait=20001 16 | infinispan.client.hotrod.connection_pool.min_idle=1001 17 | infinispan.client.hotrod.connection_pool.min_evictable_idle_time=9001 18 | infinispan.client.hotrod.connection_pool.max_pending_requests=846 19 | 20 | # thread pool 21 | infinispan.client.hotrod.async_executor_factory=org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory 22 | infinispan.client.hotrod.default_executor_factory.pool_size=88 23 | 24 | # marshalling 25 | #infinispan.client.hotrod.marshaller=org.infinispan.commons.marshall.jboss.GenericJBossMarshaller 26 | infinispan.client.hotrod.key_size_estimate=123456 27 | infinispan.client.hotrod.value_size_estimate=789012 28 | infinispan.client.hotrod.force_return_values=true 29 | infinispan.client.hotrod.java_serial_whitelist=SERIAL-KILLER 30 | 31 | # encryption 32 | infinispan.client.hotrod.use_ssl=true 33 | infinispan.client.hotrod.key_store_file_name=keyStoreFile 34 | infinispan.client.hotrod.key_store_type=JKS 35 | infinispan.client.hotrod.key_store_password=keyStorePass 36 | infinispan.client.hotrod.key_alias=aliasKey 37 | infinispan.client.hotrod.key_store_certificate_password=rococoyes 38 | infinispan.client.hotrod.trust_store_file_name=trustFileName 39 | # mutually exclusive with trust_store_file_name -> infinispan.client.hotrod.trust_store_path=/path/trust 40 | infinispan.client.hotrod.trust_store_type=LOL 41 | infinispan.client.hotrod.trust_store_password=trusStorePass 42 | infinispan.client.hotrod.sni_host_name=oihost 43 | infinispan.client.hotrod.ssl_protocol=TLSv1.3 44 | 45 | # authentication 46 | infinispan.client.hotrod.use_auth=true 47 | infinispan.client.hotrod.sasl_mechanism=DIGEST-MD5 48 | infinispan.client.hotrod.auth_username=elaia 49 | infinispan.client.hotrod.auth_password=elapass 50 | infinispan.client.hotrod.auth_realm=elarealm 51 | infinispan.client.hotrod.auth_server_name=my_ela_server_name 52 | infinispan.client.hotrod.sasl_properties.prop1=value1 53 | 54 | # transactions 55 | infinispan.client.hotrod.transaction.transaction_mode=FULL_XA 56 | infinispan.client.hotrod.transaction.timeout=50001 57 | 58 | # near cache 59 | infinispan.client.hotrod.near_cache.mode=INVALIDATED 60 | infinispan.client.hotrod.near_cache.max_entries=10000 61 | infinispan.client.hotrod.near_cache.name_pattern=nearSuperCache* 62 | 63 | #xsite 64 | infinispan.client.hotrod.cluster.siteA=hostA1:11222; hostA2:11223 65 | infinispan.client.hotrod.cluster.siteB=hostB1:11224; hostB2:11225 66 | 67 | # statistics 68 | infinispan.client.hotrod.statistics=true 69 | infinispan.client.hotrod.jmx=true 70 | infinispan.client.hotrod.jmx_name=elaJmx 71 | infinispan.client.hotrod.jmx_domain=elaJmxDom -------------------------------------------------------------------------------- /infinispan-spring-boot-starter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.infinispan 7 | infinispan-spring-boot-starter-parent 8 | 2.3.7-SNAPSHOT 9 | 10 | 11 | Infinispan Spring Boot Starter Integration Test 12 | infinispan-spring-boot-starter 13 | 14 | 15 | 16 | org.infinispan 17 | infinispan-spring-boot-starter-embedded 18 | ${project.version} 19 | 20 | 21 | 22 | org.infinispan 23 | infinispan-spring-boot-starter-remote 24 | ${project.version} 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | org.assertj 35 | assertj-core 36 | test 37 | 38 | 39 | 40 | org.junit.jupiter 41 | junit-jupiter-api 42 | test 43 | 44 | 45 | org.junit.jupiter 46 | junit-jupiter-engine 47 | test 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter/src/test/java/test/infinispan/autoconfigure/CacheDisabledTest.java: -------------------------------------------------------------------------------- 1 | package test.infinispan.autoconfigure; 2 | 3 | import org.infinispan.client.hotrod.RemoteCacheManager; 4 | import org.infinispan.manager.DefaultCacheManager; 5 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 6 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 7 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 8 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | import org.springframework.beans.factory.NoSuchBeanDefinitionException; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.context.ApplicationContext; 16 | 17 | @SpringBootTest( 18 | classes = { 19 | CacheAutoConfiguration.class, 20 | InfinispanRemoteAutoConfiguration.class, 21 | InfinispanRemoteCacheManagerAutoConfiguration.class, 22 | InfinispanEmbeddedAutoConfiguration.class, 23 | InfinispanEmbeddedCacheManagerAutoConfiguration.class 24 | }, 25 | properties = { 26 | "spring.cache.type=NONE", 27 | "infinispan.remote.server-list=127.0.0.1:6667" 28 | }) 29 | public class CacheDisabledTest { 30 | @Autowired 31 | private ApplicationContext context; 32 | 33 | @Test 34 | public void testDefaultCacheManager() { 35 | Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> { 36 | context.getBean(DefaultCacheManager.class); 37 | }); 38 | } 39 | 40 | @Test 41 | public void testRemoteCacheManager() { 42 | Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> { 43 | context.getBean(RemoteCacheManager.class); 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter/src/test/java/test/infinispan/autoconfigure/CacheManagerTest.java: -------------------------------------------------------------------------------- 1 | package test.infinispan.autoconfigure; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import org.infinispan.client.hotrod.RemoteCacheManager; 6 | import org.infinispan.manager.DefaultCacheManager; 7 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedAutoConfiguration; 8 | import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; 9 | import org.infinispan.spring.starter.remote.InfinispanRemoteAutoConfiguration; 10 | import org.infinispan.spring.starter.remote.InfinispanRemoteCacheManagerAutoConfiguration; 11 | import org.junit.jupiter.api.Test; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | import org.springframework.context.ApplicationContext; 15 | 16 | @SpringBootTest( 17 | classes = { 18 | InfinispanRemoteAutoConfiguration.class, 19 | InfinispanRemoteCacheManagerAutoConfiguration.class, 20 | InfinispanEmbeddedAutoConfiguration.class, 21 | InfinispanEmbeddedCacheManagerAutoConfiguration.class 22 | }, 23 | properties = { 24 | "infinispan.remote.server-list=127.0.0.1:6667" 25 | }) 26 | public class CacheManagerTest { 27 | @Autowired 28 | private ApplicationContext context; 29 | 30 | @Test 31 | public void testRemoteCacheManager() { 32 | assertNotNull(context.getBean(RemoteCacheManager.class)); 33 | } 34 | 35 | @Test 36 | public void testDefaultCacheManager() { 37 | assertNotNull(context.getBean(DefaultCacheManager.class)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.main.banner-mode=off 2 | -------------------------------------------------------------------------------- /infinispan-spring-boot-starter/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 25 | 26 | 27 | 28 | 29 | 30 | %d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n 31 | 32 | target/infinispan-spring-boot-starter-test.log 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.infinispan 7 | infinispan-build-configuration-parent 8 | 11.0.9.Final 9 | 10 | 11 | org.infinispan 12 | infinispan-spring-boot-starter-parent 13 | 2.3.7-SNAPSHOT 14 | pom 15 | 16 | Infinispan Spring Boot Starter Parent 17 | Infinispan Spring Boot Starter parent POM 18 | https://github.com/infinispan/infinispan-spring-boot 19 | 20 | 21 | 22 | Apache License, Version 2.0 23 | https://www.apache.org/licenses/LICENSE-2.0.txt 24 | repo 25 | 26 | 27 | 28 | 29 | 30 | placeholder 31 | See https://github.com/infinispan/infinispan-spring-boot for a complete list of contributors 32 | 33 | 34 | 35 | 36 | Jenkins 37 | https://ci.infinispan.org 38 | 39 | 40 | 41 | jira 42 | https://issues.jboss.org/browse/ISPN 43 | 44 | 45 | 46 | scm:git:git@github.com:infinispan/infinispan-spring-boot.git 47 | scm:git:git@github.com:infinispan/infinispan-spring-boot.git 48 | https://github.com/infinispan/infinispan-spring-boot 49 | HEAD 50 | 51 | 52 | 53 | UTF-8 54 | 1.8 55 | 1.8 56 | 57 | 2.3.4.RELEASE 58 | 11.0.9.Final 59 | 3.12.1 60 | ${version.junit5} 61 | 1.14.0 62 | Infinispan Spring Boot 63 | https://repository.jboss.org/nexus 64 | jboss-releases-repository 65 | ${jboss.releases.nexus.url}/service/local/staging/deploy/maven2/ 66 | 3.0.0-M3 67 | ${versionx.com.puppycrawl.tools.checkstyle} 68 | 69 | 70 | 71 | 72 | 73 | nexus-staging 74 | 75 | !skipNexusStaging 76 | 77 | 78 | 79 | 80 | org.sonatype.plugins 81 | nexus-staging-maven-plugin 82 | true 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 94 | 95 | org.infinispan 96 | infinispan-bom 97 | ${infinispan.version} 98 | pom 99 | import 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-dependencies 104 | ${spring-boot.version} 105 | pom 106 | import 107 | 108 | 109 | org.assertj 110 | assertj-core 111 | ${assertj.version} 112 | 113 | 114 | org.junit.jupiter 115 | junit-jupiter-api 116 | ${junit.jupiter.version} 117 | 118 | 119 | org.junit.jupiter 120 | junit-jupiter-engine 121 | ${junit.jupiter.version} 122 | 123 | 124 | com.puppycrawl.tools 125 | checkstyle 126 | ${version.checkstyle} 127 | 128 | 129 | org.testcontainers 130 | testcontainers 131 | ${testcontainers.version} 132 | 133 | 134 | org.testcontainers 135 | junit-jupiter 136 | ${testcontainers.version} 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | maven-scm-plugin 146 | 1.9.5 147 | 148 | ${project.version} 149 | 150 | 151 | 152 | maven-source-plugin 153 | ${version.maven.source} 154 | 155 | 156 | org.sonatype.plugins 157 | nexus-staging-maven-plugin 158 | 1.6.8 159 | 160 | false 161 | ${infinispan-springboot.brand.name} ${project.version} release 162 | ${jboss.releases.nexus.url} 163 | ${jboss.releases.repo.id} 164 | 2161b7b8da0080 165 | ${stagingRepositoryId} 166 | 167 | 168 | 169 | org.apache.maven.plugins 170 | maven-checkstyle-plugin 171 | ${version.checkstyle.maven-plugin} 172 | 173 | 174 | com.puppycrawl.tools 175 | checkstyle 176 | ${versionx.com.puppycrawl.tools.checkstyle} 177 | 178 | 179 | org.infinispan 180 | infinispan-checkstyle 181 | ${infinispan.version} 182 | 183 | 184 | 185 | 186 | checkstyle.xml 187 | true 188 | true 189 | error 190 | true 191 | 192 | ${project.build.sourceDirectory} 193 | 194 | false 195 | 196 | 197 | 198 | 199 | 200 | 201 | org.apache.maven.plugins 202 | maven-checkstyle-plugin 203 | 204 | 205 | checkstyle 206 | verify 207 | 208 | checkstyle 209 | 210 | 211 | 212 | 213 | 214 | org.apache.maven.plugins 215 | maven-surefire-plugin 216 | ${version.maven.surefire} 217 | 218 | 219 | org.apache.maven.plugins 220 | maven-failsafe-plugin 221 | ${version.maven.failsafe} 222 | 223 | 224 | 225 | org.apache.maven.plugins 226 | maven-source-plugin 227 | 228 | 229 | attach-sources 230 | verify 231 | 232 | jar 233 | test-jar 234 | 235 | 236 | 237 | true 238 | 239 | 240 | 241 | 242 | 243 | infinispan-spring-boot-starter-embedded 244 | infinispan-spring-boot-starter-remote 245 | infinispan-spring-boot-starter 246 | 247 | 248 | --------------------------------------------------------------------------------