diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 0e62c82da..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: 2 -jobs: - build: - machine: - image: "ubuntu-2004:202201-02" - environment: - _JAVA_OPTIONS: "-Xms1024m -Xmx2048m" - TERM: dumb - branches: - ignore: - - gh-pages # list of branches to ignore - steps: - - run: - name: Install OpenJDK 17 - command: | - wget -qO - https://adoptium.jfrog.io/adoptium/api/gpg/key/public | sudo apt-key add - - sudo add-apt-repository --yes https://adoptium.jfrog.io/adoptium/deb/ - sudo apt-get update && sudo apt-get install temurin-17-jdk - sudo update-alternatives --set java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java - sudo update-alternatives --set javac /usr/lib/jvm/temurin-17-jdk-amd64/bin/javac - java -version - - checkout - - restore_cache: - key: sc-netflix-{{ .Branch }} - - run: - name: "Download dependencies" - command: ./mvnw -s .settings.xml -U --fail-never dependency:go-offline || true - - save_cache: - key: sc-netflix-{{ .Branch }} - paths: - - ~/.m2 - - run: - name: "Running build" - command: ./mvnw -s .settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn - - run: - name: "Aggregate test results" - when: always - command: | - mkdir -p ~/junit/ - find . -type f -regex ".*/target/.*-reports/.*" -exec cp {} ~/junit/ \; - bash <(curl -s https://codecov.io/bash) - - store_artifacts: - path: ~/junit/ - destination: artifacts - - store_test_results: - path: ~/junit/ - destination: testartifacts diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 323872eea..000000000 --- a/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -root=true - -[*.java] -indent_style = tab -indent_size = 4 -continuation_indent_size = 8 - -[*.groovy] -indent_style = tab -indent_size = 4 -continuation_indent_size = 8 - -[*.xml] -indent_style = tab -indent_size = 4 -continuation_indent_size = 8 \ No newline at end of file diff --git a/.flattened-pom.xml b/.flattened-pom.xml new file mode 100644 index 000000000..048af150a --- /dev/null +++ b/.flattened-pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-build + 4.1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + pom + Spring Cloud Netflix + Spring Cloud Netflix + https://spring.io/spring-cloud/spring-cloud-netflix + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git + https://github.com/spring-cloud/spring-cloud-netflix + + + + spring + + + + false + + + true + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + + + false + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + + + false + + spring-releases + Spring Releases + https://repo.spring.io/release + + + + + diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index b44059e78..000000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,45 +0,0 @@ - -# Contributing - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into main. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -## Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -[Contributor License Agreement](https://cla.pivotal.io/sign/spring). -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -## Code of Conduct -This project adheres to the Contributor Covenant [code of -conduct](https://github.com/spring-cloud/spring-cloud-build/blob/main/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -## Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - [Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the - [Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546) to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current main (or - other target branch in the main project). -* When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0bc5ef4fa..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 63bb5b66c..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: waiting-for-triage -assignees: '' - ---- - -**Describe the bug** -Please provide details of the problem, including the version of Spring Cloud that you -are using. - -**Sample** -If possible, please provide a test case or sample application that reproduces -the problem. This makes it much easier for us to diagnose the problem and to verify that -we have fixed it. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d6..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 000000000..433fe0d0c --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,53 @@ +name: Deploy Docs +run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} +on: + workflow_dispatch: + inputs: + build-refname: + description: Enter git refname to build (e.g., 5.7.x). + required: false + push: + branches: docs-build +env: + GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} +permissions: + contents: write +jobs: + build: + if: github.repository_owner == 'spring-cloud' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 5 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up refname build + if: github.event.inputs.build-refname + run: | + git fetch --depth 1 https://github.com/$GITHUB_REPOSITORY ${{ github.event.inputs.build-refname }} + export BUILD_REFNAME=${{ github.event.inputs.build-refname }} + echo "BUILD_REFNAME=$BUILD_REFNAME" >> $GITHUB_ENV + export BUILD_VERSION=$(git cat-file --textconv FETCH_HEAD:pom.xml | python3 -c "import xml.etree.ElementTree as xml; from sys import stdin; print(xml.parse(stdin).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)") + echo BUILD_VERSION=$BUILD_VERSION >> $GITHUB_ENV + - name: Run Antora + run: | + ./mvnw --no-transfer-progress -B antora + - name: Publish Docs + uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.11 + with: + docs-username: ${{ secrets.DOCS_USERNAME }} + docs-host: ${{ secrets.DOCS_HOST }} + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} + site-path: target/antora/site + - name: Bust Cloudflare Cache + uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.11 + with: + context-root: spring-cloud-netflix + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.gitignore b/.gitignore index af22db416..6be8a4a16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,22 @@ -*~ -#* -*# -.#* -.classpath -.project -.settings/ -.springBeans target/ -bin/ -_site/ -.idea +.settings/ +.project +.classpath +*.orig +.springBeans +.factorypath +.sts4-cache +.ant-targets-build.xml +src/ant/.ant-targets-upload-dist.xml +*.sonar4clipse* +.DS_Store *.iml *.ipr *.iws -.factorypath -*.log -.shelf -*.swp -*.swo -.vscode/ -.flattened-pom.xml +/.idea/ +*.graphml +node +node_modules +build +package.json +package-lock.json diff --git a/.java-version b/.java-version deleted file mode 100644 index 98d9bcb75..000000000 --- a/.java-version +++ /dev/null @@ -1 +0,0 @@ -17 diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index 4b9372844..000000000 --- a/.mvn/maven.config +++ /dev/null @@ -1,2 +0,0 @@ --DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local --P spring diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 000000000..b901097f2 --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index cb28b0e37..2cc7d4a55 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties old mode 100755 new mode 100644 index ac184013f..642d572ce --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,18 +1,2 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/.sdkmanrc b/.sdkmanrc deleted file mode 100644 index 415f90832..000000000 --- a/.sdkmanrc +++ /dev/null @@ -1,3 +0,0 @@ -# Enable auto-env through the sdkman_auto_env config -# Add key=value pairs of SDKs to use below -java=17.0.1-tem diff --git a/.settings.xml b/.settings.xml deleted file mode 100644 index 08951cafd..000000000 --- a/.settings.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - true - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 62589edd1..000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.adoc b/README.adoc index 8467017a4..c40586721 100644 --- a/README.adoc +++ b/README.adoc @@ -1,379 +1,23 @@ -//// -DO NOT EDIT THIS FILE. IT WAS GENERATED. -Manual changes to this file will be lost when it is generated again. -Edit the files in the src/main/asciidoc/ directory instead. -//// += Spring Cloud Netflix Docs Build +You're currently viewing the Antora playbook branch. +The playbook branch hosts the docs build that is used to build and publish the production docs site. -:doctype: book -:idprefix: -:idseparator: - -:toc: left -:toclevels: 4 -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private +The Spring Cloud Netflix reference docs are built using https://antora.org[Antora]. +This README covers how to build the docs in a software branch as well as how to build the production docs site locally. -:sc-ext: java -:project-full-name: Spring Cloud Netflix +== Building the Site -image::https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main"] -image::https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main"] - - -:doctype: book -:idprefix: -:idseparator: - -:toc: left -:toclevels: 4 -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud Netflix - -This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. With a few -simple annotations you can quickly enable and configure the common patterns inside your -application and build large distributed systems with battle-tested Netflix components. The -patterns provided include Service Discovery (Eureka). - - -== Features - -* Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans -* Service Discovery: an embedded Eureka server can be created with declarative Java configuration - - -== Building - - -:jdkversion: 17 - -=== Basic Compile and Test - -To build the source you will need to install JDK {jdkversion}. - -Spring Cloud uses Maven for most build-related activities, and you -should be able to get off the ground quite quickly by cloning the -project you are interested in and typing +You can build the entire site by invoking the following on the docs-build branch and then viewing the site at `target/site/index.html` +[source,bash] ---- -$ ./mvnw install +./mvnw antora ---- -NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command -in place of `./mvnw` in the examples below. If you do that you also -might need to add `-P spring` if your local Maven settings do not -contain repository declarations for spring pre-release artifacts. +== Building a Specific Branch -NOTE: Be aware that you might need to increase the amount of memory -available to Maven by setting a `MAVEN_OPTS` environment variable with -a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in -the `.mvn` configuration, so if you find you have to do it to make a -build succeed, please raise a ticket to get the settings added to -source control. - -The projects that require middleware (i.e. Redis) for testing generally -require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running. - - -=== Documentation - -The spring-cloud-build module has a "docs" profile, and if you switch -that on it will try to build asciidoc sources from -`src/main/asciidoc`. As part of that process it will look for a -`README.adoc` and process it by loading all the includes, but not -parsing or rendering it, just copying it to `${main.basedir}` -(defaults to `${basedir}`, i.e. the root of the project). If there are -any changes in the README it will then show up after a Maven build as -a modified file in the correct place. Just commit it and push the change. - -=== Working with the code -If you don't have an IDE preference we would recommend that you use -https://www.springsource.com/developer/sts[Spring Tools Suite] or -https://eclipse.org[Eclipse] when working with the code. We use the -https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools -should also work without issue as long as they use Maven 3.3.3 or better. - -==== Activate the Spring Maven profile -Spring Cloud projects require the 'spring' Maven profile to be activated to resolve -the spring milestone and snapshot repositories. Use your preferred IDE to set this -profile to be active, or you may experience build errors. - -==== Importing into eclipse with m2eclipse -We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with -eclipse. If you don't already have m2eclipse installed it is available from the "eclipse -marketplace". - -NOTE: Older versions of m2e do not support Maven 3.3, so once the -projects are imported into Eclipse you will also need to tell -m2eclipse to use the right profile for the projects. If you -see many different errors related to the POMs in the projects, check -that you have an up to date installation. If you can't upgrade m2e, -add the "spring" profile to your `settings.xml`. Alternatively you can -copy the repository settings from the "spring" profile of the parent -pom into your `settings.xml`. - -==== Importing into eclipse without m2eclipse -If you prefer not to use m2eclipse you can generate eclipse project metadata using the -following command: - -[indent=0] +[source,bash] ---- - $ ./mvnw eclipse:eclipse +./mvnw antora ---- - -The generated eclipse projects can be imported by selecting `import existing projects` -from the `file` menu. - - - -NOTE: To build the module `spring-cloud-netflix-hystrix-contract` along with the entire Netflix project run the -`build.sh` script in the `scripts` directory. - -== Contributing - -:spring-cloud-build-branch: master - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -=== Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -=== Code of Conduct -This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of -conduct]. By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -=== Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring - Cloud Build] project. If using IntelliJ, you can use the - https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter - Plugin] to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). - -=== Checkstyle - -Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are: - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    └── checkstyle.xml <1> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules - -==== Checkstyle configuration - -Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins. - -.pom.xml ----- - -true <1> - true - <2> - true - <3> - - - - - <4> - io.spring.javaformat - spring-javaformat-maven-plugin - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - ----- -<1> Fails the build upon Checkstyle errors -<2> Fails the build upon Checkstyle violations -<3> Checkstyle analyzes also the test sources -<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules -<5> Add checkstyle plugin to your build and reporting phases - -If you need to suppress some rules (e.g. line length needs to be longer), then it's enough for you to define a file under `${project.root}/src/checkstyle/checkstyle-suppressions.xml` with your suppressions. Example: - -.projectRoot/src/checkstyle/checkstyle-suppresions.xml ----- - - - - - - ----- - -It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script: - -```bash -$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig -$ touch .springformat -``` - -=== IDE setup - -==== Intellij IDEA - -In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. -The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project. - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    ├── checkstyle.xml <1> -    └── intellij -       ├── Intellij_Project_Defaults.xml <4> -       └── Intellij_Spring_Boot_Java_Conventions.xml <5> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules -<4> Project defaults for Intellij that apply most of Checkstyle rules -<5> Project style conventions for Intellij that apply most of Checkstyle rules - -.Code style - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file. - -.Inspection profiles - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file. - -.Checkstyle - -To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle] - -Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables: - -- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL. -- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. -- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. - -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. - -=== Duplicate Finder - -Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath. - -==== Duplicate Finder configuration - -Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`. - -.pom.xml -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - ----- - -For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation]. - -You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build. - -If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project: - -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - org.joda.time.base.BaseDateTime - .*module-info - - - changelog.txt - - - - - - - ----- - - -== License - -The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-netflix/main/LICENSE.txt[here]. diff --git a/docs/antora-playbook.yml b/antora-playbook.yml similarity index 61% rename from docs/antora-playbook.yml rename to antora-playbook.yml index 9a70e676c..fd1c5da52 100644 --- a/docs/antora-playbook.yml +++ b/antora-playbook.yml @@ -6,38 +6,39 @@ antora: - '@antora/collector-extension' - '@antora/atlas-extension' - require: '@springio/antora-extensions/root-component-extension' - root_component_name: 'PROJECT_WITHOUT_SPRING' - # FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax - # and then remove this extension - - require: '@springio/antora-extensions/tabs-migration-extension' - unwrap_example_block: always - save_result: true + root_component_name: 'cloud-netflix' site: - title: PROJECT_FULL_NAME - url: https://docs.spring.io/PROJECT_NAME/reference/ + title: Spring Cloud Netflix + url: https://docs.spring.io/spring-cloud-netflix/reference + robots: allow +git: + ensure_git_suffix: false content: sources: - - url: ./.. - branches: HEAD + - url: https://github.com/spring-cloud/spring-cloud-netflix + # Refname matching: + # https://docs.antora.org/antora/latest/playbook/content-refname-matching/ + branches: [ main ] + tags: [ '({4..9}).+({1..9}).+({0..9})?(-{RC,M}+({0..9}))', '!4.1.0-M1' ] start_path: docs - worktrees: true asciidoc: attributes: page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud page-pagination: '' hide-uri-scheme: '@' tabs-sync-option: '@' - chomp: 'all' extensions: - '@asciidoctor/tabs' - '@springio/asciidoctor-extensions' - sourcemap: true urls: + latest_version_segment_strategy: redirect:to latest_version_segment: '' + redirect_facility: httpd +ui: + bundle: + url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip + snapshot: true runtime: log: failure_level: warn format: pretty -ui: - bundle: - url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip diff --git a/asciidoctor.css b/asciidoctor.css deleted file mode 100644 index 58c68541c..000000000 --- a/asciidoctor.css +++ /dev/null @@ -1,399 +0,0 @@ -/* Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */ -/* Remove the comments around the @import statement below when using this as a custom stylesheet */ -/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic|Noto+Serif:400,400italic,700,700italic|Droid+Sans+Mono:400";*/ -article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block} -audio,canvas,video{display:inline-block} -audio:not([controls]){display:none;height:0} -[hidden],template{display:none} -script{display:none!important} -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%} -body{margin:0} -a{background:transparent} -a:focus{outline:thin dotted} -a:active,a:hover{outline:0} -h1{font-size:2em;margin:.67em 0} -abbr[title]{border-bottom:1px dotted} -b,strong{font-weight:bold} -dfn{font-style:italic} -hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0} -mark{background:#ff0;color:#000} -code,kbd,pre,samp{font-family:monospace;font-size:1em} -pre{white-space:pre-wrap} -q{quotes:"\201C" "\201D" "\2018" "\2019"} -small{font-size:80%} -sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline} -sup{top:-.5em} -sub{bottom:-.25em} -img{border:0} -svg:not(:root){overflow:hidden} -figure{margin:0} -fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em} -legend{border:0;padding:0} -button,input,select,textarea{font-family:inherit;font-size:100%;margin:0} -button,input{line-height:normal} -button,select{text-transform:none} -button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer} -button[disabled],html input[disabled]{cursor:default} -input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0} -input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box} -input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none} -button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0} -textarea{overflow:auto;vertical-align:top} -table{border-collapse:collapse;border-spacing:0} -*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box} -html,body{font-size:100%} -body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto} -a:hover{cursor:pointer} -img,object,embed{max-width:100%;height:auto} -object,embed{height:100%} -img{-ms-interpolation-mode:bicubic} -#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none!important} -.left{float:left!important} -.right{float:right!important} -.text-left{text-align:left!important} -.text-right{text-align:right!important} -.text-center{text-align:center!important} -.text-justify{text-align:justify!important} -.hide{display:none} -.antialiased,body{-webkit-font-smoothing:antialiased} -img{display:inline-block;vertical-align:middle} -textarea{height:auto;min-height:50px} -select{width:100%} -p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6} -.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em} -div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr} -a{color:#2156a5;text-decoration:underline;line-height:inherit} -a:hover,a:focus{color:#1d4b8f} -a img{border:none} -p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility} -p aside{font-size:.875em;line-height:1.35;font-style:italic} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em} -h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0} -h1{font-size:2.125em} -h2{font-size:1.6875em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em} -h4,h5{font-size:1.125em} -h6{font-size:1em} -hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0} -em,i{font-style:italic;line-height:inherit} -strong,b{font-weight:bold;line-height:inherit} -small{font-size:60%;line-height:inherit} -code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)} -ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit} -ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em} -ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em} -ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit} -ul.square{list-style-type:square} -ul.circle{list-style-type:circle} -ul.disc{list-style-type:disc} -ul.no-bullet{list-style:none} -ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0} -dl dt{margin-bottom:.3125em;font-weight:bold} -dl dd{margin-bottom:1.25em} -abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help} -abbr{text-transform:none} -blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} -blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} -blockquote cite:before{content:"\2014 \0020"} -blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} -blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} -@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2} -h1{font-size:2.75em} -h2{font-size:2.3125em} -h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em} -h4{font-size:1.4375em}}table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} -table thead,table tfoot{background:#f7f8f7;font-weight:bold} -table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} -table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} -table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} -table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} -h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em} -h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400} -.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table} -.clearfix:after,.float-group:after{clear:both} -*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed} -pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed} -.keyseq{color:rgba(51,51,51,.8)} -kbd{display:inline-block;color:rgba(0,0,0,.8);font-size:.75em;line-height:1.4;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:-.15em .15em 0 .15em;padding:.2em .6em .2em .5em;vertical-align:middle;white-space:nowrap} -.keyseq kbd:first-child{margin-left:0} -.keyseq kbd:last-child{margin-right:0} -.menuseq,.menu{color:rgba(0,0,0,.8)} -b.button:before,b.button:after{position:relative;top:-1px;font-weight:400} -b.button:before{content:"[";padding:0 3px 0 2px} -b.button:after{content:"]";padding:0 2px 0 3px} -p a>code:hover{color:rgba(0,0,0,.9)} -#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em} -#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table} -#header:after,#content:after,#footnotes:after,#footer:after{clear:both} -#content{margin-top:1.25em} -#content:before{content:none} -#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0} -#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8} -#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px} -#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap} -#header .details span:first-child{margin-left:-.125em} -#header .details span.email a{color:rgba(0,0,0,.85)} -#header .details br{display:none} -#header .details br+span:before{content:"\00a0\2013\00a0"} -#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)} -#header .details br+span#revremark:before{content:"\00a0|\00a0"} -#header #revnumber{text-transform:capitalize} -#header #revnumber:after{content:"\00a0"} -#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem} -#toc{border-bottom:1px solid #efefed;padding-bottom:.5em} -#toc>ul{margin-left:.125em} -#toc ul.sectlevel0>li>a{font-style:italic} -#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0} -#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none} -#toc a{text-decoration:none} -#toc a:active{text-decoration:underline} -#toctitle{color:#7a2518;font-size:1.2em} -@media only screen and (min-width:768px){#toctitle{font-size:1.375em} -body.toc2{padding-left:15em;padding-right:0} -#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto} -#toc.toc2 #toctitle{margin-top:0;font-size:1.2em} -#toc.toc2>ul{font-size:.9em;margin-bottom:0} -#toc.toc2 ul ul{margin-left:0;padding-left:1em} -#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em} -body.toc2.toc-right{padding-left:0;padding-right:15em} -body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0} -#toc.toc2{width:20em} -#toc.toc2 #toctitle{font-size:1.375em} -#toc.toc2>ul{font-size:.95em} -#toc.toc2 ul ul{padding-left:1.25em} -body.toc2.toc-right{padding-left:0;padding-right:20em}}#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -#content #toc>:first-child{margin-top:0} -#content #toc>:last-child{margin-bottom:0} -#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em} -#footer-text{color:rgba(255,255,255,.8);line-height:1.44} -.sect1{padding-bottom:.625em} -@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}}.sect1+.sect1{border-top:1px solid #efefed} -#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400} -#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em} -#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible} -#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none} -#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221} -.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em} -.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic} -table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0} -.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)} -table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit} -.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%} -.admonitionblock>table td.icon{text-align:center;width:80px} -.admonitionblock>table td.icon img{max-width:none} -.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase} -.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)} -.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0} -.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px} -.exampleblock>.content>:first-child{margin-top:0} -.exampleblock>.content>:last-child{margin-bottom:0} -.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px} -.sidebarblock>:first-child{margin-top:0} -.sidebarblock>:last-child{margin-bottom:0} -.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center} -.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0} -.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8} -.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1} -.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em} -.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal} -@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)} -.listingblock pre.highlightjs{padding:0} -.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px} -.listingblock pre.prettyprint{border-width:0} -.listingblock>.content{position:relative} -.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999} -.listingblock:hover code[data-lang]:before{display:block} -.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999} -.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"} -table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none} -table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0} -table.pyhltable td.code{padding-left:.75em;padding-right:0} -pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8} -pre.pygments .lineno{display:inline-block;margin-right:.25em} -table.pyhltable .linenodiv{background:none!important;padding-right:0!important} -.quoteblock{margin:0 1em 1.25em 1.5em;display:table} -.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} -.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} -.quoteblock blockquote{margin:0;padding:0;border:0} -.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)} -.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} -.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} -.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} -.quoteblock .quoteblock blockquote{padding:0 0 0 .75em} -.quoteblock .quoteblock blockquote:before{display:none} -.verseblock{margin:0 1em 1.25em 1em} -.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility} -.verseblock pre strong{font-weight:400} -.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex} -.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} -.quoteblock .attribution br,.verseblock .attribution br{display:none} -.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.05em;color:rgba(0,0,0,.6)} -.quoteblock.abstract{margin:0 0 1.25em 0;display:block} -.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} -.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} -table.tableblock{max-width:100%;border-collapse:separate} -table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} -table.spread{width:100%} -table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} -table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} -table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} -table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} -table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} -table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} -table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} -table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} -table.frame-all{border-width:1px} -table.frame-sides{border-width:0 1px} -table.frame-topbot{border-width:1px 0} -th.halign-left,td.halign-left{text-align:left} -th.halign-right,td.halign-right{text-align:right} -th.halign-center,td.halign-center{text-align:center} -th.valign-top,td.valign-top{vertical-align:top} -th.valign-bottom,td.valign-bottom{vertical-align:bottom} -th.valign-middle,td.valign-middle{vertical-align:middle} -table thead th,table tfoot th{font-weight:bold} -tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} -tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} -p.tableblock>code:only-child{background:none;padding:0} -p.tableblock{font-size:1em} -td>div.verse{white-space:pre} -ol{margin-left:1.75em} -ul li ol{margin-left:1.5em} -dl dd{margin-left:1.125em} -dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0} -ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em} -ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} -ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} -ul.checklist li>p:first-child>.fa-check-square-o:first-child,ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em} -ul.checklist li>p:first-child>input[type="checkbox"]:first-child{position:relative;top:1px} -ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} -ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} -ul.inline>li>*{display:block} -.unstyled dl dt{font-weight:400;font-style:normal} -ol.arabic{list-style-type:decimal} -ol.decimal{list-style-type:decimal-leading-zero} -ol.loweralpha{list-style-type:lower-alpha} -ol.upperalpha{list-style-type:upper-alpha} -ol.lowerroman{list-style-type:lower-roman} -ol.upperroman{list-style-type:upper-roman} -ol.lowergreek{list-style-type:lower-greek} -.hdlist>table,.colist>table{border:0;background:none} -.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} -td.hdlist1{padding-right:.75em;font-weight:bold} -td.hdlist1,td.hdlist2{vertical-align:top} -.literalblock+.colist,.listingblock+.colist{margin-top:-.5em} -.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1} -.colist>table tr>td:last-of-type{padding:.25em 0} -.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd} -.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0} -.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em} -.imageblock>.title{margin-bottom:0} -.imageblock.thumb,.imageblock.th{border-width:6px} -.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em} -.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0} -.image.left{margin-right:.625em} -.image.right{margin-left:.625em} -a.image{text-decoration:none} -span.footnote,span.footnoteref{vertical-align:super;font-size:.875em} -span.footnote a,span.footnoteref a{text-decoration:none} -span.footnote a:active,span.footnoteref a:active{text-decoration:underline} -#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em} -#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0} -#footnotes .footnote{padding:0 .375em;line-height:1.3;font-size:.875em;margin-left:1.2em;text-indent:-1.2em;margin-bottom:.2em} -#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none} -#footnotes .footnote:last-of-type{margin-bottom:0} -#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0} -.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0} -.gist .file-data>table td.line-data{width:99%} -div.unbreakable{page-break-inside:avoid} -.big{font-size:larger} -.small{font-size:smaller} -.underline{text-decoration:underline} -.overline{text-decoration:overline} -.line-through{text-decoration:line-through} -.aqua{color:#00bfbf} -.aqua-background{background-color:#00fafa} -.black{color:#000} -.black-background{background-color:#000} -.blue{color:#0000bf} -.blue-background{background-color:#0000fa} -.fuchsia{color:#bf00bf} -.fuchsia-background{background-color:#fa00fa} -.gray{color:#606060} -.gray-background{background-color:#7d7d7d} -.green{color:#006000} -.green-background{background-color:#007d00} -.lime{color:#00bf00} -.lime-background{background-color:#00fa00} -.maroon{color:#600000} -.maroon-background{background-color:#7d0000} -.navy{color:#000060} -.navy-background{background-color:#00007d} -.olive{color:#606000} -.olive-background{background-color:#7d7d00} -.purple{color:#600060} -.purple-background{background-color:#7d007d} -.red{color:#bf0000} -.red-background{background-color:#fa0000} -.silver{color:#909090} -.silver-background{background-color:#bcbcbc} -.teal{color:#006060} -.teal-background{background-color:#007d7d} -.white{color:#bfbfbf} -.white-background{background-color:#fafafa} -.yellow{color:#bfbf00} -.yellow-background{background-color:#fafa00} -span.icon>.fa{cursor:default} -.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default} -.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c} -.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111} -.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900} -.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400} -.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000} -.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold} -.conum[data-value] *{color:#fff!important} -.conum[data-value]+b{display:none} -.conum[data-value]:after{content:attr(data-value)} -pre .conum[data-value]{position:relative;top:-.125em} -b.conum *{color:inherit!important} -.conum:not([data-value]):empty{display:none} -h1,h2{letter-spacing:-.01em} -dt,th.tableblock,td.content{text-rendering:optimizeLegibility} -p,td.content{letter-spacing:-.01em} -p strong,td.content strong{letter-spacing:-.005em} -p,blockquote,dt,td.content{font-size:1.0625rem} -p{margin-bottom:1.25rem} -.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em} -.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc} -.print-only{display:none!important} -@media print{@page{margin:1.25cm .75cm} -*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important} -a{color:inherit!important;text-decoration:underline!important} -a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important} -a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em} -abbr[title]:after{content:" (" attr(title) ")"} -pre,blockquote,tr,img{page-break-inside:avoid} -thead{display:table-header-group} -img{max-width:100%!important} -p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3} -h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid} -#toc,.sidebarblock,.exampleblock>.content{background:none!important} -#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important} -.sect1{padding-bottom:0!important} -.sect1+.sect1{border:0!important} -#header>h1:first-child{margin-top:1.25rem} -body.book #header{text-align:center} -body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0} -body.book #header .details{border:0!important;display:block;padding:0!important} -body.book #header .details span:first-child{margin-left:0!important} -body.book #header .details br{display:block} -body.book #header .details br+span:before{content:none!important} -body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important} -body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always} -.listingblock code[data-lang]:before{display:block} -#footer{background:none!important;padding:0 .9375em} -#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em} -.hide-on-print{display:none!important} -.print-only{display:block!important} -.hide-for-print{display:none!important} -.show-for-print{display:inherit!important}} \ No newline at end of file diff --git a/docs/.flattened-pom.xml b/docs/.flattened-pom.xml new file mode 100644 index 000000000..ccfd882ee --- /dev/null +++ b/docs/.flattened-pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + + org.springframework.cloud + spring-cloud-netflix-docs + 4.1.0-SNAPSHOT + Spring Cloud Netflix Docs + Spring Cloud Docs + https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-docs + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-docs + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-docs + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-docs + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server + 4.1.0-SNAPSHOT + compile + + + diff --git a/docs/.github/workflows/deploy-docs.yml b/docs/.github/workflows/deploy-docs.yml deleted file mode 100644 index be4b92dfc..000000000 --- a/docs/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploy Docs -on: - push: - branches-ignore: [ gh-pages ] - tags: '**' - repository_dispatch: - types: request-build-reference # legacy - #schedule: - #- cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: -permissions: - actions: write -jobs: - build: - runs-on: ubuntu-latest - # if: github.repository_owner == 'spring-cloud' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: docs-build - fetch-depth: 1 - - name: Dispatch (partial build) - if: github.ref_type == 'branch' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} - - name: Dispatch (full build) - if: github.ref_type == 'tag' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) diff --git a/docs/antora.yml b/docs/antora.yml deleted file mode 100644 index 15b346da0..000000000 --- a/docs/antora.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: PROJECT_WITHOUT_SPRING -version: true -title: PROJECT_NAME -nav: - - modules/ROOT/nav.adoc -ext: - collector: - run: - command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests - local: true - scan: - dir: ./target/classes/antora-resources/ diff --git a/docs/modules/ROOT/assets/images/Hystrix.png b/docs/modules/ROOT/assets/images/Hystrix.png deleted file mode 100644 index 7d4e17ed4..000000000 Binary files a/docs/modules/ROOT/assets/images/Hystrix.png and /dev/null differ diff --git a/docs/modules/ROOT/assets/images/HystrixFallback.png b/docs/modules/ROOT/assets/images/HystrixFallback.png deleted file mode 100644 index 372018c75..000000000 Binary files a/docs/modules/ROOT/assets/images/HystrixFallback.png and /dev/null differ diff --git a/docs/modules/ROOT/assets/images/HystrixGraph.png b/docs/modules/ROOT/assets/images/HystrixGraph.png deleted file mode 100644 index c07c6bd58..000000000 Binary files a/docs/modules/ROOT/assets/images/HystrixGraph.png and /dev/null differ diff --git a/docs/modules/ROOT/assets/images/RequestLatency.png b/docs/modules/ROOT/assets/images/RequestLatency.png deleted file mode 100644 index 6c7e93beb..000000000 Binary files a/docs/modules/ROOT/assets/images/RequestLatency.png and /dev/null differ diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc deleted file mode 100644 index 28978e1a2..000000000 --- a/docs/modules/ROOT/nav.adoc +++ /dev/null @@ -1,9 +0,0 @@ -* xref:index.adoc[] -* xref:_attributes.adoc[] -* xref:intro.adoc[] -* xref:README.adoc[] -* xref:_configprops.adoc[] -* xref:appendix.adoc[] -* xref:sagan-boot.adoc[] -* xref:sagan-index.adoc[] -* xref:spring-cloud-netflix.adoc[] diff --git a/docs/modules/ROOT/pages/README.adoc b/docs/modules/ROOT/pages/README.adoc deleted file mode 100644 index 9e74f1298..000000000 --- a/docs/modules/ROOT/pages/README.adoc +++ /dev/null @@ -1,30 +0,0 @@ - -image::https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-netflix/tree/main"] -image::https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-netflix/branch/main"] - - - -[[features]] -= Features - -* Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans -* Service Discovery: an embedded Eureka server can be created with declarative Java configuration - - -[[building]] -= Building - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building-jdk8.adoc[] - -NOTE: To build the module `spring-cloud-netflix-hystrix-contract` along with the entire Netflix project run the -`build.sh` script in the `scripts` directory. - -[[contributing]] -= Contributing - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[] - -[[license]] -= License - -The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-netflix/main/LICENSE.txt[here]. diff --git a/docs/modules/ROOT/pages/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc deleted file mode 100644 index 1fcb32f33..000000000 --- a/docs/modules/ROOT/pages/_attributes.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:doctype: book -:idprefix: -:idseparator: - -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud Netflix diff --git a/docs/modules/ROOT/pages/_configprops.adoc b/docs/modules/ROOT/pages/_configprops.adoc deleted file mode 100644 index fc61da104..000000000 --- a/docs/modules/ROOT/pages/_configprops.adoc +++ /dev/null @@ -1,20 +0,0 @@ -|=== -|Name | Default | Description - -|eureka.client.eureka-connection-idle-timeout-seconds | `+++30+++` | Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed. In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving the connection hanging in limbo. -|eureka.client.eureka-server-connect-timeout-seconds | `+++5+++` | Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout. Note that the connections in the client are pooled by {@link HttpClient} and this setting affects the actual connection creation and also the wait time to get the connection from the pool. -|eureka.client.eureka-server-d-n-s-name | | Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing serviceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime. -|eureka.client.eureka-server-port | | Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls eurekaServerServiceUrls(String). The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime. -|eureka.client.eureka-server-read-timeout-seconds | `+++8+++` | Indicates how long to wait (in seconds) before a read from eureka server needs to timeout. -|eureka.client.eureka-server-total-connections | `+++200+++` | Gets the total number of connections that is allowed from eureka client to all eureka servers. -|eureka.client.eureka-server-total-connections-per-host | `+++50+++` | Gets the total number of connections that is allowed from eureka client to a eureka server host. -|eureka.client.eureka-server-u-r-l-context | | Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS. This information is not required if the contract returns the service urls from eurekaServerServiceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime. -|eureka.client.eureka-service-url-poll-interval-seconds | `+++0+++` | Indicates how often(in seconds) to poll for changes to eureka server information. Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it. -|eureka.client.prefer-same-zone-eureka | `+++true+++` | Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason. Ideally eureka clients are configured to talk to servers in the same zone The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds -|eureka.client.register-with-eureka | `+++true+++` | Indicates whether or not this instance should register its information with eureka server for discovery by others. In some cases, you do not want your instances to be discovered whereas you just want do discover other instances. -|eureka.server.peer-eureka-nodes-update-interval-ms | `+++0+++` | -|eureka.server.peer-eureka-status-refresh-time-interval-ms | `+++0+++` | -|ribbon.eureka.enabled | `+++true+++` | Enables the use of Eureka with Ribbon. -|spring.cloud.loadbalancer.eureka.approximate-zone-from-hostname | `+++false+++` | Used to determine whether we should try to get the `zone` value from host name. - -|=== diff --git a/docs/modules/ROOT/pages/appendix.adoc b/docs/modules/ROOT/pages/appendix.adoc deleted file mode 100644 index eef1c9056..000000000 --- a/docs/modules/ROOT/pages/appendix.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:numbered!: -[appendix] -[[common-application-properties]] -= Common application properties -:page-section-summary-toc: 1 - - -Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches. -This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. - -NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. -Also, you can define your own properties. - diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc deleted file mode 120000 index 5d677a319..000000000 --- a/docs/modules/ROOT/pages/index.adoc +++ /dev/null @@ -1 +0,0 @@ -spring-cloud-netflix.adoc \ No newline at end of file diff --git a/docs/modules/ROOT/pages/intro.adoc b/docs/modules/ROOT/pages/intro.adoc deleted file mode 100644 index 7e77b3776..000000000 --- a/docs/modules/ROOT/pages/intro.adoc +++ /dev/null @@ -1,7 +0,0 @@ - -This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. With a few -simple annotations you can quickly enable and configure the common patterns inside your -application and build large distributed systems with battle-tested Netflix components. The -patterns provided include Service Discovery (Eureka). - diff --git a/docs/modules/ROOT/pages/sagan-boot.adoc b/docs/modules/ROOT/pages/sagan-boot.adoc deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/modules/ROOT/pages/sagan-index.adoc b/docs/modules/ROOT/pages/sagan-index.adoc deleted file mode 100644 index eb78f3386..000000000 --- a/docs/modules/ROOT/pages/sagan-index.adoc +++ /dev/null @@ -1,48 +0,0 @@ -Spring Cloud Netflix provides Netflix OSS integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The patterns provided include Service Discovery (Eureka). - -## Features - -Spring Cloud Netflix features: - -* Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans -* Service Discovery: an embedded Eureka server can be created with declarative Java configuration - -## Getting Started - -As long as Spring Cloud Netflix and Eureka Core are on the -classpath any Spring Boot application with `spring-cloud-starter-netflix-eureka-client` in dependencies will try to contact a Eureka -server on `http://localhost:8761` (the default value of -`eureka.client.serviceUrl.defaultZone`): - -```java -@SpringBootApplication -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello World"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} -``` - -To run your own server use the `spring-cloud-starter-netflix-eureka-server` dependency and `@EnableEurekaServer`. - -## Contributing - -We welcome contributions. You can read more on how to contribute to the project https://github.com/spring-cloud/spring-cloud-netflix#contributing[here]. - -## Community Support - -* You can report issues through https://github.com/spring-cloud/spring-cloud-netflix/issues[Github]. -* We monitor https://stackoverflow.com/[StackOverflow] for questions with the `spring-cloud-netflix` tag. -* You can contact our team at https://gitter.im/spring-cloud/spring-cloud[Gitter]. - -## Commercial Support - -Commercial Support is provided as part of the https://spring.io/support[VMware Spring Runtime] offering. diff --git a/docs/modules/ROOT/pages/spring-cloud-netflix.adoc b/docs/modules/ROOT/pages/spring-cloud-netflix.adoc deleted file mode 100755 index bd087aa8e..000000000 --- a/docs/modules/ROOT/pages/spring-cloud-netflix.adoc +++ /dev/null @@ -1,643 +0,0 @@ - - -:github-tag: main -:github-repo: spring-cloud/spring-cloud-netflix -:github-raw: https://raw.github.com/{github-repo}/{github-tag} -:github-code: https://github.com/{github-repo}/tree/{github-tag} -:all: {asterisk}{asterisk} -:nofooter: -:branch: main - -[[spring-cloud-netflix]] -= Spring Cloud Netflix - -*{spring-cloud-version}* - - - -[[service-discovery:-eureka-clients]] -== Service Discovery: Eureka Clients - -Service Discovery is one of the key tenets of a microservice-based architecture. -Trying to hand-configure each client or some form of convention can be difficult to do and can be brittle. -Eureka is the Netflix Service Discovery Server and Client. -The server can be configured and deployed to be highly available, with each server replicating state about the registered services to the others. - -[[netflix-eureka-client-starter]] -=== How to Include Eureka Client - -To include the Eureka Client in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-netflix-eureka-client`. -See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. - -[[registering-with-eureka]] -=== Registering with Eureka - -When a client registers with Eureka, it provides meta-data about itself -- such as host, port, health indicator URL, home page, and other details. -Eureka receives heartbeat messages from each instance belonging to a service. -If the heartbeat fails over a configurable timetable, the instance is normally removed from the registry. -// TODO "normally"? Is there some configuration detail that causes a different behavior? - -The following example shows a minimal Eureka client application: - -[source,java,indent=0] ----- -@SpringBootApplication -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello world"; - } - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).web(true).run(args); - } - -} ----- - -Note that the preceding example shows a normal https://projects.spring.io/spring-boot/[Spring Boot] application. -By having `spring-cloud-starter-netflix-eureka-client` on the classpath, your application automatically registers with the Eureka Server. Configuration is required to locate the Eureka server, as shown in the following example: - -.application.yml ----- -eureka: - client: - serviceUrl: - defaultZone: http://localhost:8761/eureka/ ----- - -In the preceding example, `defaultZone` is a magic string fallback value that provides the service URL for any client that does not express a preference (in other words, it is a useful default). - -WARNING: The `defaultZone` property is case sensitive and requires camel case because the `serviceUrl` property is a `Map`. Therefore, the `defaultZone` property does not follow the normal Spring Boot snake-case convention of `default-zone`. - -The default application name (that is, the service ID), virtual host, and non-secure port (taken from the `Environment`) are `${spring.application.name}`, `${spring.application.name}` and `${server.port}`, respectively. - -Having `spring-cloud-starter-netflix-eureka-client` on the classpath makes the app into both a Eureka "`instance`" (that is, it registers itself) and a "`client`" (it can query the registry to locate other services). -The instance behaviour is driven by `eureka.instance.*` configuration keys, but the defaults are fine if you ensure that your application has a value for `spring.application.name` (this is the default for the Eureka service ID or VIP). - -See {github-code}/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java[EurekaInstanceConfigBean] and {github-code}/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBean.java[EurekaClientConfigBean] for more details on the configurable options. - -To disable the Eureka Discovery Client, you can set `eureka.client.enabled` to `false`. Eureka Discovery Client will also be disabled when `spring.cloud.discovery.enabled` is set to `false`. - - -NOTE: Specifying the version of the Spring Cloud Netflix Eureka server as a path parameter is not currently supported. This means you cannot set the version in the context path (`eurekaServerURLContext`). Instead, you can include the version in the server URL (for example, you can set `defaultZone: http://localhost:8761/eureka/v2`). - -[[authenticating-with-the-eureka-server]] -=== Authenticating with the Eureka Server - -HTTP basic authentication is automatically added to your eureka client if one of the `eureka.client.serviceUrl.defaultZone` URLs has credentials embedded in it (curl style, as follows: `https://user:password@localhost:8761/eureka`). -For more complex needs, you can create a `@Bean` of type `DiscoveryClientOptionalArgs` and inject `ClientFilter` instances into it, all of which is applied to the calls from the client to the server. - -When Eureka server requires client side certificate for authentication, the client side certificate and trust store can be configured via properties, as shown in following example: - -.application.yml -[source,yaml] ----- -eureka: - client: - tls: - enabled: true - key-store: - key-store-type: PKCS12 - key-store-password: - key-password: - trust-store: - trust-store-type: PKCS12 - trust-store-password: ----- - -The `eureka.client.tls.enabled` needs to be true to enable Eureka client side TLS. When `eureka.client.tls.trust-store` is omitted, a JVM default trust store is used. The default value for `eureka.client.tls.key-store-type` and `eureka.client.tls.trust-store-type` is PKCS12. When password properties are omitted, empty password is assumed. - -NOTE: Because of a limitation in Eureka, it is not possible to support per-server basic auth credentials, so only the first set that are found is used. - -If you want to customize the RestTemplate used by the Eureka HTTP Client you may want to create a bean of `EurekaClientHttpRequestFactorySupplier` and provide your own logic for generating a `ClientHttpRequestFactory` instance. - -All default timeout-related properties for RestTemplate used by the Eureka HTTP Client are set to 3 minutes (in keeping with Apache HC5 default `RequestConfig` and `SocketConfig`). Therefore, to specify the timeout values, you must specify the value directly with the properties in `eureka.client.rest-template-timeout`. (All timeout properties are in milliseconds.) - -.application.yml -[source,yaml] ----- -eureka: - client: - rest-template-timeout: - connect-timeout: 5000 - connect-request-timeout: 8000 - socket-timeout: 10000 ----- - -[[status-page-and-health-indicator]] -=== Status Page and Health Indicator - -The status page and health indicators for a Eureka instance default to `/info` and `/health` respectively, which are the default locations of useful endpoints in a Spring Boot Actuator application. -You need to change these, even for an Actuator application if you use a non-default context path or servlet path (such as `server.servletPath=/custom`). The following example shows the default values for the two settings: - -.application.yml ----- -eureka: - instance: - statusPageUrlPath: ${server.servletPath}/info - healthCheckUrlPath: ${server.servletPath}/health ----- - -These links show up in the metadata that is consumed by clients and are used in some scenarios to decide whether to send requests to your application, so it is helpful if they are accurate. - -NOTE: In Dalston it was also required to set the status and health check URLs when changing -that management context path. This requirement was removed beginning in Edgware. - -[[registering-a-secure-application]] -=== Registering a Secure Application - -If your app wants to be contacted over HTTPS, you can set two flags in the `EurekaInstanceConfigBean`: - -* `eureka.instance.[nonSecurePortEnabled]=[false]` -* `eureka.instance.[securePortEnabled]=[true]` - -Doing so makes Eureka publish instance information that shows an explicit preference for secure communication. -The Spring Cloud `DiscoveryClient` always returns a URI starting with `https` for a service configured this way. -Similarly, when a service is configured this way, the Eureka (native) instance information has a secure health check URL. - -Because of the way Eureka works internally, it still publishes a non-secure URL for the status and home pages unless you also override those explicitly. -You can use placeholders to configure the eureka instance URLs, as shown in the following example: - -.application.yml ----- -eureka: - instance: - statusPageUrl: https://${eureka.hostname}/info - healthCheckUrl: https://${eureka.hostname}/health - homePageUrl: https://${eureka.hostname}/ ----- - -(Note that `${eureka.hostname}` is a native placeholder only available -in later versions of Eureka. You could achieve the same thing with -Spring placeholders as well -- for example, by using `${eureka.instance.hostName}`.) - -NOTE: If your application runs behind a proxy, and the SSL termination is in the proxy (for example, if you run in Cloud Foundry or other platforms as a service), then you need to ensure that the proxy "`forwarded`" headers are intercepted and handled by the application. -If the Tomcat container embedded in a Spring Boot application has explicit configuration for the 'X-Forwarded-\*` headers, this happens automatically. -The links rendered by your app to itself being wrong (the wrong host, port, or protocol) is a sign that you got this configuration wrong. - -[[eureka-s-health-checks]] -=== Eureka's Health Checks - -By default, Eureka uses the client heartbeat to determine if a client is up. -Unless specified otherwise, the Discovery Client does not propagate the current health check status of the application, per the Spring Boot Actuator. -Consequently, after successful registration, Eureka always announces that the application is in 'UP' state. This behavior can be altered by enabling Eureka health checks, which results in propagating application status to Eureka. -As a consequence, every other application does not send traffic to applications in states other then 'UP'. -The following example shows how to enable health checks for the client: - -.application.yml ----- -eureka: - client: - healthcheck: - enabled: true ----- - -WARNING: `eureka.client.healthcheck.enabled=true` should only be set in `application.yml`. Setting the value in `bootstrap.yml` causes undesirable side effects, such as registering in Eureka with an `UNKNOWN` status. - -If you require more control over the health checks, consider implementing your own `com.netflix.appinfo.HealthCheckHandler`. - -[[eureka-metadata-for-instances-and-clients]] -=== Eureka Metadata for Instances and Clients - -It is worth spending a bit of time understanding how the Eureka metadata works, so you can use it in a way that makes sense in your platform. -There is standard metadata for information such as hostname, IP address, port numbers, the status page, and health check. -These are published in the service registry and used by clients to contact the services in a straightforward way. -Additional metadata can be added to the instance registration in the `eureka.instance.metadataMap`, and this metadata is accessible in the remote clients. -In general, additional metadata does not change the behavior of the client, unless the client is made aware of the meaning of the metadata. -There are a couple of special cases, described later in this document, where Spring Cloud already assigns meaning to the metadata map. -// TODO Add links from here to the relevant places in the document - -[[using-eureka-on-cloud-foundry]] -==== Using Eureka on Cloud Foundry - -Cloud Foundry has a global router so that all instances of the same app have the same hostname (other PaaS solutions with a similar architecture have the same arrangement). -This is not necessarily a barrier to using Eureka. -However, if you use the router (recommended or even mandatory, depending on the way your platform was set up), you need to explicitly set the hostname and port numbers (secure or non-secure) so that they use the router. -You might also want to use instance metadata so that you can distinguish between the instances on the client (for example, in a custom load balancer). -By default, the `eureka.instance.instanceId` is `vcap.application.instance_id`, as shown in the following example: - -.application.yml ----- -eureka: - instance: - hostname: ${vcap.application.uris[0]} - nonSecurePort: 80 ----- - -Depending on the way the security rules are set up in your Cloud Foundry instance, you might be able to register and use the IP address of the host VM for direct service-to-service calls. -This feature is not yet available on Pivotal Web Services (https://run.pivotal.io[PWS]). - -[[using-eureka-on-aws]] -==== Using Eureka on AWS - -If the application is planned to be deployed to an AWS cloud, the Eureka instance must be configured to be AWS-aware. You can do so by customizing the {github-code}/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java[EurekaInstanceConfigBean] as follows: - -[source,java,indent=0] ----- -@Bean -@Profile("!default") -public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) { - EurekaInstanceConfigBean bean = new EurekaInstanceConfigBean(inetUtils); - AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka"); - bean.setDataCenterInfo(info); - return bean; -} ----- - -[[changing-the-eureka-instance-id]] -==== Changing the Eureka Instance ID - -A vanilla Netflix Eureka instance is registered with an ID that is equal to its host name (that is, there is only one service per host). -Spring Cloud Eureka provides a sensible default, which is defined as follows: - -`${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}` - -An example is `myhost:myappname:8080`. - -By using Spring Cloud, you can override this value by providing a unique identifier in `eureka.instance.instanceId`, as shown in the following example: - -.application.yml ----- -eureka: - instance: - instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}} ----- - -With the metadata shown in the preceding example and multiple service instances deployed on localhost, the random value is inserted there to make the instance unique. -In Cloud Foundry, the `vcap.application.instance_id` is populated automatically in a Spring Boot application, so the random value is not needed. - -[[using-the-eurekaclient]] -=== Using the EurekaClient - -Once you have an application that is a discovery client, you can use it to discover service instances from the <> -. -One way to do so is to use the native `com.netflix.discovery.EurekaClient` (as opposed to the Spring Cloud `DiscoveryClient`), as shown in the following example: - ----- -@Autowired -private EurekaClient discoveryClient; - -public String serviceUrl() { - InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false); - return instance.getHomePageUrl(); -} ----- - -[TIP] -==== -Do not use the `EurekaClient` in a `@PostConstruct` method or in a `@Scheduled` method (or anywhere where the `ApplicationContext` might not be started yet). -It is initialized in a `SmartLifecycle` (with `phase=0`), so the earliest you can rely on it being available is in another `SmartLifecycle` with a higher phase. -==== - -[[eurekaclient-with-jersey]] -==== EurekaClient with Jersey - -By default, EurekaClient uses Spring's `RestTemplate` for HTTP communication. -If you wish to use Jersey instead, you need to add the Jersey dependencies to your classpath. -The following example shows the dependencies you need to add: - ----- - - com.sun.jersey - jersey-client - - - com.sun.jersey - jersey-core - - - com.sun.jersey.contribs - jersey-apache-client4 - ----- - -[[alternatives-to-the-native-netflix-eurekaclient]] -=== Alternatives to the Native Netflix EurekaClient - -You need not use the raw Netflix `EurekaClient`. -Also, it is usually more convenient to use it behind a wrapper of some sort. -Spring Cloud has support for <> (a REST client builder) and <> through the logical Eureka service identifiers (VIPs) instead of physical URLs. - -You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient`, which provides a simple API (not specific to Netflix) for discovery clients, as shown in the following example: - ----- -@Autowired -private DiscoveryClient discoveryClient; - -public String serviceUrl() { - List list = discoveryClient.getInstances("STORES"); - if (list != null && list.size() > 0 ) { - return list.get(0).getUri(); - } - return null; -} ----- - -[[why-is-it-so-slow-to-register-a-service?]] -=== Why Is It so Slow to Register a Service? - -Being an instance also involves a periodic heartbeat to the registry -(through the client's `serviceUrl`) with a default duration of 30 seconds. -A service is not available for discovery by clients until the instance, the server, and the client all have the same metadata in their local -cache (so it could take 3 heartbeats). -You can change the period by setting `eureka.instance.leaseRenewalIntervalInSeconds`. -Setting it to a value of less than 30 speeds up the process of getting clients connected to other services. -In production, it is probably better to stick with the default, because of internal computations in the server that make assumptions about the lease renewal period. - -[[zones]] -=== Zones - -If you have deployed Eureka clients to multiple zones, you may prefer that those clients use services within the same zone before trying services in another zone. -To set that up, you need to configure your Eureka clients correctly. - -First, you need to make sure you have Eureka servers deployed to each zone and that -they are peers of each other. -See the section on <> -for more information. - -Next, you need to tell Eureka which zone your service is in. -You can do so by using the `metadataMap` property. -For example, if `service 1` is deployed to both `zone 1` and `zone 2`, you need to set the following Eureka properties in `service 1`: - -*Service 1 in Zone 1* -``` -eureka.instance.metadataMap.zone = zone1 -eureka.client.preferSameZoneEureka = true -``` - -*Service 1 in Zone 2* -``` -eureka.instance.metadataMap.zone = zone2 -eureka.client.preferSameZoneEureka = true -``` - -[[refreshing-eureka-clients]] -=== Refreshing Eureka Clients - -By default, the `EurekaClient` bean is refreshable, meaning the Eureka client properties can be changed and refreshed. -When a refresh occurs clients will be unregistered from the Eureka server and there might be a brief moment of time -where all instance of a given service are not available. One way to eliminate this from happening is to disable -the ability to refresh Eureka clients. To do this set `eureka.client.refresh.enable=false`. - -[[using-eureka-with-spring-cloud-loadbalancer]] -=== Using Eureka with Spring Cloud LoadBalancer - -We offer support for the Spring Cloud LoadBalancer `ZonePreferenceServiceInstanceListSupplier`. -The `zone` value from the Eureka instance metadata (`eureka.instance.metadataMap.zone`) is used for setting the -value of `spring-cloud-loadbalancer-zone` property that is used to filter service instances by zone. - -If that is missing and if the `spring.cloud.loadbalancer.eureka.approximateZoneFromHostname` flag is set to `true`, -it can use the domain name from the server hostname as a proxy for the zone. - -If there is no other source of zone data, then a guess is made, based on the client configuration (as opposed to the instance configuration). -We take `eureka.client.availabilityZones`, which is a map from region name to a list of zones, and pull out the first zone for the instance's own region (that is, the `eureka.client.region`, which defaults to "us-east-1", for compatibility with native Netflix). - -[[aot-and-native-image-support]] -=== AOT and Native Image Support - -Spring Cloud Netflix Eureka Client integration supports Spring AOT transformations and native images, however, only with refresh mode disabled. - -WARNING: If you want to run Eureka Client in AOT or native image modes, make sure to set `spring.cloud.refresh.enabled` to `false` - -[[spring-cloud-eureka-server]] -== Service Discovery: Eureka Server - -This section describes how to set up a Eureka server. - -[[netflix-eureka-server-starter]] -=== How to Include Eureka Server - -To include Eureka Server in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-netflix-eureka-server`. -See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. - -NOTE: If your project already uses Thymeleaf as its template engine, the Freemarker templates of the Eureka server may not be loaded correctly. In this case it is necessary to configure the template loader manually: - -.application.yml ----- -spring: - freemarker: - template-loader-path: classpath:/templates/ - prefer-file-system-access: false ----- - -[[spring-cloud-running-eureka-server]] -=== How to Run a Eureka Server - -The following example shows a minimal Eureka server: - -[source,java,indent=0] ----- -@SpringBootApplication -@EnableEurekaServer -public class Application { - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).web(true).run(args); - } - -} ----- - -The server has a home page with a UI and HTTP API endpoints for the normal Eureka functionality under `/eureka/*`. - -The following links have some Eureka background reading: https://github.com/cfregly/fluxcapacitor/wiki/NetflixOSS-FAQ#eureka-service-discovery-load-balancer[flux capacitor] and https://groups.google.com/forum/?fromgroups#!topic/eureka_netflix/g3p2r7gHnN0[google group discussion]. - -[TIP] -==== -Due to Gradle's dependency resolution rules and the lack of a parent bom feature, depending on `spring-cloud-starter-netflix-eureka-server` can cause failures on application startup. -To remedy this issue, add the Spring Boot Gradle plugin and import the Spring cloud starter parent bom as follows: - -.build.gradle -[source,java,indent=0] ----- -buildscript { - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:{spring-boot-docs-version}") - } -} - -apply plugin: "spring-boot" - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:{spring-cloud-version}" - } -} ----- -==== - -[[defaultopenfortrafficcount-and-its-effect-on-eurekaserver-warmup-time]] -=== `defaultOpenForTrafficCount` and its effect on EurekaServer warmup time - -Netflix Eureka's `waitTimeInMsWhenSyncEmpty` setting is not taken into account in Spring Cloud Eureka server at the beginning. In order to enable the warmup time, set `eureka.server.defaultOpenForTrafficCount=0`. - -[[spring-cloud-eureka-server-zones-and-regions]] -=== High Availability, Zones and Regions - -The Eureka server does not have a back end store, but the service instances in the registry all have to send heartbeats to keep their registrations up to date (so this can be done in memory). -Clients also have an in-memory cache of Eureka registrations (so they do not have to go to the registry for every request to a service). - -By default, every Eureka server is also a Eureka client and requires (at least one) service URL to locate a peer. -If you do not provide it, the service runs and works, but it fills your logs with a lot of noise about not being able to register with the peer. - -[[spring-cloud-eureka-server-standalone-mode]] -=== Standalone Mode - -The combination of the two caches (client and server) and the heartbeats make a standalone Eureka server fairly resilient to failure, as long as there is some sort of monitor or elastic runtime (such as Cloud Foundry) keeping it alive. -In standalone mode, you might prefer to switch off the client side behavior so that it does not keep trying and failing to reach its peers. -The following example shows how to switch off the client-side behavior: - -.application.yml (Standalone Eureka Server) ----- -server: - port: 8761 - -eureka: - instance: - hostname: localhost - client: - registerWithEureka: false - fetchRegistry: false - serviceUrl: - defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ ----- - -Notice that the `serviceUrl` is pointing to the same host as the local instance. - -[[spring-cloud-eureka-server-peer-awareness]] -=== Peer Awareness - -Eureka can be made even more resilient and available by running multiple instances and asking them to register with each other. -In fact, this is the default behavior, so all you need to do to make it work is add a valid `serviceUrl` to a peer, as shown in the following example: - -.application.yml (Two Peer Aware Eureka Servers) ----- - ---- -spring: - profiles: peer1 -eureka: - instance: - hostname: peer1 - client: - serviceUrl: - defaultZone: https://peer2/eureka/ - ---- -spring: - profiles: peer2 -eureka: - instance: - hostname: peer2 - client: - serviceUrl: - defaultZone: https://peer1/eureka/ ----- - -In the preceding example, we have a YAML file that can be used to run the same server on two hosts (`peer1` and `peer2`) by running it in different Spring profiles. -You could use this configuration to test the peer awareness on a single host (there is not much value in doing that in production) by manipulating `/etc/hosts` to resolve the host names. -In fact, the `eureka.instance.hostname` is not needed if you are running on a machine that knows its own hostname (by default, it is looked up by using `java.net.InetAddress`). - -You can add multiple peers to a system, and, as long as they are all connected to each other by at least one edge, they synchronize -the registrations amongst themselves. -If the peers are physically separated (inside a data center or between multiple data centers), then the system can, in principle, survive "`split-brain`" type failures. -You can add multiple peers to a system, and as long as they are all -directly connected to each other, they will synchronize -the registrations amongst themselves. - -.application.yml (Three Peer Aware Eureka Servers) ----- -eureka: - client: - serviceUrl: - defaultZone: https://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/ - ---- -spring: - profiles: peer1 -eureka: - instance: - hostname: peer1 - ---- -spring: - profiles: peer2 -eureka: - instance: - hostname: peer2 - ---- -spring: - profiles: peer3 -eureka: - instance: - hostname: peer3 ----- - -[[spring-cloud-eureka-server-prefer-ip-address]] -=== When to Prefer IP Address - -In some cases, it is preferable for Eureka to advertise the IP addresses of services rather than the hostname. -Set `eureka.instance.preferIpAddress` to `true` and, when the application registers with eureka, it uses its IP address rather than its hostname. - -[TIP] -==== -If the hostname cannot be determined by Java, then the IP address is sent to Eureka. -Only explict way of setting the hostname is by setting `eureka.instance.hostname` property. -You can set your hostname at the run-time by using an environment variable -- for example, `eureka.instance.hostname=${HOST_NAME}`. -==== - -[[securing-the-eureka-server]] -=== Securing The Eureka Server - -You can secure your Eureka server simply by adding Spring Security to your -server's classpath via `spring-boot-starter-security`. By default, when Spring Security is on the classpath it will require that -a valid CSRF token be sent with every request to the app. Eureka clients will not generally possess a valid -cross site request forgery (CSRF) token you will need to disable this requirement for the `/eureka/**` endpoints. -For example: - -[source,java,indent=0] ----- -@Bean -public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.authorizeHttpRequests((authz) -> authz - .anyRequest().authenticated()) - .httpBasic(withDefaults()); - http.csrf().ignoringRequestMatchers("/eureka/**"); - return http.build(); -} ----- - -For more information on CSRF see the https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#csrf[Spring Security documentation]. - -A demo Eureka Server can be found in the Spring Cloud Samples https://github.com/spring-cloud-samples/eureka/tree/Eureka-With-Security-4.x[repo]. - -[[jdk-11-support]] -=== JDK 11 Support - -The JAXB modules which the Eureka server depends upon were removed in JDK 11. If you intend to use JDK 11 -when running a Eureka server you must include these dependencies in your POM or Gradle file. - -[source,xml,indent=0] ----- - - org.glassfish.jaxb - jaxb-runtime - ----- - -[[aot-and-native-image-support]] -=== AOT and Native Image Support - -Spring Cloud Netflix Eureka Server does not support Spring AOT transformations or native images. - -[[configuration-properties]] -== Configuration properties - -To see the list of all Spring Cloud Netflix related configuration properties please check link:appendix.html[the Appendix page]. - - - diff --git a/docs/pom.xml b/docs/pom.xml deleted file mode 100644 index 54235b7bf..000000000 --- a/docs/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - - spring-cloud-netflix-docs - jar - Spring Cloud Netflix Docs - Spring Cloud Docs - - spring-cloud-netflix - ${basedir}/.. - - .*.eureka.* - - deploy - - none - - - - ${project.groupId} - spring-cloud-starter-netflix-eureka-client - - - ${project.groupId} - spring-cloud-starter-netflix-eureka-server - - - - src/main/asciidoc - - - - docs - - - - pl.project13.maven - git-commit-id-plugin - - - maven-dependency-plugin - - - maven-resources-plugin - - - org.codehaus.mojo - exec-maven-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - maven-antrun-plugin - - - maven-deploy-plugin - - - - - - diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh deleted file mode 100755 index 6a79e2344..000000000 --- a/docs/src/main/asciidoc/ghpages.sh +++ /dev/null @@ -1,330 +0,0 @@ -ALLOW#!/bin/bash -x - -set -e - -# Set default props like MAVEN_PATH, ROOT_FOLDER etc. -function set_default_props() { - # The script should be run from the root folder - ROOT_FOLDER=`pwd` - echo "Current folder is ${ROOT_FOLDER}" - - if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - echo "You're not in the root folder of the project!" - exit 1 - fi - - # Prop that will let commit the changes - COMMIT_CHANGES="no" - MAVEN_PATH=${MAVEN_PATH:-} - echo "Path to Maven is [${MAVEN_PATH}]" - REPO_NAME=${PWD##*/} - echo "Repo name is [${REPO_NAME}]" - SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git} - echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}" -} - -# Check if gh-pages exists and docs have been built -function check_if_anything_to_sync() { - git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` - - if ! (git remote set-branches --add origin gh-pages && git fetch -q); then - echo "No gh-pages, so not syncing" - exit 0 - fi - - if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then - echo "No gh-pages sources in docs/target/generated-docs, so not syncing" - exit 0 - fi -} - -function retrieve_current_branch() { - # Code getting the name of the current branch. For main we want to publish as we did until now - # https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch - # If there is a branch already passed will reuse it - otherwise will try to find it - CURRENT_BRANCH=${BRANCH} - if [[ -z "${CURRENT_BRANCH}" ]] ; then - CURRENT_BRANCH=$(git symbolic-ref -q HEAD) - CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} - CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} - fi - echo "Current branch is [${CURRENT_BRANCH}]" - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" -} - -# Switches to the provided value of the release version. We always prefix it with `v` -function switch_to_tag() { - git checkout v${VERSION} -} - -# Build the docs if switch is on -function build_docs_if_applicable() { - if [[ "${BUILD}" == "yes" ]] ; then - ./mvnw clean install -P docs -pl docs -DskipTests - fi -} - -# Get the name of the `docs.main` property -# Get allow branches - assumes that a `docs` module is available under `docs` profile -function retrieve_doc_properties() { - MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args='${docs.main}' \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) - echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" - - - ALLOW_PROPERTY=${ALLOW_PROPERTY:-"docs.allowed.branches"} - ALLOWED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args="\${${ALLOW_PROPERTY}}" \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ - -P docs \ - -pl docs) - echo "Extracted '${ALLOW_PROPERTY}' from Maven build [${ALLOWED_BRANCHES_VALUE}]" -} - -# Stash any outstanding changes -function stash_changes() { - git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") - if [ "$dirty" != "0" ]; then git stash; fi -} - -# Switch to gh-pages branch to sync it with current branch -function add_docs_from_target() { - local DESTINATION_REPO_FOLDER - if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then - DESTINATION_REPO_FOLDER=${ROOT_FOLDER} - elif [[ "${CLONE}" == "yes" ]]; then - mkdir -p ${ROOT_FOLDER}/target - local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static - if [[ ! -e "${clonedStatic}/.git" ]]; then - echo "Cloning Spring Cloud Static to target" - git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} && git checkout gh-pages - else - echo "Spring Cloud Static already cloned - will pull changes" - cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages - fi - DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - else - if [[ ! -e "${DESTINATION}/.git" ]]; then - echo "[${DESTINATION}] is not a git repository" - exit 1 - fi - DESTINATION_REPO_FOLDER=${DESTINATION}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - echo "Destination was provided [${DESTINATION}]" - fi - cd ${DESTINATION_REPO_FOLDER} - git checkout gh-pages - git pull origin gh-pages - - # Add git branches - ################################################################### - if [[ -z "${VERSION}" ]] ; then - copy_docs_for_current_version - else - copy_docs_for_provided_version - fi - commit_changes_if_applicable -} - - -# Copies the docs by using the retrieved properties from Maven build -function copy_docs_for_current_version() { - if [[ "${CURRENT_BRANCH}" == "main" ]] ; then - echo -e "Current branch is main - will copy the current docs only to the root folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f ${ROOT_FOLDER}/ - git add -A ${ROOT_FOLDER}/$file - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Current branch is [${CURRENT_BRANCH}]" - # https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${ALLOWED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then - mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} - echo -e "Branch [${CURRENT_BRANCH}] is allowed! Will copy the current docs to the [${CURRENT_BRANCH}] folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - else - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file - fi - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Branch [${CURRENT_BRANCH}] is not on the allow list! Check out the Maven [${ALLOW_PROPERTY}] property in - [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." - fi - fi -} - -# Copies the docs by using the explicitly provided version -function copy_docs_for_provided_version() { - local FOLDER=${DESTINATION_REPO_FOLDER}/${VERSION} - mkdir -p ${FOLDER} - echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder" - for f in ${ROOT_FOLDER}/docs/target/generated-docs/*; do - file=${f#${ROOT_FOLDER}/docs/target/generated-docs/*} - copy_docs_for_branch ${file} ${FOLDER} - done - COMMIT_CHANGES="yes" - CURRENT_BRANCH="v${VERSION}" -} - -# Copies the docs from target to the provided destination -# Params: -# $1 - file from target -# $2 - destination to which copy the files -function copy_docs_for_branch() { - local file=$1 - local destination=$2 - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ ("${file}" == "${MAIN_ADOC_VALUE}.html") || ("${file}" == "${REPO_NAME}.html") ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${destination}/index.html - git add -A ${destination}/index.html - else - cp -rf $f ${destination} - git add -A ${destination}/$file - fi - fi -} - -function commit_changes_if_applicable() { - if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then - COMMIT_SUCCESSFUL="no" - git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes" - - # Uncomment the following push if you want to auto push to - # the gh-pages branch whenever you commit to main locally. - # This is a little extreme. Use with care! - ################################################################### - if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then - git push origin gh-pages - fi - fi -} - -# Switch back to the previous branch and exit block -function checkout_previous_branch() { - # If -version was provided we need to come back to root project - cd ${ROOT_FOLDER} - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" - if [ "$dirty" != "0" ]; then git stash pop; fi - exit 0 -} - -# Assert if properties have been properly passed -function assert_properties() { -echo "VERSION [${VERSION}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]" -if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi -if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi -if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi -} - -# Prints the usage -function print_usage() { -cat </` -- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will - switch to gh-pages of that repo and copy the generated docs to `docs//` - -USAGE: - -You can use the following options: - --v|--version - the script will apply the whole procedure for a particular library version --d|--destination - the root of destination folder where the docs should be copied. You have to use the full path. - E.g. point to spring-cloud-static folder. Can't be used with (-c) --b|--build - will run the standard build process after checking out the branch --c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination. - Obviously can't be used with (-d) - -EOF -} - - -# ========================================== -# ____ ____ _____ _____ _____ _______ -# / ____|/ ____| __ \|_ _| __ \__ __| -# | (___ | | | |__) | | | | |__) | | | -# \___ \| | | _ / | | | ___/ | | -# ____) | |____| | \ \ _| |_| | | | -# |_____/ \_____|_| \_\_____|_| |_| -# -# ========================================== - -while [[ $# > 0 ]] -do -key="$1" -case ${key} in - -v|--version) - VERSION="$2" - shift # past argument - ;; - -d|--destination) - DESTINATION="$2" - shift # past argument - ;; - -b|--build) - BUILD="yes" - ;; - -c|--clone) - CLONE="yes" - ;; - -h|--help) - print_usage - exit 0 - ;; - *) - echo "Invalid option: [$1]" - print_usage - exit 1 - ;; -esac -shift # past argument or value -done - -assert_properties -set_default_props -check_if_anything_to_sync -if [[ -z "${VERSION}" ]] ; then - retrieve_current_branch -else - switch_to_tag -fi -build_docs_if_applicable -retrieve_doc_properties -stash_changes -add_docs_from_target -checkout_previous_branch diff --git a/docs/src/main/asciidoc/images/Hystrix.png b/docs/src/main/asciidoc/images/Hystrix.png deleted file mode 100644 index 7d4e17ed4..000000000 Binary files a/docs/src/main/asciidoc/images/Hystrix.png and /dev/null differ diff --git a/docs/src/main/asciidoc/images/HystrixFallback.png b/docs/src/main/asciidoc/images/HystrixFallback.png deleted file mode 100644 index 372018c75..000000000 Binary files a/docs/src/main/asciidoc/images/HystrixFallback.png and /dev/null differ diff --git a/docs/src/main/asciidoc/images/HystrixGraph.png b/docs/src/main/asciidoc/images/HystrixGraph.png deleted file mode 100644 index c07c6bd58..000000000 Binary files a/docs/src/main/asciidoc/images/HystrixGraph.png and /dev/null differ diff --git a/docs/src/main/asciidoc/images/RequestLatency.png b/docs/src/main/asciidoc/images/RequestLatency.png deleted file mode 100644 index 6c7e93beb..000000000 Binary files a/docs/src/main/asciidoc/images/RequestLatency.png and /dev/null differ diff --git a/eclipse/eclipse-code-formatter.xml b/eclipse/eclipse-code-formatter.xml deleted file mode 100644 index 2586a2a22..000000000 --- a/eclipse/eclipse-code-formatter.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/eclipse/org.eclipse.jdt.core.prefs b/eclipse/org.eclipse.jdt.core.prefs deleted file mode 100644 index fd3498331..000000000 --- a/eclipse/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,412 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=default -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=default -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.processAnnotations=disabled -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 -org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=false -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=do not insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=90 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=90 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/eclipse/org.eclipse.jdt.ui.prefs b/eclipse/org.eclipse.jdt.ui.prefs deleted file mode 100644 index e7f77db53..000000000 --- a/eclipse/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,125 +0,0 @@ -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=true -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=false -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=false -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=false -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=false -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup.use_type_arguments=false -cleanup_profile=_Spring Cloud Cleanup Conventions -cleanup_settings_version=2 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_Spring Cloud Java Conventions -formatter_settings_version=13 -org.eclipse.jdt.ui.exception.name=e -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=java;javax;;org.springframework;\#; -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=9999 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=9999 -org.eclipse.jdt.ui.text.custom_code_templates= -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=true -sp_cleanup.always_use_this_for_non_static_field_access=true -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=false -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=false -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=false -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=true -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=true -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/mvnw b/mvnw index 8d937f4c1..41c0f0c23 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -27,6 +27,7 @@ # # Optional ENV vars # ----------------- +# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,10 +36,6 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then - if [ -f /usr/local/etc/mavenrc ] ; then - . /usr/local/etc/mavenrc - fi - if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -53,7 +50,7 @@ fi cygwin=false; darwin=false; mingw=false -case "$(uname)" in +case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true @@ -61,9 +58,9 @@ case "$(uname)" in # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + export JAVA_HOME="`/usr/libexec/java_home`" else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + export JAVA_HOME="/Library/Java/Home" fi fi ;; @@ -71,38 +68,68 @@ esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=$(java-config --jre-home) + JAVA_HOME=`java-config --jre-home` fi fi +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && - JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then if $darwin ; then - javaHome="$(dirname "\"$javaExecutable\"")" - javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" else - javaExecutable="$(readlink -f "\"$javaExecutable\"")" + javaExecutable="`readlink -f \"$javaExecutable\"`" fi - javaHome="$(dirname "\"$javaExecutable\"")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` JAVA_HOME="$javaHome" export JAVA_HOME fi @@ -118,7 +145,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + JAVACMD="`which java`" fi fi @@ -132,9 +159,12 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { + if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" @@ -150,99 +180,96 @@ find_maven_basedir() { fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=$(cd "$wdir/.." || exit 1; pwd) + wdir=`cd "$wdir/.."; pwd` fi # end of workaround done - printf '%s' "$(cd "$basedir" || exit 1; pwd)" + echo "${basedir}" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - # Remove \r in case we run on Windows within Git Bash - # and check out the repository with auto CRLF management - # enabled. Otherwise, we may read lines that are delimited with - # \r\n and produce $'-Xarg\r' rather than -Xarg due to word - # splitting rules. - tr -s '\r\n' ' ' < "$1" + echo "$(tr -s '\n' ' ' < "$1")" fi } -log() { - if [ "$MVNW_VERBOSE" = true ]; then - printf '%s\n' "$1" - fi -} - -BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +BASE_DIR=`find_maven_basedir "$(pwd)"` if [ -z "$BASE_DIR" ]; then exit 1; fi -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR -log "$MAVEN_PROJECTBASEDIR" - ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## -wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" -else - log "Couldn't find $wrapperJarPath, downloading it ..." - - if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; esac - done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` fi if command -v wget > /dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget "$jarUrl" -O "$wrapperJarPath" else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" fi elif command -v curl > /dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") + javaClass=`cygpath --path --windows "$javaClass"` fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") fi fi fi @@ -251,58 +278,33 @@ fi # End of extension ########################################################################################## -# If specified, validate the SHA-256 sum of the Maven wrapper jar file -wrapperSha256Sum="" -while IFS="=" read -r key value; do - case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; - esac -done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" -if [ -n "$wrapperSha256Sum" ]; then - wrapperSha256Result=false - if command -v sha256sum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - elif command -v shasum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." - exit 1 - fi - if [ $wrapperSha256Result = false ]; then - echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 - echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 - echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 - exit 1 - fi +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR fi - MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -# shellcheck disable=SC2086 # safe args exec "$JAVACMD" \ $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index f80fbad3e..86115719e 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,205 +1,182 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.2.0 -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %WRAPPER_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file -SET WRAPPER_SHA_256_SUM="" -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B -) -IF NOT %WRAPPER_SHA_256_SUM%=="" ( - powershell -Command "&{"^ - "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ - "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ - " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ - " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ - " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ - " exit 1;"^ - "}"^ - "}" - if ERRORLEVEL 1 goto error -) - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% ^ - %JVM_CONFIG_MAVEN_PROPS% ^ - %MAVEN_OPTS% ^ - %MAVEN_DEBUG_OPTS% ^ - -classpath %WRAPPER_JAR% ^ - "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause - -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index bd1535700..632f9c243 100644 --- a/pom.xml +++ b/pom.xml @@ -1,260 +1,70 @@ - - - 4.0.0 - spring-cloud-netflix - 4.1.0-SNAPSHOT - pom - Spring Cloud Netflix - Spring Cloud Netflix - - org.springframework.cloud - spring-cloud-build - 4.1.0-SNAPSHOT - - - - https://github.com/spring-cloud/spring-cloud-netflix - scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git - scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git - HEAD - - - netflix - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - 1.17.6 - 5.15.0 + + - - jacoco - reuseReports - ${project.basedir}/../target/jacoco.exec - java - 3.1.0 - - true + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix-docs-build + 0.0.1-SNAPSHOT + + Spring Cloud Netflix Docs Build + Builds Spring Cloud Netflix Docs. + https://spring.io/projects/spring-cloud-netflix + + scm:git:https://github.com/spring-cloud/spring-cloud-netflix.git + + + scm:git:git@github.com:spring-cloud/spring-cloud-netflix.git + + https://github.com/spring-cloud/spring-cloud-netflix + + + https://github.com/spring-cloud/spring-cloud-netflix/issues + + + + 0.0.3 + + - org.codehaus.mojo - flatten-maven-plugin - - - org.apache.maven.plugins - maven-eclipse-plugin - ${maven-eclipse-plugin.version} + io.spring.maven.antora + antora-maven-plugin + ${io.spring.maven.antora-version} + true - false - - - .settings/org.eclipse.jdt.ui.prefs - ${maven.multiModuleProjectDirectory}/eclipse/org.eclipse.jdt.ui.prefs - - - .settings/org.eclipse.jdt.core.prefs - ${maven.multiModuleProjectDirectory}/eclipse/org.eclipse.jdt.core.prefs - - - - - - io.spring.javaformat - spring-javaformat-maven-plugin - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - org.basepom.maven - duplicate-finder-maven-plugin - - - about.html - plugin.properties - mozilla/public-suffix-list.txt - - false + + + + + + + 9d489079e5ec46dbb238909fee5c9c29 + WB1FQYI187 + springcloudnetflix + - - - - org.springframework.cloud - spring-cloud-netflix-dependencies - ${project.version} - pom - import - - - org.springframework.cloud - spring-cloud-commons-dependencies - ${spring-cloud-commons.version} - pom - import - - - org.springframework.cloud - spring-cloud-test-support - test - ${spring-cloud-commons.version} - - - org.springframework.cloud - spring-cloud-config-dependencies - ${spring-cloud-config.version} - pom - import - - - javax.inject - javax.inject - 1 - - - - - org.testcontainers - mockserver - ${testcontainers.version} - - - org.testcontainers - junit-jupiter - ${testcontainers.version} - - - org.mock-server - mockserver-client-java - ${mockserverclient.version} - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - spring-cloud-netflix-dependencies - spring-cloud-netflix-eureka-client - spring-cloud-netflix-eureka-server - spring-cloud-starter-netflix-eureka-client - spring-cloud-starter-netflix-eureka-server - spring-cloud-netflix-eureka-client-tls-tests - docs - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - - - sonar - - - - org.jacoco - jacoco-maven-plugin - - - pre-unit-test - - prepare-agent - - - surefireArgLine - ${project.build.directory}/jacoco.exec - - - - post-unit-test - test - - report - - - - ${project.build.directory}/jacoco.exec - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${surefireArgLine} - - - - - - + + + spring-snapshot + https://repo.spring.io/snapshot + + true + + + false + + + + spring-milestone + https://repo.spring.io/milestone + + + diff --git a/scripts/compileOnly.sh b/scripts/compileOnly.sh deleted file mode 100755 index 0b6040169..000000000 --- a/scripts/compileOnly.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -o errexit - -(cd spring-cloud-netflix-hystrix-contract && ../mvnw clean install -B -Pdocs -DskipTests) -./mvnw clean install -B -Pdocs -DskipTests -fae diff --git a/scripts/runAcceptanceTests.sh b/scripts/runAcceptanceTests.sh deleted file mode 100755 index 60186d417..000000000 --- a/scripts/runAcceptanceTests.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -set -o errexit - -mkdir -p target - -SCRIPT_URL="https://raw.githubusercontent.com/spring-cloud-samples/brewery/3.1.x/runAcceptanceTests.sh" -AT_WHAT_TO_TEST="EUREKA" - -cd target - -curl "${SCRIPT_URL}" --output runAcceptanceTests.sh - -chmod +x runAcceptanceTests.sh - -echo "Killing all running apps" -./runAcceptanceTests.sh -t "${AT_WHAT_TO_TEST}" --killnow - -./runAcceptanceTests.sh -t "${AT_WHAT_TO_TEST}" --killattheend - -SCRIPT_URL="https://raw.githubusercontent.com/spring-cloud-samples/tests/main/scripts/runTests.sh" - -curl "${SCRIPT_URL}" --output runIntegrationTests.sh - -chmod +x runIntegrationTests.sh - -./runIntegrationTests.sh diff --git a/spring-cloud-netflix-dependencies/pom.xml b/spring-cloud-netflix-dependencies/pom.xml deleted file mode 100644 index dd0f85f03..000000000 --- a/spring-cloud-netflix-dependencies/pom.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - 4.0.0 - - spring-cloud-dependencies-parent - org.springframework.cloud - 4.1.0-SNAPSHOT - - - spring-cloud-netflix-dependencies - 4.1.0-SNAPSHOT - pom - spring-cloud-netflix-dependencies - Spring Cloud Netflix Dependencies - - 2.0.1 - - - - - org.springframework.cloud - spring-cloud-netflix-eureka-client - ${project.version} - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - ${project.version} - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - ${project.version} - - - org.springframework.cloud - spring-cloud-netflix-eureka-server - ${project.version} - - - com.netflix.eureka - eureka-client - ${eureka.version} - - - com.netflix.archaius - archaius-core - - - com.github.vlsi.compactmap - compactmap - - - javax.servlet - servlet-api - - - commons-logging - commons-logging - - - com.google.code.findbugs - jsr305 - - - com.google.code.findbugs - annotations - - - org.glassfish.jersey.core - jersey-client - - - - - com.netflix.eureka - eureka-core - ${eureka.version} - - - com.netflix.archaius - archaius-core - - - javax.servlet - servlet-api - - - commons-logging - commons-logging - - - log4j - log4j - - - com.netflix.blitz4j - blitz4j - - - com.google.code.findbugs - annotations - - - com.google.code.findbugs - jsr305 - - - jackson-dataformat-xml - com.fasterxml.jackson.dataformat - - - * - com.amazonaws - - - - - com.netflix.eureka - eureka-core-jersey3 - ${eureka.version} - - - com.netflix.eureka - eureka-client-jersey3 - ${eureka.version} - - - aopalliance - aopalliance - - - - - - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - diff --git a/spring-cloud-netflix-eureka-client-tls-tests/.flattened-pom.xml b/spring-cloud-netflix-eureka-client-tls-tests/.flattened-pom.xml new file mode 100644 index 000000000..70ad86711 --- /dev/null +++ b/spring-cloud-netflix-eureka-client-tls-tests/.flattened-pom.xml @@ -0,0 +1,196 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + .. + + org.springframework.cloud + spring-cloud-netflix-eureka-client-tls-tests + 4.1.0-SNAPSHOT + Spring Cloud Netflix Eureka Client TLS Tests + Spring Cloud Netflix Eureka Client TLS Tests + https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client-tls-tests + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-client-tls-tests + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-client-tls-tests + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client-tls-tests + + + + org.springframework.cloud + spring-cloud-netflix-eureka-client + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-netflix-eureka-server + 4.1.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot + 3.2.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot-autoconfigure + 3.2.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot-starter-logging + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-commons + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-context + 4.1.0-SNAPSHOT + compile + + + org.springframework + spring-web + 6.1.0-M5 + compile + + + com.fasterxml.jackson.core + jackson-annotations + 2.15.2 + compile + + + org.springframework.retry + spring-retry + 2.0.3 + compile + + + javax.annotation + javax.annotation-api + + + true + + + org.springframework.boot + spring-boot-starter-actuator + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-aop + 3.2.0-SNAPSHOT + compile + true + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + compile + + + org.springframework.boot + spring-boot-autoconfigure-processor + 3.2.0-SNAPSHOT + compile + true + + + diff --git a/spring-cloud-netflix-eureka-client-tls-tests/pom.xml b/spring-cloud-netflix-eureka-client-tls-tests/pom.xml deleted file mode 100644 index 488aa9428..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - .. - - spring-cloud-netflix-eureka-client-tls-tests - jar - Spring Cloud Netflix Eureka Client TLS Tests - Spring Cloud Netflix Eureka Client TLS Tests - - - - org.springframework.cloud - spring-cloud-netflix-eureka-client - - - org.springframework.cloud - spring-cloud-netflix-eureka-server - - - - org.springframework.boot - spring-boot - - - org.springframework.boot - spring-boot-autoconfigure - - - org.springframework.boot - spring-boot-starter-logging - true - - - org.springframework.cloud - spring-cloud-commons - - - org.springframework.cloud - spring-cloud-context - - - org.springframework - spring-web - - - com.fasterxml.jackson.core - jackson-annotations - - - org.springframework.retry - spring-retry - true - - - javax.annotation - javax.annotation-api - - - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.boot - spring-boot-starter-aop - true - - - com.fasterxml.jackson.core - jackson-databind - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.cloud - spring-cloud-test-support - test - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.junit.vintage - junit-vintage-engine - test - - - org.bouncycastle - bcpkix-jdk15on - 1.68 - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Suite.java - - - **/*Test.java - **/*Tests.java - - - - - maven-deploy-plugin - - true - - - - - diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/AppRunner.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/AppRunner.java deleted file mode 100644 index 2c70d09bf..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/AppRunner.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.test.TestSocketUtils; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; - -public class AppRunner implements AutoCloseable { - - private final Class appClass; - - private final Map props; - - private ConfigurableApplicationContext app; - - public AppRunner(Class appClass) { - this.appClass = appClass; - props = new LinkedHashMap<>(); - } - - public void property(String key, String value) { - props.put(key, value); - } - - public void start() { - if (app == null) { - SpringApplicationBuilder builder = new SpringApplicationBuilder(appClass); - builder.properties("spring.application.name=" + appClass.getName()); - builder.properties("spring.jmx.enabled=false"); - builder.properties(String.format("server.port=%d", availabeTcpPort())); - builder.properties(props()); - - app = builder.build().run(); - } - } - - private int availabeTcpPort() { - return TestSocketUtils.findAvailableTcpPort(); - } - - private String[] props() { - List result = new ArrayList<>(); - - for (String key : props.keySet()) { - String value = props.get(key); - result.add(String.format("%s=%s", key, value)); - } - - return result.toArray(new String[0]); - } - - public void stop() { - if (app != null) { - app.stop(); - int attempts = 5; - while (app.isRunning() && attempts > 0) { - attempts = attempts - 1; - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - app = null; - } - } - - public ConfigurableApplicationContext app() { - return app; - } - - public String getProperty(String key) { - return app.getEnvironment().getProperty(key); - } - - public T getBean(Class type) { - return app.getBean(type); - } - - public ApplicationContext parent() { - return app.getParent(); - } - - public Map getParentBeans(Class type) { - return parent().getBeansOfType(type); - } - - public int port() { - if (app == null) { - throw new RuntimeException("App is not running."); - } - return app.getEnvironment().getProperty("server.port", Integer.class, -1); - } - - public String root() { - if (app == null) { - throw new RuntimeException("App is not running."); - } - - String protocol = tlsEnabled() ? "https" : "http"; - return String.format("%s://localhost:%d/", protocol, port()); - } - - private boolean tlsEnabled() { - return app.getEnvironment().getProperty("server.ssl.enabled", Boolean.class, false); - } - - @Override - public void close() { - stop(); - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/BaseCertTest.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/BaseCertTest.java deleted file mode 100644 index 6c414ff8a..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/BaseCertTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.security.KeyStore; -import java.util.function.Supplier; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.BeanCreationException; - -import static org.assertj.core.api.Assertions.assertThat; - -abstract class BaseCertTest { - - private static final Log log = LogFactory.getLog(BaseCertTest.class); - - protected static final String KEY_STORE_PASSWORD = "test-key-store-password"; - - protected static final String KEY_PASSWORD = "test-key-password"; - - protected static final String WRONG_PASSWORD = "test-wrong-password"; - - protected static File caCert; - - protected static File wrongCaCert; - - protected static File serverCert; - - protected static File clientCert; - - protected static File wrongClientCert; - - protected BaseCertTest() { - } - - @SuppressWarnings("rawtypes") - static EurekaServerRunner startEurekaServer(Class config) { - EurekaServerRunner server = new EurekaServerRunner(config); - server.enableTls(); - server.setKeyStore(serverCert, KEY_STORE_PASSWORD, "server", KEY_PASSWORD); - server.setTrustStore(caCert, KEY_STORE_PASSWORD); - - server.start(); - return server; - } - - static void stopEurekaServer(EurekaServerRunner server) { - server.stop(); - } - - @SuppressWarnings("rawtypes") - static EurekaClientRunner startService(EurekaServerRunner server, Class config) { - EurekaClientRunner service = new EurekaClientRunner(config, server, "testservice"); - enableTlsClient(service); - service.start(); - return service; - } - - static void stopService(EurekaClientRunner service) { - service.stop(); - } - - static void enableTlsClient(EurekaClientRunner runner) { - runner.enableTls(); - runner.setKeyStore(clientCert, KEY_STORE_PASSWORD, KEY_PASSWORD); - runner.setTrustStore(caCert, KEY_STORE_PASSWORD); - } - - static void waitForRegistration(Supplier clientSupplier) { - try (EurekaClientRunner client = clientSupplier.get()) { - enableTlsClient(client); - client.start(); - client.waitServiceViaEureka(60); - } - } - - @BeforeAll - static void createCertificates() throws Exception { - KeyTool tool = new KeyTool(); - - KeyAndCert ca = tool.createCA("MyCA"); - KeyAndCert server = ca.sign("server"); - KeyAndCert client = ca.sign("client"); - - caCert = saveCert(ca); - serverCert = saveKeyAndCert(server); - clientCert = saveKeyAndCert(client); - - KeyAndCert wrongCa = tool.createCA("WrongCA"); - KeyAndCert wrongClient = wrongCa.sign("client"); - - wrongCaCert = saveCert(wrongCa); - wrongClientCert = saveKeyAndCert(wrongClient); - } - - @AfterAll - static void afterClass() { - log.info("Tests finished!"); - } - - abstract EurekaClientRunner createEurekaClient(); - - /** - * Already proved this in waitForRegistration(). Keep this Test to express test - * purpose explicitly. - */ - @Test - void clientCertCanWork() { - } - - @Test - void noCertCannotWork() { - try (EurekaClientRunner client = createEurekaClient()) { - client.disableTls(); - client.start(); - assertThat(client.foundServiceViaEureka()).isFalse(); - } - } - - @Test - void wrongCertCannotWork() { - try (EurekaClientRunner client = createEurekaClient()) { - enableTlsClient(client); - client.setKeyStore(wrongClientCert); - client.start(); - assertThat(client.foundServiceViaEureka()).isFalse(); - } - } - - @Test - void wrongPasswordCauseFailure() { - EurekaClientRunner client = createEurekaClient(); - enableTlsClient(client); - client.setKeyStore(clientCert, WRONG_PASSWORD, WRONG_PASSWORD); - Assertions.assertThrows(BeanCreationException.class, client::start); - } - - @Test - void nonExistKeyStoreCauseFailure() { - EurekaClientRunner client = createEurekaClient(); - enableTlsClient(client); - client.setKeyStore(new File("nonExistFile")); - Assertions.assertThrows(BeanCreationException.class, client::start); - } - - @Test - void wrongTrustStoreCannotWork() { - try (EurekaClientRunner client = createEurekaClient()) { - enableTlsClient(client); - client.setTrustStore(wrongCaCert); - client.start(); - assertThat(client.foundServiceViaEureka()).isFalse(); - } - } - - private static File saveKeyAndCert(KeyAndCert keyCert) throws Exception { - return saveKeyStore(keyCert.subject(), () -> keyCert.storeKeyAndCert(KEY_PASSWORD)); - } - - private static File saveCert(KeyAndCert keyCert) throws Exception { - return saveKeyStore(keyCert.subject(), keyCert::storeCert); - } - - private static File saveKeyStore(String prefix, KeyStoreSupplier func) throws Exception { - File result = File.createTempFile(prefix, ".p12"); - result.deleteOnExit(); - - try (OutputStream output = new FileOutputStream(result)) { - KeyStore store = func.createKeyStore(); - store.store(output, KEY_STORE_PASSWORD.toCharArray()); - } - return result; - } - - interface KeyStoreSupplier { - - KeyStore createKeyStore() throws Exception; - - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientRunner.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientRunner.java deleted file mode 100644 index d789aa910..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientRunner.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.io.File; -import java.util.function.BooleanSupplier; - -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; - -import org.springframework.cloud.client.discovery.DiscoveryClient; - -public class EurekaClientRunner extends AppRunner { - - public EurekaClientRunner(Class appClass, AppRunner server) { - super(appClass); - - property("eureka.client.registerWithEureka", "false"); - property("eureka.client.fetchRegistry", "true"); - property("eureka.client.serviceUrl.defaultZone", server.root() + "eureka/"); - property("eureka.client.refresh.enable", "true"); - } - - public EurekaClientRunner(Class appClass, AppRunner server, String service) { - this(appClass, server); - property("eureka.client.registerWithEureka", "true"); - property("spring.application.name", service); - } - - public void enableTls() { - property("eureka.client.tls.enabled", "true"); - } - - public void disableTls() { - property("eureka.client.tls.enabled", "false"); - } - - public void setKeyStore(File keyStore, String keyStorePassword, String keyPassword) { - property("eureka.client.tls.key-store", pathOf(keyStore)); - property("eureka.client.tls.key-store-password", keyStorePassword); - property("eureka.client.tls.key-password", keyPassword); - } - - public void setKeyStore(File keyStore) { - property("eureka.client.tls.key-store", pathOf(keyStore)); - } - - public void setTrustStore(File trustStore, String password) { - property("eureka.client.tls.trust-store", pathOf(trustStore)); - property("eureka.client.tls.trust-store-password", password); - } - - public void setTrustStore(File trustStore) { - property("eureka.client.tls.trust-store", pathOf(trustStore)); - } - - private String pathOf(File file) { - return String.format("file:%s", file.getAbsolutePath()); - } - - public void waitServiceViaEureka(int seconds) { - assertInSeconds(this::foundServiceViaEureka, seconds); - } - - private void assertInSeconds(BooleanSupplier assertion, int seconds) { - long start = System.currentTimeMillis(); - long limit = 1000L * seconds; - long duration; - - do { - if (assertion.getAsBoolean()) { - return; - } - duration = System.currentTimeMillis() - start; - Thread.yield(); - - } - while (duration < limit); - - throw new RuntimeException(); - } - - public boolean foundServiceViaEureka() { - DiscoveryClient discovery = getBean(DiscoveryClient.class); - return !discovery.getServices().isEmpty(); - } - - @SuppressWarnings("unchecked") - public AbstractDiscoveryClientOptionalArgs discoveryClientOptionalArgs() { - return getBean(AbstractDiscoveryClientOptionalArgs.class); - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientSuite.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientSuite.java deleted file mode 100644 index 9fcaebe61..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientSuite.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * We need to use a suite cause we need to first run all the Eureka Servers, then close - * all of them. We can't run one EurekaServer, close it and then run another one, cause - * Eureka is using static executor services that are shutdown when we close a context. - * That means that when the new context starts we will fail cause the executor service is - * already shutdown. - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ EurekaClientTest.class, RestTemplateEurekaClientTest.class }) -public class EurekaClientSuite { - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientTest.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientTest.java deleted file mode 100644 index 9503e5639..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.BeforeAll; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; - -import static org.assertj.core.api.Assertions.assertThat; - -public class EurekaClientTest extends BaseCertTest { - - private static final Log log = LogFactory.getLog(EurekaClientTest.class); - - static EurekaServerRunner server; - - static EurekaClientRunner service; - - @BeforeAll - public static void setupAll() { - server = startEurekaServer(EurekaClientTest.TestEurekaServer.class); - service = startService(server, EurekaClientTest.TestApp.class); - assertThat(service.discoveryClientOptionalArgs()).isInstanceOf(RestTemplateDiscoveryClientOptionalArgs.class); - log.info("Successfully asserted that Jersey will be used"); - waitForRegistration(() -> new EurekaClientTest().createEurekaClient()); - } - - @Override - EurekaClientRunner createEurekaClient() { - return new EurekaClientRunner(TestApp.class, server); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - public static class TestApp { - - } - - @SpringBootConfiguration - @EnableAutoConfiguration - @EnableEurekaServer - public static class TestEurekaServer { - - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServerRunner.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServerRunner.java deleted file mode 100644 index b6ab8e7d2..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServerRunner.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.io.File; - -public class EurekaServerRunner extends AppRunner { - - public EurekaServerRunner(Class appClass) { - super(appClass); - - property("eureka.client.registerWithEureka", "false"); - property("eureka.client.fetchRegistry", "false"); - property("eureka.server.waitTimeInMsWhenSyncEmpty", "0"); - property("eureka.client.refresh.enable", "true"); - } - - public void enableTls() { - property("server.ssl.enabled", "true"); - property("server.ssl.client-auth", "need"); - } - - public void setKeyStore(File keyStore, String keyStorePassword, String key, String keyPassword) { - property("server.ssl.key-store", pathOf(keyStore)); - property("server.ssl.key-store-type", "PKCS12"); - property("server.ssl.key-store-password", keyStorePassword); - property("server.ssl.key-alias", key); - property("server.ssl.key-password", keyPassword); - } - - public void setTrustStore(File trustStore, String password) { - property("server.ssl.trust-store", pathOf(trustStore)); - property("server.ssl.trust-store-type", "PKCS12"); - property("server.ssl.trust-store-password", password); - } - - private String pathOf(File file) { - return String.format("file:%s", file.getAbsolutePath()); - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyAndCert.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyAndCert.java deleted file mode 100644 index ae808937f..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyAndCert.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.security.KeyPair; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; - -public class KeyAndCert { - - private final KeyPair keyPair; - - private final X509Certificate certificate; - - public KeyAndCert(KeyPair keyPair, X509Certificate certificate) { - this.keyPair = keyPair; - this.certificate = certificate; - } - - public KeyPair keyPair() { - return keyPair; - } - - public PublicKey publicKey() { - return keyPair.getPublic(); - } - - public PrivateKey privateKey() { - return keyPair.getPrivate(); - } - - public X509Certificate certificate() { - return certificate; - } - - public String subject() { - String dn = certificate.getSubjectX500Principal().getName(); - int index = dn.indexOf('='); - return dn.substring(index + 1); - } - - public KeyAndCert sign(String subject) throws Exception { - KeyTool tool = new KeyTool(); - return tool.signCertificate(subject, this); - } - - public KeyAndCert sign(KeyPair keyPair, String subject) throws Exception { - KeyTool tool = new KeyTool(); - return tool.signCertificate(keyPair, subject, this); - } - - public KeyStore storeKeyAndCert(String keyPassword) throws Exception { - KeyStore result = KeyStore.getInstance("PKCS12"); - result.load(null); - - result.setKeyEntry(subject(), keyPair.getPrivate(), keyPassword.toCharArray(), certChain()); - return result; - } - - private Certificate[] certChain() { - return new Certificate[] { certificate() }; - } - - public KeyStore storeCert() throws Exception { - return storeCert("PKCS12"); - } - - public KeyStore storeCert(String storeType) throws Exception { - KeyStore result = KeyStore.getInstance(storeType); - result.load(null); - - result.setCertificateEntry(subject(), certificate()); - return result; - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyTool.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyTool.java deleted file mode 100644 index b29173f18..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/KeyTool.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.Date; - -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.asn1.x509.BasicConstraints; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.asn1.x509.KeyUsage; -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder; -import org.bouncycastle.operator.ContentSigner; -import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; - -public class KeyTool { - - private static final long ONE_DAY = 1000L * 60L * 60L * 24L; - - private static final long TEN_YEARS = ONE_DAY * 365L * 10L; - - public KeyAndCert createCA(String ca) throws Exception { - KeyPair keyPair = createKeyPair(); - X509Certificate certificate = createCert(keyPair, ca); - return new KeyAndCert(keyPair, certificate); - } - - public KeyAndCert signCertificate(String subject, KeyAndCert signer) throws Exception { - return signCertificate(createKeyPair(), subject, signer); - } - - public KeyAndCert signCertificate(KeyPair keyPair, String subject, KeyAndCert signer) throws Exception { - X509Certificate certificate = createCert(keyPair.getPublic(), signer.privateKey(), signer.subject(), subject); - return new KeyAndCert(keyPair, certificate); - } - - public KeyPair createKeyPair() throws Exception { - return createKeyPair(1024); - } - - public KeyPair createKeyPair(int keySize) throws Exception { - KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); - gen.initialize(keySize, new SecureRandom()); - return gen.generateKeyPair(); - } - - public X509Certificate createCert(KeyPair keyPair, String ca) throws Exception { - JcaX509v3CertificateBuilder builder = certBuilder(keyPair.getPublic(), ca, ca); - builder.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.keyCertSign)); - builder.addExtension(Extension.basicConstraints, false, new BasicConstraints(true)); - - return signCert(builder, keyPair.getPrivate()); - } - - public X509Certificate createCert(PublicKey publicKey, PrivateKey privateKey, String issuer, String subject) - throws Exception { - JcaX509v3CertificateBuilder builder = certBuilder(publicKey, issuer, subject); - builder.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.digitalSignature)); - builder.addExtension(Extension.basicConstraints, false, new BasicConstraints(false)); - - GeneralName[] names = new GeneralName[] { new GeneralName(GeneralName.dNSName, "localhost") }; - builder.addExtension(Extension.subjectAlternativeName, false, GeneralNames.getInstance(new DERSequence(names))); - - return signCert(builder, privateKey); - } - - private JcaX509v3CertificateBuilder certBuilder(PublicKey publicKey, String issuer, String subject) { - X500Name issuerName = new X500Name(String.format("dc=%s", issuer)); - X500Name subjectName = new X500Name(String.format("dc=%s", subject)); - - long now = System.currentTimeMillis(); - BigInteger serialNum = BigInteger.valueOf(now); - Date notBefore = new Date(now - ONE_DAY); - Date notAfter = new Date(now + TEN_YEARS); - - return new JcaX509v3CertificateBuilder(issuerName, serialNum, notBefore, notAfter, subjectName, publicKey); - } - - private X509Certificate signCert(JcaX509v3CertificateBuilder builder, PrivateKey privateKey) throws Exception { - ContentSigner signer = new JcaContentSignerBuilder("SHA256WithRSA").build(privateKey); - X509CertificateHolder holder = builder.build(signer); - - return new JcaX509CertificateConverter().getCertificate(holder); - } - -} diff --git a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/RestTemplateEurekaClientTest.java b/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/RestTemplateEurekaClientTest.java deleted file mode 100644 index 5ce74316c..000000000 --- a/spring-cloud-netflix-eureka-client-tls-tests/src/test/java/org/springframework/cloud/netflix/eureka/RestTemplateEurekaClientTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2018-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.configuration.TlsProperties; -import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration; -import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RestTemplateEurekaClientTest extends BaseCertTest { - - private static final Log log = LogFactory.getLog(RestTemplateEurekaClientTest.class); - - private static EurekaServerRunner server; - - private static EurekaClientRunner service; - - @BeforeAll - public static void setupAll() { - server = startEurekaServer(RestTemplateEurekaClientTest.RestTemplateTestEurekaServer.class); - service = startService(server, RestTemplateEurekaClientTest.RestTemplateTestApp.class); - // Will use RestTemplate - assertThat(service.discoveryClientOptionalArgs()).isInstanceOf(RestTemplateDiscoveryClientOptionalArgs.class); - log.info("Successfully asserted that RestTemplate will be used"); - waitForRegistration(() -> new RestTemplateEurekaClientTest().createEurekaClient()); - } - - @AfterAll - public static void tearDownAll() { - stopService(service); - stopEurekaServer(server); - } - - @Override - EurekaClientRunner createEurekaClient() { - return new EurekaClientRunner(RestTemplateTestApp.class, server); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - public static class RestTemplateTestApp { - - // Want to force reusing exactly the same bean as on production without excluding - // jersey from the classpath - @Bean - public RestTemplateDiscoveryClientOptionalArgs forceRestTemplateDiscoveryClientOptionalArgs( - TlsProperties tlsProperties, DiscoveryClientOptionalArgsConfiguration configuration, - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) - throws GeneralSecurityException, IOException { - return configuration.restTemplateDiscoveryClientOptionalArgs(tlsProperties, - eurekaClientHttpRequestFactorySupplier); - } - - } - - @SpringBootConfiguration - @EnableAutoConfiguration - @EnableEurekaServer - public static class RestTemplateTestEurekaServer { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/.flattened-pom.xml b/spring-cloud-netflix-eureka-client/.flattened-pom.xml new file mode 100644 index 000000000..d67c9ae2d --- /dev/null +++ b/spring-cloud-netflix-eureka-client/.flattened-pom.xml @@ -0,0 +1,237 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + .. + + org.springframework.cloud + spring-cloud-netflix-eureka-client + 4.1.0-SNAPSHOT + Spring Cloud Netflix Eureka Client + Spring Cloud Netflix Eureka Client + https://spring.io/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-client + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-client + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-client + + + + org.springframework.boot + spring-boot-configuration-processor + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-actuator + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-webflux + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-config-client + 4.1.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-loadbalancer + 4.1.0-SNAPSHOT + compile + true + + + com.netflix.eureka + eureka-client + 2.0.1 + compile + + + com.netflix.archaius + archaius-core + + + com.github.vlsi.compactmap + compactmap + + + javax.servlet + servlet-api + + + commons-logging + commons-logging + + + com.google.code.findbugs + jsr305 + + + com.google.code.findbugs + annotations + + + org.glassfish.jersey.core + jersey-client + + + + + javax.inject + javax.inject + 1 + compile + true + + + com.netflix.eureka + eureka-core + 2.0.1 + compile + + + com.netflix.archaius + archaius-core + + + javax.servlet + servlet-api + + + commons-logging + commons-logging + + + log4j + log4j + + + blitz4j + com.netflix.blitz4j + + + com.google.code.findbugs + annotations + + + com.google.code.findbugs + jsr305 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.amazonaws + * + + + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + 3.2.0-SNAPSHOT + compile + true + + + org.apache.httpcomponents.client5 + httpclient5 + 5.2.1 + compile + + + diff --git a/spring-cloud-netflix-eureka-client/pom.xml b/spring-cloud-netflix-eureka-client/pom.xml deleted file mode 100644 index a764e0390..000000000 --- a/spring-cloud-netflix-eureka-client/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - .. - - spring-cloud-netflix-eureka-client - jar - Spring Cloud Netflix Eureka Client - Spring Cloud Netflix Eureka Client - - - false - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.boot - spring-boot-starter-webflux - true - - - org.springframework.cloud - spring-cloud-config-client - true - - - org.springframework.cloud - spring-cloud-config-server - test - - - org.springframework.cloud - spring-cloud-loadbalancer - true - - - com.netflix.eureka - eureka-client - - - javax.inject - javax.inject - true - - - com.netflix.eureka - eureka-core - true - - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.apache.httpcomponents.client5 - httpclient5 - - - org.springframework.boot - spring-boot-starter-security - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.springframework.cloud - spring-cloud-test-support - test - - - org.springframework.retry - spring-retry - test - - - javax.annotation - javax.annotation-api - - - - - io.projectreactor - reactor-test - test - - - org.testcontainers - mockserver - test - - - org.testcontainers - junit-jupiter - test - - - org.mock-server - mockserver-client-java - test - - - diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaClient.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaClient.java deleted file mode 100644 index a430feb3b..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaClient.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.lang.reflect.Field; -import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import com.netflix.discovery.DiscoveryClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.client.discovery.event.HeartbeatEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.http.HttpStatus; -import org.springframework.util.ReflectionUtils; - -/** - * Subclass of {@link DiscoveryClient} that sends a {@link HeartbeatEvent} when - * {@link CloudEurekaClient#onCacheRefreshed()} is called. - * - * @author Spencer Gibb - */ -public class CloudEurekaClient extends DiscoveryClient { - - private static final Log log = LogFactory.getLog(CloudEurekaClient.class); - - private final AtomicLong cacheRefreshedCount = new AtomicLong(0); - - private final ApplicationEventPublisher publisher; - - private final Field eurekaTransportField; - - private final ApplicationInfoManager applicationInfoManager; - - private final AtomicReference eurekaHttpClient = new AtomicReference<>(); - - public CloudEurekaClient(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config, - TransportClientFactories transportClientFactories, ApplicationEventPublisher publisher) { - this(applicationInfoManager, config, transportClientFactories, null, publisher); - } - - public CloudEurekaClient(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config, - TransportClientFactories transportClientFactories, AbstractDiscoveryClientOptionalArgs args, - ApplicationEventPublisher publisher) { - super(applicationInfoManager, config, transportClientFactories, args); - this.applicationInfoManager = applicationInfoManager; - this.publisher = publisher; - this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class, "eurekaTransport"); - ReflectionUtils.makeAccessible(this.eurekaTransportField); - } - - public ApplicationInfoManager getApplicationInfoManager() { - return applicationInfoManager; - } - - public void cancelOverrideStatus(InstanceInfo info) { - getEurekaHttpClient().deleteStatusOverride(info.getAppName(), info.getId(), info); - } - - public InstanceInfo getInstanceInfo(String appname, String instanceId) { - EurekaHttpResponse response = getEurekaHttpClient().getInstance(appname, instanceId); - HttpStatus httpStatus = HttpStatus.valueOf(response.getStatusCode()); - if (httpStatus.is2xxSuccessful() && response.getEntity() != null) { - return response.getEntity(); - } - return null; - } - - EurekaHttpClient getEurekaHttpClient() { - if (this.eurekaHttpClient.get() == null) { - try { - Object eurekaTransport = this.eurekaTransportField.get(this); - Field registrationClientField = ReflectionUtils.findField(eurekaTransport.getClass(), - "registrationClient"); - ReflectionUtils.makeAccessible(registrationClientField); - this.eurekaHttpClient.compareAndSet(null, - (EurekaHttpClient) registrationClientField.get(eurekaTransport)); - } - catch (IllegalAccessException e) { - log.error("error getting EurekaHttpClient", e); - } - } - return this.eurekaHttpClient.get(); - } - - public void setStatus(InstanceStatus newStatus, InstanceInfo info) { - getEurekaHttpClient().statusUpdate(info.getAppName(), info.getId(), newStatus, info); - } - - @Override - protected void onCacheRefreshed() { - super.onCacheRefreshed(); - - if (this.cacheRefreshedCount != null) { // might be called during construction and - // will be null - long newCount = this.cacheRefreshedCount.incrementAndGet(); - log.trace("onCacheRefreshed called with count: " + newCount); - this.publisher.publishEvent(new HeartbeatEvent(this, newCount)); - } - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaInstanceConfig.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaInstanceConfig.java deleted file mode 100644 index 4b1fe1c06..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaInstanceConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.appinfo.InstanceInfo; - -/** - * @author Spencer Gibb - */ -public interface CloudEurekaInstanceConfig extends EurekaInstanceConfig { - - void setNonSecurePort(int port); - - void setSecurePort(int securePort); - - InstanceInfo.InstanceStatus getInitialStatus(); - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaTransportConfig.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaTransportConfig.java deleted file mode 100644 index 2a6f1b5e0..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/CloudEurekaTransportConfig.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Objects; - -import com.netflix.discovery.shared.transport.EurekaTransportConfig; - -/** - * @author Spencer Gibb - * @author Gregor Zurowski - */ -public class CloudEurekaTransportConfig implements EurekaTransportConfig { - - private int sessionedClientReconnectIntervalSeconds = 20 * 60; - - private double retryableClientQuarantineRefreshPercentage = 0.66; - - private int bootstrapResolverRefreshIntervalSeconds = 5 * 60; - - private int applicationsResolverDataStalenessThresholdSeconds = 5 * 60; - - private int asyncResolverRefreshIntervalMs = 5 * 60 * 1000; - - private int asyncResolverWarmUpTimeoutMs = 5000; - - private int asyncExecutorThreadPoolSize = 5; - - private String readClusterVip; - - private String writeClusterVip; - - private boolean bootstrapResolverForQuery = true; - - private String bootstrapResolverStrategy; - - private boolean applicationsResolverUseIp = false; - - @Override - public boolean useBootstrapResolverForQuery() { - return this.bootstrapResolverForQuery; - } - - @Override - public boolean applicationsResolverUseIp() { - return this.applicationsResolverUseIp; - } - - public int getSessionedClientReconnectIntervalSeconds() { - return sessionedClientReconnectIntervalSeconds; - } - - public void setSessionedClientReconnectIntervalSeconds(int sessionedClientReconnectIntervalSeconds) { - this.sessionedClientReconnectIntervalSeconds = sessionedClientReconnectIntervalSeconds; - } - - public double getRetryableClientQuarantineRefreshPercentage() { - return retryableClientQuarantineRefreshPercentage; - } - - public void setRetryableClientQuarantineRefreshPercentage(double retryableClientQuarantineRefreshPercentage) { - this.retryableClientQuarantineRefreshPercentage = retryableClientQuarantineRefreshPercentage; - } - - public int getBootstrapResolverRefreshIntervalSeconds() { - return bootstrapResolverRefreshIntervalSeconds; - } - - public void setBootstrapResolverRefreshIntervalSeconds(int bootstrapResolverRefreshIntervalSeconds) { - this.bootstrapResolverRefreshIntervalSeconds = bootstrapResolverRefreshIntervalSeconds; - } - - public int getApplicationsResolverDataStalenessThresholdSeconds() { - return applicationsResolverDataStalenessThresholdSeconds; - } - - public void setApplicationsResolverDataStalenessThresholdSeconds( - int applicationsResolverDataStalenessThresholdSeconds) { - this.applicationsResolverDataStalenessThresholdSeconds = applicationsResolverDataStalenessThresholdSeconds; - } - - public int getAsyncResolverRefreshIntervalMs() { - return asyncResolverRefreshIntervalMs; - } - - public void setAsyncResolverRefreshIntervalMs(int asyncResolverRefreshIntervalMs) { - this.asyncResolverRefreshIntervalMs = asyncResolverRefreshIntervalMs; - } - - public int getAsyncResolverWarmUpTimeoutMs() { - return asyncResolverWarmUpTimeoutMs; - } - - public void setAsyncResolverWarmUpTimeoutMs(int asyncResolverWarmUpTimeoutMs) { - this.asyncResolverWarmUpTimeoutMs = asyncResolverWarmUpTimeoutMs; - } - - public int getAsyncExecutorThreadPoolSize() { - return asyncExecutorThreadPoolSize; - } - - public void setAsyncExecutorThreadPoolSize(int asyncExecutorThreadPoolSize) { - this.asyncExecutorThreadPoolSize = asyncExecutorThreadPoolSize; - } - - public String getReadClusterVip() { - return readClusterVip; - } - - public void setReadClusterVip(String readClusterVip) { - this.readClusterVip = readClusterVip; - } - - public String getWriteClusterVip() { - return writeClusterVip; - } - - public void setWriteClusterVip(String writeClusterVip) { - this.writeClusterVip = writeClusterVip; - } - - public boolean isBootstrapResolverForQuery() { - return bootstrapResolverForQuery; - } - - public void setBootstrapResolverForQuery(boolean bootstrapResolverForQuery) { - this.bootstrapResolverForQuery = bootstrapResolverForQuery; - } - - public String getBootstrapResolverStrategy() { - return bootstrapResolverStrategy; - } - - public void setBootstrapResolverStrategy(String bootstrapResolverStrategy) { - this.bootstrapResolverStrategy = bootstrapResolverStrategy; - } - - public boolean isApplicationsResolverUseIp() { - return applicationsResolverUseIp; - } - - public void setApplicationsResolverUseIp(boolean applicationsResolverUseIp) { - this.applicationsResolverUseIp = applicationsResolverUseIp; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CloudEurekaTransportConfig that = (CloudEurekaTransportConfig) o; - return sessionedClientReconnectIntervalSeconds == that.sessionedClientReconnectIntervalSeconds - && Double.compare(retryableClientQuarantineRefreshPercentage, - that.retryableClientQuarantineRefreshPercentage) == 0 - && bootstrapResolverRefreshIntervalSeconds == that.bootstrapResolverRefreshIntervalSeconds - && applicationsResolverDataStalenessThresholdSeconds == that.applicationsResolverDataStalenessThresholdSeconds - && asyncResolverRefreshIntervalMs == that.asyncResolverRefreshIntervalMs - && asyncResolverWarmUpTimeoutMs == that.asyncResolverWarmUpTimeoutMs - && asyncExecutorThreadPoolSize == that.asyncExecutorThreadPoolSize - && Objects.equals(readClusterVip, that.readClusterVip) - && Objects.equals(writeClusterVip, that.writeClusterVip) - && bootstrapResolverForQuery == that.bootstrapResolverForQuery - && Objects.equals(bootstrapResolverStrategy, that.bootstrapResolverStrategy) - && applicationsResolverUseIp == that.applicationsResolverUseIp; - } - - @Override - public int hashCode() { - return Objects.hash(sessionedClientReconnectIntervalSeconds, retryableClientQuarantineRefreshPercentage, - bootstrapResolverRefreshIntervalSeconds, applicationsResolverDataStalenessThresholdSeconds, - asyncResolverRefreshIntervalMs, asyncResolverWarmUpTimeoutMs, asyncExecutorThreadPoolSize, - readClusterVip, writeClusterVip, bootstrapResolverForQuery, bootstrapResolverStrategy, - applicationsResolverUseIp); - } - - @Override - public String toString() { - return new StringBuilder("CloudEurekaTransportConfig{").append("sessionedClientReconnectIntervalSeconds=") - .append(sessionedClientReconnectIntervalSeconds).append(", ") - .append("retryableClientQuarantineRefreshPercentage=") - .append(retryableClientQuarantineRefreshPercentage).append(", ") - .append("bootstrapResolverRefreshIntervalSeconds=").append(bootstrapResolverRefreshIntervalSeconds) - .append(", ").append("applicationsResolverDataStalenessThresholdSeconds=") - .append(applicationsResolverDataStalenessThresholdSeconds).append(", ") - .append("asyncResolverRefreshIntervalMs=").append(asyncResolverRefreshIntervalMs).append(", ") - .append("asyncResolverWarmUpTimeoutMs=").append(asyncResolverWarmUpTimeoutMs).append(", ") - .append("asyncExecutorThreadPoolSize=").append(asyncExecutorThreadPoolSize).append(", ") - .append("readClusterVip='").append(readClusterVip).append("', ").append("writeClusterVip='") - .append(writeClusterVip).append("', ").append("bootstrapResolverForQuery=") - .append(bootstrapResolverForQuery).append(", ").append("bootstrapResolverStrategy='") - .append(bootstrapResolverStrategy).append("', ").append("applicationsResolverUseIp=") - .append(applicationsResolverUseIp).append(", ").append("}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java deleted file mode 100644 index 29776c7b9..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.Map; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.LeaseInfo; -import com.netflix.appinfo.MyDataCenterInfo; -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import com.netflix.discovery.DiscoveryClient; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.TimedSupervisorTask; -import com.netflix.discovery.converters.jackson.DataCenterTypeInfoResolver; -import com.netflix.discovery.converters.jackson.builder.ApplicationsJacksonBuilder; -import com.netflix.discovery.converters.jackson.mixin.InstanceInfoJsonMixIn; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.resolver.AsyncResolver; -import com.netflix.discovery.shared.resolver.DefaultEndpoint; -import com.netflix.discovery.shared.resolver.EurekaEndpoint; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator; -import com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient; -import com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; - -import org.springframework.aop.support.AopUtils; -import org.springframework.aot.hint.MemberCategory; -import org.springframework.aot.hint.RuntimeHints; -import org.springframework.aot.hint.RuntimeHintsRegistrar; -import org.springframework.aot.hint.TypeReference; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.SearchStrategy; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.cloud.client.CommonsClientAutoConfiguration; -import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled; -import org.springframework.cloud.client.actuator.HasFeatures; -import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; -import org.springframework.cloud.client.serviceregistry.ServiceRegistryAutoConfiguration; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.context.scope.refresh.RefreshScope; -import org.springframework.cloud.netflix.eureka.metadata.DefaultManagementMetadataProvider; -import org.springframework.cloud.netflix.eureka.metadata.ManagementMetadata; -import org.springframework.cloud.netflix.eureka.metadata.ManagementMetadataProvider; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry; -import org.springframework.cloud.util.ProxyUtils; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; - -import static org.springframework.cloud.commons.util.IdUtils.getDefaultInstanceId; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Jon Schneider - * @author Matt Jenkins - * @author Ryan Baxter - * @author Daniel Lavoie - * @author Olga Maciaszek-Sharma - * @author Tim Ysewyn - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties -@ConditionalOnClass(EurekaClientConfig.class) -@ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true) -@ConditionalOnDiscoveryEnabled -@AutoConfigureBefore({ CommonsClientAutoConfiguration.class, ServiceRegistryAutoConfiguration.class }) -@AutoConfigureAfter(name = { "org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration", - "org.springframework.cloud.autoconfigure.RefreshAutoConfiguration", - "org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration", - "org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration" }) -public class EurekaClientAutoConfiguration { - - private final ConfigurableEnvironment env; - - public EurekaClientAutoConfiguration(ConfigurableEnvironment env) { - this.env = env; - } - - @Bean - public HasFeatures eurekaFeature() { - return HasFeatures.namedFeature("Eureka Client", EurekaClient.class); - } - - @Bean - @ConditionalOnMissingBean(value = EurekaClientConfig.class, search = SearchStrategy.CURRENT) - public EurekaClientConfigBean eurekaClientConfigBean(ConfigurableEnvironment env) { - return new EurekaClientConfigBean(); - } - - @Bean - @ConditionalOnMissingBean - public ManagementMetadataProvider serviceManagementMetadataProvider() { - return new DefaultManagementMetadataProvider(); - } - - private String getProperty(String property) { - return this.env.containsProperty(property) ? this.env.getProperty(property) : ""; - } - - @Bean - @ConditionalOnMissingBean(value = EurekaInstanceConfig.class, search = SearchStrategy.CURRENT) - public EurekaInstanceConfigBean eurekaInstanceConfigBean(InetUtils inetUtils, - ManagementMetadataProvider managementMetadataProvider) { - String hostname = getProperty("eureka.instance.hostname"); - boolean preferIpAddress = Boolean.parseBoolean(getProperty("eureka.instance.prefer-ip-address")); - String ipAddress = getProperty("eureka.instance.ip-address"); - boolean isSecurePortEnabled = Boolean.parseBoolean(getProperty("eureka.instance.secure-port-enabled")); - - String serverContextPath = env.getProperty("server.servlet.context-path", "/"); - int serverPort = Integer.parseInt(env.getProperty("server.port", env.getProperty("port", "8080"))); - - Integer managementPort = env.getProperty("management.server.port", Integer.class); - - String managementContextPath = env.getProperty("management.server.servlet.context-path"); - if (!StringUtils.hasText(managementContextPath)) { - managementContextPath = env.getProperty("management.server.base-path"); - } - - Integer jmxPort = env.getProperty("com.sun.management.jmxremote.port", Integer.class); - EurekaInstanceConfigBean instance = new EurekaInstanceConfigBean(inetUtils); - - instance.setNonSecurePort(serverPort); - instance.setInstanceId(getDefaultInstanceId(env)); - instance.setPreferIpAddress(preferIpAddress); - instance.setSecurePortEnabled(isSecurePortEnabled); - if (StringUtils.hasText(ipAddress)) { - instance.setIpAddress(ipAddress); - } - - if (isSecurePortEnabled) { - instance.setSecurePort(serverPort); - } - - if (StringUtils.hasText(hostname)) { - instance.setHostname(hostname); - } - String statusPageUrlPath = getProperty("eureka.instance.status-page-url-path"); - String healthCheckUrlPath = getProperty("eureka.instance.health-check-url-path"); - - if (StringUtils.hasText(statusPageUrlPath)) { - instance.setStatusPageUrlPath(statusPageUrlPath); - } - if (StringUtils.hasText(healthCheckUrlPath)) { - instance.setHealthCheckUrlPath(healthCheckUrlPath); - } - - ManagementMetadata metadata = managementMetadataProvider.get(instance, serverPort, serverContextPath, - managementContextPath, managementPort); - - if (metadata != null) { - instance.setStatusPageUrl(metadata.getStatusPageUrl()); - instance.setHealthCheckUrl(metadata.getHealthCheckUrl()); - if (instance.isSecurePortEnabled()) { - instance.setSecureHealthCheckUrl(metadata.getSecureHealthCheckUrl()); - } - Map metadataMap = instance.getMetadataMap(); - metadataMap.computeIfAbsent("management.port", k -> String.valueOf(metadata.getManagementPort())); - } - else { - // without the metadata the status and health check URLs will not be set - // and the status page and health check url paths will not include the - // context path so set them here - if (StringUtils.hasText(managementContextPath)) { - instance.setHealthCheckUrlPath(managementContextPath + instance.getHealthCheckUrlPath()); - instance.setStatusPageUrlPath(managementContextPath + instance.getStatusPageUrlPath()); - } - } - - setupJmxPort(instance, jmxPort); - return instance; - } - - private void setupJmxPort(EurekaInstanceConfigBean instance, Integer jmxPort) { - Map metadataMap = instance.getMetadataMap(); - if (metadataMap.get("jmx.port") == null && jmxPort != null) { - metadataMap.put("jmx.port", String.valueOf(jmxPort)); - } - } - - @Bean - public EurekaServiceRegistry eurekaServiceRegistry() { - return new EurekaServiceRegistry(); - } - - // @Bean - // @ConditionalOnBean(AutoServiceRegistrationProperties.class) - // @ConditionalOnProperty(value = - // "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) - // public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient, - // CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager - // applicationInfoManager, ObjectProvider healthCheckHandler) { - // return EurekaRegistration.builder(instanceConfig) - // .with(applicationInfoManager) - // .with(eurekaClient) - // .with(healthCheckHandler) - // .build(); - // } - - @Bean - @ConditionalOnBean(AutoServiceRegistrationProperties.class) - @ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) - public EurekaAutoServiceRegistration eurekaAutoServiceRegistration(ApplicationContext context, - EurekaServiceRegistry registry, EurekaRegistration registration) { - return new EurekaAutoServiceRegistration(context, registry, registration); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnMissingRefreshScope - protected static class EurekaClientConfiguration { - - @Autowired - private ApplicationContext context; - - @Autowired - private AbstractDiscoveryClientOptionalArgs optionalArgs; - - @Bean(destroyMethod = "shutdown") - @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) - public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, - TransportClientFactories transportClientFactories) { - return new CloudEurekaClient(manager, config, transportClientFactories, this.optionalArgs, this.context); - } - - @Bean - @ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT) - public ApplicationInfoManager eurekaApplicationInfoManager(EurekaInstanceConfig config) { - InstanceInfo instanceInfo = new InstanceInfoFactory().create(config); - return new ApplicationInfoManager(config, instanceInfo); - } - - @Bean - @ConditionalOnBean(AutoServiceRegistrationProperties.class) - @ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) - public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient, - CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager, - @Autowired(required = false) ObjectProvider healthCheckHandler) { - return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager).with(eurekaClient) - .with(healthCheckHandler).build(); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnRefreshScope - protected static class RefreshableEurekaClientConfiguration { - - @Autowired - private ApplicationContext context; - - @Autowired - private AbstractDiscoveryClientOptionalArgs optionalArgs; - - @Bean(destroyMethod = "shutdown") - @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) - @org.springframework.cloud.context.config.annotation.RefreshScope - @Lazy - public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, - EurekaInstanceConfig instance, TransportClientFactories transportClientFactories, - @Autowired(required = false) HealthCheckHandler healthCheckHandler) { - // If we use the proxy of the ApplicationInfoManager we could run into a - // problem - // when shutdown is called on the CloudEurekaClient where the - // ApplicationInfoManager bean is - // requested but wont be allowed because we are shutting down. To avoid this - // we use the - // object directly. - ApplicationInfoManager appManager; - if (AopUtils.isAopProxy(manager)) { - appManager = ProxyUtils.getTargetObject(manager); - } - else { - appManager = manager; - } - CloudEurekaClient cloudEurekaClient = new CloudEurekaClient(appManager, config, transportClientFactories, - this.optionalArgs, this.context); - cloudEurekaClient.registerHealthCheck(healthCheckHandler); - return cloudEurekaClient; - } - - @Bean - @ConditionalOnMissingBean(value = ApplicationInfoManager.class, search = SearchStrategy.CURRENT) - @org.springframework.cloud.context.config.annotation.RefreshScope - @Lazy - public ApplicationInfoManager eurekaApplicationInfoManager(EurekaInstanceConfig config) { - InstanceInfo instanceInfo = new InstanceInfoFactory().create(config); - return new ApplicationInfoManager(config, instanceInfo); - } - - @Bean - @org.springframework.cloud.context.config.annotation.RefreshScope - @ConditionalOnBean(AutoServiceRegistrationProperties.class) - @ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true) - public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient, - CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager, - @Autowired(required = false) ObjectProvider healthCheckHandler) { - return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager).with(eurekaClient) - .with(healthCheckHandler).build(); - } - - } - - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - @Documented - @Conditional(OnMissingRefreshScopeCondition.class) - @interface ConditionalOnMissingRefreshScope { - - } - - @Target({ ElementType.TYPE, ElementType.METHOD }) - @Retention(RetentionPolicy.RUNTIME) - @Documented - @ConditionalOnClass(RefreshScope.class) - @ConditionalOnBean(RefreshAutoConfiguration.class) - @ConditionalOnProperty(value = "eureka.client.refresh.enable", havingValue = "true", matchIfMissing = true) - @interface ConditionalOnRefreshScope { - - } - - private static class OnMissingRefreshScopeCondition extends AnyNestedCondition { - - OnMissingRefreshScopeCondition() { - super(ConfigurationPhase.REGISTER_BEAN); - } - - @ConditionalOnMissingClass("org.springframework.cloud.context.scope.refresh.RefreshScope") - static class MissingClass { - - } - - @ConditionalOnMissingBean(RefreshAutoConfiguration.class) - static class MissingScope { - - } - - @ConditionalOnProperty(value = "eureka.client.refresh.enable", havingValue = "false") - static class OnPropertyDisabled { - - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(Health.class) - protected static class EurekaHealthIndicatorConfiguration { - - @Bean - @ConditionalOnMissingBean - @ConditionalOnEnabledHealthIndicator("eureka") - public EurekaHealthIndicator eurekaHealthIndicator(EurekaClient eurekaClient, - EurekaInstanceConfig instanceConfig, EurekaClientConfig clientConfig) { - return new EurekaHealthIndicator(eurekaClient, instanceConfig, clientConfig); - } - - } - -} - -// Remove after adding hints to GraalVM reachability metadata repo -class EurekaClientHints implements RuntimeHintsRegistrar { - - @Override - public void registerHints(RuntimeHints hints, ClassLoader classLoader) { - if (!ClassUtils.isPresent("com.netflix.discovery.DiscoveryClient", classLoader)) { - return; - } - hints.reflection().registerType(TypeReference.of(DiscoveryClient.class), - hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INTROSPECT_DECLARED_METHODS)) - .registerType(TypeReference.of(EurekaEndpoint.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)) - .registerType(TypeReference.of(DefaultEndpoint.class), - hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)) - .registerType(TypeReference.of(EurekaHttpClientDecorator.class), - hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, - MemberCategory.INTROSPECT_DECLARED_METHODS)) - .registerType(TypeReference.of(EurekaHttpResponse.class), - hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)) - .registerType(TypeReference.of(EurekaHttpClientDecorator.RequestExecutor.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS)) - .registerType(TypeReference.of(ApplicationInfoManager.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS)) - .registerType(TypeReference.of(InstanceInfo.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)) - .registerType(TypeReference.of(InstanceInfo.ActionType.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(InstanceInfo.PortWrapper.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(LeaseInfo.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(MyDataCenterInfo.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(DataCenterInfo.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(DataCenterInfo.Name.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(EurekaClient.class), - hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)) - .registerType(TypeReference.of(TimedSupervisorTask.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(DataCenterTypeInfoResolver.class), - hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)) - .registerType(TypeReference.of(ApplicationsJacksonBuilder.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(InstanceInfoJsonMixIn.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(Application.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(Applications.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(AsyncResolver.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(RetryableEurekaHttpClient.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(SessionedEurekaHttpClient.class), - hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, - MemberCategory.DECLARED_FIELDS)) - .registerType(TypeReference.of(EurekaServiceInstance.class), - hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, - MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS)); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBean.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBean.java deleted file mode 100644 index f0aea7ce6..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBean.java +++ /dev/null @@ -1,1044 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import com.netflix.appinfo.EurekaAccept; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.EurekaTransportConfig; -import org.apache.hc.client5.http.classic.HttpClient; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.NestedConfigurationProperty; -import org.springframework.core.Ordered; -import org.springframework.core.env.PropertyResolver; -import org.springframework.util.StringUtils; - -import static org.springframework.cloud.netflix.eureka.EurekaConstants.DEFAULT_PREFIX; - -/** - * Eureka client configuration bean. - * - * @author Dave Syer - * @author Gregor Zurowski - */ -@ConfigurationProperties(EurekaClientConfigBean.PREFIX) -public class EurekaClientConfigBean implements EurekaClientConfig, Ordered { - - /** - * Default prefix for Eureka client config properties. - */ - public static final String PREFIX = "eureka.client"; - - /** - * Default Eureka URL. - */ - public static final String DEFAULT_URL = "http://localhost:8761" + DEFAULT_PREFIX + "/"; - - /** - * Default availability zone if none is resolved based on region. - */ - public static final String DEFAULT_ZONE = "defaultZone"; - - private static final int MINUTES = 60; - - @Autowired(required = false) - PropertyResolver propertyResolver; - - /** - * Flag to indicate that the Eureka client is enabled. - */ - private boolean enabled = true; - - @NestedConfigurationProperty - private EurekaTransportConfig transport = new CloudEurekaTransportConfig(); - - /** - * Indicates how often(in seconds) to fetch the registry information from the eureka - * server. - */ - private int registryFetchIntervalSeconds = 30; - - /** - * Indicates how often(in seconds) to replicate instance changes to be replicated to - * the eureka server. - */ - private int instanceInfoReplicationIntervalSeconds = 30; - - /** - * Indicates how long initially (in seconds) to replicate instance info to the eureka - * server. - */ - private int initialInstanceInfoReplicationIntervalSeconds = 40; - - /** - * Indicates how often(in seconds) to poll for changes to eureka server information. - * Eureka servers could be added or removed and this setting controls how soon the - * eureka clients should know about it. - */ - private int eurekaServiceUrlPollIntervalSeconds = 5 * MINUTES; - - /** - * Gets the proxy port to eureka server if any. - */ - private String proxyPort; - - /** - * Gets the proxy host to eureka server if any. - */ - private String proxyHost; - - /** - * Gets the proxy user name if any. - */ - private String proxyUserName; - - /** - * Gets the proxy password if any. - */ - private String proxyPassword; - - /** - * Indicates how long to wait (in seconds) before a read from eureka server needs to - * timeout. - */ - private int eurekaServerReadTimeoutSeconds = 8; - - /** - * Indicates how long to wait (in seconds) before a connection to eureka server needs - * to timeout. Note that the connections in the client are pooled by - * {@link HttpClient} and this setting affects the actual connection creation and also - * the wait time to get the connection from the pool. - */ - private int eurekaServerConnectTimeoutSeconds = 5; - - /** - * Gets the name of the implementation which implements BackupRegistry to fetch the - * registry information as a fallback option for only the first time when the eureka - * client starts. - * - * This may be needed for applications which needs additional resiliency for registry - * information without which it cannot operate. - */ - private String backupRegistryImpl; - - /** - * Gets the total number of connections that is allowed from eureka client to all - * eureka servers. - */ - private int eurekaServerTotalConnections = 200; - - /** - * Gets the total number of connections that is allowed from eureka client to a eureka - * server host. - */ - private int eurekaServerTotalConnectionsPerHost = 50; - - /** - * Gets the URL context to be used to construct the service url to contact eureka - * server when the list of eureka servers come from the DNS. This information is not - * required if the contract returns the service urls from eurekaServerServiceUrls. - * - * The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the - * eureka client expects the DNS to configured a certain way so that it can fetch - * changing eureka servers dynamically. The changes are effective at runtime. - */ - private String eurekaServerURLContext; - - /** - * Gets the port to be used to construct the service url to contact eureka server when - * the list of eureka servers come from the DNS.This information is not required if - * the contract returns the service urls eurekaServerServiceUrls(String). - * - * The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the - * eureka client expects the DNS to configured a certain way so that it can fetch - * changing eureka servers dynamically. - * - * The changes are effective at runtime. - */ - private String eurekaServerPort; - - /** - * Gets the DNS name to be queried to get the list of eureka servers.This information - * is not required if the contract returns the service urls by implementing - * serviceUrls. - * - * The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the - * eureka client expects the DNS to configured a certain way so that it can fetch - * changing eureka servers dynamically. - * - * The changes are effective at runtime. - */ - private String eurekaServerDNSName; - - /** - * Gets the region (used in AWS datacenters) where this instance resides. - */ - private String region = "us-east-1"; - - /** - * Indicates how much time (in seconds) that the HTTP connections to eureka server can - * stay idle before it can be closed. - * - * In the AWS environment, it is recommended that the values is 30 seconds or less, - * since the firewall cleans up the connection information after a few mins leaving - * the connection hanging in limbo. - */ - private int eurekaConnectionIdleTimeoutSeconds = 30; - - /** - * Indicates whether the client is only interested in the registry information for a - * single VIP. - */ - private String registryRefreshSingleVipAddress; - - /** - * The thread pool size for the heartbeatExecutor to initialise with. - */ - private int heartbeatExecutorThreadPoolSize = 2; - - /** - * Heartbeat executor exponential back off related property. It is a maximum - * multiplier value for retry delay, in case where a sequence of timeouts occurred. - */ - private int heartbeatExecutorExponentialBackOffBound = 10; - - /** - * The thread pool size for the cacheRefreshExecutor to initialise with. - */ - private int cacheRefreshExecutorThreadPoolSize = 2; - - /** - * Cache refresh executor exponential back off related property. It is a maximum - * multiplier value for retry delay, in case where a sequence of timeouts occurred. - */ - private int cacheRefreshExecutorExponentialBackOffBound = 10; - - /** - * Map of availability zone to list of fully qualified URLs to communicate with eureka - * server. Each value can be a single URL or a comma separated list of alternative - * locations. - * - * Typically the eureka server URLs carry protocol,host,port,context and version - * information if any. Example: - * https://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/ - * - * The changes are effective at runtime at the next service url refresh cycle as - * specified by eurekaServiceUrlPollIntervalSeconds. - */ - private Map serviceUrl = new HashMap<>(); - - { - this.serviceUrl.put(DEFAULT_ZONE, DEFAULT_URL); - } - - /** - * Indicates whether the content fetched from eureka server has to be compressed - * whenever it is supported by the server. The registry information from the eureka - * server is compressed for optimum network traffic. - */ - private boolean gZipContent = true; - - /** - * Indicates whether the eureka client should use the DNS mechanism to fetch a list of - * eureka servers to talk to. When the DNS name is updated to have additional servers, - * that information is used immediately after the eureka client polls for that - * information as specified in eurekaServiceUrlPollIntervalSeconds. - * - * Alternatively, the service urls can be returned serviceUrls, but the users should - * implement their own mechanism to return the updated list in case of changes. - * - * The changes are effective at runtime. - */ - private boolean useDnsForFetchingServiceUrls = false; - - /** - * Indicates whether or not this instance should register its information with eureka - * server for discovery by others. - * - * In some cases, you do not want your instances to be discovered whereas you just - * want do discover other instances. - */ - private boolean registerWithEureka = true; - - /** - * Indicates whether or not this instance should try to use the eureka server in the - * same zone for latency and/or other reason. - * - * Ideally eureka clients are configured to talk to servers in the same zone - * - * The changes are effective at runtime at the next registry fetch cycle as specified - * by registryFetchIntervalSeconds - */ - private boolean preferSameZoneEureka = true; - - /** - * Indicates whether to log differences between the eureka server and the eureka - * client in terms of registry information. - * - * Eureka client tries to retrieve only delta changes from eureka server to minimize - * network traffic. After receiving the deltas, eureka client reconciles the - * information from the server to verify it has not missed out some information. - * Reconciliation failures could happen when the client has had network issues - * communicating to server.If the reconciliation fails, eureka client gets the full - * registry information. - * - * While getting the full registry information, the eureka client can log the - * differences between the client and the server and this setting controls that. - * - * The changes are effective at runtime at the next registry fetch cycle as specified - * by registryFetchIntervalSecondsr - */ - private boolean logDeltaDiff; - - /** - * Indicates whether the eureka client should disable fetching of delta and should - * rather resort to getting the full registry information. - * - * Note that the delta fetches can reduce the traffic tremendously, because the rate - * of change with the eureka server is normally much lower than the rate of fetches. - * - * The changes are effective at runtime at the next registry fetch cycle as specified - * by registryFetchIntervalSeconds - */ - private boolean disableDelta; - - /** - * Comma separated list of regions for which the eureka registry information will be - * fetched. It is mandatory to define the availability zones for each of these regions - * as returned by availabilityZones. Failing to do so, will result in failure of - * discovery client startup. - * - */ - private String fetchRemoteRegionsRegistry; - - /** - * Gets the list of availability zones (used in AWS data centers) for the region in - * which this instance resides. - * - * The changes are effective at runtime at the next registry fetch cycle as specified - * by registryFetchIntervalSeconds. - */ - private Map availabilityZones = new HashMap<>(); - - /** - * Indicates whether to get the applications after filtering the applications for - * instances with only InstanceStatus UP states. - */ - private boolean filterOnlyUpInstances = true; - - /** - * Indicates whether this client should fetch eureka registry information from eureka - * server. - */ - private boolean fetchRegistry = true; - - /** - * Get a replacement string for Dollar sign $ during - * serializing/deserializing information in eureka server. - */ - private String dollarReplacement = "_-"; - - /** - * Get a replacement string for underscore sign _ during serializing/ - * deserializing information in eureka server. - */ - private String escapeCharReplacement = "__"; - - /** - * Indicates whether server can redirect a client request to a backup server/cluster. - * If set to false, the server will handle the request directly, If set to true, it - * may send HTTP redirect to the client, with a new server location. - */ - private boolean allowRedirects = false; - - /** - * If set to true, local status updates via ApplicationInfoManager will trigger - * on-demand (but rate limited) register/updates to remote eureka servers. - */ - private boolean onDemandUpdateStatusChange = true; - - /** - * This is a transient config and once the latest codecs are stable, can be removed - * (as there will only be one). - */ - private String encoderName; - - /** - * This is a transient config and once the latest codecs are stable, can be removed - * (as there will only be one). - */ - private String decoderName; - - /** - * EurekaAccept name for client data accept. - */ - private String clientDataAccept = EurekaAccept.full.name(); - - /** - * Indicates whether the client should explicitly unregister itself from the remote - * server on client shutdown. - */ - private boolean shouldUnregisterOnShutdown = true; - - /** - * Indicates whether the client should enforce registration during initialization. - * Defaults to false. - */ - private boolean shouldEnforceRegistrationAtInit = false; - - /** - * Order of the discovery client used by `CompositeDiscoveryClient` for sorting - * available clients. - */ - private int order = 0; - - @Override - public boolean shouldGZipContent() { - return this.gZipContent; - } - - @Override - public boolean shouldUseDnsForFetchingServiceUrls() { - return this.useDnsForFetchingServiceUrls; - } - - @Override - public boolean shouldRegisterWithEureka() { - return this.registerWithEureka; - } - - @Override - public boolean shouldPreferSameZoneEureka() { - return this.preferSameZoneEureka; - } - - @Override - public boolean shouldLogDeltaDiff() { - return this.logDeltaDiff; - } - - @Override - public boolean shouldDisableDelta() { - return this.disableDelta; - } - - @Override - public boolean shouldUnregisterOnShutdown() { - return this.shouldUnregisterOnShutdown; - } - - @Override - public boolean shouldEnforceRegistrationAtInit() { - return this.shouldEnforceRegistrationAtInit; - } - - @Override - public String fetchRegistryForRemoteRegions() { - return this.fetchRemoteRegionsRegistry; - } - - @Override - public String[] getAvailabilityZones(String region) { - String value = this.availabilityZones.get(region); - if (value == null) { - value = DEFAULT_ZONE; - } - return value.split(","); - } - - @Override - public List getEurekaServerServiceUrls(String myZone) { - String serviceUrls = this.serviceUrl.get(myZone); - if (serviceUrls == null || serviceUrls.isEmpty()) { - serviceUrls = this.serviceUrl.get(DEFAULT_ZONE); - } - if (StringUtils.hasText(serviceUrls)) { - final String[] serviceUrlsSplit = StringUtils.commaDelimitedListToStringArray(serviceUrls); - List eurekaServiceUrls = new ArrayList<>(serviceUrlsSplit.length); - for (String eurekaServiceUrl : serviceUrlsSplit) { - if (!endsWithSlash(eurekaServiceUrl)) { - eurekaServiceUrl += "/"; - } - eurekaServiceUrls.add(eurekaServiceUrl.trim()); - } - return eurekaServiceUrls; - } - - return new ArrayList<>(); - } - - private boolean endsWithSlash(String url) { - return url.endsWith("/"); - } - - @Override - public boolean shouldFilterOnlyUpInstances() { - return this.filterOnlyUpInstances; - } - - @Override - public boolean shouldFetchRegistry() { - return this.fetchRegistry; - } - - @Override - public boolean allowRedirects() { - return this.allowRedirects; - } - - @Override - public boolean shouldOnDemandUpdateStatusChange() { - return this.onDemandUpdateStatusChange; - } - - @Override - public String getExperimental(String name) { - if (this.propertyResolver != null) { - return this.propertyResolver.getProperty(PREFIX + ".experimental." + name, String.class, null); - } - return null; - } - - @Override - public EurekaTransportConfig getTransportConfig() { - return getTransport(); - } - - public PropertyResolver getPropertyResolver() { - return propertyResolver; - } - - public void setPropertyResolver(PropertyResolver propertyResolver) { - this.propertyResolver = propertyResolver; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public EurekaTransportConfig getTransport() { - return transport; - } - - public void setTransport(EurekaTransportConfig transport) { - this.transport = transport; - } - - @Override - public int getRegistryFetchIntervalSeconds() { - return registryFetchIntervalSeconds; - } - - public void setRegistryFetchIntervalSeconds(int registryFetchIntervalSeconds) { - this.registryFetchIntervalSeconds = registryFetchIntervalSeconds; - } - - @Override - public int getInstanceInfoReplicationIntervalSeconds() { - return instanceInfoReplicationIntervalSeconds; - } - - public void setInstanceInfoReplicationIntervalSeconds(int instanceInfoReplicationIntervalSeconds) { - this.instanceInfoReplicationIntervalSeconds = instanceInfoReplicationIntervalSeconds; - } - - @Override - public int getInitialInstanceInfoReplicationIntervalSeconds() { - return initialInstanceInfoReplicationIntervalSeconds; - } - - public void setInitialInstanceInfoReplicationIntervalSeconds(int initialInstanceInfoReplicationIntervalSeconds) { - this.initialInstanceInfoReplicationIntervalSeconds = initialInstanceInfoReplicationIntervalSeconds; - } - - @Override - public int getEurekaServiceUrlPollIntervalSeconds() { - return eurekaServiceUrlPollIntervalSeconds; - } - - public void setEurekaServiceUrlPollIntervalSeconds(int eurekaServiceUrlPollIntervalSeconds) { - this.eurekaServiceUrlPollIntervalSeconds = eurekaServiceUrlPollIntervalSeconds; - } - - @Override - public String getProxyPort() { - return proxyPort; - } - - public void setProxyPort(String proxyPort) { - this.proxyPort = proxyPort; - } - - @Override - public String getProxyHost() { - return proxyHost; - } - - public void setProxyHost(String proxyHost) { - this.proxyHost = proxyHost; - } - - @Override - public String getProxyUserName() { - return proxyUserName; - } - - public void setProxyUserName(String proxyUserName) { - this.proxyUserName = proxyUserName; - } - - @Override - public String getProxyPassword() { - return proxyPassword; - } - - public void setProxyPassword(String proxyPassword) { - this.proxyPassword = proxyPassword; - } - - @Override - public int getEurekaServerReadTimeoutSeconds() { - return eurekaServerReadTimeoutSeconds; - } - - public void setEurekaServerReadTimeoutSeconds(int eurekaServerReadTimeoutSeconds) { - this.eurekaServerReadTimeoutSeconds = eurekaServerReadTimeoutSeconds; - } - - @Override - public int getEurekaServerConnectTimeoutSeconds() { - return eurekaServerConnectTimeoutSeconds; - } - - public void setEurekaServerConnectTimeoutSeconds(int eurekaServerConnectTimeoutSeconds) { - this.eurekaServerConnectTimeoutSeconds = eurekaServerConnectTimeoutSeconds; - } - - @Override - public String getBackupRegistryImpl() { - return backupRegistryImpl; - } - - public void setBackupRegistryImpl(String backupRegistryImpl) { - this.backupRegistryImpl = backupRegistryImpl; - } - - @Override - public int getEurekaServerTotalConnections() { - return eurekaServerTotalConnections; - } - - public void setEurekaServerTotalConnections(int eurekaServerTotalConnections) { - this.eurekaServerTotalConnections = eurekaServerTotalConnections; - } - - @Override - public int getEurekaServerTotalConnectionsPerHost() { - return eurekaServerTotalConnectionsPerHost; - } - - public void setEurekaServerTotalConnectionsPerHost(int eurekaServerTotalConnectionsPerHost) { - this.eurekaServerTotalConnectionsPerHost = eurekaServerTotalConnectionsPerHost; - } - - @Override - public String getEurekaServerURLContext() { - return eurekaServerURLContext; - } - - public void setEurekaServerURLContext(String eurekaServerURLContext) { - this.eurekaServerURLContext = eurekaServerURLContext; - } - - @Override - public String getEurekaServerPort() { - return eurekaServerPort; - } - - public void setEurekaServerPort(String eurekaServerPort) { - this.eurekaServerPort = eurekaServerPort; - } - - @Override - public String getEurekaServerDNSName() { - return eurekaServerDNSName; - } - - public void setEurekaServerDNSName(String eurekaServerDNSName) { - this.eurekaServerDNSName = eurekaServerDNSName; - } - - @Override - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - @Override - public int getEurekaConnectionIdleTimeoutSeconds() { - return eurekaConnectionIdleTimeoutSeconds; - } - - public void setEurekaConnectionIdleTimeoutSeconds(int eurekaConnectionIdleTimeoutSeconds) { - this.eurekaConnectionIdleTimeoutSeconds = eurekaConnectionIdleTimeoutSeconds; - } - - @Override - public String getRegistryRefreshSingleVipAddress() { - return registryRefreshSingleVipAddress; - } - - public void setRegistryRefreshSingleVipAddress(String registryRefreshSingleVipAddress) { - this.registryRefreshSingleVipAddress = registryRefreshSingleVipAddress; - } - - @Override - public int getHeartbeatExecutorThreadPoolSize() { - return heartbeatExecutorThreadPoolSize; - } - - public void setHeartbeatExecutorThreadPoolSize(int heartbeatExecutorThreadPoolSize) { - this.heartbeatExecutorThreadPoolSize = heartbeatExecutorThreadPoolSize; - } - - @Override - public int getHeartbeatExecutorExponentialBackOffBound() { - return heartbeatExecutorExponentialBackOffBound; - } - - public void setHeartbeatExecutorExponentialBackOffBound(int heartbeatExecutorExponentialBackOffBound) { - this.heartbeatExecutorExponentialBackOffBound = heartbeatExecutorExponentialBackOffBound; - } - - @Override - public int getCacheRefreshExecutorThreadPoolSize() { - return cacheRefreshExecutorThreadPoolSize; - } - - public void setCacheRefreshExecutorThreadPoolSize(int cacheRefreshExecutorThreadPoolSize) { - this.cacheRefreshExecutorThreadPoolSize = cacheRefreshExecutorThreadPoolSize; - } - - @Override - public int getCacheRefreshExecutorExponentialBackOffBound() { - return cacheRefreshExecutorExponentialBackOffBound; - } - - public void setCacheRefreshExecutorExponentialBackOffBound(int cacheRefreshExecutorExponentialBackOffBound) { - this.cacheRefreshExecutorExponentialBackOffBound = cacheRefreshExecutorExponentialBackOffBound; - } - - public Map getServiceUrl() { - return serviceUrl; - } - - public void setServiceUrl(Map serviceUrl) { - this.serviceUrl = serviceUrl; - } - - public boolean isgZipContent() { - return gZipContent; - } - - public void setgZipContent(boolean gZipContent) { - this.gZipContent = gZipContent; - } - - public boolean isUseDnsForFetchingServiceUrls() { - return useDnsForFetchingServiceUrls; - } - - public void setUseDnsForFetchingServiceUrls(boolean useDnsForFetchingServiceUrls) { - this.useDnsForFetchingServiceUrls = useDnsForFetchingServiceUrls; - } - - public boolean isRegisterWithEureka() { - return registerWithEureka; - } - - public void setRegisterWithEureka(boolean registerWithEureka) { - this.registerWithEureka = registerWithEureka; - } - - public boolean isPreferSameZoneEureka() { - return preferSameZoneEureka; - } - - public void setPreferSameZoneEureka(boolean preferSameZoneEureka) { - this.preferSameZoneEureka = preferSameZoneEureka; - } - - public boolean isLogDeltaDiff() { - return logDeltaDiff; - } - - public void setLogDeltaDiff(boolean logDeltaDiff) { - this.logDeltaDiff = logDeltaDiff; - } - - public boolean isDisableDelta() { - return disableDelta; - } - - public void setDisableDelta(boolean disableDelta) { - this.disableDelta = disableDelta; - } - - public String getFetchRemoteRegionsRegistry() { - return fetchRemoteRegionsRegistry; - } - - public void setFetchRemoteRegionsRegistry(String fetchRemoteRegionsRegistry) { - this.fetchRemoteRegionsRegistry = fetchRemoteRegionsRegistry; - } - - public Map getAvailabilityZones() { - return availabilityZones; - } - - public void setAvailabilityZones(Map availabilityZones) { - this.availabilityZones = availabilityZones; - } - - public boolean isFilterOnlyUpInstances() { - return filterOnlyUpInstances; - } - - public void setFilterOnlyUpInstances(boolean filterOnlyUpInstances) { - this.filterOnlyUpInstances = filterOnlyUpInstances; - } - - public boolean isFetchRegistry() { - return fetchRegistry; - } - - public void setFetchRegistry(boolean fetchRegistry) { - this.fetchRegistry = fetchRegistry; - } - - @Override - public String getDollarReplacement() { - return dollarReplacement; - } - - public void setDollarReplacement(String dollarReplacement) { - this.dollarReplacement = dollarReplacement; - } - - @Override - public String getEscapeCharReplacement() { - return escapeCharReplacement; - } - - public void setEscapeCharReplacement(String escapeCharReplacement) { - this.escapeCharReplacement = escapeCharReplacement; - } - - public boolean isAllowRedirects() { - return allowRedirects; - } - - public void setAllowRedirects(boolean allowRedirects) { - this.allowRedirects = allowRedirects; - } - - public boolean isOnDemandUpdateStatusChange() { - return onDemandUpdateStatusChange; - } - - public void setOnDemandUpdateStatusChange(boolean onDemandUpdateStatusChange) { - this.onDemandUpdateStatusChange = onDemandUpdateStatusChange; - } - - @Override - public String getEncoderName() { - return encoderName; - } - - public void setEncoderName(String encoderName) { - this.encoderName = encoderName; - } - - @Override - public String getDecoderName() { - return decoderName; - } - - public void setDecoderName(String decoderName) { - this.decoderName = decoderName; - } - - @Override - public String getClientDataAccept() { - return clientDataAccept; - } - - public void setClientDataAccept(String clientDataAccept) { - this.clientDataAccept = clientDataAccept; - } - - public boolean isShouldUnregisterOnShutdown() { - return shouldUnregisterOnShutdown; - } - - public void setShouldUnregisterOnShutdown(boolean shouldUnregisterOnShutdown) { - this.shouldUnregisterOnShutdown = shouldUnregisterOnShutdown; - } - - public boolean isShouldEnforceRegistrationAtInit() { - return shouldEnforceRegistrationAtInit; - } - - public void setShouldEnforceRegistrationAtInit(boolean shouldEnforceRegistrationAtInit) { - this.shouldEnforceRegistrationAtInit = shouldEnforceRegistrationAtInit; - } - - @Override - public int getOrder() { - return order; - } - - public void setOrder(int order) { - this.order = order; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaClientConfigBean that = (EurekaClientConfigBean) o; - return Objects.equals(propertyResolver, that.propertyResolver) && enabled == that.enabled - && Objects.equals(transport, that.transport) - && registryFetchIntervalSeconds == that.registryFetchIntervalSeconds - && instanceInfoReplicationIntervalSeconds == that.instanceInfoReplicationIntervalSeconds - && initialInstanceInfoReplicationIntervalSeconds == that.initialInstanceInfoReplicationIntervalSeconds - && eurekaServiceUrlPollIntervalSeconds == that.eurekaServiceUrlPollIntervalSeconds - && eurekaServerReadTimeoutSeconds == that.eurekaServerReadTimeoutSeconds - && eurekaServerConnectTimeoutSeconds == that.eurekaServerConnectTimeoutSeconds - && eurekaServerTotalConnections == that.eurekaServerTotalConnections - && eurekaServerTotalConnectionsPerHost == that.eurekaServerTotalConnectionsPerHost - && eurekaConnectionIdleTimeoutSeconds == that.eurekaConnectionIdleTimeoutSeconds - && heartbeatExecutorThreadPoolSize == that.heartbeatExecutorThreadPoolSize - && heartbeatExecutorExponentialBackOffBound == that.heartbeatExecutorExponentialBackOffBound - && cacheRefreshExecutorThreadPoolSize == that.cacheRefreshExecutorThreadPoolSize - && cacheRefreshExecutorExponentialBackOffBound == that.cacheRefreshExecutorExponentialBackOffBound - && gZipContent == that.gZipContent && useDnsForFetchingServiceUrls == that.useDnsForFetchingServiceUrls - && registerWithEureka == that.registerWithEureka && preferSameZoneEureka == that.preferSameZoneEureka - && logDeltaDiff == that.logDeltaDiff && disableDelta == that.disableDelta - && filterOnlyUpInstances == that.filterOnlyUpInstances && fetchRegistry == that.fetchRegistry - && allowRedirects == that.allowRedirects - && onDemandUpdateStatusChange == that.onDemandUpdateStatusChange - && shouldUnregisterOnShutdown == that.shouldUnregisterOnShutdown - && shouldEnforceRegistrationAtInit == that.shouldEnforceRegistrationAtInit - && Objects.equals(proxyPort, that.proxyPort) && Objects.equals(proxyHost, that.proxyHost) - && Objects.equals(proxyUserName, that.proxyUserName) - && Objects.equals(proxyPassword, that.proxyPassword) - && Objects.equals(backupRegistryImpl, that.backupRegistryImpl) - && Objects.equals(eurekaServerURLContext, that.eurekaServerURLContext) - && Objects.equals(eurekaServerPort, that.eurekaServerPort) - && Objects.equals(eurekaServerDNSName, that.eurekaServerDNSName) && Objects.equals(region, that.region) - && Objects.equals(registryRefreshSingleVipAddress, that.registryRefreshSingleVipAddress) - && Objects.equals(serviceUrl, that.serviceUrl) - && Objects.equals(fetchRemoteRegionsRegistry, that.fetchRemoteRegionsRegistry) - && Objects.equals(availabilityZones, that.availabilityZones) - && Objects.equals(dollarReplacement, that.dollarReplacement) - && Objects.equals(escapeCharReplacement, that.escapeCharReplacement) - && Objects.equals(encoderName, that.encoderName) && Objects.equals(decoderName, that.decoderName) - && Objects.equals(clientDataAccept, that.clientDataAccept) && Objects.equals(order, that.order); - } - - @Override - public int hashCode() { - return Objects.hash(propertyResolver, enabled, transport, registryFetchIntervalSeconds, - instanceInfoReplicationIntervalSeconds, initialInstanceInfoReplicationIntervalSeconds, - eurekaServiceUrlPollIntervalSeconds, proxyPort, proxyHost, proxyUserName, proxyPassword, - eurekaServerReadTimeoutSeconds, eurekaServerConnectTimeoutSeconds, backupRegistryImpl, - eurekaServerTotalConnections, eurekaServerTotalConnectionsPerHost, eurekaServerURLContext, - eurekaServerPort, eurekaServerDNSName, region, eurekaConnectionIdleTimeoutSeconds, - registryRefreshSingleVipAddress, heartbeatExecutorThreadPoolSize, - heartbeatExecutorExponentialBackOffBound, cacheRefreshExecutorThreadPoolSize, - cacheRefreshExecutorExponentialBackOffBound, serviceUrl, gZipContent, useDnsForFetchingServiceUrls, - registerWithEureka, preferSameZoneEureka, logDeltaDiff, disableDelta, fetchRemoteRegionsRegistry, - availabilityZones, filterOnlyUpInstances, fetchRegistry, dollarReplacement, escapeCharReplacement, - allowRedirects, onDemandUpdateStatusChange, encoderName, decoderName, clientDataAccept, - shouldUnregisterOnShutdown, shouldEnforceRegistrationAtInit, order); - } - - @Override - public String toString() { - return new StringBuilder("EurekaClientConfigBean{").append("propertyResolver=").append(propertyResolver) - .append(", ").append("enabled=").append(enabled).append(", ").append("transport=").append(transport) - .append(", ").append("registryFetchIntervalSeconds=").append(registryFetchIntervalSeconds).append(", ") - .append("instanceInfoReplicationIntervalSeconds=").append(instanceInfoReplicationIntervalSeconds) - .append(", ").append("initialInstanceInfoReplicationIntervalSeconds=") - .append(initialInstanceInfoReplicationIntervalSeconds).append(", ") - .append("eurekaServiceUrlPollIntervalSeconds=").append(eurekaServiceUrlPollIntervalSeconds).append(", ") - .append("proxyPort='").append(proxyPort).append("', ").append("proxyHost='").append(proxyHost) - .append("', ").append("proxyUserName='").append(proxyUserName).append("', ").append("proxyPassword='") - .append(proxyPassword).append("', ").append("eurekaServerReadTimeoutSeconds=") - .append(eurekaServerReadTimeoutSeconds).append(", ").append("eurekaServerConnectTimeoutSeconds=") - .append(eurekaServerConnectTimeoutSeconds).append(", ").append("backupRegistryImpl='") - .append(backupRegistryImpl).append("', ").append("eurekaServerTotalConnections=") - .append(eurekaServerTotalConnections).append(", ").append("eurekaServerTotalConnectionsPerHost=") - .append(eurekaServerTotalConnectionsPerHost).append(", ").append("eurekaServerURLContext='") - .append(eurekaServerURLContext).append("', ").append("eurekaServerPort='").append(eurekaServerPort) - .append("', ").append("eurekaServerDNSName='").append(eurekaServerDNSName).append("', ") - .append("region='").append(region).append("', ").append("eurekaConnectionIdleTimeoutSeconds=") - .append(eurekaConnectionIdleTimeoutSeconds).append(", ").append("registryRefreshSingleVipAddress='") - .append(registryRefreshSingleVipAddress).append("', ").append("heartbeatExecutorThreadPoolSize=") - .append(heartbeatExecutorThreadPoolSize).append(", ") - .append("heartbeatExecutorExponentialBackOffBound=").append(heartbeatExecutorExponentialBackOffBound) - .append(", ").append("cacheRefreshExecutorThreadPoolSize=").append(cacheRefreshExecutorThreadPoolSize) - .append(", ").append("cacheRefreshExecutorExponentialBackOffBound=") - .append(cacheRefreshExecutorExponentialBackOffBound).append(", ").append("serviceUrl=") - .append(serviceUrl).append(", ").append("gZipContent=").append(gZipContent).append(", ") - .append("useDnsForFetchingServiceUrls=").append(useDnsForFetchingServiceUrls).append(", ") - .append("registerWithEureka=").append(registerWithEureka).append(", ").append("preferSameZoneEureka=") - .append(preferSameZoneEureka).append(", ").append("logDeltaDiff=").append(logDeltaDiff).append(", ") - .append("disableDelta=").append(disableDelta).append(", ").append("fetchRemoteRegionsRegistry='") - .append(fetchRemoteRegionsRegistry).append("', ").append("availabilityZones=").append(availabilityZones) - .append(", ").append("filterOnlyUpInstances=").append(filterOnlyUpInstances).append(", ") - .append("fetchRegistry=").append(fetchRegistry).append(", ").append("dollarReplacement='") - .append(dollarReplacement).append("', ").append("escapeCharReplacement='").append(escapeCharReplacement) - .append("', ").append("allowRedirects=").append(allowRedirects).append(", ") - .append("onDemandUpdateStatusChange=").append(onDemandUpdateStatusChange).append(", ") - .append("encoderName='").append(encoderName).append("', ").append("decoderName='").append(decoderName) - .append("', ").append("clientDataAccept='").append(clientDataAccept).append("', ") - .append("shouldUnregisterOnShutdown='").append(shouldUnregisterOnShutdown) - .append("shouldEnforceRegistrationAtInit='").append(shouldEnforceRegistrationAtInit).append("', ") - .append("order='").append(order).append("'}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaConstants.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaConstants.java deleted file mode 100644 index 7526c7609..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaConstants.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -/** - * Class containing Eureka-specific constants. - * - * @author Spencer Gibb - */ -public final class EurekaConstants { - - /** - * Default Eureka prefix. - */ - public static final String DEFAULT_PREFIX = "/eureka"; - - private EurekaConstants() { - throw new AssertionError("Must not instantiate constant utility class"); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClient.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClient.java deleted file mode 100644 index 527d7ba9a..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClient.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.core.Ordered; - -/** - * A {@link DiscoveryClient} implementation for Eureka. - * - * @author Spencer Gibb - * @author Tim Ysewyn - */ -public class EurekaDiscoveryClient implements DiscoveryClient { - - /** - * Client description {@link String}. - */ - public static final String DESCRIPTION = "Spring Cloud Eureka Discovery Client"; - - private final EurekaClient eurekaClient; - - private final EurekaClientConfig clientConfig; - - public EurekaDiscoveryClient(EurekaClient eurekaClient, EurekaClientConfig clientConfig) { - this.clientConfig = clientConfig; - this.eurekaClient = eurekaClient; - } - - @Override - public String description() { - return DESCRIPTION; - } - - @Override - public List getInstances(String serviceId) { - List infos = this.eurekaClient.getInstancesByVipAddress(serviceId, false); - List instances = new ArrayList<>(); - for (InstanceInfo info : infos) { - instances.add(new EurekaServiceInstance(info)); - } - return instances; - } - - @Override - public List getServices() { - Applications applications = this.eurekaClient.getApplications(); - if (applications == null) { - return Collections.emptyList(); - } - List registered = applications.getRegisteredApplications(); - List names = new ArrayList<>(); - for (Application app : registered) { - if (app.getInstances().isEmpty()) { - continue; - } - names.add(app.getName().toLowerCase()); - - } - return names; - } - - @Override - public int getOrder() { - return clientConfig instanceof Ordered ? ((Ordered) clientConfig).getOrder() : DiscoveryClient.DEFAULT_ORDER; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClientConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClientConfiguration.java deleted file mode 100644 index 1e7b65046..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClientConfiguration.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.health.SimpleStatusAggregator; -import org.springframework.boot.actuate.health.StatusAggregator; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.ConditionalOnBlockingDiscoveryEnabled; -import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled; -import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Jon Schneider - * @author Jakub Narloch - * @author Olga Maciaszek-Sharma - * @author Tim Ysewyn - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties -@ConditionalOnClass(EurekaClientConfig.class) -@ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true) -@ConditionalOnDiscoveryEnabled -@ConditionalOnBlockingDiscoveryEnabled -public class EurekaDiscoveryClientConfiguration { - - @Bean - @ConditionalOnMissingBean - public EurekaDiscoveryClient discoveryClient(EurekaClient client, EurekaClientConfig clientConfig) { - return new EurekaDiscoveryClient(client, clientConfig); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnProperty(value = "eureka.client.healthcheck.enabled", matchIfMissing = false) - protected static class EurekaHealthCheckHandlerConfiguration { - - @Autowired(required = false) - private StatusAggregator statusAggregator = new SimpleStatusAggregator(); - - @Bean - @ConditionalOnMissingBean(HealthCheckHandler.class) - public EurekaHealthCheckHandler eurekaHealthCheckHandler() { - return new EurekaHealthCheckHandler(this.statusAggregator); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(RefreshScopeRefreshedEvent.class) - protected static class EurekaClientConfigurationRefresher - implements ApplicationListener { - - @Autowired(required = false) - private EurekaClient eurekaClient; - - @Autowired(required = false) - private EurekaAutoServiceRegistration autoRegistration; - - public void onApplicationEvent(RefreshScopeRefreshedEvent event) { - // This will force the creation of the EurkaClient bean if not already created - // to make sure the client will be reregistered after a refresh event - if (eurekaClient != null) { - eurekaClient.getApplications(); - } - if (autoRegistration != null) { - // register in case meta data changed - this.autoRegistration.stop(); - this.autoRegistration.start(); - } - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandler.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandler.java deleted file mode 100644 index 7156ecc72..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandler.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.InstanceInfo.InstanceStatus; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.actuate.health.CompositeHealthContributor; -import org.springframework.boot.actuate.health.CompositeReactiveHealthContributor; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.HealthContributor; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.actuate.health.NamedContributor; -import org.springframework.boot.actuate.health.ReactiveHealthContributor; -import org.springframework.boot.actuate.health.ReactiveHealthIndicator; -import org.springframework.boot.actuate.health.Status; -import org.springframework.boot.actuate.health.StatusAggregator; -import org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthContributor; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.Lifecycle; -import org.springframework.core.Ordered; -import org.springframework.util.Assert; - -/** - * A Eureka health checker, maps the application status into {@link InstanceStatus} that - * will be propagated to Eureka registry. - * - * On each heartbeat Eureka performs the health check invoking registered - * {@link HealthCheckHandler}. By default this implementation will perform aggregation of - * all registered {@link HealthIndicator} through registered {@link StatusAggregator}. - * - * A {@code null} status is returned when the application context is closed (or in the - * process of being closed). This prevents Eureka from updating the health status and only - * consider the status present in the current InstanceInfo. - * - * @author Jakub Narloch - * @author Spencer Gibb - * @author Nowrin Anwar Joyita - * @author Bertrand Renuart - * @author Olga Maciaszek-Sharma - * @see HealthCheckHandler - * @see StatusAggregator - */ -public class EurekaHealthCheckHandler - implements HealthCheckHandler, ApplicationContextAware, InitializingBean, Ordered, Lifecycle { - - private static final Map STATUS_MAPPING = new HashMap<>() { - { - put(Status.UNKNOWN, InstanceStatus.UNKNOWN); - put(Status.OUT_OF_SERVICE, InstanceStatus.DOWN); - put(Status.DOWN, InstanceStatus.DOWN); - put(Status.UP, InstanceStatus.UP); - } - }; - - private final StatusAggregator statusAggregator; - - private ApplicationContext applicationContext; - - private final Map healthContributors = new HashMap<>(); - - /** - * {@code true} until the context is stopped. - */ - private boolean running = true; - - private final Map reactiveHealthContributors = new HashMap<>(); - - public EurekaHealthCheckHandler(StatusAggregator statusAggregator) { - this.statusAggregator = statusAggregator; - Assert.notNull(statusAggregator, "StatusAggregator must not be null"); - - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - - @Override - public void afterPropertiesSet() { - populateHealthContributors(applicationContext.getBeansOfType(HealthContributor.class)); - reactiveHealthContributors.putAll(applicationContext.getBeansOfType(ReactiveHealthContributor.class)); - } - - void populateHealthContributors(Map healthContributors) { - for (Map.Entry entry : healthContributors.entrySet()) { - // ignore EurekaHealthIndicator and flatten the rest of the composite - // otherwise there is a never ending cycle of down. See gh-643 - if (entry.getValue() instanceof DiscoveryCompositeHealthContributor indicator) { - indicator.getIndicators().forEach((name, discoveryHealthIndicator) -> { - if (!(discoveryHealthIndicator instanceof EurekaHealthIndicator)) { - this.healthContributors.put(name, (HealthIndicator) discoveryHealthIndicator::health); - } - }); - } - else { - this.healthContributors.put(entry.getKey(), entry.getValue()); - } - } - } - - @Override - public InstanceStatus getStatus(InstanceStatus instanceStatus) { - if (running) { - return getHealthStatus(); - } - else { - // Return nothing if the context is not running, so the status held by the - // InstanceInfo remains unchanged. - // See gh-1571 - return null; - } - } - - protected InstanceStatus getHealthStatus() { - Status status = getStatus(statusAggregator); - return mapToInstanceStatus(status); - } - - protected Status getStatus(StatusAggregator statusAggregator) { - Set statusSet = new HashSet<>(); - for (HealthContributor contributor : healthContributors.values()) { - processContributor(statusSet, contributor); - } - for (ReactiveHealthContributor contributor : reactiveHealthContributors.values()) { - processContributor(statusSet, contributor); - } - return statusAggregator.getAggregateStatus(statusSet); - } - - private void processContributor(Set statusSet, HealthContributor contributor) { - if (contributor instanceof CompositeHealthContributor) { - for (NamedContributor contrib : (CompositeHealthContributor) contributor) { - processContributor(statusSet, contrib.getContributor()); - } - } - else if (contributor instanceof HealthIndicator) { - statusSet.add(((HealthIndicator) contributor).health().getStatus()); - } - } - - private void processContributor(Set statusSet, ReactiveHealthContributor contributor) { - if (contributor instanceof CompositeReactiveHealthContributor) { - for (NamedContributor contrib : (CompositeReactiveHealthContributor) contributor) { - processContributor(statusSet, contrib.getContributor()); - } - } - else if (contributor instanceof ReactiveHealthIndicator) { - Health health = ((ReactiveHealthIndicator) contributor).health().block(); - if (health != null) { - statusSet.add(health.getStatus()); - } - } - } - - protected InstanceStatus mapToInstanceStatus(Status status) { - if (!STATUS_MAPPING.containsKey(status)) { - return InstanceStatus.UNKNOWN; - } - return STATUS_MAPPING.get(status); - } - - @Override - public int getOrder() { - // registered with a high order priority so the close() method is invoked early - // and *BEFORE* EurekaAutoServiceRegistration - // (must be in effect when the registration is closed and the eureka replication - // triggered -> health check handler is - // consulted at that moment) - return Ordered.HIGHEST_PRECEDENCE; - } - - @Override - public void start() { - running = true; - } - - @Override - public void stop() { - running = false; - } - - @Override - public boolean isRunning() { - return true; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthIndicator.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthIndicator.java deleted file mode 100644 index c109650f2..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaHealthIndicator.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.discovery.DiscoveryClient; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; - -import org.springframework.aop.support.AopUtils; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.Health.Builder; -import org.springframework.boot.actuate.health.Status; -import org.springframework.cloud.client.discovery.health.DiscoveryHealthIndicator; -import org.springframework.cloud.util.ProxyUtils; - -/** - * @author Dave Syer - */ -public class EurekaHealthIndicator implements DiscoveryHealthIndicator { - - private final EurekaClient eurekaClient; - - private final EurekaInstanceConfig instanceConfig; - - private final EurekaClientConfig clientConfig; - - public EurekaHealthIndicator(EurekaClient eurekaClient, EurekaInstanceConfig instanceConfig, - EurekaClientConfig clientConfig) { - super(); - this.eurekaClient = eurekaClient; - this.instanceConfig = instanceConfig; - this.clientConfig = clientConfig; - } - - @Override - public String getName() { - return "eureka"; - } - - @Override - public Health health() { - Builder builder = Health.unknown(); - Status status = getStatus(builder); - return builder.status(status).withDetail("applications", getApplications()).build(); - } - - private Status getStatus(Builder builder) { - Status status = new Status(this.eurekaClient.getInstanceRemoteStatus().toString(), - "Remote status from Eureka server"); - DiscoveryClient discoveryClient = getDiscoveryClient(); - if (discoveryClient != null && clientConfig.shouldFetchRegistry()) { - long lastFetch = discoveryClient.getLastSuccessfulRegistryFetchTimePeriod(); - - if (lastFetch < 0) { - status = new Status("UP", - "Eureka discovery client has not yet successfully connected to a Eureka server"); - } - else if (lastFetch > clientConfig.getRegistryFetchIntervalSeconds() * 2000) { - status = new Status("UP", - "Eureka discovery client is reporting failures to connect to a Eureka server"); - builder.withDetail("renewalPeriod", instanceConfig.getLeaseRenewalIntervalInSeconds()); - builder.withDetail("failCount", lastFetch / clientConfig.getRegistryFetchIntervalSeconds()); - } - } - - return status; - } - - private DiscoveryClient getDiscoveryClient() { - DiscoveryClient discoveryClient = null; - if (AopUtils.isAopProxy(eurekaClient)) { - discoveryClient = ProxyUtils.getTargetObject(eurekaClient); - } - else if (eurekaClient instanceof DiscoveryClient) { - discoveryClient = (DiscoveryClient) eurekaClient; - } - return discoveryClient; - } - - private Map getApplications() { - Applications applications = this.eurekaClient.getApplications(); - if (applications == null) { - return Collections.emptyMap(); - } - Map result = new HashMap<>(); - for (Application application : applications.getRegisteredApplications()) { - if (!application.getInstances().isEmpty()) { - result.put(application.getName(), application.getInstances().size()); - } - } - return result; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java deleted file mode 100644 index 430f53cc3..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java +++ /dev/null @@ -1,640 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import com.netflix.appinfo.MyDataCenterInfo; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.commons.util.InetUtils.HostInfo; -import org.springframework.context.EnvironmentAware; -import org.springframework.core.env.Environment; -import org.springframework.util.StringUtils; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Ryan Baxter - * @author Gregor Zurowski - */ -@ConfigurationProperties("eureka.instance") -public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig, EnvironmentAware { - - private static final String UNKNOWN = "unknown"; - - private HostInfo hostInfo; - - private InetUtils inetUtils; - - /** - * Default prefix for actuator endpoints. - */ - private String actuatorPrefix = "/actuator"; - - /** - * Get the name of the application to be registered with eureka. - */ - private String appname = UNKNOWN; - - /** - * Get the name of the application group to be registered with eureka. - */ - private String appGroupName; - - /** - * Indicates whether the instance should be enabled for taking traffic as soon as it - * is registered with eureka. Sometimes the application might need to do some - * pre-processing before it is ready to take traffic. - */ - private boolean instanceEnabledOnit; - - /** - * Get the non-secure port on which the instance should receive traffic. - */ - private int nonSecurePort = 80; - - /** - * Get the Secure port on which the instance should receive traffic. - */ - private int securePort = 443; - - /** - * Indicates whether the non-secure port should be enabled for traffic or not. - */ - private boolean nonSecurePortEnabled = true; - - /** - * Indicates whether the secure port should be enabled for traffic or not. - */ - private boolean securePortEnabled; - - /** - * Indicates how often (in seconds) the eureka client needs to send heartbeats to - * eureka server to indicate that it is still alive. If the heartbeats are not - * received for the period specified in leaseExpirationDurationInSeconds, eureka - * server will remove the instance from its view, there by disallowing traffic to this - * instance. - * - * Note that the instance could still not take traffic if it implements - * HealthCheckCallback and then decides to make itself unavailable. - */ - private int leaseRenewalIntervalInSeconds = 30; - - /** - * Indicates the time in seconds that the eureka server waits since it received the - * last heartbeat before it can remove this instance from its view and there by - * disallowing traffic to this instance. - * - * Setting this value too long could mean that the traffic could be routed to the - * instance even though the instance is not alive. Setting this value too small could - * mean, the instance may be taken out of traffic because of temporary network - * glitches.This value to be set to atleast higher than the value specified in - * leaseRenewalIntervalInSeconds. - */ - private int leaseExpirationDurationInSeconds = 90; - - /** - * Gets the virtual host name defined for this instance. - * - * This is typically the way other instance would find this instance by using the - * virtual host name.Think of this as similar to the fully qualified domain name, that - * the users of your services will need to find this instance. - */ - private String virtualHostName = UNKNOWN; - - /** - * Get the unique Id (within the scope of the appName) of this instance to be - * registered with eureka. - */ - private String instanceId; - - /** - * Gets the secure virtual host name defined for this instance. - * - * This is typically the way other instance would find this instance by using the - * secure virtual host name.Think of this as similar to the fully qualified domain - * name, that the users of your services will need to find this instance. - */ - private String secureVirtualHostName = UNKNOWN; - - /** - * Gets the AWS autoscaling group name associated with this instance. This information - * is specifically used in an AWS environment to automatically put an instance out of - * service after the instance is launched and it has been disabled for traffic.. - */ - private String aSGName; - - /** - * Gets the metadata name/value pairs associated with this instance. This information - * is sent to eureka server and can be used by other instances. - */ - private Map metadataMap = new HashMap<>(); - - /** - * Returns the data center this instance is deployed. This information is used to get - * some AWS specific instance information if the instance is deployed in AWS. - */ - private DataCenterInfo dataCenterInfo = new MyDataCenterInfo(DataCenterInfo.Name.MyOwn); - - /** - * Get the IPAdress of the instance. This information is for academic purposes only as - * the communication from other instances primarily happen using the information - * supplied in {@link #getHostName(boolean)}. - */ - private String ipAddress; - - /** - * Gets the relative status page URL path for this instance. The status page URL is - * then constructed out of the hostName and the type of communication - secure or - * unsecure as specified in securePort and nonSecurePort. - * - * It is normally used for informational purposes for other services to find about the - * status of this instance. Users can provide a simple HTML indicating what is the - * current status of the instance. - */ - private String statusPageUrlPath = actuatorPrefix + "/info"; - - /** - * Gets the absolute status page URL path for this instance. The users can provide the - * statusPageUrlPath if the status page resides in the same instance talking to - * eureka, else in the cases where the instance is a proxy for some other server, - * users can provide the full URL. If the full URL is provided it takes precedence. - * - * It is normally used for informational purposes for other services to find about the - * status of this instance. Users can provide a simple HTML indicating what is the - * current status of the instance. - */ - private String statusPageUrl; - - /** - * Gets the relative home page URL Path for this instance. The home page URL is then - * constructed out of the hostName and the type of communication - secure or unsecure. - * - * It is normally used for informational purposes for other services to use it as a - * landing page. - */ - private String homePageUrlPath = "/"; - - /** - * Gets the absolute home page URL for this instance. The users can provide the - * homePageUrlPath if the home page resides in the same instance talking to eureka, - * else in the cases where the instance is a proxy for some other server, users can - * provide the full URL. If the full URL is provided it takes precedence. - * - * It is normally used for informational purposes for other services to use it as a - * landing page. The full URL should follow the format http://${eureka.hostname}:7001/ - * where the value ${eureka.hostname} is replaced at runtime. - */ - private String homePageUrl; - - /** - * Gets the relative health check URL path for this instance. The health check page - * URL is then constructed out of the hostname and the type of communication - secure - * or unsecure as specified in securePort and nonSecurePort. - * - * It is normally used for making educated decisions based on the health of the - * instance - for example, it can be used to determine whether to proceed deployments - * to an entire farm or stop the deployments without causing further damage. - */ - private String healthCheckUrlPath = actuatorPrefix + "/health"; - - /** - * Gets the absolute health check page URL for this instance. The users can provide - * the healthCheckUrlPath if the health check page resides in the same instance - * talking to eureka, else in the cases where the instance is a proxy for some other - * server, users can provide the full URL. If the full URL is provided it takes - * precedence. - * - *

- * It is normally used for making educated decisions based on the health of the - * instance - for example, it can be used to determine whether to proceed deployments - * to an entire farm or stop the deployments without causing further damage. The full - * URL should follow the format http://${eureka.hostname}:7001/ where the value - * ${eureka.hostname} is replaced at runtime. - */ - private String healthCheckUrl; - - /** - * Gets the absolute secure health check page URL for this instance. The users can - * provide the secureHealthCheckUrl if the health check page resides in the same - * instance talking to eureka, else in the cases where the instance is a proxy for - * some other server, users can provide the full URL. If the full URL is provided it - * takes precedence. - * - *

- * It is normally used for making educated decisions based on the health of the - * instance - for example, it can be used to determine whether to proceed deployments - * to an entire farm or stop the deployments without causing further damage. The full - * URL should follow the format http://${eureka.hostname}:7001/ where the value - * ${eureka.hostname} is replaced at runtime. - */ - private String secureHealthCheckUrl; - - /** - * Get the namespace used to find properties. Ignored in Spring Cloud. - */ - private String namespace = "eureka"; - - /** - * The hostname if it can be determined at configuration time (otherwise it will be - * guessed from OS primitives). - */ - private String hostname; - - /** - * Flag to say that, when guessing a hostname, the IP address of the server should be - * used in preference to the hostname reported by the OS. - */ - private boolean preferIpAddress = false; - - /** - * Initial status to register with remote Eureka server. - */ - private InstanceStatus initialStatus = InstanceStatus.UP; - - private String[] defaultAddressResolutionOrder = new String[0]; - - private Environment environment; - - public String getHostname() { - return getHostName(false); - } - - @SuppressWarnings("unused") - private EurekaInstanceConfigBean() { - } - - @Autowired - public EurekaInstanceConfigBean(InetUtils inetUtils) { - this.inetUtils = inetUtils; - this.hostInfo = this.inetUtils.findFirstNonLoopbackHostInfo(); - this.ipAddress = this.hostInfo.getIpAddress(); - this.hostname = this.hostInfo.getHostname(); - } - - @Override - public String getInstanceId() { - if (this.instanceId == null && this.metadataMap != null) { - return this.metadataMap.get("instanceId"); - } - return this.instanceId; - } - - @Override - public boolean getSecurePortEnabled() { - return this.securePortEnabled; - } - - public void setHostname(String hostname) { - this.hostname = hostname; - this.hostInfo.override = true; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - this.hostInfo.override = true; - } - - @Override - public String getHostName(boolean refresh) { - if (refresh && !this.hostInfo.override) { - this.ipAddress = this.hostInfo.getIpAddress(); - this.hostname = this.hostInfo.getHostname(); - } - return this.preferIpAddress ? this.ipAddress : this.hostname; - } - - @Override - public void setEnvironment(Environment environment) { - this.environment = environment; - // set some defaults from the environment, but allow the defaults to use relaxed - // binding - String springAppName = this.environment.getProperty("spring.application.name", ""); - if (StringUtils.hasText(springAppName)) { - setAppname(springAppName); - setVirtualHostName(springAppName); - setSecureVirtualHostName(springAppName); - } - } - - private HostInfo getHostInfo() { - return hostInfo; - } - - private void setHostInfo(HostInfo hostInfo) { - this.hostInfo = hostInfo; - } - - private InetUtils getInetUtils() { - return inetUtils; - } - - private void setInetUtils(InetUtils inetUtils) { - this.inetUtils = inetUtils; - } - - public String getAppname() { - return appname; - } - - public void setAppname(String appname) { - this.appname = appname; - } - - public String getAppGroupName() { - return appGroupName; - } - - public void setAppGroupName(String appGroupName) { - this.appGroupName = appGroupName; - } - - public boolean isInstanceEnabledOnit() { - return instanceEnabledOnit; - } - - public void setInstanceEnabledOnit(boolean instanceEnabledOnit) { - this.instanceEnabledOnit = instanceEnabledOnit; - } - - public int getNonSecurePort() { - return nonSecurePort; - } - - public void setNonSecurePort(int nonSecurePort) { - this.nonSecurePort = nonSecurePort; - } - - public int getSecurePort() { - return securePort; - } - - public void setSecurePort(int securePort) { - this.securePort = securePort; - } - - public boolean isNonSecurePortEnabled() { - return nonSecurePortEnabled; - } - - public void setNonSecurePortEnabled(boolean nonSecurePortEnabled) { - this.nonSecurePortEnabled = nonSecurePortEnabled; - } - - public boolean isSecurePortEnabled() { - return securePortEnabled; - } - - public void setSecurePortEnabled(boolean securePortEnabled) { - this.securePortEnabled = securePortEnabled; - } - - public int getLeaseRenewalIntervalInSeconds() { - return leaseRenewalIntervalInSeconds; - } - - public void setLeaseRenewalIntervalInSeconds(int leaseRenewalIntervalInSeconds) { - this.leaseRenewalIntervalInSeconds = leaseRenewalIntervalInSeconds; - } - - public int getLeaseExpirationDurationInSeconds() { - return leaseExpirationDurationInSeconds; - } - - public void setLeaseExpirationDurationInSeconds(int leaseExpirationDurationInSeconds) { - this.leaseExpirationDurationInSeconds = leaseExpirationDurationInSeconds; - } - - public String getVirtualHostName() { - return virtualHostName; - } - - public void setVirtualHostName(String virtualHostName) { - this.virtualHostName = virtualHostName; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public String getSecureVirtualHostName() { - return secureVirtualHostName; - } - - public void setSecureVirtualHostName(String secureVirtualHostName) { - this.secureVirtualHostName = secureVirtualHostName; - } - - public String getASGName() { - return aSGName; - } - - public void setASGName(String aSGName) { - this.aSGName = aSGName; - } - - public Map getMetadataMap() { - return metadataMap; - } - - public void setMetadataMap(Map metadataMap) { - this.metadataMap = metadataMap; - } - - public DataCenterInfo getDataCenterInfo() { - return dataCenterInfo; - } - - public void setDataCenterInfo(DataCenterInfo dataCenterInfo) { - this.dataCenterInfo = dataCenterInfo; - } - - public String getIpAddress() { - return ipAddress; - } - - public String getStatusPageUrlPath() { - return statusPageUrlPath; - } - - public void setStatusPageUrlPath(String statusPageUrlPath) { - this.statusPageUrlPath = statusPageUrlPath; - } - - public String getStatusPageUrl() { - return statusPageUrl; - } - - public void setStatusPageUrl(String statusPageUrl) { - this.statusPageUrl = statusPageUrl; - } - - public String getHomePageUrlPath() { - return homePageUrlPath; - } - - public void setHomePageUrlPath(String homePageUrlPath) { - this.homePageUrlPath = homePageUrlPath; - } - - public String getHomePageUrl() { - return homePageUrl; - } - - public void setHomePageUrl(String homePageUrl) { - this.homePageUrl = homePageUrl; - } - - public String getHealthCheckUrlPath() { - return healthCheckUrlPath; - } - - public void setHealthCheckUrlPath(String healthCheckUrlPath) { - this.healthCheckUrlPath = healthCheckUrlPath; - } - - public String getHealthCheckUrl() { - return healthCheckUrl; - } - - public void setHealthCheckUrl(String healthCheckUrl) { - this.healthCheckUrl = healthCheckUrl; - } - - public String getSecureHealthCheckUrl() { - return secureHealthCheckUrl; - } - - public void setSecureHealthCheckUrl(String secureHealthCheckUrl) { - this.secureHealthCheckUrl = secureHealthCheckUrl; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public boolean isPreferIpAddress() { - return preferIpAddress; - } - - public void setPreferIpAddress(boolean preferIpAddress) { - this.preferIpAddress = preferIpAddress; - } - - public InstanceStatus getInitialStatus() { - return initialStatus; - } - - public void setInitialStatus(InstanceStatus initialStatus) { - this.initialStatus = initialStatus; - } - - public String[] getDefaultAddressResolutionOrder() { - return defaultAddressResolutionOrder; - } - - public void setDefaultAddressResolutionOrder(String[] defaultAddressResolutionOrder) { - this.defaultAddressResolutionOrder = defaultAddressResolutionOrder; - } - - public Environment getEnvironment() { - return environment; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaInstanceConfigBean that = (EurekaInstanceConfigBean) o; - return Objects.equals(hostInfo, that.hostInfo) && Objects.equals(inetUtils, that.inetUtils) - && Objects.equals(appname, that.appname) && Objects.equals(appGroupName, that.appGroupName) - && instanceEnabledOnit == that.instanceEnabledOnit && nonSecurePort == that.nonSecurePort - && securePort == that.securePort && nonSecurePortEnabled == that.nonSecurePortEnabled - && securePortEnabled == that.securePortEnabled - && leaseRenewalIntervalInSeconds == that.leaseRenewalIntervalInSeconds - && leaseExpirationDurationInSeconds == that.leaseExpirationDurationInSeconds - && Objects.equals(virtualHostName, that.virtualHostName) && Objects.equals(instanceId, that.instanceId) - && Objects.equals(secureVirtualHostName, that.secureVirtualHostName) - && Objects.equals(aSGName, that.aSGName) && Objects.equals(metadataMap, that.metadataMap) - && Objects.equals(dataCenterInfo, that.dataCenterInfo) && Objects.equals(ipAddress, that.ipAddress) - && Objects.equals(statusPageUrlPath, that.statusPageUrlPath) - && Objects.equals(statusPageUrl, that.statusPageUrl) - && Objects.equals(homePageUrlPath, that.homePageUrlPath) - && Objects.equals(homePageUrl, that.homePageUrl) - && Objects.equals(healthCheckUrlPath, that.healthCheckUrlPath) - && Objects.equals(healthCheckUrl, that.healthCheckUrl) - && Objects.equals(secureHealthCheckUrl, that.secureHealthCheckUrl) - && Objects.equals(namespace, that.namespace) && Objects.equals(hostname, that.hostname) - && preferIpAddress == that.preferIpAddress && Objects.equals(initialStatus, that.initialStatus) - && Arrays.equals(defaultAddressResolutionOrder, that.defaultAddressResolutionOrder) - && Objects.equals(environment, that.environment); - } - - @Override - public int hashCode() { - return Objects.hash(hostInfo, inetUtils, appname, appGroupName, instanceEnabledOnit, nonSecurePort, securePort, - nonSecurePortEnabled, securePortEnabled, leaseRenewalIntervalInSeconds, - leaseExpirationDurationInSeconds, virtualHostName, instanceId, secureVirtualHostName, aSGName, - metadataMap, dataCenterInfo, ipAddress, statusPageUrlPath, statusPageUrl, homePageUrlPath, homePageUrl, - healthCheckUrlPath, healthCheckUrl, secureHealthCheckUrl, namespace, hostname, preferIpAddress, - initialStatus, Arrays.hashCode(defaultAddressResolutionOrder), environment); - } - - @Override - public String toString() { - return new StringBuilder("EurekaInstanceConfigBean{").append("hostInfo=").append(hostInfo).append(", ") - .append("inetUtils=").append(inetUtils).append(", ").append("appname='").append(appname).append("', ") - .append("appGroupName='").append(appGroupName).append("', ").append("instanceEnabledOnit=") - .append(instanceEnabledOnit).append(", ").append("nonSecurePort=").append(nonSecurePort).append(", ") - .append("securePort=").append(securePort).append(", ").append("nonSecurePortEnabled=") - .append(nonSecurePortEnabled).append(", ").append("securePortEnabled=").append(securePortEnabled) - .append(", ").append("leaseRenewalIntervalInSeconds=").append(leaseRenewalIntervalInSeconds) - .append(", ").append("leaseExpirationDurationInSeconds=").append(leaseExpirationDurationInSeconds) - .append(", ").append("virtualHostName='").append(virtualHostName).append("', ").append("instanceId='") - .append(instanceId).append("', ").append("secureVirtualHostName='").append(secureVirtualHostName) - .append("', ").append("aSGName='").append(aSGName).append("', ").append("metadataMap=") - .append(metadataMap).append(", ").append("dataCenterInfo=").append(dataCenterInfo).append(", ") - .append("ipAddress='").append(ipAddress).append("', ").append("statusPageUrlPath='") - .append(statusPageUrlPath).append("', ").append("statusPageUrl='").append(statusPageUrl).append("', ") - .append("homePageUrlPath='").append(homePageUrlPath).append("', ").append("homePageUrl='") - .append(homePageUrl).append("', ").append("healthCheckUrlPath='").append(healthCheckUrlPath) - .append("', ").append("healthCheckUrl='").append(healthCheckUrl).append("', ") - .append("secureHealthCheckUrl='").append(secureHealthCheckUrl).append("', ").append("namespace='") - .append(namespace).append("', ").append("hostname='").append(hostname).append("', ") - .append("preferIpAddress=").append(preferIpAddress).append(", ").append("initialStatus=") - .append(initialStatus).append(", ").append("defaultAddressResolutionOrder=") - .append(Arrays.toString(defaultAddressResolutionOrder)).append(", ").append("environment=") - .append(environment).append(", ").append("}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstance.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstance.java deleted file mode 100644 index fadc02442..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstance.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.net.URI; -import java.util.Map; -import java.util.Objects; - -import com.netflix.appinfo.InstanceInfo; - -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.core.style.ToStringCreator; -import org.springframework.util.Assert; - -import static com.netflix.appinfo.InstanceInfo.PortType.SECURE; - -/** - * An Eureka-specific {@link ServiceInstance} implementation. - * - * @author Spencer Gibb - * @author Dave Syer - * @author Olga Maciaszek-Sharma - * @author Tim Ysewyn - */ -public class EurekaServiceInstance implements ServiceInstance { - - private final InstanceInfo instance; - - public EurekaServiceInstance(InstanceInfo instance) { - Assert.notNull(instance, "Service instance required"); - this.instance = instance; - } - - public InstanceInfo getInstanceInfo() { - return instance; - } - - @Override - public String getInstanceId() { - return this.instance.getId(); - } - - @Override - public String getServiceId() { - return this.instance.getAppName(); - } - - @Override - public String getHost() { - return this.instance.getHostName(); - } - - @Override - public int getPort() { - if (isSecure()) { - return this.instance.getSecurePort(); - } - return this.instance.getPort(); - } - - @Override - public boolean isSecure() { - // assume if secure is enabled, that is the default - return this.instance.isPortEnabled(SECURE); - } - - @Override - public URI getUri() { - return DefaultServiceInstance.getUri(this); - } - - @Override - public Map getMetadata() { - return this.instance.getMetadata(); - } - - @Override - public String getScheme() { - return getUri().getScheme(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaServiceInstance that = (EurekaServiceInstance) o; - return Objects.equals(this.instance, that.instance); - } - - @Override - public int hashCode() { - return Objects.hash(this.instance); - } - - @Override - public String toString() { - return new ToStringCreator(this).append("instance", instance).toString(); - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactory.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactory.java deleted file mode 100644 index 22effe03b..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Map; - -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.LeaseInfo; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * See com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider. - * - * @author Spencer Gibb - */ -public class InstanceInfoFactory { - - private static final Log log = LogFactory.getLog(InstanceInfoFactory.class); - - public InstanceInfo create(EurekaInstanceConfig config) { - LeaseInfo.Builder leaseInfoBuilder = LeaseInfo.Builder.newBuilder() - .setRenewalIntervalInSecs(config.getLeaseRenewalIntervalInSeconds()) - .setDurationInSecs(config.getLeaseExpirationDurationInSeconds()); - - // Builder the instance information to be registered with eureka - // server - InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder(); - - String namespace = config.getNamespace(); - if (!namespace.endsWith(".")) { - namespace = namespace + "."; - } - builder.setNamespace(namespace).setAppName(config.getAppname()).setInstanceId(config.getInstanceId()) - .setAppGroupName(config.getAppGroupName()).setDataCenterInfo(config.getDataCenterInfo()) - .setIPAddr(config.getIpAddress()).setHostName(config.getHostName(false)) - .setPort(config.getNonSecurePort()) - .enablePort(InstanceInfo.PortType.UNSECURE, config.isNonSecurePortEnabled()) - .setSecurePort(config.getSecurePort()) - .enablePort(InstanceInfo.PortType.SECURE, config.getSecurePortEnabled()) - .setVIPAddress(config.getVirtualHostName()).setSecureVIPAddress(config.getSecureVirtualHostName()) - .setHomePageUrl(config.getHomePageUrlPath(), config.getHomePageUrl()) - .setStatusPageUrl(config.getStatusPageUrlPath(), config.getStatusPageUrl()) - .setHealthCheckUrls(config.getHealthCheckUrlPath(), config.getHealthCheckUrl(), - config.getSecureHealthCheckUrl()) - .setASGName(config.getASGName()); - - // Start off with the STARTING state to avoid traffic - if (!config.isInstanceEnabledOnit()) { - InstanceInfo.InstanceStatus initialStatus = InstanceInfo.InstanceStatus.STARTING; - if (log.isInfoEnabled()) { - log.info("Setting initial instance status as: " + initialStatus); - } - builder.setStatus(initialStatus); - } - else { - if (log.isInfoEnabled()) { - log.info("Setting initial instance status as: " + InstanceInfo.InstanceStatus.UP - + ". This may be too early for the instance to advertise itself as available. " - + "You would instead want to control this via a healthcheck handler."); - } - } - - // Add any user-specific metadata information - for (Map.Entry mapEntry : config.getMetadataMap().entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - // only add the metadata if the value is present - if (value != null && !value.isEmpty()) { - builder.add(key, value); - } - } - - InstanceInfo instanceInfo = builder.build(); - instanceInfo.setLeaseInfo(leaseInfoBuilder.build()); - return instanceInfo; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/RestTemplateTimeoutProperties.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/RestTemplateTimeoutProperties.java deleted file mode 100644 index 394420ddb..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/RestTemplateTimeoutProperties.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Objects; - -import org.apache.hc.client5.http.config.RequestConfig; -import org.apache.hc.core5.http.io.SocketConfig; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient; -import org.springframework.web.client.RestTemplate; - -/** - * Properties for configuring timeouts used in {@link RestTemplate} required by - * {@link RestTemplateEurekaHttpClient}. - * - * @author Jiwon Jeon - * @since 3.1.6 - */ -@ConfigurationProperties("eureka.client.rest-template-timeout") -public class RestTemplateTimeoutProperties { - - /** - * Default values are set to 180000, in keeping with {@link RequestConfig} and - * {@link SocketConfig} defaults. - */ - private int connectTimeout = 3 * 60 * 1000; - - private int connectRequestTimeout = 3 * 60 * 1000; - - private int socketTimeout = 3 * 60 * 1000; - - public int getConnectTimeout() { - return connectTimeout; - } - - public int getConnectRequestTimeout() { - return connectRequestTimeout; - } - - public int getSocketTimeout() { - return socketTimeout; - } - - public void setConnectTimeout(int connectTimeout) { - this.connectTimeout = connectTimeout; - } - - public void setConnectRequestTimeout(int connectRequestTimeout) { - this.connectRequestTimeout = connectRequestTimeout; - } - - public void setSocketTimeout(int socketTimeout) { - this.socketTimeout = socketTimeout; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - RestTemplateTimeoutProperties that = (RestTemplateTimeoutProperties) o; - - return connectTimeout == that.connectTimeout && connectRequestTimeout == that.connectRequestTimeout - && socketTimeout == that.socketTimeout; - } - - @Override - public int hashCode() { - return Objects.hash(connectTimeout, connectRequestTimeout, socketTimeout); - } - - @Override - public String toString() { - return "RestTemplateTimeoutProperties{" + ", connectTimeout=" + connectTimeout + ", connectRequestTimeout=" - + connectRequestTimeout + ", socketTimeout=" + socketTimeout + '}'; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java deleted file mode 100644 index d621a8213..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/DiscoveryClientOptionalArgsConfiguration.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.SearchStrategy; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.configuration.SSLContextFactory; -import org.springframework.cloud.configuration.TlsProperties; -import org.springframework.cloud.netflix.eureka.RestTemplateTimeoutProperties; -import org.springframework.cloud.netflix.eureka.http.DefaultEurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.http.RestTemplateTransportClientFactories; -import org.springframework.cloud.netflix.eureka.http.WebClientDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.http.WebClientTransportClientFactories; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Daniel Lavoie - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties(RestTemplateTimeoutProperties.class) -public class DiscoveryClientOptionalArgsConfiguration { - - protected static final Log logger = LogFactory.getLog(DiscoveryClientOptionalArgsConfiguration.class); - - @Bean - @ConfigurationProperties("eureka.client.tls") - public TlsProperties tlsProperties() { - return new TlsProperties(); - } - - @Bean - @ConditionalOnClass(name = "org.springframework.web.client.RestTemplate") - @ConditionalOnMissingClass("org.glassfish.jersey.client.JerseyClient") - @ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class }, search = SearchStrategy.CURRENT) - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, - havingValue = "false") - public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs(TlsProperties tlsProperties, - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) - throws GeneralSecurityException, IOException { - logger.info("Eureka HTTP Client uses RestTemplate."); - RestTemplateDiscoveryClientOptionalArgs result = new RestTemplateDiscoveryClientOptionalArgs( - eurekaClientHttpRequestFactorySupplier); - setupTLS(result, tlsProperties); - return result; - } - - @Bean - @ConditionalOnClass(name = "org.springframework.web.client.RestTemplate") - @ConditionalOnMissingClass("org.glassfish.jersey.client.JerseyClient") - @ConditionalOnMissingBean(value = { TransportClientFactories.class }, search = SearchStrategy.CURRENT) - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, - havingValue = "false") - public RestTemplateTransportClientFactories restTemplateTransportClientFactories( - RestTemplateDiscoveryClientOptionalArgs optionalArgs) { - return new RestTemplateTransportClientFactories(optionalArgs); - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnClass(name = "org.springframework.web.client.RestTemplate") - EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier( - RestTemplateTimeoutProperties restTemplateTimeoutProperties) { - return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties); - } - - private static void setupTLS(AbstractDiscoveryClientOptionalArgs args, TlsProperties properties) - throws GeneralSecurityException, IOException { - if (properties.isEnabled()) { - SSLContextFactory factory = new SSLContextFactory(properties); - args.setSSLContext(factory.createSSLContext()); - } - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(name = "org.glassfish.jersey.client.JerseyClient") - @ConditionalOnBean(value = AbstractDiscoveryClientOptionalArgs.class, search = SearchStrategy.CURRENT) - static class DiscoveryClientOptionalArgsTlsConfiguration { - - DiscoveryClientOptionalArgsTlsConfiguration(TlsProperties tlsProperties, - AbstractDiscoveryClientOptionalArgs optionalArgs) throws GeneralSecurityException, IOException { - logger.info("Eureka HTTP Client uses Jersey"); - setupTLS(optionalArgs, tlsProperties); - } - - } - - @ConditionalOnMissingClass("org.glassfish.jersey.client.JerseyClient") - @ConditionalOnClass(name = "org.springframework.web.reactive.function.client.WebClient") - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", havingValue = "true") - protected static class WebClientConfiguration { - - @Autowired - private TlsProperties tlsProperties; - - @Bean - @ConditionalOnMissingBean( - value = { AbstractDiscoveryClientOptionalArgs.class, RestTemplateDiscoveryClientOptionalArgs.class }, - search = SearchStrategy.CURRENT) - public WebClientDiscoveryClientOptionalArgs webClientDiscoveryClientOptionalArgs( - ObjectProvider builder) throws GeneralSecurityException, IOException { - logger.info("Eureka HTTP Client uses WebClient."); - WebClientDiscoveryClientOptionalArgs result = new WebClientDiscoveryClientOptionalArgs( - builder::getIfAvailable); - setupTLS(result, tlsProperties); - return result; - } - - @Bean - @ConditionalOnMissingBean(value = TransportClientFactories.class, search = SearchStrategy.CURRENT) - public WebClientTransportClientFactories webClientTransportClientFactories( - ObjectProvider builder) { - return new WebClientTransportClientFactories(builder::getIfAvailable); - } - - } - - @Configuration - @ConditionalOnMissingClass({ "org.glassfish.jersey.client.JerseyClient", - "org.springframework.web.reactive.function.client.WebClient" }) - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", havingValue = "true") - protected static class WebClientNotFoundConfiguration { - - public WebClientNotFoundConfiguration() { - throw new IllegalStateException( - "eureka.client.webclient.enabled is true, " + "but WebClient is not on the classpath. Please add " - + "spring-boot-starter-webflux as a dependency."); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfiguration.java deleted file mode 100644 index f2c78efbd..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfiguration.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.discovery.EurekaClient; -import jakarta.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.util.StringUtils; - -/** - * Extra configuration for config server if it happens to be a Eureka instance. - * - * @author Dave Syer - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties -@ConditionalOnClass(value = { EurekaInstanceConfigBean.class, EurekaClient.class }, - name = "org.springframework.cloud.config.server.config.ConfigServerProperties") -public class EurekaClientConfigServerAutoConfiguration { - - @Autowired(required = false) - private EurekaInstanceConfig instance; - - @Autowired - private Environment env; - - @PostConstruct - public void init() { - if (this.instance == null) { - return; - } - String prefix = this.env.getProperty("spring.cloud.config.server.prefix"); - if (StringUtils.hasText(prefix) && !StringUtils.hasText(this.instance.getMetadataMap().get("configPath"))) { - this.instance.getMetadataMap().put("configPath", prefix); - } - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfiguration.java deleted file mode 100644 index b4804bc4f..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfiguration.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.EurekaHttpClient; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.AllNestedConditions; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.SearchStrategy; -import org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration; -import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.config.client.ConfigServerInstanceProvider; -import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator; -import org.springframework.cloud.configuration.TlsProperties; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.http.DefaultEurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient; -import org.springframework.cloud.netflix.eureka.http.RestTemplateTransportClientFactory; -import org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient; -import org.springframework.cloud.netflix.eureka.http.WebClientTransportClientFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.lang.Nullable; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Bootstrap configuration for config client that wants to lookup the config server via - * discovery. - * - * @author Dave Syer - */ -@ConditionalOnClass(ConfigServicePropertySourceLocator.class) -@Conditional(EurekaConfigServerBootstrapConfiguration.EurekaConfigServerBootstrapCondition.class) -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties -public class EurekaConfigServerBootstrapConfiguration { - - @Bean - @ConditionalOnMissingBean(value = EurekaClientConfig.class, search = SearchStrategy.CURRENT) - public EurekaClientConfigBean eurekaClientConfigBean() { - return new EurekaClientConfigBean(); - } - - @Bean - @ConditionalOnMissingBean(EurekaHttpClient.class) - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", matchIfMissing = true, - havingValue = "false") - public RestTemplateEurekaHttpClient configDiscoveryRestTemplateEurekaHttpClient(EurekaClientConfigBean config, - Environment env, @Nullable TlsProperties properties, - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) { - return (RestTemplateEurekaHttpClient) new RestTemplateTransportClientFactory(properties, - eurekaClientHttpRequestFactorySupplier) - .newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env)); - } - - @Bean - @ConditionalOnMissingBean - EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier() { - return new DefaultEurekaClientHttpRequestFactorySupplier(); - } - - @Bean - public ConfigServerInstanceProvider.Function eurekaConfigServerInstanceProvider(EurekaHttpClient client, - EurekaClientConfig config) { - return new EurekaConfigServerInstanceProvider(client, config)::getInstances; - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(name = "org.springframework.web.reactive.function.client.WebClient") - @ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled", havingValue = "true") - @ImportAutoConfiguration({ CodecsAutoConfiguration.class, WebClientAutoConfiguration.class }) - protected static class WebClientConfiguration { - - @Bean - @ConditionalOnMissingBean(EurekaHttpClient.class) - public WebClientEurekaHttpClient configDiscoveryWebClientEurekaHttpClient(EurekaClientConfigBean config, - ObjectProvider builder, Environment env) { - return (WebClientEurekaHttpClient) new WebClientTransportClientFactory(builder::getIfAvailable) - .newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env)); - } - - } - - static class EurekaConfigServerBootstrapCondition extends AllNestedConditions { - - EurekaConfigServerBootstrapCondition() { - super(ConfigurationPhase.REGISTER_BEAN); - } - - @ConditionalOnProperty("spring.cloud.config.discovery.enabled") - static class OnCloudConfigProperty { - - } - - @ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true) - static class OnEurekaClient { - - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapper.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapper.java deleted file mode 100644 index edd935be0..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapper.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.util.Collections; -import java.util.List; - -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import org.apache.commons.logging.Log; - -import org.springframework.boot.BootstrapContext; -import org.springframework.boot.BootstrapRegistry; -import org.springframework.boot.BootstrapRegistryInitializer; -import org.springframework.boot.context.properties.bind.BindHandler; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.config.client.ConfigClientProperties; -import org.springframework.cloud.config.client.ConfigServerInstanceProvider; -import org.springframework.cloud.configuration.TlsProperties; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.http.DefaultEurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier; -import org.springframework.cloud.netflix.eureka.http.RestTemplateTransportClientFactory; -import org.springframework.util.ClassUtils; - -public class EurekaConfigServerBootstrapper implements BootstrapRegistryInitializer { - - @Override - public void initialize(BootstrapRegistry registry) { - if (!ClassUtils.isPresent("org.springframework.cloud.config.client.ConfigServerInstanceProvider", null)) { - return; - } - - // It is important that we pass a lambda for the Function or else we will get a - // ClassNotFoundException when config is not on the classpath - registry.registerIfAbsent(ConfigServerInstanceProvider.Function.class, EurekaFunction::create); - } - - private static Boolean getDiscoveryEnabled(Binder binder) { - return binder.bind(ConfigClientProperties.CONFIG_DISCOVERY_ENABLED, Boolean.class).orElse(false) - && binder.bind("eureka.client.enabled", Boolean.class).orElse(true) - && binder.bind("spring.cloud.discovery.enabled", Boolean.class).orElse(true); - } - - final static class EurekaFunction implements ConfigServerInstanceProvider.Function { - - private final BootstrapContext context; - - static EurekaFunction create(BootstrapContext context) { - return new EurekaFunction(context); - } - - private EurekaFunction(BootstrapContext context) { - this.context = context; - } - - @Override - public List apply(String serviceId, Binder binder, BindHandler bindHandler, Log log) { - if (binder == null || !getDiscoveryEnabled(binder)) { - return Collections.emptyList(); - } - - EurekaClientConfigBean config = binder.bind(EurekaClientConfigBean.PREFIX, EurekaClientConfigBean.class) - .orElseGet(EurekaClientConfigBean::new); - EurekaHttpClient httpClient = new RestTemplateTransportClientFactory( - context.getOrElse(TlsProperties.class, null), - context.getOrElse(EurekaClientHttpRequestFactorySupplier.class, - new DefaultEurekaClientHttpRequestFactorySupplier())) - .newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, binder)); - return new EurekaConfigServerInstanceProvider(httpClient, config).getInstances(serviceId); - } - - @Override - public List apply(String serviceId) { - // This should never be called now but is here for backward - // compatibility - return apply(serviceId, null, null, null); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerInstanceProvider.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerInstanceProvider.java deleted file mode 100644 index 1f0934d03..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerInstanceProvider.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.util.ArrayList; -import java.util.List; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.netflix.eureka.EurekaServiceInstance; -import org.springframework.http.HttpStatus; - -public class EurekaConfigServerInstanceProvider { - - private final Log log; - - private final EurekaHttpClient client; - - private final EurekaClientConfig config; - - public EurekaConfigServerInstanceProvider(EurekaHttpClient client, EurekaClientConfig config) { - this(LogFactory.getLog(EurekaConfigServerInstanceProvider.class), client, config); - } - - public EurekaConfigServerInstanceProvider(Log log, EurekaHttpClient client, EurekaClientConfig config) { - this.log = log; - this.client = client; - this.config = config; - } - - public List getInstances(String serviceId) { - if (log.isDebugEnabled()) { - log.debug("eurekaConfigServerInstanceProvider finding instances for " + serviceId); - } - EurekaHttpResponse response = client.getApplications(config.getRegion()); - List instances = new ArrayList<>(); - if (!isSuccessful(response) || response.getEntity() == null) { - return instances; - } - - Applications applications = response.getEntity(); - applications.shuffleInstances(config.shouldFilterOnlyUpInstances()); - List infos = applications.getInstancesByVirtualHostName(serviceId); - for (InstanceInfo info : infos) { - instances.add(new EurekaServiceInstance(info)); - } - if (log.isDebugEnabled()) { - log.debug("eurekaConfigServerInstanceProvider found " + infos.size() + " instance(s) for " + serviceId - + ", " + instances); - } - return instances; - } - - private boolean isSuccessful(EurekaHttpResponse response) { - HttpStatus httpStatus = HttpStatus.resolve(response.getStatusCode()); - return httpStatus != null && httpStatus.is2xxSuccessful(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaTlsProperties.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaTlsProperties.java deleted file mode 100644 index 3cbb8f02e..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/EurekaTlsProperties.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.springframework.cloud.configuration.TlsProperties; - -/** - * Eureka client TLS properties. - */ - -public class EurekaTlsProperties extends TlsProperties { - - /** - * Prefix for Eureka client TLS properties. - */ - public static final String PREFIX = "eureka.client.tls"; - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/HostnameBasedUrlRandomizer.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/HostnameBasedUrlRandomizer.java deleted file mode 100644 index 494a18c44..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/config/HostnameBasedUrlRandomizer.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.util.List; - -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.endpoint.EndpointUtils; -import com.netflix.discovery.shared.resolver.DefaultEndpoint; - -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.core.env.Environment; -import org.springframework.util.StringUtils; - -public final class HostnameBasedUrlRandomizer implements EndpointUtils.ServiceUrlRandomizer { - - private final String hostname; - - HostnameBasedUrlRandomizer(String hostname) { - this.hostname = hostname; - } - - @Override - public void randomize(List urlList) { - int listSize = 0; - if (urlList != null) { - listSize = urlList.size(); - } - if (!StringUtils.hasText(hostname) || listSize == 0) { - return; - } - // Find the hashcode of the instance hostname and use it to find an entry - // and then arrange the rest of the entries after this entry. - int instanceHashcode = hostname.hashCode(); - if (instanceHashcode < 0) { - instanceHashcode = instanceHashcode * -1; - } - int backupInstance = instanceHashcode % listSize; - for (int i = 0; i < backupInstance; i++) { - String zone = urlList.remove(0); - urlList.add(zone); - } - } - - public static String getEurekaUrl(EurekaClientConfig config, String hostname) { - List urls = EndpointUtils.getDiscoveryServiceUrls(config, EurekaClientConfigBean.DEFAULT_ZONE, - new HostnameBasedUrlRandomizer(hostname)); - return urls.get(0); - } - - public static DefaultEndpoint randomEndpoint(EurekaClientConfig config, Environment env) { - String hostname = env.getProperty("eureka.instance.hostname"); - return new DefaultEndpoint(getEurekaUrl(config, hostname)); - } - - public static DefaultEndpoint randomEndpoint(EurekaClientConfig config, Binder binder) { - String hostname = binder.bind("eureka.instance.hostname", String.class).orElseGet(() -> null); - return new DefaultEndpoint(getEurekaUrl(config, hostname)); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/DefaultEurekaClientHttpRequestFactorySupplier.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/DefaultEurekaClientHttpRequestFactorySupplier.java deleted file mode 100644 index 36bf1b35a..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/DefaultEurekaClientHttpRequestFactorySupplier.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import org.apache.hc.client5.http.config.RequestConfig; -import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; -import org.apache.hc.client5.http.impl.classic.HttpClients; -import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; -import org.apache.hc.client5.http.io.HttpClientConnectionManager; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; -import org.apache.hc.core5.http.io.SocketConfig; -import org.apache.hc.core5.util.Timeout; - -import org.springframework.cloud.netflix.eureka.RestTemplateTimeoutProperties; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.lang.Nullable; - -/** - * Supplier for the {@link ClientHttpRequestFactory} to be used by Eureka client that uses - * {@link HttpClients}. - * - * @author Marcin Grzejszczak - * @author Olga Maciaszek-Sharma - * @author Jiwon Jeon - * @since 3.0.0 - */ -public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClientHttpRequestFactorySupplier { - - private final RestTemplateTimeoutProperties restTemplateTimeoutProperties; - - /** - * @deprecated in favour of - * {@link DefaultEurekaClientHttpRequestFactorySupplier#DefaultEurekaClientHttpRequestFactorySupplier(RestTemplateTimeoutProperties)} - */ - @Deprecated - public DefaultEurekaClientHttpRequestFactorySupplier() { - this.restTemplateTimeoutProperties = new RestTemplateTimeoutProperties(); - } - - public DefaultEurekaClientHttpRequestFactorySupplier(RestTemplateTimeoutProperties restTemplateTimeoutProperties) { - this.restTemplateTimeoutProperties = restTemplateTimeoutProperties; - } - - @Override - public ClientHttpRequestFactory get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier) { - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - if (sslContext != null || hostnameVerifier != null || restTemplateTimeoutProperties != null) { - httpClientBuilder.setConnectionManager( - buildConnectionManager(sslContext, hostnameVerifier, restTemplateTimeoutProperties)); - } - if (restTemplateTimeoutProperties != null) { - httpClientBuilder.setDefaultRequestConfig(buildRequestConfig()); - } - - CloseableHttpClient httpClient = httpClientBuilder.build(); - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - requestFactory.setHttpClient(httpClient); - return requestFactory; - } - - private HttpClientConnectionManager buildConnectionManager(SSLContext sslContext, HostnameVerifier hostnameVerifier, - RestTemplateTimeoutProperties restTemplateTimeoutProperties) { - PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder - .create(); - SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder = SSLConnectionSocketFactoryBuilder - .create(); - if (sslContext != null) { - sslConnectionSocketFactoryBuilder.setSslContext(sslContext); - } - if (hostnameVerifier != null) { - sslConnectionSocketFactoryBuilder.setHostnameVerifier(hostnameVerifier); - } - connectionManagerBuilder.setSSLSocketFactory(sslConnectionSocketFactoryBuilder.build()); - if (restTemplateTimeoutProperties != null) { - connectionManagerBuilder.setDefaultSocketConfig(SocketConfig.custom() - .setSoTimeout(Timeout.of(restTemplateTimeoutProperties.getSocketTimeout(), TimeUnit.MILLISECONDS)) - .build()); - } - return connectionManagerBuilder.build(); - } - - private RequestConfig buildRequestConfig() { - return RequestConfig.custom() - .setConnectTimeout(Timeout.of(restTemplateTimeoutProperties.getConnectTimeout(), TimeUnit.MILLISECONDS)) - .setConnectionRequestTimeout( - Timeout.of(restTemplateTimeoutProperties.getConnectRequestTimeout(), TimeUnit.MILLISECONDS)) - .build(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaApplications.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaApplications.java deleted file mode 100644 index c71dadf85..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaApplications.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; - -/** - * A simple wrapper class for {@link Applications} that insure proprer Jackson - * serialization through the JsonPropert overwrites. - * - * @author Daniel Lavoie - */ -public class EurekaApplications extends com.netflix.discovery.shared.Applications { - - @JsonCreator - public EurekaApplications(@JsonProperty("apps__hashcode") String appsHashCode, - @JsonProperty("versions__delta") Long versionDelta, - @JsonProperty("application") List registeredApplications) { - super(appsHashCode, versionDelta, registeredApplications); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaClientHttpRequestFactorySupplier.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaClientHttpRequestFactorySupplier.java deleted file mode 100644 index b5a104c3c..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/EurekaClientHttpRequestFactorySupplier.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.lang.Nullable; - -/** - * Supplier for the {@link ClientHttpRequestFactory} to be used by Eureka client. - * - * @author Marcin Grzejszczak - * @since 3.0.0 - */ -public interface EurekaClientHttpRequestFactorySupplier { - - /** - * Returns a constructed {@link ClientHttpRequestFactory}. - * @param sslContext SSL Context - * @param hostnameVerifier Hostname verifier - * @return {@link ClientHttpRequestFactory} - */ - ClientHttpRequestFactory get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier); - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateDiscoveryClientOptionalArgs.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateDiscoveryClientOptionalArgs.java deleted file mode 100644 index 0e74905b4..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateDiscoveryClientOptionalArgs.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; - -/** - * @author Daniel Lavoie - */ -public class RestTemplateDiscoveryClientOptionalArgs extends AbstractDiscoveryClientOptionalArgs { - - protected final EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier; - - public RestTemplateDiscoveryClientOptionalArgs( - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) { - this.eurekaClientHttpRequestFactorySupplier = eurekaClientHttpRequestFactorySupplier; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClient.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClient.java deleted file mode 100644 index 26f2a8875..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClient.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder; -import com.netflix.discovery.util.StringUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; - -import static com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse; - -/** - * @author Daniel Lavoie - */ -public class RestTemplateEurekaHttpClient implements EurekaHttpClient { - - protected final Log logger = LogFactory.getLog(getClass()); - - private final RestTemplate restTemplate; - - private String serviceUrl; - - public RestTemplateEurekaHttpClient(RestTemplate restTemplate, String serviceUrl) { - this.restTemplate = restTemplate; - this.serviceUrl = serviceUrl; - if (!serviceUrl.endsWith("/")) { - this.serviceUrl = this.serviceUrl + "/"; - } - } - - public String getServiceUrl() { - return this.serviceUrl; - } - - public RestTemplate getRestTemplate() { - return restTemplate; - } - - @Override - public EurekaHttpResponse register(InstanceInfo info) { - String urlPath = serviceUrl + "apps/" + info.getAppName(); - - HttpHeaders headers = new HttpHeaders(); - headers.add(HttpHeaders.ACCEPT_ENCODING, "gzip"); - headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.POST, new HttpEntity<>(info, headers), - Void.class); - - return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse cancel(String appName, String id) { - String urlPath = serviceUrl + "apps/" + appName + '/' + id; - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.DELETE, null, Void.class); - - return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse sendHeartBeat(String appName, String id, InstanceInfo info, - InstanceStatus overriddenStatus) { - String urlPath = serviceUrl + "apps/" + appName + '/' + id + "?status=" + info.getStatus().toString() - + "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString() - + (overriddenStatus != null ? "&overriddenstatus=" + overriddenStatus.name() : ""); - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.PUT, null, - InstanceInfo.class); - - EurekaHttpResponseBuilder eurekaResponseBuilder = anEurekaHttpResponse( - response.getStatusCode().value(), InstanceInfo.class).headers(headersOf(response)); - - if (response.hasBody()) { - eurekaResponseBuilder.entity(response.getBody()); - } - - return eurekaResponseBuilder.build(); - } - - @Override - public EurekaHttpResponse statusUpdate(String appName, String id, InstanceStatus newStatus, - InstanceInfo info) { - String urlPath = serviceUrl + "apps/" + appName + '/' + id + "/status?value=" + newStatus.name() - + "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString(); - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.PUT, null, Void.class); - - return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse deleteStatusOverride(String appName, String id, InstanceInfo info) { - String urlPath = serviceUrl + "apps/" + appName + '/' + id + "/status?lastDirtyTimestamp=" - + info.getLastDirtyTimestamp().toString(); - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.DELETE, null, Void.class); - - return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse getApplications(String... regions) { - return getApplicationsInternal("apps/", regions); - } - - private EurekaHttpResponse getApplicationsInternal(String urlPath, String[] regions) { - String url = serviceUrl + urlPath; - - if (regions != null && regions.length > 0) { - url = url + (urlPath.contains("?") ? "&" : "?") + "regions=" + StringUtil.join(regions); - } - - ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, null, - EurekaApplications.class); - - return anEurekaHttpResponse(response.getStatusCode().value(), - response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody() - ? (Applications) response.getBody() : null).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse getDelta(String... regions) { - return getApplicationsInternal("apps/delta", regions); - } - - @Override - public EurekaHttpResponse getVip(String vipAddress, String... regions) { - return getApplicationsInternal("vips/" + vipAddress, regions); - } - - @Override - public EurekaHttpResponse getSecureVip(String secureVipAddress, String... regions) { - return getApplicationsInternal("svips/" + secureVipAddress, regions); - } - - @Override - public EurekaHttpResponse getApplication(String appName) { - String urlPath = serviceUrl + "apps/" + appName; - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.GET, null, Application.class); - - Application application = response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody() - ? response.getBody() : null; - - return anEurekaHttpResponse(response.getStatusCode().value(), application).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse getInstance(String appName, String id) { - return getInstanceInternal("apps/" + appName + '/' + id); - } - - @Override - public EurekaHttpResponse getInstance(String id) { - return getInstanceInternal("instances/" + id); - } - - private EurekaHttpResponse getInstanceInternal(String urlPath) { - urlPath = serviceUrl + urlPath; - - ResponseEntity response = restTemplate.exchange(urlPath, HttpMethod.GET, null, - InstanceInfo.class); - - return anEurekaHttpResponse(response.getStatusCode().value(), - response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody() ? response.getBody() - : null).headers(headersOf(response)).build(); - } - - @Override - public void shutdown() { - // Nothing to do - } - - private static Map headersOf(ResponseEntity response) { - HttpHeaders httpHeaders = response.getHeaders(); - if (httpHeaders == null || httpHeaders.isEmpty()) { - return Collections.emptyMap(); - } - Map headers = new HashMap<>(); - for (Entry> entry : httpHeaders.entrySet()) { - if (!entry.getValue().isEmpty()) { - headers.put(entry.getKey(), entry.getValue().get(0)); - } - } - return headers; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactories.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactories.java deleted file mode 100644 index d6f8b0cc0..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactories.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.Collection; -import java.util.Optional; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.TransportClientFactory; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; - -/** - * @author Daniel Lavoie - */ -public class RestTemplateTransportClientFactories implements TransportClientFactories { - - private final RestTemplateDiscoveryClientOptionalArgs args; - - public RestTemplateTransportClientFactories(RestTemplateDiscoveryClientOptionalArgs args) { - this.args = args; - } - - @Override - public TransportClientFactory newTransportClientFactory(EurekaClientConfig clientConfig, - Collection additionalFilters, InstanceInfo myInstanceInfo) { - return new RestTemplateTransportClientFactory(this.args.getSSLContext(), this.args.getHostnameVerifier(), - this.args.eurekaClientHttpRequestFactorySupplier); - } - - @Override - public TransportClientFactory newTransportClientFactory(final EurekaClientConfig clientConfig, - final Collection additionalFilters, final InstanceInfo myInstanceInfo, - final Optional sslContext, final Optional hostnameVerifier) { - return new RestTemplateTransportClientFactory(this.args.getSSLContext(), this.args.getHostnameVerifier(), - this.args.eurekaClientHttpRequestFactorySupplier); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactory.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactory.java deleted file mode 100644 index 7fa09749b..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactory.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Optional; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.converters.jackson.mixin.ApplicationsJsonMixIn; -import com.netflix.discovery.converters.jackson.mixin.InstanceInfoJsonMixIn; -import com.netflix.discovery.converters.jackson.serializer.InstanceInfoJsonBeanSerializer; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.resolver.EurekaEndpoint; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.TransportClientFactory; - -import org.springframework.cloud.configuration.SSLContextFactory; -import org.springframework.cloud.configuration.TlsProperties; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.support.BasicAuthenticationInterceptor; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.client.DefaultResponseErrorHandler; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -/** - * Provides the custom {@link RestTemplate} required by the - * {@link RestTemplateEurekaHttpClient}. Relies on Jackson for serialization and - * deserialization. - * - * @author Daniel Lavoie - */ -public class RestTemplateTransportClientFactory implements TransportClientFactory { - - private final Optional sslContext; - - private final Optional hostnameVerifier; - - private final EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier; - - public RestTemplateTransportClientFactory(TlsProperties tlsProperties, - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) { - this.sslContext = context(tlsProperties); - this.hostnameVerifier = Optional.empty(); - this.eurekaClientHttpRequestFactorySupplier = eurekaClientHttpRequestFactorySupplier; - } - - private Optional context(TlsProperties properties) { - if (properties == null || !properties.isEnabled()) { - return Optional.empty(); - } - try { - return Optional.of(new SSLContextFactory(properties).createSSLContext()); - } - catch (Exception e) { - throw new IllegalStateException(e); - } - } - - public RestTemplateTransportClientFactory(Optional sslContext, - Optional hostnameVerifier, - EurekaClientHttpRequestFactorySupplier eurekaClientHttpRequestFactorySupplier) { - this.sslContext = sslContext; - this.hostnameVerifier = hostnameVerifier; - this.eurekaClientHttpRequestFactorySupplier = eurekaClientHttpRequestFactorySupplier; - } - - public RestTemplateTransportClientFactory() { - this.sslContext = Optional.empty(); - this.hostnameVerifier = Optional.empty(); - this.eurekaClientHttpRequestFactorySupplier = new DefaultEurekaClientHttpRequestFactorySupplier(); - } - - @Override - public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) { - return new RestTemplateEurekaHttpClient(restTemplate(serviceUrl.getServiceUrl()), - stripUserInfo(serviceUrl.getServiceUrl())); - } - - // apache http client 5.2 fails with non-null userinfo - // basic auth added in restTemplate() below - private String stripUserInfo(String serviceUrl) { - return UriComponentsBuilder.fromUriString(serviceUrl).userInfo(null).toUriString(); - } - - private RestTemplate restTemplate(String serviceUrl) { - ClientHttpRequestFactory requestFactory = this.eurekaClientHttpRequestFactorySupplier - .get(this.sslContext.orElse(null), this.hostnameVerifier.orElse(null)); - RestTemplate restTemplate = new RestTemplate(requestFactory); - - try { - URI serviceURI = new URI(serviceUrl); - if (serviceURI.getUserInfo() != null) { - String[] credentials = serviceURI.getUserInfo().split(":"); - if (credentials.length == 2) { - restTemplate.getInterceptors() - .add(new BasicAuthenticationInterceptor(credentials[0], credentials[1])); - } - } - } - catch (URISyntaxException ignore) { - - } - - restTemplate.getMessageConverters().add(0, mappingJacksonHttpMessageConverter()); - restTemplate.setErrorHandler(new ErrorHandler()); - - restTemplate.getInterceptors().add((request, body, execution) -> { - ClientHttpResponse response = execution.execute(request, body); - if (!response.getStatusCode().equals(HttpStatus.NOT_FOUND)) { - return response; - } - return new NotFoundHttpResponse(response); - }); - - return restTemplate; - } - - /** - * Provides the serialization configurations required by the Eureka Server. JSON - * content exchanged with eureka requires a root node matching the entity being - * serialized or deserialized. Achived with - * {@link SerializationFeature#WRAP_ROOT_VALUE} and - * {@link DeserializationFeature#UNWRAP_ROOT_VALUE}. - * {@link PropertyNamingStrategies.SnakeCaseStrategy} is applied to the underlying - * {@link ObjectMapper}. - * @return a {@link MappingJackson2HttpMessageConverter} object - */ - public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() { - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - converter.setObjectMapper(new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)); - - SimpleModule jsonModule = new SimpleModule(); - jsonModule.setSerializerModifier(createJsonSerializerModifier()); - converter.getObjectMapper().registerModule(jsonModule); - - converter.getObjectMapper().configure(SerializationFeature.WRAP_ROOT_VALUE, true); - converter.getObjectMapper().configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - converter.getObjectMapper().addMixIn(Applications.class, ApplicationsJsonMixIn.class); - converter.getObjectMapper().addMixIn(InstanceInfo.class, InstanceInfoJsonMixIn.class); - - return converter; - } - - public static BeanSerializerModifier createJsonSerializerModifier() { - return new BeanSerializerModifier() { - @Override - public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, - JsonSerializer serializer) { - if (beanDesc.getBeanClass().isAssignableFrom(InstanceInfo.class)) { - return new InstanceInfoJsonBeanSerializer((BeanSerializerBase) serializer, false); - } - return serializer; - } - }; - } - - @Override - public void shutdown() { - } - - /** - * Response that ignores body, specifically for 404 errors. - */ - private static class NotFoundHttpResponse implements ClientHttpResponse { - - private final ClientHttpResponse response; - - NotFoundHttpResponse(ClientHttpResponse response) { - this.response = response; - } - - @Override - public HttpStatusCode getStatusCode() throws IOException { - return response.getStatusCode(); - } - - @Override - public int getRawStatusCode() throws IOException { - return response.getRawStatusCode(); - } - - @Override - public String getStatusText() throws IOException { - return response.getStatusText(); - } - - @Override - public void close() { - response.close(); - } - - @Override - public InputStream getBody() throws IOException { - // ignore body on 404 for heartbeat, see gh-4145 - return null; - } - - @Override - public HttpHeaders getHeaders() { - return response.getHeaders(); - } - - } - - class ErrorHandler extends DefaultResponseErrorHandler { - - @Override - protected boolean hasError(HttpStatusCode statusCode) { - /** - * When the Eureka server restarts and a client tries to sent a heartbeat the - * server will respond with a 404. By default RestTemplate will throw an - * exception in this case. What we want is to return the 404 to the upstream - * code so it will send another registration request to the server. - */ - if (statusCode.is4xxClientError()) { - return false; - } - return super.hasError(statusCode); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientDiscoveryClientOptionalArgs.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientDiscoveryClientOptionalArgs.java deleted file mode 100644 index 552162500..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientDiscoveryClientOptionalArgs.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.function.Supplier; - -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; - -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Daniel Lavoie - * @author Haytham Mohamed - */ -public class WebClientDiscoveryClientOptionalArgs extends AbstractDiscoveryClientOptionalArgs { - - public WebClientDiscoveryClientOptionalArgs(Supplier builder) { - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClient.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClient.java deleted file mode 100644 index 5788c99f5..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClient.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.Map; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import com.netflix.discovery.shared.transport.EurekaHttpResponse.EurekaHttpResponseBuilder; -import com.netflix.discovery.util.StringUtil; -import reactor.core.publisher.Mono; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -import static com.netflix.discovery.shared.transport.EurekaHttpResponse.anEurekaHttpResponse; - -/** - * @author Daniel Lavoie - * @author Haytham Mohamed - */ -public class WebClientEurekaHttpClient implements EurekaHttpClient { - - private WebClient webClient; - - public WebClientEurekaHttpClient(WebClient webClient) { - this.webClient = webClient; - } - - @Override - public EurekaHttpResponse register(InstanceInfo info) { - return webClient.post().uri("apps/" + info.getAppName()).body(BodyInserters.fromValue(info)) - .header(HttpHeaders.ACCEPT_ENCODING, "gzip") - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity().map(this::eurekaHttpResponse) - .block(); - } - - @Override - public EurekaHttpResponse cancel(String appName, String id) { - return webClient.delete().uri("apps/" + appName + '/' + id).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity().map(this::eurekaHttpResponse) - .block(); - } - - @Override - public EurekaHttpResponse sendHeartBeat(String appName, String id, InstanceInfo info, - InstanceStatus overriddenStatus) { - String urlPath = "apps/" + appName + '/' + id + "?status=" + info.getStatus().toString() - + "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString() - + (overriddenStatus != null ? "&overriddenstatus=" + overriddenStatus.name() : ""); - - ResponseEntity response = webClient.put().uri(urlPath) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(InstanceInfo.class).block(); - - EurekaHttpResponseBuilder builder = anEurekaHttpResponse(statusCodeValueOf(response), - InstanceInfo.class).headers(headersOf(response)); - - InstanceInfo entity = response.getBody(); - - if (entity != null) { - builder.entity(entity); - } - - return builder.build(); - - } - - @Override - public EurekaHttpResponse statusUpdate(String appName, String id, InstanceStatus newStatus, - InstanceInfo info) { - String urlPath = "apps/" + appName + '/' + id + "/status?value=" + newStatus.name() + "&lastDirtyTimestamp=" - + info.getLastDirtyTimestamp().toString(); - - return webClient.put().uri(urlPath).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .retrieve().onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity() - .map(this::eurekaHttpResponse).block(); - } - - @Override - public EurekaHttpResponse deleteStatusOverride(String appName, String id, InstanceInfo info) { - String urlPath = "apps/" + appName + '/' + id + "/status?lastDirtyTimestamp=" - + info.getLastDirtyTimestamp().toString(); - - return webClient.delete().uri(urlPath).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .retrieve().onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity() - .map(this::eurekaHttpResponse).block(); - } - - @Override - public EurekaHttpResponse getApplications(String... regions) { - return getApplicationsInternal("apps/", regions); - } - - private EurekaHttpResponse getApplicationsInternal(String urlPath, String[] regions) { - String url = urlPath; - - if (regions != null && regions.length > 0) { - url = url + (urlPath.contains("?") ? "&" : "?") + "regions=" + StringUtil.join(regions); - } - - ResponseEntity response = webClient.get().uri(url) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(Applications.class).block(); - - int statusCode = statusCodeValueOf(response); - - Applications body = response.getBody(); - - return anEurekaHttpResponse(statusCode, statusCode == HttpStatus.OK.value() && body != null ? body : null) - .headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse getDelta(String... regions) { - return getApplicationsInternal("apps/delta", regions); - } - - @Override - public EurekaHttpResponse getVip(String vipAddress, String... regions) { - return getApplicationsInternal("vips/" + vipAddress, regions); - } - - @Override - public EurekaHttpResponse getSecureVip(String secureVipAddress, String... regions) { - return getApplicationsInternal("svips/" + secureVipAddress, regions); - } - - @Override - public EurekaHttpResponse getApplication(String appName) { - - ResponseEntity response = webClient.get().uri("apps/" + appName) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(Application.class).block(); - - int statusCode = statusCodeValueOf(response); - Application body = response.getBody(); - - Application application = statusCode == HttpStatus.OK.value() && body != null ? body : null; - - return anEurekaHttpResponse(statusCode, application).headers(headersOf(response)).build(); - } - - @Override - public EurekaHttpResponse getInstance(String appName, String id) { - return getInstanceInternal("apps/" + appName + '/' + id); - } - - @Override - public EurekaHttpResponse getInstance(String id) { - return getInstanceInternal("instances/" + id); - } - - private EurekaHttpResponse getInstanceInternal(String urlPath) { - ResponseEntity response = webClient.get().uri(urlPath) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve() - .onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(InstanceInfo.class).block(); - - int statusCode = statusCodeValueOf(response); - InstanceInfo body = response.getBody(); - - return anEurekaHttpResponse(statusCode, statusCode == HttpStatus.OK.value() && body != null ? body : null) - .headers(headersOf(response)).build(); - } - - @Override - public void shutdown() { - // Nothing to do - } - - public WebClient getWebClient() { - return this.webClient; - } - - private Mono ignoreError(ClientResponse response) { - return Mono.empty(); - } - - private static Map headersOf(ResponseEntity response) { - return response.getHeaders().toSingleValueMap(); - } - - private int statusCodeValueOf(ResponseEntity response) { - return response.getStatusCode().value(); - } - - private EurekaHttpResponse eurekaHttpResponse(ResponseEntity response) { - return anEurekaHttpResponse(statusCodeValueOf(response)).headers(headersOf(response)).build(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactories.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactories.java deleted file mode 100644 index b3315b5ec..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactories.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.Collection; -import java.util.Optional; -import java.util.function.Supplier; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.TransportClientFactory; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; - -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Daniel Lavoie - * @author Haytham Mohamed - */ -public class WebClientTransportClientFactories implements TransportClientFactories { - - private final Supplier builder; - - public WebClientTransportClientFactories(Supplier builder) { - this.builder = builder; - } - - @Override - public TransportClientFactory newTransportClientFactory(EurekaClientConfig clientConfig, - Collection additionalFilters, InstanceInfo myInstanceInfo) { - return new WebClientTransportClientFactory(builder); - } - - @Override - public TransportClientFactory newTransportClientFactory(final EurekaClientConfig clientConfig, - final Collection additionalFilters, final InstanceInfo myInstanceInfo, - final Optional sslContext, final Optional hostnameVerifier) { - return new WebClientTransportClientFactory(builder); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactory.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactory.java deleted file mode 100644 index 5a4a20cd7..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactory.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.function.Supplier; - -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.converters.jackson.mixin.ApplicationsJsonMixIn; -import com.netflix.discovery.converters.jackson.mixin.InstanceInfoJsonMixIn; -import com.netflix.discovery.converters.jackson.serializer.InstanceInfoJsonBeanSerializer; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.resolver.EurekaEndpoint; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.TransportClientFactory; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.codec.ClientCodecConfigurer; -import org.springframework.http.codec.json.Jackson2JsonDecoder; -import org.springframework.http.codec.json.Jackson2JsonEncoder; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.ExchangeFilterFunction; -import org.springframework.web.reactive.function.client.ExchangeFilterFunctions; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Provides the custom {@link WebClient.Builder} required by the - * {@link WebClientEurekaHttpClient}. Relies on Jackson for serialization and - * deserialization. - * - * @author Daniel Lavoie - * @author Haytham Mohamed - */ -public class WebClientTransportClientFactory implements TransportClientFactory { - - private final Supplier builderSupplier; - - public WebClientTransportClientFactory(Supplier builderSupplier) { - this.builderSupplier = builderSupplier; - } - - @Override - public EurekaHttpClient newClient(EurekaEndpoint endpoint) { - // we want a copy to modify. Don't change the original - WebClient.Builder builder = this.builderSupplier.get().clone(); - setUrl(builder, endpoint.getServiceUrl()); - setCodecs(builder); - builder.filter(http4XxErrorExchangeFilterFunction()); - return new WebClientEurekaHttpClient(builder.build()); - } - - private WebClient.Builder setUrl(WebClient.Builder builder, String serviceUrl) { - String url = serviceUrl; - try { - URI serviceURI = new URI(serviceUrl); - if (serviceURI.getUserInfo() != null) { - String[] credentials = serviceURI.getUserInfo().split(":"); - if (credentials.length == 2) { - builder.filter(ExchangeFilterFunctions.basicAuthentication(credentials[0], credentials[1])); - url = serviceUrl.replace(credentials[0] + ":" + credentials[1] + "@", ""); - } - } - } - catch (URISyntaxException ignore) { - } - return builder.baseUrl(url); - } - - private static BeanSerializerModifier createJsonSerializerModifier() { - return new BeanSerializerModifier() { - @Override - public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, - JsonSerializer serializer) { - if (beanDesc.getBeanClass().isAssignableFrom(InstanceInfo.class)) { - return new InstanceInfoJsonBeanSerializer((BeanSerializerBase) serializer, false); - } - return serializer; - } - }; - } - - private void setCodecs(WebClient.Builder builder) { - ObjectMapper objectMapper = objectMapper(); - builder.codecs(configurer -> { - ClientCodecConfigurer.ClientDefaultCodecs defaults = configurer.defaultCodecs(); - defaults.jackson2JsonEncoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_JSON)); - defaults.jackson2JsonDecoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON)); - - }); - } - - /** - * Provides the serialization configurations required by the Eureka Server. JSON - * content exchanged with eureka requires a root node matching the entity being - * serialized or deserialized. Achieved with - * {@link SerializationFeature#WRAP_ROOT_VALUE} and - * {@link DeserializationFeature#UNWRAP_ROOT_VALUE}. - * {@link PropertyNamingStrategies.SnakeCaseStrategy} is applied to the underlying - * {@link ObjectMapper}. - * @return a {@link ObjectMapper} object - */ - private ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); - - SimpleModule jsonModule = new SimpleModule(); - jsonModule.setSerializerModifier(createJsonSerializerModifier()); - objectMapper.registerModule(jsonModule); - - objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - objectMapper.addMixIn(Applications.class, ApplicationsJsonMixIn.class); - objectMapper.addMixIn(InstanceInfo.class, InstanceInfoJsonMixIn.class); - - return objectMapper; - } - - // Skip over 4xx http errors - private ExchangeFilterFunction http4XxErrorExchangeFilterFunction() { - return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> { - // literally 400 pass the tests, not 4xxClientError - if (clientResponse.statusCode().value() == 400) { - ClientResponse newResponse = clientResponse.mutate().statusCode(HttpStatus.OK).build(); - newResponse.body((clientHttpResponse, context) -> clientHttpResponse.getBody()); - return Mono.just(newResponse); - } - if (clientResponse.statusCode().equals(HttpStatus.NOT_FOUND)) { - ClientResponse newResponse = clientResponse.mutate().statusCode(clientResponse.statusCode()) - // ignore body on 404 for heartbeat, see gh-4145 - .body(Flux.empty()).build(); - return Mono.just(newResponse); - } - return Mono.just(clientResponse); - }); - } - - @Override - public void shutdown() { - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfiguration.java deleted file mode 100644 index bdcf6c509..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfiguration.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.loadbalancer; - -import com.netflix.appinfo.EurekaInstanceConfig; -import com.netflix.discovery.EurekaClientConfig; -import jakarta.annotation.PostConstruct; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.cloud.loadbalancer.config.LoadBalancerZoneConfig; -import org.springframework.cloud.netflix.eureka.support.ZoneUtils; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.StringUtils; - -import static org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration.LOADBALANCER_ZONE; - -/** - * A configuration for Spring Cloud LoadBalancer that retrieves client instance zone from - * Eureka and sets it as a property. Based on - * {@link EurekaLoadBalancerClientConfiguration}. - * - * @author Olga Maciaszek-Sharma - * @since 2.2.1 - * @see EurekaLoadBalancerClientConfiguration - */ -@Configuration -@ConditionalOnBean({ LoadBalancerZoneConfig.class, EurekaLoadBalancerProperties.class }) -public class EurekaLoadBalancerClientConfiguration { - - private static final Log LOG = LogFactory.getLog(EurekaLoadBalancerClientConfiguration.class); - - private final EurekaClientConfig clientConfig; - - private final EurekaInstanceConfig eurekaConfig; - - private final LoadBalancerZoneConfig zoneConfig; - - private final EurekaLoadBalancerProperties eurekaLoadBalancerProperties; - - public EurekaLoadBalancerClientConfiguration(@Autowired(required = false) EurekaClientConfig clientConfig, - @Autowired(required = false) EurekaInstanceConfig eurekaInstanceConfig, LoadBalancerZoneConfig zoneConfig, - EurekaLoadBalancerProperties eurekaLoadBalancerProperties) { - this.clientConfig = clientConfig; - this.eurekaConfig = eurekaInstanceConfig; - this.zoneConfig = zoneConfig; - this.eurekaLoadBalancerProperties = eurekaLoadBalancerProperties; - } - - @PostConstruct - public void postprocess() { - if (StringUtils.hasText(zoneConfig.getZone())) { - return; - } - String zone = getZoneFromEureka(); - if (StringUtils.hasText(zone)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Setting the value of '" + LOADBALANCER_ZONE + "' to " + zone); - } - zoneConfig.setZone(zone); - } - } - - private String getZoneFromEureka() { - String zone; - boolean approximateZoneFromHostname = eurekaLoadBalancerProperties.isApproximateZoneFromHostname(); - if (approximateZoneFromHostname && eurekaConfig != null) { - return ZoneUtils.extractApproximateZone(this.eurekaConfig.getHostName(false)); - } - else { - zone = eurekaConfig == null ? null : eurekaConfig.getMetadataMap().get("zone"); - if (!StringUtils.hasText(zone) && clientConfig != null) { - String[] zones = clientConfig.getAvailabilityZones(clientConfig.getRegion()); - // Pick the first one from the regions we want to connect to - zone = zones != null && zones.length > 0 ? zones[0] : null; - } - return zone; - } - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerProperties.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerProperties.java deleted file mode 100644 index b8389da32..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerProperties.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.loadbalancer; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * A {@link ConfigurationProperties} bean for the Eureka-specific instrumentation of - * Spring Cloud LoadBalancer. - * - * @author Olga Maciaszek-Sharma - * @since 2.2.1 - */ -@ConfigurationProperties("spring.cloud.loadbalancer.eureka") -public class EurekaLoadBalancerProperties { - - /** - * Used to determine whether we should try to get the `zone` value from host name. - */ - private boolean approximateZoneFromHostname = false; - - public boolean isApproximateZoneFromHostname() { - return approximateZoneFromHostname; - } - - public void setApproximateZoneFromHostname(boolean approximateZoneFromHostname) { - this.approximateZoneFromHostname = approximateZoneFromHostname; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/LoadBalancerEurekaAutoConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/LoadBalancerEurekaAutoConfiguration.java deleted file mode 100644 index 684a3af2c..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/loadbalancer/LoadBalancerEurekaAutoConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.loadbalancer; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientConfigurationRegistrar; -import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; -import org.springframework.cloud.loadbalancer.config.LoadBalancerZoneConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; - -/** - * An Autoconfiguration that loads default config for Spring Cloud LoadBalancer clients. - * - * @author Olga Maciaszek-Sharma - * @since 2.2.1 - * @see EurekaLoadBalancerClientConfiguration - */ -@Configuration(proxyBeanMethods = false) -@EnableConfigurationProperties -@ConditionalOnClass(LoadBalancerClientConfigurationRegistrar.class) -@LoadBalancerClients(defaultConfiguration = EurekaLoadBalancerClientConfiguration.class) -@ConditionalOnProperty(name = "eureka.client.enabled", matchIfMissing = true) -public class LoadBalancerEurekaAutoConfiguration { - - /** - * Spring Cloud LoadBalancer Zone property name. - */ - public static final String LOADBALANCER_ZONE = "spring.cloud.loadbalancer.zone"; - - @Bean - @ConditionalOnMissingBean - EurekaLoadBalancerProperties eurekaLoadBalancerProperties() { - return new EurekaLoadBalancerProperties(); - } - - @Bean - @ConditionalOnMissingBean - LoadBalancerZoneConfig zoneConfig(Environment environment) { - return new LoadBalancerZoneConfig(environment.getProperty(LOADBALANCER_ZONE)); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProvider.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProvider.java deleted file mode 100644 index de809c3d3..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProvider.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.metadata; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.util.StringUtils; - -/** - * Default implementation of {@link DefaultManagementMetadataProvider}. - * - * @author Anastasiia Smirnova - */ -public class DefaultManagementMetadataProvider implements ManagementMetadataProvider { - - private static final int RANDOM_PORT = 0; - - private static final Log log = LogFactory.getLog(DefaultManagementMetadataProvider.class); - - @Override - public ManagementMetadata get(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath, - String managementContextPath, Integer managementPort) { - if (isRandom(managementPort)) { - return null; - } - if (managementPort == null && isRandom(serverPort)) { - return null; - } - String healthCheckUrl = getHealthCheckUrl(instance, serverPort, serverContextPath, managementContextPath, - managementPort, false); - String statusPageUrl = getStatusPageUrl(instance, serverPort, serverContextPath, managementContextPath, - managementPort); - - ManagementMetadata metadata = new ManagementMetadata(healthCheckUrl, statusPageUrl, - managementPort == null ? serverPort : managementPort); - if (instance.isSecurePortEnabled()) { - metadata.setSecureHealthCheckUrl(getHealthCheckUrl(instance, serverPort, serverContextPath, - managementContextPath, managementPort, true)); - } - return metadata; - } - - private boolean isRandom(Integer port) { - return port != null && port == RANDOM_PORT; - } - - protected String getHealthCheckUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath, - String managementContextPath, Integer managementPort, boolean isSecure) { - String healthCheckUrlPath = instance.getHealthCheckUrlPath(); - String healthCheckUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath, managementPort, - healthCheckUrlPath, isSecure); - log.debug("Constructed eureka meta-data healthcheckUrl: " + healthCheckUrl); - return healthCheckUrl; - } - - public String getStatusPageUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath, - String managementContextPath, Integer managementPort) { - String statusPageUrlPath = instance.getStatusPageUrlPath(); - String statusPageUrl = getUrl(instance, serverPort, serverContextPath, managementContextPath, managementPort, - statusPageUrlPath, false); - log.debug("Constructed eureka meta-data statusPageUrl: " + statusPageUrl); - return statusPageUrl; - } - - private String getUrl(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath, - String managementContextPath, Integer managementPort, String urlPath, boolean isSecure) { - managementContextPath = refineManagementContextPath(serverContextPath, managementContextPath, managementPort); - if (managementPort == null) { - managementPort = serverPort; - } - String scheme = isSecure ? "https" : "http"; - return constructValidUrl(scheme, instance.getHostname(), managementPort, managementContextPath, urlPath); - } - - private String refineManagementContextPath(String serverContextPath, String managementContextPath, - Integer managementPort) { - // management context path is relative to server context path when no management - // port is set - if (managementContextPath != null && managementPort == null) { - return serverContextPath + managementContextPath; - } - if (managementContextPath != null) { - return managementContextPath; - } - if (managementPort != null) { - return "/"; - } - return serverContextPath; - } - - private String constructValidUrl(String scheme, String hostname, int port, String contextPath, String statusPath) { - try { - if (!contextPath.endsWith("/")) { - contextPath = contextPath + "/"; - } - String refinedContextPath = '/' + StringUtils.trimLeadingCharacter(contextPath, '/'); - URL base = new URL(scheme, hostname, port, refinedContextPath); - String refinedStatusPath = refinedStatusPath(statusPath, contextPath); - return new URL(base, refinedStatusPath).toString(); - } - catch (MalformedURLException e) { - String message = getErrorMessage(scheme, hostname, port, contextPath, statusPath); - throw new IllegalStateException(message, e); - } - } - - private String refinedStatusPath(String statusPath, String contextPath) { - if (statusPath.startsWith(contextPath) && !"/".equals(contextPath)) { - statusPath = StringUtils.replace(statusPath, contextPath, ""); - } - return StringUtils.trimLeadingCharacter(statusPath, '/'); - } - - private String getErrorMessage(String scheme, String hostname, int port, String contextPath, String statusPath) { - return String.format( - "Failed to construct url for scheme: %s, hostName: %s port: %s contextPath: %s statusPath: %s", scheme, - hostname, port, contextPath, statusPath); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadata.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadata.java deleted file mode 100644 index be075487b..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadata.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.metadata; - -import java.util.Objects; - -/** - * Stores management metadata for Eureka. - * - * @author Anastasiia Smirnova - * @author Ryan Baxter - */ -public class ManagementMetadata { - - private final String healthCheckUrl; - - private final String statusPageUrl; - - private final Integer managementPort; - - private String secureHealthCheckUrl; - - public ManagementMetadata(String healthCheckUrl, String statusPageUrl, Integer managementPort) { - this.healthCheckUrl = healthCheckUrl; - this.statusPageUrl = statusPageUrl; - this.managementPort = managementPort; - this.secureHealthCheckUrl = null; - } - - public String getHealthCheckUrl() { - return healthCheckUrl; - } - - public String getStatusPageUrl() { - return statusPageUrl; - } - - public Integer getManagementPort() { - return managementPort; - } - - public String getSecureHealthCheckUrl() { - return secureHealthCheckUrl; - } - - public void setSecureHealthCheckUrl(String secureHealthCheckUrl) { - this.secureHealthCheckUrl = secureHealthCheckUrl; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ManagementMetadata that = (ManagementMetadata) o; - return Objects.equals(healthCheckUrl, that.healthCheckUrl) && Objects.equals(statusPageUrl, that.statusPageUrl) - && Objects.equals(managementPort, that.managementPort); - } - - @Override - public int hashCode() { - return Objects.hash(healthCheckUrl, statusPageUrl, managementPort); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("ManagementMetadata{"); - sb.append("healthCheckUrl='").append(healthCheckUrl).append('\''); - sb.append(", statusPageUrl='").append(statusPageUrl).append('\''); - sb.append(", managementPort=").append(managementPort); - sb.append('}'); - return sb.toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadataProvider.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadataProvider.java deleted file mode 100644 index fb33402f3..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/ManagementMetadataProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.metadata; - -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; - -/** - * Provider for Eureka-specific management metadata. - * - * @author Anastasiia Smirnova - */ -public interface ManagementMetadataProvider { - - ManagementMetadata get(EurekaInstanceConfigBean instance, int serverPort, String serverContextPath, - String managementContextPath, Integer managementPort); - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClient.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClient.java deleted file mode 100644 index be7f210cf..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClient.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.reactive; - -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; -import org.springframework.cloud.netflix.eureka.EurekaServiceInstance; -import org.springframework.core.Ordered; - -/** - * A {@link ReactiveDiscoveryClient} implementation for Eureka. - * - * @author Tim Ysewyn - */ -public class EurekaReactiveDiscoveryClient implements ReactiveDiscoveryClient { - - private final EurekaClient eurekaClient; - - private final EurekaClientConfig clientConfig; - - public EurekaReactiveDiscoveryClient(EurekaClient eurekaClient, EurekaClientConfig clientConfig) { - this.eurekaClient = eurekaClient; - this.clientConfig = clientConfig; - } - - @Override - public String description() { - return "Spring Cloud Eureka Reactive Discovery Client"; - } - - @Override - public Flux getInstances(String serviceId) { - return Flux.defer(() -> Flux.fromIterable(eurekaClient.getInstancesByVipAddress(serviceId, false))) - .map(EurekaServiceInstance::new); - } - - @Override - public Flux getServices() { - return Flux.defer(() -> Mono.justOrEmpty(eurekaClient.getApplications())) - .flatMapIterable(Applications::getRegisteredApplications) - .filter(application -> !application.getInstances().isEmpty()).map(Application::getName) - .map(String::toLowerCase); - } - - @Override - public int getOrder() { - return clientConfig instanceof Ordered ? ((Ordered) clientConfig).getOrder() - : ReactiveDiscoveryClient.DEFAULT_ORDER; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfiguration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfiguration.java deleted file mode 100644 index 7d23f3e0a..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfiguration.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.reactive; - -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled; -import org.springframework.cloud.client.ConditionalOnDiscoveryHealthIndicatorEnabled; -import org.springframework.cloud.client.ConditionalOnReactiveDiscoveryEnabled; -import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration; -import org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration; -import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties; -import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator; -import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Configuration related to service discovery when using Netflix Eureka. - * - * @author Tim Ysewyn - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass(EurekaClientConfig.class) -@ConditionalOnDiscoveryEnabled -@ConditionalOnReactiveDiscoveryEnabled -@ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true) -@EnableConfigurationProperties -@AutoConfigureAfter({ EurekaClientAutoConfiguration.class, ReactiveCompositeDiscoveryClientAutoConfiguration.class }) -@AutoConfigureBefore(ReactiveCommonsClientAutoConfiguration.class) -@ImportAutoConfiguration(EurekaClientAutoConfiguration.class) -public class EurekaReactiveDiscoveryClientConfiguration { - - @Bean - @ConditionalOnMissingBean - public EurekaReactiveDiscoveryClient eurekaReactiveDiscoveryClient(EurekaClient client, - EurekaClientConfig clientConfig) { - return new EurekaReactiveDiscoveryClient(client, clientConfig); - } - - @Bean - @ConditionalOnClass(name = "org.springframework.boot.actuate.health.ReactiveHealthIndicator") - @ConditionalOnDiscoveryHealthIndicatorEnabled - public ReactiveDiscoveryClientHealthIndicator eurekaReactiveDiscoveryClientHealthIndicator( - EurekaReactiveDiscoveryClient client, DiscoveryClientHealthIndicatorProperties properties) { - return new ReactiveDiscoveryClientHealthIndicator(client, properties); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaAutoServiceRegistration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaAutoServiceRegistration.java deleted file mode 100644 index f90c32bae..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaAutoServiceRegistration.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.serviceregistry; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; -import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.SmartLifecycle; -import org.springframework.context.event.ContextClosedEvent; -import org.springframework.context.event.SmartApplicationListener; -import org.springframework.core.Ordered; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Jon Schneider - * @author Jakub Narloch - * @author Raiyan Raiyan - */ -public class EurekaAutoServiceRegistration - implements AutoServiceRegistration, SmartLifecycle, Ordered, SmartApplicationListener { - - private static final Log log = LogFactory.getLog(EurekaAutoServiceRegistration.class); - - private final AtomicBoolean running = new AtomicBoolean(false); - - private final int order = 0; - - private final AtomicInteger port = new AtomicInteger(0); - - private final ApplicationContext context; - - private final EurekaServiceRegistry serviceRegistry; - - private final EurekaRegistration registration; - - public EurekaAutoServiceRegistration(ApplicationContext context, EurekaServiceRegistry serviceRegistry, - EurekaRegistration registration) { - this.context = context; - this.serviceRegistry = serviceRegistry; - this.registration = registration; - } - - @Override - public void start() { - // only set the port if the nonSecurePort or securePort is 0 and this.port != 0 - if (this.port.get() != 0) { - if (this.registration.getNonSecurePort() == 0) { - this.registration.setNonSecurePort(this.port.get()); - } - - if (this.registration.getSecurePort() == 0 && this.registration.isSecure()) { - this.registration.setSecurePort(this.port.get()); - } - } - - // only initialize if nonSecurePort is greater than 0 and it isn't already running - // because of containerPortInitializer below - if (!this.running.get() && this.registration.getNonSecurePort() > 0) { - - this.serviceRegistry.register(this.registration); - - this.context.publishEvent(new InstanceRegisteredEvent<>(this, this.registration.getInstanceConfig())); - this.running.set(true); - } - } - - @Override - public void stop() { - this.serviceRegistry.deregister(this.registration); - this.running.set(false); - } - - @Override - public boolean isRunning() { - return this.running.get(); - } - - @Override - public int getPhase() { - return 0; - } - - @Override - public boolean isAutoStartup() { - return true; - } - - @Override - public void stop(Runnable callback) { - stop(); - callback.run(); - } - - @Override - public int getOrder() { - return this.order; - } - - @Override - public boolean supportsEventType(Class eventType) { - return WebServerInitializedEvent.class.isAssignableFrom(eventType) - || ContextClosedEvent.class.isAssignableFrom(eventType); - } - - @Override - public void onApplicationEvent(ApplicationEvent event) { - if (event instanceof WebServerInitializedEvent) { - onApplicationEvent((WebServerInitializedEvent) event); - } - else if (event instanceof ContextClosedEvent) { - onApplicationEvent((ContextClosedEvent) event); - } - } - - public void onApplicationEvent(WebServerInitializedEvent event) { - // TODO: take SSL into account - String contextName = event.getApplicationContext().getServerNamespace(); - if (contextName == null || !contextName.equals("management")) { - int localPort = event.getWebServer().getPort(); - if (this.port.get() == 0) { - log.info("Updating port to " + localPort); - this.port.compareAndSet(0, localPort); - start(); - } - } - } - - public void onApplicationEvent(ContextClosedEvent event) { - if (event.getApplicationContext() == context) { - stop(); - } - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaRegistration.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaRegistration.java deleted file mode 100644 index babd71258..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaRegistration.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.serviceregistry; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.aop.framework.Advised; -import org.springframework.aop.support.AopUtils; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.cloud.client.DefaultServiceInstance; -import org.springframework.cloud.client.serviceregistry.Registration; -import org.springframework.cloud.netflix.eureka.CloudEurekaClient; -import org.springframework.cloud.netflix.eureka.CloudEurekaInstanceConfig; -import org.springframework.cloud.netflix.eureka.InstanceInfoFactory; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.util.Assert; - -/** - * Eureka-specific implementation of service instance {@link Registration}. - * - * @author Spencer Gibb - * @author Tim Ysewyn - */ -public class EurekaRegistration implements Registration { - - private static final Log log = LogFactory.getLog(EurekaRegistration.class); - - private final EurekaClient eurekaClient; - - private final AtomicReference cloudEurekaClient = new AtomicReference<>(); - - private final CloudEurekaInstanceConfig instanceConfig; - - private final ApplicationInfoManager applicationInfoManager; - - private ObjectProvider healthCheckHandler; - - public EurekaRegistration(CloudEurekaInstanceConfig instanceConfig, EurekaClient eurekaClient, - ApplicationInfoManager applicationInfoManager, ObjectProvider healthCheckHandler) { - this.eurekaClient = eurekaClient; - this.instanceConfig = instanceConfig; - this.applicationInfoManager = applicationInfoManager; - this.healthCheckHandler = healthCheckHandler; - } - - public static Builder builder(CloudEurekaInstanceConfig instanceConfig) { - return new Builder(instanceConfig); - } - - @Override - public String getInstanceId() { - return this.instanceConfig.getInstanceId(); - } - - @Override - public String getServiceId() { - return this.instanceConfig.getAppname(); - } - - @Override - public String getHost() { - return this.instanceConfig.getHostName(false); - } - - @Override - public int getPort() { - if (this.instanceConfig.getSecurePortEnabled()) { - return this.instanceConfig.getSecurePort(); - } - return this.instanceConfig.getNonSecurePort(); - } - - @Override - public boolean isSecure() { - return this.instanceConfig.getSecurePortEnabled(); - } - - @Override - public URI getUri() { - return DefaultServiceInstance.getUri(this); - } - - @Override - public Map getMetadata() { - return this.instanceConfig.getMetadataMap(); - } - - public CloudEurekaClient getEurekaClient() { - if (this.cloudEurekaClient.get() == null) { - try { - this.cloudEurekaClient.compareAndSet(null, getTargetObject(eurekaClient, CloudEurekaClient.class)); - } - catch (Exception e) { - log.error("error getting CloudEurekaClient", e); - } - } - return this.cloudEurekaClient.get(); - } - - @SuppressWarnings({ "unchecked" }) - protected T getTargetObject(Object proxy, Class targetClass) throws Exception { - if (AopUtils.isJdkDynamicProxy(proxy)) { - return (T) ((Advised) proxy).getTargetSource().getTarget(); - } - else { - return (T) proxy; // expected to be cglib proxy then, which is simply a - // specialized class - } - } - - public CloudEurekaInstanceConfig getInstanceConfig() { - return instanceConfig; - } - - public ApplicationInfoManager getApplicationInfoManager() { - return applicationInfoManager; - } - - public ObjectProvider getHealthCheckHandler() { - return healthCheckHandler; - } - - public void setHealthCheckHandler(ObjectProvider healthCheckHandler) { - this.healthCheckHandler = healthCheckHandler; - } - - public void setNonSecurePort(int port) { - this.instanceConfig.setNonSecurePort(port); - } - - public int getNonSecurePort() { - return this.instanceConfig.getNonSecurePort(); - } - - public void setSecurePort(int port) { - this.instanceConfig.setSecurePort(port); - } - - public int getSecurePort() { - return this.instanceConfig.getSecurePort(); - } - - /** - * A builder for {@link EurekaRegistration} objects. - */ - public static class Builder { - - private final CloudEurekaInstanceConfig instanceConfig; - - private ApplicationInfoManager applicationInfoManager; - - private EurekaClient eurekaClient; - - private ObjectProvider healthCheckHandler; - - private EurekaClientConfig clientConfig; - - private ApplicationEventPublisher publisher; - - private TransportClientFactories transportClientFactories; - - Builder(CloudEurekaInstanceConfig instanceConfig) { - this.instanceConfig = instanceConfig; - } - - public Builder with(ApplicationInfoManager applicationInfoManager) { - this.applicationInfoManager = applicationInfoManager; - return this; - } - - public Builder with(EurekaClient eurekaClient) { - this.eurekaClient = eurekaClient; - return this; - } - - public Builder with(ObjectProvider healthCheckHandler) { - this.healthCheckHandler = healthCheckHandler; - return this; - } - - public Builder with(TransportClientFactories transportClientFactories) { - this.transportClientFactories = transportClientFactories; - return this; - } - - public Builder with(EurekaClientConfig clientConfig, ApplicationEventPublisher publisher) { - this.clientConfig = clientConfig; - this.publisher = publisher; - return this; - } - - public EurekaRegistration build() { - Assert.notNull(instanceConfig, "instanceConfig may not be null"); - - if (this.applicationInfoManager == null) { - InstanceInfo instanceInfo = new InstanceInfoFactory().create(this.instanceConfig); - this.applicationInfoManager = new ApplicationInfoManager(this.instanceConfig, instanceInfo); - } - if (this.eurekaClient == null) { - Assert.notNull(this.clientConfig, "if eurekaClient is null, EurekaClientConfig may not be null"); - Assert.notNull(this.publisher, "if eurekaClient is null, ApplicationEventPublisher may not be null"); - Assert.notNull(this.transportClientFactories, - "if eurekaClient is null, TransportClientFactories may not be null"); - - this.eurekaClient = new CloudEurekaClient(this.applicationInfoManager, this.clientConfig, - this.transportClientFactories, this.publisher); - } - return new EurekaRegistration(instanceConfig, eurekaClient, applicationInfoManager, healthCheckHandler); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistry.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistry.java deleted file mode 100644 index cc15667f4..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistry.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.serviceregistry; - -import java.util.HashMap; - -import com.netflix.appinfo.InstanceInfo; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.client.serviceregistry.ServiceRegistry; - -import static com.netflix.appinfo.InstanceInfo.InstanceStatus.UNKNOWN; - -/** - * @author Spencer Gibb - */ -public class EurekaServiceRegistry implements ServiceRegistry { - - private static final Log log = LogFactory.getLog(EurekaServiceRegistry.class); - - @Override - public void register(EurekaRegistration reg) { - maybeInitializeClient(reg); - - if (log.isInfoEnabled()) { - log.info("Registering application " + reg.getApplicationInfoManager().getInfo().getAppName() - + " with eureka with status " + reg.getInstanceConfig().getInitialStatus()); - } - - reg.getApplicationInfoManager().setInstanceStatus(reg.getInstanceConfig().getInitialStatus()); - - reg.getHealthCheckHandler() - .ifAvailable(healthCheckHandler -> reg.getEurekaClient().registerHealthCheck(healthCheckHandler)); - } - - private void maybeInitializeClient(EurekaRegistration reg) { - // force initialization of possibly scoped proxies - reg.getApplicationInfoManager().getInfo(); - reg.getEurekaClient().getApplications(); - } - - @Override - public void deregister(EurekaRegistration reg) { - if (reg.getApplicationInfoManager().getInfo() != null) { - - if (log.isInfoEnabled()) { - log.info("Unregistering application " + reg.getApplicationInfoManager().getInfo().getAppName() - + " with eureka with status DOWN"); - } - - reg.getApplicationInfoManager().setInstanceStatus(InstanceInfo.InstanceStatus.DOWN); - - // shutdown of eureka client should happen with EurekaRegistration.close() - // auto registration will create a bean which will be properly disposed - // manual registrations will need to call close() - } - } - - @Override - public void setStatus(EurekaRegistration registration, String status) { - InstanceInfo info = registration.getApplicationInfoManager().getInfo(); - - // TODO: howto deal with delete properly? - if ("CANCEL_OVERRIDE".equalsIgnoreCase(status)) { - registration.getEurekaClient().cancelOverrideStatus(info); - return; - } - - // TODO: howto deal with status types across discovery systems? - InstanceInfo.InstanceStatus newStatus = InstanceInfo.InstanceStatus.toEnum(status); - registration.getEurekaClient().setStatus(newStatus, info); - } - - @SuppressWarnings("unchecked") - @Override - public Object getStatus(EurekaRegistration registration) { - String appname = registration.getApplicationInfoManager().getInfo().getAppName(); - String instanceId = registration.getApplicationInfoManager().getInfo().getId(); - InstanceInfo info = registration.getEurekaClient().getInstanceInfo(appname, instanceId); - - HashMap status = new HashMap<>(); - if (info != null) { - status.put("status", info.getStatus().toString()); - status.put("overriddenStatus", info.getOverriddenStatus().toString()); - } - else { - status.put("status", UNKNOWN.toString()); - } - - return status; - } - - public void close() { - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/support/ZoneUtils.java b/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/support/ZoneUtils.java deleted file mode 100644 index 749353bde..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/support/ZoneUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.support; - -import org.springframework.util.StringUtils; - -/** - * Utility class for dealing with zones. - * - * @author Ryan Baxter - * - */ -public final class ZoneUtils { - - private ZoneUtils() { - throw new AssertionError("Must not instantiate utility class."); - } - - /** - * Approximates Eureka zones from a host name. This method approximates the zone to be - * everything after the first "." in the host name. - * @param host The host name to extract the host name from - * @return The approximate zone - */ - public static String extractApproximateZone(String host) { - String[] split = StringUtils.split(host, "."); - return split == null ? host : split[1]; - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 28612129f..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "properties": [ - { - "defaultValue": true, - "name": "eureka.client.healthcheck.enabled", - "description": "Enables the Eureka health check handler.", - "type": "java.lang.Boolean" - }, - { - "defaultValue": true, - "name": "eureka.client.refresh.enable", - "description": "Determines whether the EurekaClient instance can be refreshed or not(If disabled none of the Eureka client properties will be refreshable).", - "type": "java.lang.Boolean" - }, - { - "defaultValue": true, - "name": "ribbon.eureka.enabled", - "description": "Enables the use of Eureka with Ribbon.", - "type": "java.lang.Boolean" - }, - { - "defaultValue": false, - "name": "eureka.client.webclient.enabled", - "description": "Enables the use of WebClient for Eureka HTTP Client.", - "type": "java.lang.Boolean" - }, - { - "defaultValue": 1, - "name": "eureka.instance.metadata-map.weight", - "description": "The weight of service instance for weighted load balancing.", - "type": "java.lang.Integer", - "sourceType": "org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean" - } - ] -} diff --git a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring.factories b/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring.factories deleted file mode 100644 index c2189497a..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,5 +0,0 @@ -org.springframework.cloud.bootstrap.BootstrapConfiguration=\ -org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapConfiguration - -org.springframework.boot.BootstrapRegistryInitializer=\ -org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapper diff --git a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/aot.factories b/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/aot.factories deleted file mode 100644 index 281a4a28d..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/aot.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.aot.hint.RuntimeHintsRegistrar=\ -org.springframework.cloud.netflix.eureka.EurekaClientHints \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 8c150801e..000000000 --- a/spring-cloud-netflix-eureka-client/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,6 +0,0 @@ -org.springframework.cloud.netflix.eureka.config.EurekaClientConfigServerAutoConfiguration -org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration -org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration -org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration -org.springframework.cloud.netflix.eureka.reactive.EurekaReactiveDiscoveryClientConfiguration -org.springframework.cloud.netflix.eureka.loadbalancer.LoadBalancerEurekaAutoConfiguration \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/ConditionalOnRefreshScopeTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/ConditionalOnRefreshScopeTests.java deleted file mode 100644 index 9b0e39b71..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/ConditionalOnRefreshScopeTests.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration.ConditionalOnMissingRefreshScope; -import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration.ConditionalOnRefreshScope; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * @author Biju Kunjummen - */ -class ConditionalOnRefreshScopeTests { - - @Test - void refreshScopeIncluded() { - new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)) - .withUserConfiguration(Beans.class).run(c -> { - assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class); - assertThat(c.getBean("foo")).isEqualTo("foo"); - }); - } - - @Test - void refreshScopeIncludedAndPropertyDisabled() { - new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)) - .withPropertyValues("eureka.client.refresh.enable=false").withUserConfiguration(Beans.class).run(c -> { - assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class); - assertThat(c).doesNotHaveBean("foo"); - assertThat(c.getBean("bar")).isEqualTo("bar"); - }); - } - - @Test - void refreshScopeNotIncluded() { - new ApplicationContextRunner().withUserConfiguration(Beans.class).run(c -> { - assertThat(c).doesNotHaveBean("foo"); - assertThat(c.getBean("bar")).isEqualTo("bar"); - }); - - new ApplicationContextRunner().withUserConfiguration(Beans.class) - .withPropertyValues("eureka.client.refresh.enable=false").run(c -> { - assertThat(c).doesNotHaveBean("foo"); - assertThat(c.getBean("bar")).isEqualTo("bar"); - }); - } - - @Configuration(proxyBeanMethods = false) - protected static class Beans { - - @Bean - @ConditionalOnRefreshScope - public String foo() { - return "foo"; - } - - @Bean - @ConditionalOnMissingRefreshScope - public String bar() { - return "bar"; - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationRandomPortTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationRandomPortTests.java deleted file mode 100644 index bd9ed0583..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationRandomPortTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.InstanceInfo; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class EurekaClientAutoConfigurationRandomPortTests { - - @Autowired - private ApplicationInfoManager infoManager; - - @Test - void instanceInfoPortShouldNotBeZero() { - InstanceInfo info = infoManager.getInfo(); - assertThat(info.getPort()).isGreaterThan(0); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - public static class TestConfig { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java deleted file mode 100644 index 1f31e884c..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java +++ /dev/null @@ -1,687 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicBoolean; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import org.springframework.aop.framework.Advised; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SearchStrategy; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.context.properties.source.ConfigurationPropertySources; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicator; -import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; -import org.springframework.cloud.commons.util.UtilAutoConfiguration; -import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent; -import org.springframework.cloud.context.refresh.ContextRefresher; -import org.springframework.cloud.context.scope.GenericScope; -import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MutablePropertySources; -import org.springframework.core.env.SystemEnvironmentPropertySource; -import org.springframework.test.util.ReflectionTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.fail; - -/** - * @author Spencer Gibb - * @author Matt Jenkins - * @author Olga Maciaszek-Sharma - * @author Tim Ysewyn - */ -class EurekaClientAutoConfigurationTests { - - private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - @AfterEach - void after() { - if (this.context != null && this.context.isActive()) { - this.context.close(); - } - } - - private void setupContext(Class... config) { - ConfigurationPropertySources.attach(this.context.getEnvironment()); - this.context.register(PropertyPlaceholderAutoConfiguration.class, - DiscoveryClientOptionalArgsConfiguration.class, EurekaDiscoveryClientConfiguration.class); - for (Class value : config) { - this.context.register(value); - } - this.context.register(TestConfiguration.class); - this.context.refresh(); - } - - @Test - void shouldSetManagementPortInMetadataMapIfEqualToServerPort() { - TestPropertyValues.of("server.port=8989").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - - assertThat(instance.getMetadataMap().get("management.port")).isEqualTo("8989"); - } - - @Test - void shouldNotSetManagementAndJmxPortsInMetadataMap() { - TestPropertyValues.of("server.port=8989", "management.server.port=0").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - - assertThat(instance.getMetadataMap().get("management.port")).isEqualTo(null); - assertThat(instance.getMetadataMap().get("jmx.port")).isEqualTo(null); - } - - @Test - void shouldSetManagementAndJmxPortsInMetadataMap() { - TestPropertyValues.of("management.server.port=9999", "com.sun.management.jmxremote.port=6789") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getMetadataMap().get("management.port")).isEqualTo("9999"); - assertThat(instance.getMetadataMap().get("jmx.port")).isEqualTo("6789"); - } - - @Test - void shouldNotResetManagementAndJmxPortsInMetadataMap() { - TestPropertyValues.of("management.server.port=9999", "eureka.instance.metadata-map.jmx.port=9898", - "eureka.instance.metadata-map.management.port=7878").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getMetadataMap().get("management.port")).isEqualTo("7878"); - assertThat(instance.getMetadataMap().get("jmx.port")).isEqualTo("9898"); - } - - @Test - void nonSecurePortPeriods() { - testNonSecurePort("server.port"); - } - - @Test - void nonSecurePortUnderscores() { - testNonSecurePortSystemProp("SERVER_PORT"); - } - - @Test - void nonSecurePort() { - testNonSecurePortSystemProp("PORT"); - assertThat(this.context.getBeanDefinition("eurekaClient").getFactoryMethodName()).isEqualTo("eurekaClient"); - } - - @Test - void securePortPeriods() { - testSecurePort("server.port"); - } - - @Test - void securePortUnderscores() { - TestPropertyValues.of("eureka.instance.secure-port-enabled=true").applyTo(this.context); - addSystemEnvironment(this.context.getEnvironment(), "SERVER_PORT:8443"); - setupContext(); - assertThat(getInstanceConfig().getSecurePort()).isEqualTo(8443); - } - - @Test - void securePort() { - testSecurePort("PORT"); - assertThat(this.context.getBeanDefinition("eurekaClient").getFactoryMethodName()).isEqualTo("eurekaClient"); - } - - @Test - void managementPort() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().contains("9999")).as("Wrong status page: " + instance.getStatusPageUrl()) - .isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPort() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "eureka.instance.statusPageUrlPath=/myStatusPage").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().contains("/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPort() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "eureka.instance.healthCheckUrlPath=/myHealthCheck").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrl_and_healthCheckUrl_do_not_contain_server_context_path() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "server.contextPath=/service") - .applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":9999/actuator/info")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - assertThat(instance.getHealthCheckUrl().endsWith(":9999/actuator/health")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrl_and_healthCheckUrl_contain_management_context_path() { - TestPropertyValues.of("server.port=8989", "management.server.servlet.context-path=/management") - .applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":8989/management/actuator/info")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - assertThat(instance.getHealthCheckUrl().endsWith(":8989/management/actuator/health")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrl_and_healthCheckUrl_contain_management_context_path_random_port() { - TestPropertyValues.of("server.port=0", "management.server.servlet.context-path=/management") - .applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrlPath().equals("/management/actuator/info")) - .as("Wrong status page: " + instance.getStatusPageUrlPath()).isTrue(); - assertThat(instance.getHealthCheckUrlPath().equals("/management/actuator/health")) - .as("Wrong health check: " + instance.getHealthCheckUrlPath()).isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPortAndContextPath() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "management.server.servlet.context-path=/manage", "eureka.instance.status-page-url-path=/myStatusPage") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPortAndContextPath() { - TestPropertyValues - .of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage", - "eureka.instance.health-check-url-path=/myHealthCheck") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPortAndContextPathKebobCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "management.server.servlet.context-path=/manage", "eureka.instance.status-page-url-path=/myStatusPage") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPortAndContextPathKebobCase() { - TestPropertyValues - .of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage", - "eureka.instance.health-check-url-path=/myHealthCheck") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrl_and_healthCheckUrl_contain_management_base_path() { - TestPropertyValues.of("server.port=8989", "management.server.base-path=/management").applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":8989/management/actuator/info")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - assertThat(instance.getHealthCheckUrl().endsWith(":8989/management/actuator/health")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrl_and_healthCheckUrl_contain_management_base_path_random_port() { - TestPropertyValues.of("server.port=0", "management.server.base-path=/management").applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrlPath().equals("/management/actuator/info")) - .as("Wrong status page: " + instance.getStatusPageUrlPath()).isTrue(); - assertThat(instance.getHealthCheckUrlPath().equals("/management/actuator/health")) - .as("Wrong health check: " + instance.getHealthCheckUrlPath()).isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPortAndBasePath() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage", - "eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPortAndBasePath() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage", - "eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPortAndBasePathKebobCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage", - "eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPortAndBasePathKebobCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage", - "eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathWithServerPortAndContextPathKebobCase() { - TestPropertyValues - .of("server.port=8989", "server.servlet.context-path=/servletContextPath", - "eureka.instance.health-check-url-path=${server.servlet.context-path:}/myHealthCheck") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl()).as("Wrong health check: " + instance.getHealthCheckUrl()) - .endsWith(":8989/servletContextPath/myHealthCheck"); - } - - @Test - void statusPageUrlPathAndManagementPortKabobCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().contains("/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void statusPageUrlAndPreferIpAddress() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo", - "eureka.instance.prefer-ip-address:true").applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - - assertThat(instance.getStatusPageUrl()).as("statusPageUrl is wrong") - .isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/info"); - assertThat(instance.getHealthCheckUrl()).as("healthCheckUrl is wrong") - .isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/health"); - } - - @Test - void statusPageAndHealthCheckUrlsShouldSetUserDefinedIpAddress() { - TestPropertyValues - .of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo", - "eureka.instance.ip-address:192.168.13.90", "eureka.instance.prefer-ip-address:true") - .applyTo(this.context); - - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - - assertThat(instance.getStatusPageUrl()).as("statusPageUrl is wrong") - .isEqualTo("http://192.168.13.90:9999/actuator/info"); - assertThat(instance.getHealthCheckUrl()).as("healthCheckUrl is wrong") - .isEqualTo("http://192.168.13.90:9999/actuator/health"); - } - - @Test - void healthCheckUrlPathAndManagementPortKabobCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", - "eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void statusPageUrlPathAndManagementPortUpperCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999").applyTo(this.context); - addSystemEnvironment(this.context.getEnvironment(), "EUREKA_INSTANCE_STATUS_PAGE_URL_PATH=/myStatusPage"); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().contains("/myStatusPage")) - .as("Wrong status page: " + instance.getStatusPageUrl()).isTrue(); - } - - @Test - void healthCheckUrlPathAndManagementPortUpperCase() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999").applyTo(this.context); - addSystemEnvironment(this.context.getEnvironment(), "EUREKA_INSTANCE_HEALTH_CHECK_URL_PATH=/myHealthCheck"); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck")) - .as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue(); - } - - @Test - void hostname() { - TestPropertyValues.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class); - EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class); - assertThat(instance.getStatusPageUrl().contains("foo")).as("Wrong status page: " + instance.getStatusPageUrl()) - .isTrue(); - } - - @Test - void refreshScopedBeans() { - setupContext(RefreshAutoConfiguration.class); - assertThat(this.context.getBeanDefinition("eurekaClient").getBeanClassName()) - .startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean"); - assertThat(this.context.getBeanDefinition("eurekaApplicationInfoManager").getBeanClassName()) - .startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean"); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - void shouldReregisterHealthCheckHandlerAfterRefresh() throws Exception { - TestPropertyValues - .of("eureka.client.healthcheck.enabled=true", "spring.cloud.config.import-check.enabled=false", - "spring.cloud.refresh.additionalPropertySourcesToRetain=test") - .applyTo(this.context); - setupContext(RefreshAutoConfiguration.class, AutoServiceRegistrationConfiguration.class); - - EurekaClient oldEurekaClient = getLazyInitEurekaClient(); - - HealthCheckHandler healthCheckHandler = this.context.getBean("eurekaHealthCheckHandler", - HealthCheckHandler.class); - - assertThat(healthCheckHandler).isInstanceOf(EurekaHealthCheckHandler.class); - assertThat(oldEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler); - - ContextRefresher refresher = this.context.getBean(ContextRefresher.class); - if (refresher instanceof ApplicationListener) { - ApplicationListener listener = (ApplicationListener) refresher; - listener.onApplicationEvent(new ContextRefreshedWithApplicationEvent(Mockito.mock(SpringApplication.class), - new String[0], this.context)); - } - refresher.refresh(); - - EurekaClient newEurekaClient = getLazyInitEurekaClient(); - HealthCheckHandler newHealthCheckHandler = this.context.getBean("eurekaHealthCheckHandler", - HealthCheckHandler.class); - - assertThat(healthCheckHandler).isSameAs(newHealthCheckHandler); - assertThat(oldEurekaClient).isNotSameAs(newEurekaClient); - assertThat(newEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler); - } - - @Test - void shouldCloseDiscoveryClient() throws Exception { - TestPropertyValues.of("eureka.client.healthcheck.enabled=true").applyTo(this.context); - setupContext(RefreshAutoConfiguration.class, AutoServiceRegistrationConfiguration.class); - - AtomicBoolean isShutdown = (AtomicBoolean) ReflectionTestUtils.getField(getLazyInitEurekaClient(), - "isShutdown"); - - assertThat(isShutdown.get()).isFalse(); - - this.context.close(); - - assertThat(isShutdown.get()).isTrue(); - } - - @Test - void testDefaultAppName() { - setupContext(); - assertThat(getInstanceConfig().getAppname()).isEqualTo("unknown"); - assertThat(getInstanceConfig().getVirtualHostName()).isEqualTo("unknown"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).isEqualTo("unknown"); - } - - @Test - void testAppName() { - TestPropertyValues.of("spring.application.name=mytest").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getAppname()).isEqualTo("mytest"); - assertThat(getInstanceConfig().getVirtualHostName()).isEqualTo("mytest"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).isEqualTo("mytest"); - } - - @Test - void testAppNameUpper() { - addSystemEnvironment(this.context.getEnvironment(), "SPRING_APPLICATION_NAME=mytestupper"); - setupContext(); - assertThat(getInstanceConfig().getAppname()).isEqualTo("mytestupper"); - assertThat(getInstanceConfig().getVirtualHostName()).isEqualTo("mytestupper"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).isEqualTo("mytestupper"); - } - - private void addSystemEnvironment(ConfigurableEnvironment environment, String... pairs) { - MutablePropertySources sources = environment.getPropertySources(); - Map map = getOrAdd(sources, "testsysenv"); - for (String pair : pairs) { - int index = getSeparatorIndex(pair); - String key = pair.substring(0, index > 0 ? index : pair.length()); - String value = index > 0 ? pair.substring(index + 1) : ""; - map.put(key.trim(), value.trim()); - } - } - - @SuppressWarnings("unchecked") - private static Map getOrAdd(MutablePropertySources sources, String name) { - if (sources.contains(name)) { - return (Map) sources.get(name).getSource(); - } - Map map = new HashMap<>(); - sources.addFirst(new SystemEnvironmentPropertySource(name, map)); - return map; - } - - private static int getSeparatorIndex(String pair) { - int colonIndex = pair.indexOf(":"); - int equalIndex = pair.indexOf("="); - if (colonIndex == -1) { - return equalIndex; - } - if (equalIndex == -1) { - return colonIndex; - } - return Math.min(colonIndex, equalIndex); - } - - @Test - void testInstanceNamePreferred() { - addSystemEnvironment(this.context.getEnvironment(), "SPRING_APPLICATION_NAME=mytestspringappname"); - TestPropertyValues.of("eureka.instance.appname=mytesteurekaappname").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getAppname()).isEqualTo("mytesteurekaappname"); - } - - @Test - void eurekaHealthIndicatorCreated() { - setupContext(); - this.context.getBean(EurekaHealthIndicator.class); - } - - @Test - void eurekaClientClosed() { - setupContext(TestEurekaClientConfiguration.class); - if (this.context != null) { - CountDownLatch latch = this.context.getBean(CountDownLatch.class); - this.context.close(); - assertThat(latch.getCount()).isEqualTo(0); - } - } - - @Test - void eurekaConfigNotLoadedWhenDiscoveryClientDisabled() { - TestPropertyValues.of("spring.cloud.discovery.enabled=false").applyTo(this.context); - setupContext(TestConfiguration.class); - assertBeanNotPresent(EurekaClientConfigBean.class); - assertBeanNotPresent(EurekaInstanceConfigBean.class); - assertBeanNotPresent(DiscoveryClient.class); - assertBeanNotPresent(EurekaServiceRegistry.class); - assertBeanNotPresent(EurekaClient.class); - } - - @Test - void shouldNotHaveDiscoveryClientWhenBlockingDiscoveryDisabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class, - DiscoveryClientOptionalArgsConfiguration.class, EurekaClientAutoConfiguration.class, - EurekaDiscoveryClientConfiguration.class)) - .withPropertyValues("spring.cloud.discovery.blocking.enabled=false").run(context -> { - assertThat(context).doesNotHaveBean(DiscoveryClient.class); - assertThat(context).doesNotHaveBean(DiscoveryClientHealthIndicator.class); - }); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void assertBeanNotPresent(Class beanClass) { - try { - context.getBean(beanClass); - fail("Bean of type " + beanClass + " should not have been created."); - } - catch (NoSuchBeanDefinitionException exception) { - // expected exception - } - } - - private void testNonSecurePortSystemProp(String propName) { - addSystemEnvironment(this.context.getEnvironment(), propName + ":8888"); - setupContext(); - assertThat(getInstanceConfig().getNonSecurePort()).isEqualTo(8888); - } - - private void testNonSecurePort(String propName) { - TestPropertyValues.of(propName + ":8888").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getNonSecurePort()).isEqualTo(8888); - } - - private void testSecurePort(String propName) { - TestPropertyValues.of("eureka.instance.secure-port-enabled=true", propName + ":8443").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getSecurePort()).isEqualTo(8443); - } - - private EurekaInstanceConfigBean getInstanceConfig() { - return this.context.getBean(EurekaInstanceConfigBean.class); - } - - private EurekaClient getLazyInitEurekaClient() throws Exception { - return (EurekaClient) ((Advised) this.context.getBean("eurekaClient", EurekaClient.class)).getTargetSource() - .getTarget(); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties - @Import({ UtilAutoConfiguration.class, EurekaClientAutoConfiguration.class }) - protected static class TestConfiguration { - - } - - @Configuration - protected static class TestEurekaClientConfiguration { - - @Bean - public CountDownLatch countDownLatch() { - return new CountDownLatch(1); - } - - @Bean(destroyMethod = "shutdown") - @ConditionalOnMissingBean(value = EurekaClient.class, search = SearchStrategy.CURRENT) - public EurekaClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, - TransportClientFactories transportClientFactories, ApplicationContext context, - AbstractDiscoveryClientOptionalArgs optionalArgs) { - return new CloudEurekaClient(manager, config, transportClientFactories, optionalArgs, context) { - @Override - public synchronized void shutdown() { - CountDownLatch latch = countDownLatch(); - if (latch.getCount() == 1) { - latch.countDown(); - } - super.shutdown(); - } - }; - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties(AutoServiceRegistrationProperties.class) - public static class AutoServiceRegistrationConfiguration { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBeanTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBeanTests.java deleted file mode 100644 index b1c3f2e4a..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBeanTests.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.Collections; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.CompositePropertySource; -import org.springframework.core.env.MapPropertySource; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - */ -class EurekaClientConfigBeanTests { - - private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - @AfterEach - void init() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - void basicBinding() { - TestPropertyValues.of("eureka.client.proxyHost=example.com").applyTo(this.context); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(EurekaClientConfigBean.class).getProxyHost()).isEqualTo("example.com"); - } - - @Test - void serviceUrl() { - TestPropertyValues.of("eureka.client.serviceUrl.defaultZone:https://example.com").applyTo(this.context); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(EurekaClientConfigBean.class).getServiceUrl().toString()) - .isEqualTo("{defaultZone=https://example.com}"); - assertThat(getEurekaServiceUrlsForDefaultZone()).isEqualTo("[https://example.com/]"); - } - - @Test - void serviceUrlWithCompositePropertySource() { - CompositePropertySource source = new CompositePropertySource("composite"); - this.context.getEnvironment().getPropertySources().addFirst(source); - source.addPropertySource(new MapPropertySource("config", Collections.singletonMap( - "eureka.client.serviceUrl.defaultZone", - "https://example.com,https://example2.com, https://www.hugedomains.com/domain_profile.cfm?d=example3&e=com"))); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(EurekaClientConfigBean.class).getServiceUrl().toString()).isEqualTo( - "{defaultZone=https://example.com,https://example2.com, https://www.hugedomains.com/domain_profile.cfm?d=example3&e=com}"); - assertThat(getEurekaServiceUrlsForDefaultZone()).isEqualTo( - "[https://example.com/, https://example2.com/, https://www.hugedomains.com/domain_profile.cfm?d=example3&e=com/]"); - } - - @Test - void serviceUrlWithDefault() { - TestPropertyValues.of("eureka.client.serviceUrl.defaultZone:https://example.com").applyTo(this.context); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(getEurekaServiceUrlsForDefaultZone()).isEqualTo("[https://example.com/]"); - } - - @Test - void serviceUrlWithCustomZone() { - TestPropertyValues.of("eureka.client.serviceUrl.customZone:https://custom-example.com").applyTo(this.context); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(getEurekaServiceUrls("customZone")).isEqualTo("[https://custom-example.com/]"); - } - - @Test - void serviceUrlWithEmptyServiceUrls() { - TestPropertyValues.of("eureka.client.serviceUrl.defaultZone:").applyTo(this.context); - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - assertThat(getEurekaServiceUrlsForDefaultZone()).isEqualTo("[]"); - } - - private String getEurekaServiceUrlsForDefaultZone() { - return getEurekaServiceUrls("defaultZone"); - } - - private String getEurekaServiceUrls(String myZone) { - return this.context.getBean(EurekaClientConfigBean.class).getEurekaServerServiceUrls(myZone).toString(); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties(EurekaClientConfigBean.class) - protected static class TestConfiguration { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandlerTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandlerTests.java deleted file mode 100644 index 21a078226..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaHealthCheckHandlerTests.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; - -import org.springframework.boot.actuate.health.AbstractHealthIndicator; -import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator; -import org.springframework.boot.actuate.health.CompositeHealthContributor; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.HealthContributor; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.actuate.health.NamedContributor; -import org.springframework.boot.actuate.health.ReactiveHealthIndicator; -import org.springframework.boot.actuate.health.SimpleStatusAggregator; -import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicator; -import org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthContributor; -import org.springframework.cloud.client.discovery.health.DiscoveryHealthIndicator; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests the {@link EurekaHealthCheckHandler} with different health indicator registered. - * - * @author Jakub Narloch - * @author Nowrin Anwar Joyita - * @author Olga Maciaszek-Sharma - */ -class EurekaHealthCheckHandlerTests { - - private EurekaHealthCheckHandler healthCheckHandler; - - @BeforeEach - void setUp() { - - healthCheckHandler = new EurekaHealthCheckHandler(new SimpleStatusAggregator()); - } - - @Test - void testNoHealthCheckRegistered() { - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.UNKNOWN); - } - - @Test - void testAllUp() { - initialize(UpHealthConfiguration.class, ReactiveUpHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.UP); - } - - @Test - void testHealthCheckNotReturnedWhenStopped() { - initialize(UpHealthConfiguration.class); - - healthCheckHandler.stop(); - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - - assertThat(status).isNull(); - healthCheckHandler.start(); - InstanceStatus newStatus = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(newStatus).isEqualTo(InstanceStatus.UP); - } - - @Test - void testDownWithBlockingIndicators() { - initialize(UpHealthConfiguration.class, DownHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - @Test - void testDownWithReactiveIndicators() { - initialize(UpHealthConfiguration.class, ReactiveDownHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - @Test - void testDownWhenBlockingIndicatorUpAndReactiveDown() { - initialize(ReactiveUpHealthConfiguration.class, DownHealthConfiguration.class); - - InstanceStatus status = this.healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - @Test - void testDownWhenBlockingIndicatorDownAndReactiveUp() { - initialize(ReactiveUpHealthConfiguration.class, ReactiveDownHealthConfiguration.class); - - InstanceStatus status = this.healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - @Test - void testUnknown() { - initialize(FatalHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN); - assertThat(status).isEqualTo(InstanceStatus.UNKNOWN); - } - - @Test - void testEurekaIgnored() { - initialize(EurekaDownHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UP); - assertThat(status).isEqualTo(InstanceStatus.UP); - } - - @Test - void testCompositeComponentsDown() { - initialize(CompositeComponentsDownHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UP); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - @Test - void testCompositeComponentsUp() { - initialize(CompositeComponentsUpHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UP); - assertThat(status).isEqualTo(InstanceStatus.UP); - } - - @Test - void testCompositeComponentsOneDown() { - initialize(CompositeComponentsOneDownHealthConfiguration.class); - - InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UP); - assertThat(status).isEqualTo(InstanceStatus.DOWN); - } - - private void initialize(Class... configurations) { - ApplicationContext applicationContext = new AnnotationConfigApplicationContext(configurations); - healthCheckHandler.setApplicationContext(applicationContext); - healthCheckHandler.afterPropertiesSet(); - } - - public static class UpHealthConfiguration { - - @Bean - public HealthIndicator healthIndicator() { - return new AbstractHealthIndicator() { - @Override - protected void doHealthCheck(Health.Builder builder) { - builder.up(); - } - }; - } - - } - - public static class DownHealthConfiguration { - - @Bean - public HealthIndicator healthIndicator() { - return new AbstractHealthIndicator() { - @Override - protected void doHealthCheck(Health.Builder builder) { - builder.down(); - } - }; - } - - } - - public static class FatalHealthConfiguration { - - @Bean - public HealthIndicator healthIndicator() { - return new AbstractHealthIndicator() { - @Override - protected void doHealthCheck(Health.Builder builder) { - builder.status("fatal"); - } - }; - } - - } - - public static class ReactiveUpHealthConfiguration { - - @Bean - public ReactiveHealthIndicator reactiveHealthIndicator() { - return new AbstractReactiveHealthIndicator() { - @Override - protected Mono doHealthCheck(Health.Builder builder) { - return Mono.just(builder.up().build()); - } - }; - } - - } - - public static class ReactiveDownHealthConfiguration { - - @Bean - public ReactiveHealthIndicator reactiveHealthIndicator() { - return new AbstractReactiveHealthIndicator() { - @Override - protected Mono doHealthCheck(Health.Builder builder) { - return Mono.just(builder.down().build()); - } - }; - } - - } - - public static class EurekaDownHealthConfiguration { - - @Bean - public DiscoveryHealthIndicator discoveryHealthIndicator() { - return new DiscoveryClientHealthIndicator(null, null) { - @Override - public Health health() { - return Health.up().build(); - } - }; - } - - @Bean - public DiscoveryHealthIndicator eurekaHealthIndicator() { - return new EurekaHealthIndicator(null, null, null) { - @Override - public Health health() { - return Health.down().build(); - } - }; - } - - @Bean - public DiscoveryCompositeHealthContributor discoveryCompositeHealthContributor( - List indicators) { - return new DiscoveryCompositeHealthContributor(indicators); - } - - } - - protected static class CompositeComponentsDownHealthConfiguration { - - @Bean - public CompositeHealthContributor compositeHealthContributor() { - return new TestCompositeHealthContributor(InstanceStatus.DOWN, InstanceStatus.DOWN); - } - - } - - protected static class CompositeComponentsUpHealthConfiguration { - - @Bean - public CompositeHealthContributor compositeHealthContributor() { - return new TestCompositeHealthContributor(InstanceStatus.UP, InstanceStatus.UP); - } - - } - - protected static class CompositeComponentsOneDownHealthConfiguration { - - @Bean - public CompositeHealthContributor compositeHealthContributor() { - return new TestCompositeHealthContributor(InstanceStatus.UP, InstanceStatus.DOWN); - } - - } - - static class TestCompositeHealthContributor implements CompositeHealthContributor { - - private final Map contributorMap = new HashMap<>(); - - TestCompositeHealthContributor(InstanceStatus firstContributorStatus, InstanceStatus secondContributorStatus) { - contributorMap.put("first", new AbstractHealthIndicator() { - @Override - protected void doHealthCheck(Health.Builder builder) { - builder.status(firstContributorStatus.name()); - } - }); - contributorMap.put("second", new AbstractHealthIndicator() { - @Override - protected void doHealthCheck(Health.Builder builder) { - builder.status(secondContributorStatus.name()); - } - }); - } - - @Override - public HealthContributor getContributor(String name) { - return contributorMap.get(name); - } - - @Override - public Iterator> iterator() { - Iterator> iterator = contributorMap.entrySet().iterator(); - return new Iterator<>() { - - @Override - public boolean hasNext() { - return iterator.hasNext(); - } - - @Override - public NamedContributor next() { - Map.Entry entry = iterator.next(); - return NamedContributor.of(entry.getKey(), entry.getValue()); - } - - }; - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java deleted file mode 100644 index 109d5e2f9..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBeanTests.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.InstanceInfo.InstanceStatus; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.commons.util.InetUtilsProperties; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.util.StringUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * @author Spencer Gibb - * @author Ryan Baxter - * @author Tim Ysewyn - */ -class EurekaInstanceConfigBeanTests { - - private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - private String hostName; - - private String ipAddress; - - @BeforeEach - void init() { - try (InetUtils utils = new InetUtils(new InetUtilsProperties())) { - InetUtils.HostInfo hostInfo = utils.findFirstNonLoopbackHostInfo(); - this.hostName = hostInfo.getHostname(); - this.ipAddress = hostInfo.getIpAddress(); - } - } - - @AfterEach - void clear() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - void basicBinding() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getAppGroupName()).isEqualTo("mygroup"); - } - - @Test - void nonSecurePort() { - TestPropertyValues.of("eureka.instance.nonSecurePort:8888").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getNonSecurePort()).isEqualTo(8888); - } - - @Test - void instanceId() { - TestPropertyValues.of("eureka.instance.instanceId:special").applyTo(this.context); - setupContext(); - EurekaInstanceConfigBean instance = getInstanceConfig(); - assertThat(instance.getInstanceId()).isEqualTo("special"); - } - - @Test - void initialHostName() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - if (this.hostName != null) { - assertThat(getInstanceConfig().getHostname()).isEqualTo(this.hostName); - } - } - - @Test - void refreshHostName() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - ReflectionTestUtils.setField(getInstanceConfig(), "hostname", "marvin"); - assertThat(getInstanceConfig().getHostname()).isEqualTo("marvin"); - getInstanceConfig().getHostName(true); - if (this.hostName != null) { - assertThat(getInstanceConfig().getHostname()).isEqualTo(this.hostName); - } - } - - @Test - void refreshHostNameWhenSetByUser() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - getInstanceConfig().setHostname("marvin"); - assertThat(getInstanceConfig().getHostname()).isEqualTo("marvin"); - getInstanceConfig().getHostName(true); - assertThat(getInstanceConfig().getHostname()).isEqualTo("marvin"); - } - - @Test - void initialIpAddress() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - if (this.ipAddress != null) { - assertThat(getInstanceConfig().getIpAddress()).isEqualTo(this.ipAddress); - } - } - - @Test - void refreshIpAddress() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - ReflectionTestUtils.setField(getInstanceConfig(), "ipAddress", "10.0.0.1"); - assertThat(getInstanceConfig().getIpAddress()).isEqualTo("10.0.0.1"); - getInstanceConfig().getHostName(true); - if (this.ipAddress != null) { - assertThat(getInstanceConfig().getIpAddress()).isEqualTo(this.ipAddress); - } - } - - @Test - void refreshIpAddressWhenSetByUser() { - TestPropertyValues.of("eureka.instance.appGroupName=mygroup").applyTo(this.context); - setupContext(); - getInstanceConfig().setIpAddress("10.0.0.1"); - assertThat(getInstanceConfig().getIpAddress()).isEqualTo("10.0.0.1"); - getInstanceConfig().getHostName(true); - assertThat(getInstanceConfig().getIpAddress()).isEqualTo("10.0.0.1"); - } - - @Test - void testDefaultInitialStatus() { - setupContext(); - assertThat(getInstanceConfig().getInitialStatus()).as("initialStatus wrong").isEqualTo(InstanceStatus.UP); - } - - @Test - void testCustomInitialStatus() { - TestPropertyValues.of("eureka.instance.initial-status:STARTING").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getInitialStatus()).as("initialStatus wrong").isEqualTo(InstanceStatus.STARTING); - } - - @Test - void testPreferIpAddress() { - TestPropertyValues.of("eureka.instance.preferIpAddress:true").applyTo(this.context); - setupContext(); - EurekaInstanceConfigBean instance = getInstanceConfig(); - assertThat(getInstanceConfig().getHostname().equals(instance.getIpAddress())) - .as("Wrong hostname: " + instance.getHostname()).isTrue(); - - } - - @Test - void testDefaultVirtualHostName() { - TestPropertyValues.of("spring.application.name:myapp").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getVirtualHostName()).as("virtualHostName wrong").isEqualTo("myapp"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).as("secureVirtualHostName wrong").isEqualTo("myapp"); - - } - - @Test - void testCustomVirtualHostName() { - TestPropertyValues.of("spring.application.name:myapp", "eureka.instance.virtualHostName=myvirthost", - "eureka.instance.secureVirtualHostName=mysecurevirthost").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getVirtualHostName()).as("virtualHostName wrong").isEqualTo("myvirthost"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).as("secureVirtualHostName wrong") - .isEqualTo("mysecurevirthost"); - - } - - @Test - void testDefaultAppName() { - setupContext(); - assertThat(getInstanceConfig().getAppname()).as("default app name is wrong").isEqualTo("unknown"); - assertThat(getInstanceConfig().getVirtualHostName()).as("default virtual hostname is wrong") - .isEqualTo("unknown"); - assertThat(getInstanceConfig().getSecureVirtualHostName()).as("default secure virtual hostname is wrong") - .isEqualTo("unknown"); - } - - @Test - void testCustomInstanceId() { - TestPropertyValues.of("eureka.instance.instanceId=myinstance").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getInstanceId()).as("instance id is wrong").isEqualTo("myinstance"); - } - - @Test - void testCustomInstanceIdWithMetadata() { - TestPropertyValues.of("eureka.instance.metadataMap.instanceId=myinstance").applyTo(this.context); - setupContext(); - assertThat(getInstanceConfig().getInstanceId()).as("instance id is wrong").isEqualTo("myinstance"); - } - - @Test - void testDefaultInstanceId() { - setupContext(); - assertThat(getInstanceConfig().getInstanceId()).as("default instance id is wrong").isEqualTo(null); - } - - private void setupContext() { - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - } - - private EurekaInstanceConfigBean getInstanceConfig() { - return this.context.getBean(EurekaInstanceConfigBean.class); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties - protected static class TestConfiguration { - - @Autowired - ConfigurableEnvironment env; - - @Bean - public EurekaInstanceConfigBean eurekaInstanceConfigBean() { - EurekaInstanceConfigBean configBean = new EurekaInstanceConfigBean( - new InetUtils(new InetUtilsProperties())); - String springAppName = this.env.getProperty("spring.application.name", ""); - if (StringUtils.hasText(springAppName)) { - configBean.setSecureVirtualHostName(springAppName); - configBean.setVirtualHostName(springAppName); - configBean.setAppname(springAppName); - } - return configBean; - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstanceTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstanceTests.java deleted file mode 100644 index f497c4183..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaServiceInstanceTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.InstanceInfo; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - -class EurekaServiceInstanceTests { - - @Test - void getSchemeReturnsNonNull() { - InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test").setHostName("myhost") - .setPort(8080).build(); - EurekaServiceInstance instance = new EurekaServiceInstance(instanceInfo); - Assertions.assertThat(instance.getScheme()).isEqualTo("http"); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactoryTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactoryTests.java deleted file mode 100644 index 1e58aac3a..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/InstanceInfoFactoryTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka; - -import com.netflix.appinfo.InstanceInfo; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.commons.util.InetUtilsProperties; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -class InstanceInfoFactoryTests { - - private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - - @Test - void instanceIdIsHostNameByDefault() { - InstanceInfo instanceInfo = setupInstance(); - try (InetUtils utils = new InetUtils(new InetUtilsProperties())) { - assertThat(instanceInfo.getId()).isEqualTo(utils.findFirstNonLoopbackHostInfo().getHostname()); - } - } - - @Test - void instanceIdIsIpWhenIpPreferred() { - InstanceInfo instanceInfo = setupInstance("eureka.instance.preferIpAddress:true"); - assertThat(instanceInfo.getId().matches("(\\d+\\.){3}\\d+")).isTrue(); - } - - @Test - void instanceInfoIdIsInstanceIdWhenSet() { - InstanceInfo instanceInfo = setupInstance("eureka.instance.instanceId:special"); - assertThat(instanceInfo.getId()).isEqualTo("special"); - } - - private InstanceInfo setupInstance(String... pairs) { - TestPropertyValues.of(pairs).applyTo(this.context); - - this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class); - this.context.refresh(); - - EurekaInstanceConfigBean instanceConfig = getInstanceConfig(); - return new InstanceInfoFactory().create(instanceConfig); - } - - private EurekaInstanceConfigBean getInstanceConfig() { - return this.context.getBean(EurekaInstanceConfigBean.class); - } - - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties - protected static class TestConfiguration { - - @Bean - public EurekaInstanceConfigBean eurekaInstanceConfigBean() { - return new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/ConfigRefreshTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/ConfigRefreshTests.java deleted file mode 100644 index 40e2ae6c0..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/ConfigRefreshTests.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import com.netflix.discovery.EurekaClient; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent; -import org.springframework.cloud.netflix.eureka.sample.RefreshEurekaSampleApplication; -import org.springframework.context.ApplicationEventPublisher; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Ryan Baxter - */ -@SpringBootTest(webEnvironment = RANDOM_PORT, classes = RefreshEurekaSampleApplication.class) -class ConfigRefreshTests { - - @Autowired - private ApplicationEventPublisher publisher; - - @Autowired - // Mocked in RefreshEurekaSampleApplication - private EurekaClient client; - - @Test - // This test is used to verify that getApplications is called the correct number of - // times when a refresh event is fired. The getApplications call in - // EurekaClientConfigurationRefresher.onApplicationEvent - // ensures that the EurekaClient bean is recreated after a refresh event and that we - // reregister the client with the server - void verifyGetApplications() { - if (publisher != null) { - publisher.publishEvent(new RefreshScopeRefreshedEvent()); - } - verify(client, times(3)).getApplications(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfigurationTests.java deleted file mode 100644 index b663c77fc..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaClientConfigServerAutoConfigurationTests.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import com.netflix.appinfo.EurekaInstanceConfig; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.commons.util.UtilAutoConfiguration; -import org.springframework.cloud.config.server.config.ConfigServerProperties; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * @author Biju Kunjummen - */ -class EurekaClientConfigServerAutoConfigurationTests { - - @Test - void offByDefault() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class)) - .run(c -> assertThat(c.getBeanNamesForType(EurekaInstanceConfigBean.class).length).isEqualTo(0)); - } - - @Test - void onWhenRequested() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class, - UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class)) - .withPropertyValues("spring.cloud.config.server.prefix=/config").run(c -> { - assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1); - EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class); - assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/config"); - }); - } - - @Test - void notOverridingMetamapSettings() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class, - UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class)) - .withPropertyValues("spring.cloud.config.server.prefix=/config") - .withPropertyValues("eureka.instance.metadataMap.configPath=/differentpath").run(c -> { - assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1); - EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class); - assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/differentpath"); - }); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationTests.java deleted file mode 100644 index 5799b9717..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationTests.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.util.Collections; -import java.util.List; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.test.context.assertj.AssertableApplicationContext; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.system.OutputCaptureRule; -import org.springframework.cloud.config.client.ConfigServerInstanceProvider; -import org.springframework.cloud.netflix.eureka.CloudEurekaClient; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient; -import org.springframework.cloud.test.ClassPathExclusions; -import org.springframework.cloud.test.ModifiedClassPathRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author Spencer Gibb - */ -@RunWith(ModifiedClassPathRunner.class) -@ClassPathExclusions("spring-webflux-*") -public class EurekaConfigServerBootstrapConfigurationTests { - - @Rule - public OutputCaptureRule output = new OutputCaptureRule(); - - @Test - public void offByDefault() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .run(this::assertEurekaBeansNotPresent); - } - - @Test - public void properBeansCreatedWhenDiscoveryEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true").run(this::assertEurekaBeansPresent); - } - - @Test - public void beansNotCreatedWhenDiscoveryNotEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=false") - .run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenDiscoveryDisabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.disabled").run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenEurekaClientEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("eureka.client.enabled=true").run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenEurekaClientNotEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("eureka.client.enabled=false").run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenEurekaClientDisabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("eureka.client.disabled").run(this::assertEurekaBeansNotPresent); - } - - @Test - public void properBeansCreatedWhenDiscoveryEnabled_EurekaEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true") - .run(this::assertEurekaBeansPresent); - } - - @Test - public void beansNotCreatedWhenDiscoveryEnabled_EurekaNotEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false") - .run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=true") - .run(this::assertEurekaBeansNotPresent); - } - - @Test - public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaNotEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=false") - .run(this::assertEurekaBeansNotPresent); - } - - @Test - public void eurekaDnsConfigurationWorks() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true", - "eureka.instance.hostname=eurekaclient1", - "eureka.client.use-dns-for-fetching-service-urls=true", - "eureka.client.eureka-server-d-n-s-name=myeurekahost", - "eureka.client.eureka-server-u-r-l-context=eureka", "eureka.client.eureka-server-port=30000") - .run(context -> assertThat(output) - .contains("Cannot get cnames bound to the region:txt.us-east-1.myeurekahost")); - } - - @Test - public void eurekaConfigServerInstanceProviderCalled() { - // FIXME: why do I need to do this? (fails in maven build without it. - TomcatURLStreamHandlerFactory.disable(); - new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class) - .properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true", - "eureka.client.enabled=true", - "spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(), - "logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG") - .run(); - assertThat(output).contains("eurekaConfigServerInstanceProvider finding instances for configserver") - .contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver"); - } - - private void assertEurekaBeansPresent(AssertableApplicationContext context) { - assertThat(context).hasSingleBean(EurekaClientConfigBean.class); - assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class); - assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class); - } - - private void assertEurekaBeansNotPresent(AssertableApplicationContext context) { - assertThat(context).doesNotHaveBean(EurekaClientConfigBean.class); - assertThat(context).doesNotHaveBean(EurekaHttpClient.class); - assertThat(context).doesNotHaveBean(ConfigServerInstanceProvider.Function.class); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - protected static class TestConfigDiscoveryConfiguration { - - @Bean - public EurekaClient getClient() { - return mock(CloudEurekaClient.class); - } - - } - - @Configuration - protected static class TestConfigDiscoveryBootstrapConfiguration { - - @SuppressWarnings("unchecked") - @Bean - public EurekaHttpClient mockEurekaHttpClient() { - InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("configserver").build(); - List instanceInfos = Collections.singletonList(instanceInfo); - - Applications applications = mock(Applications.class); - when(applications.getInstancesByVirtualHostName("configserver")).thenReturn(instanceInfos); - - EurekaHttpResponse response = mock(EurekaHttpResponse.class); - when(response.getStatusCode()).thenReturn(200); - when(response.getEntity()).thenReturn(applications); - - EurekaHttpClient client = mock(EurekaHttpClient.class); - when(client.getApplications("us-east-1")).thenReturn(response); - return client; - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests.java deleted file mode 100644 index 717b55868..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient; -import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpStatus; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -/** - * @author Spencer Gibb - */ -@SpringBootTest(properties = { "spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true", - "spring.config.use-legacy-processing=true", "eureka.client.webclient.enabled=true", - "spring.codec.max-in-memory-size=310000" }, webEnvironment = RANDOM_PORT) -class EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests { - - @LocalServerPort - private int port; - - @Autowired - private WebClientEurekaHttpClient eurekaHttpClient; - - @Test - void webClientRespectsCodecProperties() { - WebClient webClient = eurekaHttpClient.getWebClient(); - ClientResponse response = webClient.get().uri("http://localhost:" + port).exchange().block(); - assertThat(response).isNotNull(); - assertThat(response.statusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.bodyToMono(String.class).block()).startsWith("....").hasSize(300000); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - @RestController - static class WebClientController { - - @GetMapping("/") - public String hello() { - return ".".repeat(300000); - } - - @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.authorizeHttpRequests().anyRequest().permitAll().and().csrf().disable(); - return http.build(); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientTests.java deleted file mode 100644 index 735853d28..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapConfigurationWebClientTests.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.config.client.ConfigServerInstanceProvider; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient; -import org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - */ -class EurekaConfigServerBootstrapConfigurationWebClientTests { - - @Test - void properBeansCreatedWhenEnabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true", - "eureka.client.webclient.enabled=true") - .run(context -> { - assertThat(context).hasSingleBean(EurekaClientConfigBean.class); - assertThat(context).hasSingleBean(WebClientEurekaHttpClient.class); - assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class); - }); - } - - @Test - void properBeansCreatedWhenEnabledWebClientDisabled() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class)) - .withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true") - .run(context -> { - assertThat(context).hasSingleBean(EurekaClientConfigBean.class); - assertThat(context).doesNotHaveBean(WebClientEurekaHttpClient.class); - assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class); - assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class); - }); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperIT.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperIT.java deleted file mode 100644 index 10d494030..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperIT.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2013-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.BeanDescription; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationConfig; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; -import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.converters.jackson.serializer.InstanceInfoJsonBeanSerializer; -import com.netflix.discovery.shared.Application; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockserver.client.MockServerClient; -import org.testcontainers.containers.MockServerContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.config.environment.Environment; -import org.springframework.cloud.config.environment.PropertySource; -import org.springframework.cloud.netflix.eureka.http.EurekaApplications; -import org.springframework.context.ConfigurableApplicationContext; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockserver.model.HttpRequest.request; -import static org.mockserver.model.HttpResponse.response; - -/** - * @author Ryan Baxter - */ -@Testcontainers -public class EurekaConfigServerBootstrapperIT { - - public static final DockerImageName MOCKSERVER_IMAGE = DockerImageName.parse("mockserver/mockserver") - .withTag("mockserver-" + MockServerClient.class.getPackage().getImplementationVersion()); - - @Container - static MockServerContainer mockServer = new MockServerContainer(MOCKSERVER_IMAGE); - - private ConfigurableApplicationContext context; - - @BeforeEach - void before() { - - } - - @AfterEach - void after() { - this.context.close(); - } - - @Test - public void contextLoads() throws JsonProcessingException { - Environment environment = new Environment("test", "default"); - Map properties = new HashMap<>(); - properties.put("hello", "world"); - PropertySource p = new PropertySource("p1", properties); - environment.add(p); - ObjectMapper objectMapper = new ObjectMapper(); - SimpleModule jsonModule = new SimpleModule(); - jsonModule.setSerializerModifier(createJsonSerializerModifier()); - objectMapper.registerModule(jsonModule); - try (MockServerClient mockServerClient = new MockServerClient(mockServer.getHost(), - mockServer.getMappedPort(MockServerContainer.PORT))) { - mockServerClient.when(request().withPath("/application/default")) - .respond(response().withBody(objectMapper.writeValueAsString(environment)) - .withHeader("content-type", "application/json")); - InstanceInfo configServerInstanceInfo = InstanceInfo.Builder.newBuilder() - .setVIPAddress("eureka-configserver").setInstanceId("eureka-configserver") - .setAppName("eureka-configserver").setStatus(InstanceInfo.InstanceStatus.UP) - .enablePort(InstanceInfo.PortType.UNSECURE, true).setHostName("localhost") - .setPort(mockServer.getMappedPort(MockServerContainer.PORT)).build(); - Application configServer = new Application("eureka-configserver", - Collections.singletonList(configServerInstanceInfo)); - EurekaApplications eurekaApplications = new EurekaApplications("hashcode", 0L, - Collections.singletonList(configServer)); - mockServerClient.when(request().withPath("/apps/")) - .respond(response() - .withBody("{\"applications\":" + objectMapper.writeValueAsString(eurekaApplications) + "}") - .withHeader("content-type", "application/json")); - this.context = setup().run(); - assertThat(this.context.getEnvironment().getProperty("hello")).isEqualTo("world"); - } - - } - - public static BeanSerializerModifier createJsonSerializerModifier() { - return new BeanSerializerModifier() { - @Override - public JsonSerializer modifySerializer(SerializationConfig config, BeanDescription beanDesc, - JsonSerializer serializer) { - if (beanDesc.getBeanClass().isAssignableFrom(InstanceInfo.class)) { - return new InstanceInfoJsonBeanSerializer((BeanSerializerBase) serializer, false); - } - return serializer; - } - }; - } - - SpringApplicationBuilder setup(String... env) { - SpringApplicationBuilder builder = new SpringApplicationBuilder(TestConfig.class) - .properties(addDefaultEnv(env)); - return builder; - } - - private String[] addDefaultEnv(String[] env) { - Set set = new LinkedHashSet<>(); - if (env != null && env.length > 0) { - set.addAll(Arrays.asList(env)); - } - set.add("spring.config.import=classpath:bootstrapper.yaml"); - set.add("spring.cloud.config.enabled=true"); - set.add("spring.cloud.service-registry.auto-registration.enabled=false"); - set.add("eureka.client.serviceUrl.defaultZone=http://" + mockServer.getHost() + ":" - + mockServer.getMappedPort(MockServerContainer.PORT)); - return set.toArray(new String[0]); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - static class TestConfig { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperTests.java deleted file mode 100644 index 9f173aa51..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaConfigServerBootstrapperTests.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.apache.commons.logging.Log; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.context.properties.bind.BindHandler; -import org.springframework.boot.context.properties.bind.Binder; -import org.springframework.cloud.config.client.ConfigClientProperties; -import org.springframework.cloud.config.client.ConfigServerInstanceProvider; -import org.springframework.web.client.ResourceAccessException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -import static org.mockito.Mockito.mock; - -class EurekaConfigServerBootstrapperTests { - - @Test - void notEnabledReturnsEmptyList() { - new SpringApplicationBuilder(TestConfig.class) - .properties("spring.cloud.service-registry.auto-registration.enabled=false") - .addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> { - ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext() - .get(ConfigServerInstanceProvider.Function.class); - assertThat(providerFn.apply("id")).as("Should return empty list").isEmpty(); - })).run().close(); - } - - @Test - public void discoveryClientNotEnabledProvidesEmptyList() { - new SpringApplicationBuilder(TestConfig.class) - .properties("spring.cloud.config.discovery.enabled=true", "spring.cloud.discovery.enabled=false", - "spring.cloud.service-registry.auto-registration.enabled=false") - .addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> { - ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext() - .get(ConfigServerInstanceProvider.Function.class); - Binder binder = event.getBootstrapContext().get(Binder.class); - BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class); - assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class))) - .as("Should return empty list").isEmpty(); - })).run().close(); - } - - @Test - public void eurekaClientNotEnabledProvidesEmptyList() { - new SpringApplicationBuilder(TestConfig.class) - .properties("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false", - "spring.cloud.service-registry.auto-registration.enabled=false") - .addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> { - ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext() - .get(ConfigServerInstanceProvider.Function.class); - Binder binder = event.getBootstrapContext().get(Binder.class); - BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class); - assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class))) - .as("Should return empty list").isEmpty(); - })).run().close(); - } - - @Test - void enabledAddsInstanceProviderFn() { - new SpringApplicationBuilder(TestConfig.class) - .properties("spring.config.import: classpath:bootstrapper.yaml", - ConfigClientProperties.PREFIX + ".enabled=true") - .addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> { - ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext() - .get(ConfigServerInstanceProvider.Function.class); - Binder binder = event.getBootstrapContext().get(Binder.class); - BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class); - assertThatThrownBy(() -> providerFn.apply("id", binder, bindHandler, mock(Log.class))) - .isInstanceOf(ResourceAccessException.class) - .hasMessageContaining("I/O error on GET request for \"http://localhost:8761/eureka/apps/\"") - .as("Should have tried to connect to Eureka to fetch instances."); - })).run().close(); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - static class TestConfig { - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationNoWebfluxTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationNoWebfluxTest.java deleted file mode 100644 index 9e40ca5d6..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationNoWebfluxTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication; -import org.springframework.cloud.test.ClassPathExclusions; -import org.springframework.cloud.test.ModifiedClassPathRunner; -import org.springframework.context.ConfigurableApplicationContext; - -import static org.assertj.core.api.AssertionsForClassTypes.fail; -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; - -/** - * @author Daniel Lavoie - */ -@RunWith(ModifiedClassPathRunner.class) -@ClassPathExclusions({ "jersey-client-*", "jersey-core-*", "jersey-apache-client4-*", "spring-webflux-*" }) -@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) -public class EurekaHttpClientsOptionalArgsConfigurationNoWebfluxTest { - - @Test - public void contextFailsWithoutWebClient() { - - ConfigurableApplicationContext ctx = null; - try { - TomcatURLStreamHandlerFactory.disable(); - ctx = new SpringApplicationBuilder(EurekaSampleApplication.class) - .properties("eureka.client.webclient.enabled=true").run(); - fail("exception not thrown"); - } - catch (Exception e) { - // this is the desired state - assertThat(e).hasStackTraceContaining("WebClient is not on the classpath"); - } - if (ctx != null) { - ctx.close(); - } - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationTest.java deleted file mode 100644 index fd4cac894..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/EurekaHttpClientsOptionalArgsConfigurationTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.cloud.netflix.eureka.http.RestTemplateDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.http.WebClientDiscoveryClientOptionalArgs; -import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication; -import org.springframework.cloud.test.ClassPathExclusions; -import org.springframework.cloud.test.ModifiedClassPathRunner; - -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; - -/** - * @author Daniel Lavoie - */ -@RunWith(ModifiedClassPathRunner.class) -@ClassPathExclusions({ "jersey-client-*", "jersey-core-*", "jersey-apache-client4-*" }) -@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) -public class EurekaHttpClientsOptionalArgsConfigurationTest { - - @Test - public void contextLoadsWithRestTemplate() { - new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class) - .withPropertyValues("eureka.client.webclient.enabled=false").run(context -> { - assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class); - assertThat(context).doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class); - }); - } - - @Test - public void contextLoadsWithWebClient() { - new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class) - .withPropertyValues("eureka.client.webclient.enabled=true").run(context -> { - assertThat(context).doesNotHaveBean(RestTemplateDiscoveryClientOptionalArgs.class); - assertThat(context).hasSingleBean(WebClientDiscoveryClientOptionalArgs.class); - }); - } - - @Test - public void contextLoadsWithRestTemplateAsDefault() { - new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class).run(context -> { - assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class); - assertThat(context).doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class); - }); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/JerseyOptionalArgsConfigurationTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/JerseyOptionalArgsConfigurationTest.java deleted file mode 100644 index 177502c49..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/config/JerseyOptionalArgsConfigurationTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.config; - -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.netflix.eureka.sample.EurekaSampleApplication; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Daniel Lavoie - */ -@DirtiesContext -@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) -class JerseyOptionalArgsConfigurationTest { - - @Autowired - private AbstractDiscoveryClientOptionalArgs optionalArgs; - - @Test - void contextLoads() { - assertThat(optionalArgs).isNotNull(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/healthcheck/EurekaHealthCheckTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/healthcheck/EurekaHealthCheckTests.java deleted file mode 100644 index 34e81a556..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/healthcheck/EurekaHealthCheckTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.healthcheck; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.annotation.DirtiesContext; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests the Eureka health check handler. - * - * @author Jakub Narloch - * @author Olga Maciaszek-Sharma - */ -@SpringBootTest(classes = EurekaHealthCheckTests.EurekaHealthCheckApplication.class, - webEnvironment = WebEnvironment.RANDOM_PORT, value = { "eureka.client.healthcheck.enabled=true", "debug=true" }) -@DirtiesContext -class EurekaHealthCheckTests { - - @Autowired - private EurekaClient discoveryClient; - - @Test - void shouldRegisterService() { - System.setProperty("status", "UP"); - - InstanceInfo.InstanceStatus status = this.discoveryClient.getHealthCheckHandler() - .getStatus(InstanceInfo.InstanceStatus.UNKNOWN); - - assertThat(status).isNotNull(); - assertThat(status).isEqualTo(InstanceInfo.InstanceStatus.UP); - } - - @Test - void shouldMapOutOfServiceToDown() { - System.setProperty("status", "OUT_OF_SERVICE"); - - InstanceInfo.InstanceStatus status = this.discoveryClient.getHealthCheckHandler() - .getStatus(InstanceInfo.InstanceStatus.UNKNOWN); - - assertThat(status).isNotNull(); - assertThat(status).isEqualTo(InstanceInfo.InstanceStatus.DOWN); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - protected static class EurekaHealthCheckApplication { - - @Bean - public HealthIndicator healthIndicator() { - return () -> new Health.Builder().status(System.getProperty("status")).build(); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/AbstractEurekaHttpClientTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/AbstractEurekaHttpClientTests.java deleted file mode 100644 index 104331c15..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/AbstractEurekaHttpClientTests.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.shared.Applications; -import com.netflix.discovery.shared.transport.EurekaHttpClient; -import com.netflix.discovery.shared.transport.EurekaHttpResponse; -import org.junit.jupiter.api.Test; - -import org.springframework.http.HttpStatus; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Haytham Mohamed - **/ -abstract class AbstractEurekaHttpClientTests { - - protected EurekaHttpClient eurekaHttpClient; - - protected InstanceInfo info; - - abstract void setup(); - - @Test - void testRegister() { - assertThat(eurekaHttpClient.register(info).getStatusCode()).isEqualTo(HttpStatus.OK.value()); - } - - @Test - void testCancel() { - assertThat(eurekaHttpClient.cancel("test", "test").getStatusCode()).isEqualTo(HttpStatus.OK.value()); - } - - @Test - void testSendHeartBeat() { - EurekaHttpResponse response = eurekaHttpClient.sendHeartBeat("test", "test", info, null); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK.value()); - assertThat(response.getEntity()).isNotNull(); - } - - @Test - void testSendHeartBeatFourOFour() { - assertThat(eurekaHttpClient.sendHeartBeat("fourOFour", "test", info, null).getStatusCode()) - .isEqualTo(HttpStatus.NOT_FOUND.value()); - } - - @Test - void testSendHeartBeatFourOFourWithBody() { - assertThat(eurekaHttpClient.sendHeartBeat("fourOFourWithBody", "test", info, null).getStatusCode()) - .isEqualTo(HttpStatus.NOT_FOUND.value()); - } - - @Test - void testStatusUpdate() { - assertThat(eurekaHttpClient.statusUpdate("test", "test", InstanceInfo.InstanceStatus.UP, info).getStatusCode()) - .isEqualTo(HttpStatus.OK.value()); - } - - @Test - void testDeleteStatusOverride() { - assertThat(eurekaHttpClient.deleteStatusOverride("test", "test", info).getStatusCode()) - .isEqualTo(HttpStatus.OK.value()); - } - - @Test - void testGetApplications() { - Applications entity = eurekaHttpClient.getApplications().getEntity(); - assertThat(entity).isNotNull(); - assertThat(eurekaHttpClient.getApplications("us", "eu").getEntity()).isNotNull(); - } - - @Test - void testGetDelta() { - eurekaHttpClient.getDelta().getEntity(); - eurekaHttpClient.getDelta("us", "eu").getEntity(); - } - - @Test - void testGetVips() { - eurekaHttpClient.getVip("test"); - eurekaHttpClient.getVip("test", "us", "eu"); - } - - @Test - void testGetSecureVip() { - eurekaHttpClient.getSecureVip("test"); - eurekaHttpClient.getSecureVip("test", "us", "eu"); - } - - @Test - void testGetApplication() { - eurekaHttpClient.getApplication("test"); - } - - @Test - void testGetInstance() { - eurekaHttpClient.getInstance("test"); - eurekaHttpClient.getInstance("test", "test"); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/EurekaServerMockApplication.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/EurekaServerMockApplication.java deleted file mode 100644 index 5534f6278..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/EurekaServerMockApplication.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.Collections; -import java.util.HashMap; - -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.LeaseInfo; -import com.netflix.appinfo.MyDataCenterInfo; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.provisioning.InMemoryUserDetailsManager; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import static com.netflix.appinfo.InstanceInfo.DEFAULT_PORT; -import static com.netflix.appinfo.InstanceInfo.DEFAULT_SECURE_PORT; -import static org.springframework.util.Assert.isTrue; - -/** - * Mocked Eureka Server. - * - * @author Daniel Lavoie - */ -@Configuration(proxyBeanMethods = false) -@RestController -@RequestMapping("/eureka") -@SpringBootApplication -public class EurekaServerMockApplication { - - private static final InstanceInfo INFO = InstanceInfo.Builder.newBuilder().setInstanceId("app1instance1") - .setAppName("app1").setAppNameForDeser("app1fordeser").setAppGroupName("app1group") - .setAppGroupNameForDeser("app1group1fordeser").setHostName("app1host1") - .setStatus(InstanceInfo.InstanceStatus.UP).setOverriddenStatus(InstanceInfo.InstanceStatus.DOWN) - .setIPAddr("127.0.0.1").setSID("app1sid").setPort(8080).setSecurePort(4443) - .enablePort(InstanceInfo.PortType.UNSECURE, true).setHomePageUrl("/", "http://localhost/") - .setHomePageUrlForDeser("http://localhost/").setStatusPageUrl("/status", "http://localhost/info") - .setStatusPageUrlForDeser("http://localhost/status") - .setHealthCheckUrls("/ping", "http://localhost/ping", null) - .setHealthCheckUrlsForDeser("http://localhost/ping", null).setVIPAddress("localhost:8080") - .setVIPAddressDeser("localhost:8080").setSecureVIPAddress("localhost:4443") - .setSecureVIPAddressDeser("localhost:4443") - .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)) - .setLeaseInfo(LeaseInfo.Builder.newBuilder().setDurationInSecs(30).setRenewalIntervalInSecs(30) - .setEvictionTimestamp(System.currentTimeMillis() + 30000) - .setRenewalTimestamp(System.currentTimeMillis() - 1000) - .setRegistrationTimestamp(System.currentTimeMillis() - 2000).build()) - .add("metadatakey1", "metadatavalue1").setASGName("asg1").setIsCoordinatingDiscoveryServer(false) - .setLastUpdatedTimestamp(System.currentTimeMillis()).setLastDirtyTimestamp(System.currentTimeMillis()) - .setActionType(InstanceInfo.ActionType.ADDED).setNamespace("namespace1").build(); - - /** - * Simulates Eureka Server own's serialization. - * @return converter - */ - @Bean - public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() { - return new RestTemplateTransportClientFactory().mappingJacksonHttpMessageConverter(); - } - - @ResponseStatus(HttpStatus.OK) - @PostMapping("/apps/{appName}") - public void register(@PathVariable String appName, @RequestBody InstanceInfo instanceInfo) { - isTrue(instanceInfo.getPort() != DEFAULT_PORT && instanceInfo.getPort() != 0, "Port not received from client"); - isTrue(instanceInfo.getSecurePort() != DEFAULT_SECURE_PORT && instanceInfo.getSecurePort() != 0, - "Secure Port not received from client"); - // Nothing to do - } - - @ResponseStatus(HttpStatus.OK) - @DeleteMapping("/apps/{appName}/{id}") - public void cancel(@PathVariable String appName, @PathVariable String id) { - - } - - @ResponseStatus(HttpStatus.OK) - @PutMapping(value = "/apps/{appName}/{id}", params = { "status", "lastDirtyTimestamp" }) - public ResponseEntity sendHeartBeat(@PathVariable String appName, @PathVariable String id, - @RequestParam String status, @RequestParam String lastDirtyTimestamp, - @RequestParam(required = false) String overriddenstatus) { - if ("fourOFour".equals(appName)) { - return new ResponseEntity(HttpStatus.NOT_FOUND); - } - if ("fourOFourWithBody".equals(appName)) { - return new ResponseEntity( - "{ \"error\": \"Not Found\", \"message\": null, \"path\": \"/1\", \"requestId\": \"9e5d3244-1\", \"status\": 404, \"timestamp\": \"2023-03-04T03:31:20.810+00:00\" }", - HttpStatus.NOT_FOUND); - } - return new ResponseEntity<>(new InstanceInfo(null, null, null, null, null, null, null, null, null, null, null, - null, null, 0, null, null, null, null, null, null, null, new HashMap<>(), 0L, 0L, null, null), - HttpStatus.OK); - } - - @ResponseStatus(HttpStatus.OK) - @PutMapping(value = "/apps/{appName}/{id}/status", params = { "value", "lastDirtyTimestamp" }) - public void statusUpdate(@PathVariable String appName, @PathVariable String id, @RequestParam String value, - @RequestParam String lastDirtyTimestamp) { - - } - - @ResponseStatus(HttpStatus.OK) - @DeleteMapping(value = "/apps/{appName}/{id}/status", params = "lastDirtyTimestamp") - public void deleteStatusOverride(@PathVariable String appName, @PathVariable String id, - @RequestParam String lastDirtyTimestamp) { - - } - - @GetMapping({ "/apps/", "/apps/delta", "/vips/{address}", "/svips/{address}" }) - public Applications getApplications(@PathVariable(required = false) String address, - @RequestParam(required = false) String regions) { - Applications applications = new Applications(); - applications.addApplication(new Application("app1", Collections.singletonList(INFO))); - return applications; - } - - @GetMapping("/apps/{appName}") - public Application getApplication(@PathVariable String appName) { - return new Application(); - } - - @GetMapping({ "/apps/{appName}/{id}", "/instances/{id}" }) - public InstanceInfo getInstance(@PathVariable(required = false) String appName, @PathVariable String id) { - return INFO; - } - - @Configuration(proxyBeanMethods = false) - @Order(Ordered.HIGHEST_PRECEDENCE) - protected static class TestSecurityConfiguration { - - @Bean - public InMemoryUserDetailsManager userDetailsService() { - UserDetails user = User.withDefaultPasswordEncoder().username("test").password("test").roles("USER") - .build(); - return new InMemoryUserDetailsManager(user); - } - - @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - // @formatter:off - http - .securityMatcher("/v2/apps/**") - .httpBasic(); - // @formatter:on - return http.build(); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClientTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClientTests.java deleted file mode 100644 index 8c6f32b82..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateEurekaHttpClientTests.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import java.util.List; - -import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider; -import com.netflix.discovery.shared.resolver.DefaultEndpoint; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.support.BasicAuthenticationInterceptor; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.client.RestTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Daniel Lavoie - */ -@SpringBootTest(classes = EurekaServerMockApplication.class, - properties = { "debug=true", "security.basic.enabled=true", "eureka.client.fetch-registry=false", - "eureka.client.register-with-eureka=false", "logging.level.org.springframework=INFO" }, - webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -class RestTemplateEurekaHttpClientTests extends AbstractEurekaHttpClientTests { - - @Autowired - private InetUtils inetUtils; - - @Value("http://${security.user.name}:${security.user.password}@localhost:${local.server.port}/eureka") - private String serviceUrl; - - @BeforeEach - void setup() { - eurekaHttpClient = new RestTemplateTransportClientFactory().newClient(new DefaultEndpoint(serviceUrl)); - - EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils); - - String appname = "customapp"; - config.setIpAddress("127.0.0.1"); - config.setHostname("localhost"); - config.setAppname(appname); - config.setVirtualHostName(appname); - config.setSecureVirtualHostName(appname); - config.setNonSecurePort(4444); - config.setSecurePort(8443); - config.setInstanceId("127.0.0.1:customapp:4444"); - - info = new EurekaConfigBasedInstanceInfoProvider(config).get(); - } - - @Test - void basicAuth() { - assertThat(eurekaHttpClient).isInstanceOf(RestTemplateEurekaHttpClient.class); - RestTemplateEurekaHttpClient restTemplateEurekaHttpClient = (RestTemplateEurekaHttpClient) eurekaHttpClient; - RestTemplate restTemplate = restTemplateEurekaHttpClient.getRestTemplate(); - List interceptors = restTemplate.getInterceptors(); - boolean hasBasicAuth = interceptors.stream() - .anyMatch(interceptor -> interceptor instanceof BasicAuthenticationInterceptor); - assertThat(hasBasicAuth).as("Basic Auth not configured").isTrue(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactoryTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactoryTest.java deleted file mode 100644 index 33d1b7af0..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/RestTemplateTransportClientFactoryTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import com.netflix.discovery.shared.resolver.DefaultEndpoint; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -/** - * @author Daniel Lavoie - */ -class RestTemplateTransportClientFactoryTest { - - private RestTemplateTransportClientFactory transportClientFatory; - - @BeforeEach - void setup() { - transportClientFatory = new RestTemplateTransportClientFactory(); - } - - @Test - void testWithoutUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://localhost:8761")); - } - - @Test - void testInvalidUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://test@localhost:8761")); - } - - @Test - void testUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://test:test@localhost:8761")); - } - - @AfterEach - void shutdown() { - transportClientFatory.shutdown(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClientTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClientTests.java deleted file mode 100644 index 3dd7030cf..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientEurekaHttpClientTests.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider; -import com.netflix.discovery.shared.resolver.DefaultEndpoint; -import org.junit.jupiter.api.BeforeEach; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Daniel Lavoie - */ -@SpringBootTest(classes = EurekaServerMockApplication.class, - properties = { "debug=true", "security.basic.enabled=true", "eureka.client.webclient.enabled=true", - "eureka.client.fetch-registry=false", "eureka.client.register-with-eureka=false" }, - webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -class WebClientEurekaHttpClientTests extends AbstractEurekaHttpClientTests { - - @Autowired - private InetUtils inetUtils; - - @Value("http://${security.user.name}:${security.user.password}@localhost:${local.server.port}/eureka/") - private String serviceUrl; - - @BeforeEach - void setup() { - eurekaHttpClient = new WebClientTransportClientFactory(WebClient::builder) - .newClient(new DefaultEndpoint(serviceUrl)); - - EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils); - - String appname = "customapp"; - config.setIpAddress("127.0.0.1"); - config.setHostname("localhost"); - config.setAppname(appname); - config.setVirtualHostName(appname); - config.setSecureVirtualHostName(appname); - config.setNonSecurePort(4444); - config.setSecurePort(8443); - config.setInstanceId("127.0.0.1:customapp:4444"); - - info = new EurekaConfigBasedInstanceInfoProvider(config).get(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactoryTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactoryTest.java deleted file mode 100644 index b7d2d17ba..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/http/WebClientTransportClientFactoryTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.http; - -import com.netflix.discovery.shared.resolver.DefaultEndpoint; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Daniel Lavoie - */ -class WebClientTransportClientFactoryTest { - - private WebClientTransportClientFactory transportClientFatory; - - @BeforeEach - void setup() { - transportClientFatory = new WebClientTransportClientFactory(WebClient::builder); - } - - @Test - void testWithoutUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://localhost:8761")); - } - - @Test - void testInvalidUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://test@localhost:8761")); - } - - @Test - void testUserInfo() { - transportClientFatory.newClient(new DefaultEndpoint("http://test:test@localhost:8761")); - } - - @AfterEach - void shutdown() { - transportClientFatory.shutdown(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfigurationTests.java deleted file mode 100644 index 1b6bf181a..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/loadbalancer/EurekaLoadBalancerClientConfigurationTests.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.loadbalancer; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.commons.util.InetUtilsProperties; -import org.springframework.cloud.loadbalancer.config.LoadBalancerZoneConfig; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link EurekaLoadBalancerClientConfiguration}. - * - * @author Olga Maciaszek-Sharma - */ -class EurekaLoadBalancerClientConfigurationTests { - - private final EurekaClientConfigBean eurekaClientConfig = new EurekaClientConfigBean(); - - private final EurekaInstanceConfigBean eurekaInstanceConfig = new EurekaInstanceConfigBean( - new InetUtils(new InetUtilsProperties())); - - private final LoadBalancerZoneConfig zoneConfig = new LoadBalancerZoneConfig(null); - - private final EurekaLoadBalancerProperties eurekaLoadBalancerProperties = new EurekaLoadBalancerProperties(); - - private final EurekaLoadBalancerClientConfiguration postprocessor = new EurekaLoadBalancerClientConfiguration( - eurekaClientConfig, eurekaInstanceConfig, zoneConfig, eurekaLoadBalancerProperties); - - @Test - void shouldSetZoneFromInstanceMetadata() { - eurekaInstanceConfig.getMetadataMap().put("zone", "myZone"); - - postprocessor.postprocess(); - - assertThat(zoneConfig.getZone()).isEqualTo("myZone"); - } - - @Test - void shouldSetZoneToDefaultWhenNotSetInMetadata() { - postprocessor.postprocess(); - - assertThat(zoneConfig.getZone()).isEqualTo("defaultZone"); - } - - @Test - void shouldResolveApproximateZoneFromHost() { - eurekaInstanceConfig.setHostname("this.is.a.test.com"); - eurekaLoadBalancerProperties.setApproximateZoneFromHostname(true); - - postprocessor.postprocess(); - - assertThat(zoneConfig.getZone()).isEqualTo("is.a.test.com"); - } - - @Test - void disabledViaProperty() { - new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(LoadBalancerEurekaAutoConfiguration.class)) - .withPropertyValues("eureka.client.enabled=false").run(context -> { - assertThat(context).doesNotHaveBean(EurekaLoadBalancerProperties.class); - assertThat(context).doesNotHaveBean(LoadBalancerZoneConfig.class); - }); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProviderTest.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProviderTest.java deleted file mode 100644 index c002b695f..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProviderTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.metadata; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class DefaultManagementMetadataProviderTest { - - private static final EurekaInstanceConfigBean INSTANCE = mock(EurekaInstanceConfigBean.class); - - private final ManagementMetadataProvider provider = new DefaultManagementMetadataProvider(); - - @BeforeEach - void setUp() { - when(INSTANCE.getHostname()).thenReturn("host"); - when(INSTANCE.getHealthCheckUrlPath()).thenReturn("health"); - when(INSTANCE.getStatusPageUrlPath()).thenReturn("info"); - when(INSTANCE.isSecurePortEnabled()).thenReturn(false); - } - - @Test - void serverPortIsRandomAndManagementPortIsNull() { - int serverPort = 0; - String serverContextPath = "/"; - String managementContextPath = null; - Integer managementPort = null; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual).isNull(); - } - - @Test - void managementPortIsRandom() { - int serverPort = 0; - String serverContextPath = "/"; - String managementContextPath = null; - Integer managementPort = 0; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual).isNull(); - } - - @Test - void serverPort() { - int serverPort = 7777; - String serverContextPath = "/"; - String managementContextPath = null; - Integer managementPort = null; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:7777/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:7777/info"); - assertThat(actual.getManagementPort()).isEqualTo(7777); - } - - @Test - void serverPortManagementPort() { - int serverPort = 7777; - String serverContextPath = "/"; - String managementContextPath = null; - Integer managementPort = 8888; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:8888/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:8888/info"); - assertThat(actual.getManagementPort()).isEqualTo(8888); - } - - @Test - void serverPortManagementPortServerContextPath() { - int serverPort = 7777; - String serverContextPath = "/Server"; - String managementContextPath = null; - Integer managementPort = 8888; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:8888/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:8888/info"); - assertThat(actual.getManagementPort()).isEqualTo(8888); - } - - @Test - void serverPortManagementPortServerContextPathManagementContextPath() { - int serverPort = 7777; - String serverContextPath = "/Server"; - String managementContextPath = "/Management"; - Integer managementPort = 8888; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:8888/Management/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:8888/Management/info"); - assertThat(actual.getManagementPort()).isEqualTo(8888); - } - - @Test - void serverPortServerContextPathManagementContextPath() { - int serverPort = 7777; - String serverContextPath = "/Server"; - String managementContextPath = "/Management"; - Integer managementPort = null; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:7777/Server/Management/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:7777/Server/Management/info"); - assertThat(actual.getManagementPort()).isEqualTo(7777); - } - - @Test - void serverPortManagementContextPath() { - int serverPort = 7777; - String serverContextPath = "/"; - String managementContextPath = "/Management"; - Integer managementPort = null; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:7777/Management/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:7777/Management/info"); - assertThat(actual.getManagementPort()).isEqualTo(7777); - } - - @Test - void serverPortServerContextPath() { - int serverPort = 7777; - String serverContextPath = "/Server"; - String managementContextPath = null; - Integer managementPort = null; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:7777/Server/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:7777/Server/info"); - assertThat(actual.getManagementPort()).isEqualTo(7777); - } - - @Test - void serverPortManagementPortManagementContextPath() { - int serverPort = 7777; - String serverContextPath = "/"; - String managementContextPath = "/Management"; - Integer managementPort = 8888; - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:8888/Management/health"); - assertThat(actual.getSecureHealthCheckUrl()).isNullOrEmpty(); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:8888/Management/info"); - assertThat(actual.getManagementPort()).isEqualTo(8888); - - } - - @Test - void setSecureHealthCheckUrl() { - int serverPort = 7777; - String serverContextPath = "/"; - String managementContextPath = "/Management"; - Integer managementPort = 8888; - doReturn(true).when(INSTANCE).isSecurePortEnabled(); - ManagementMetadata actual = provider.get(INSTANCE, serverPort, serverContextPath, managementContextPath, - managementPort); - - assertThat(actual.getHealthCheckUrl()).isEqualTo("http://host:8888/Management/health"); - assertThat(actual.getSecureHealthCheckUrl()).isEqualTo("https://host:8888/Management/health"); - assertThat(actual.getStatusPageUrl()).isEqualTo("http://host:8888/Management/info"); - assertThat(actual.getManagementPort()).isEqualTo(8888); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfigurationTests.java deleted file mode 100644 index 2a80deab8..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientConfigurationTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.reactive; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration; -import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; -import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator; -import org.springframework.cloud.commons.util.UtilAutoConfiguration; -import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration; -import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Tim Ysewyn - */ -class EurekaReactiveDiscoveryClientConfigurationTests { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class, - ReactiveCommonsClientAutoConfiguration.class, EurekaClientAutoConfiguration.class, - DiscoveryClientOptionalArgsConfiguration.class, EurekaReactiveDiscoveryClientConfiguration.class)); - - @Test - void shouldWorkWithDefaults() { - contextRunner.run(context -> { - assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); - assertThat(context).hasSingleBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - - @Test - void shouldNotHaveDiscoveryClientWhenDiscoveryDisabled() { - contextRunner.withPropertyValues("spring.cloud.discovery.enabled=false").run(context -> { - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - - @Test - void shouldNotHaveDiscoveryClientWhenReactiveDiscoveryDisabled() { - contextRunner.withPropertyValues("spring.cloud.discovery.reactive.enabled=false").run(context -> { - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - - @Test - void shouldNotHaveDiscoveryClientWhenEurekaClientDisabled() { - contextRunner.withPropertyValues("eureka.client.enabled=false").run(context -> { - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - - @Test - void worksWithoutWebflux() { - contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.reactive")).run(context -> { - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClient.class); - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - - @Test - void worksWithoutActuator() { - contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.boot.actuate")).run(context -> { - assertThat(context).hasSingleBean(ReactiveDiscoveryClient.class); - assertThat(context).doesNotHaveBean(ReactiveDiscoveryClientHealthIndicator.class); - }); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientTests.java deleted file mode 100644 index 3fe553b87..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/reactive/EurekaReactiveDiscoveryClientTests.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2019-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.reactive; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import reactor.core.publisher.Flux; -import reactor.test.StepVerifier; - -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - -/** - * @author Tim Ysewyn - */ -@ExtendWith(MockitoExtension.class) -class EurekaReactiveDiscoveryClientTests { - - @Mock - private EurekaClient eurekaClient; - - @InjectMocks - private EurekaReactiveDiscoveryClient client; - - @Test - void verifyDefaults() { - assertThat(client.description()).isEqualTo("Spring Cloud Eureka Reactive Discovery Client"); - assertThat(client.getOrder()).isEqualTo(ReactiveDiscoveryClient.DEFAULT_ORDER); - } - - @Test - void verifyDefaultsWhenUsingEurekaClientConfigBean() { - EurekaClientConfigBean configBean = new EurekaClientConfigBean(); - configBean.setOrder(1); - EurekaReactiveDiscoveryClient client = new EurekaReactiveDiscoveryClient(eurekaClient, configBean); - assertThat(client.description()).isEqualTo("Spring Cloud Eureka Reactive Discovery Client"); - assertThat(client.getOrder()).isEqualTo(1); - } - - @Test - void shouldReturnEmptyFluxOfServices() { - when(eurekaClient.getApplications()).thenReturn(new Applications()); - Flux services = this.client.getServices(); - StepVerifier.create(services).expectNextCount(0).expectComplete().verify(); - } - - @Test - void shouldReturnEmptyFluxOfServicesWhenNoInstancesFound() { - Applications applications = new Applications(); - applications.addApplication(new Application("my-service")); - when(eurekaClient.getApplications()).thenReturn(applications); - Flux services = this.client.getServices(); - StepVerifier.create(services).expectNextCount(0).expectComplete().verify(); - } - - @Test - void shouldReturnFluxOfServices() { - Applications applications = new Applications(); - Application app = new Application("my-service"); - app.addInstance(new InstanceInfo("instance", "my-service", "", "127.0.0.1", "", null, null, "", "", "", "", "", - "", 0, null, "", null, null, null, null, null, null, null, null, null, null)); - applications.addApplication(app); - when(eurekaClient.getApplications()).thenReturn(applications); - Flux services = this.client.getServices(); - StepVerifier.create(services).expectNext("my-service").expectComplete().verify(); - } - - @Test - void shouldReturnEmptyFluxForNonExistingService() { - when(eurekaClient.getInstancesByVipAddress("nonexistent-service", false)).thenReturn(emptyList()); - Flux instances = this.client.getInstances("nonexistent-service"); - StepVerifier.create(instances).expectNextCount(0).expectComplete().verify(); - } - - @Test - void shouldReturnFluxOfServiceInstances() { - InstanceInfo instanceInfo = new InstanceInfo( - new InstanceInfo("instance", "my-service", "", "127.0.0.1", "", null, null, "", "", "", "", "", "", 0, - null, "", null, null, null, null, null, null, null, null, null, null)); - when(eurekaClient.getInstancesByVipAddress("my-service", false)).thenReturn(singletonList(instanceInfo)); - Flux instances = this.client.getInstances("my-service"); - StepVerifier.create(instances).expectNextCount(1).expectComplete().verify(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/ApplicationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/ApplicationTests.java deleted file mode 100644 index 89298fbb5..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/ApplicationTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.sample; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.annotation.DirtiesContext; - -@SpringBootTest(classes = EurekaSampleApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -class ApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/EurekaSampleApplication.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/EurekaSampleApplication.java deleted file mode 100644 index 8341b4c72..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/EurekaSampleApplication.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.sample; - -import java.io.Closeable; - -import com.netflix.appinfo.HealthCheckHandler; -import com.netflix.appinfo.InstanceInfo; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.cloud.client.serviceregistry.ServiceRegistry; -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -@Configuration(proxyBeanMethods = false) -@ComponentScan -@EnableAutoConfiguration -@RestController -public class EurekaSampleApplication implements ApplicationContextAware, Closeable { - - @Autowired - private DiscoveryClient discoveryClient; - - @Autowired - private ServiceRegistry serviceRegistry; - - @Autowired - private InetUtils inetUtils; - - @Autowired - private EurekaClientConfigBean clientConfig; - - private ApplicationContext context; - - private EurekaRegistration registration; - - @Bean - public HealthCheckHandler healthCheckHandler() { - return currentStatus -> InstanceInfo.InstanceStatus.UP; - } - - @RequestMapping("/") - public String home() { - return "Hello world " + registration.getUri(); - } - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - this.context = context; - } - - @RequestMapping(path = "/register", method = POST) - public String register() { - EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils); - String appname = "customapp"; - config.setIpAddress("127.0.0.1"); - config.setHostname("localhost"); - config.setAppname(appname); - config.setVirtualHostName(appname); - config.setSecureVirtualHostName(appname); - config.setNonSecurePort(4444); - config.setInstanceId("127.0.0.1:customapp:4444"); - - this.registration = EurekaRegistration.builder(config).with(this.clientConfig, this.context).build(); - - this.serviceRegistry.register(this.registration); - return config.getInstanceId(); - } - - @RequestMapping(path = "/deregister", method = POST) - public String deregister() { - this.serviceRegistry.deregister(this.registration); - return "deregister"; - } - - @Override - public void close() { - deregister(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/RefreshEurekaSampleApplication.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/RefreshEurekaSampleApplication.java deleted file mode 100644 index 4aa9a02d5..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/sample/RefreshEurekaSampleApplication.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.sample; - -import com.netflix.discovery.EurekaClient; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.cloud.netflix.eureka.CloudEurekaClient; -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.RestController; - -import static org.mockito.Mockito.mock; - -/** - * @author Ryan Baxter - */ -@SpringBootConfiguration(proxyBeanMethods = false) -@EnableAutoConfiguration -@RestController -public class RefreshEurekaSampleApplication { - - @Bean - public EurekaClient getClient() { - return mock(CloudEurekaClient.class); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistryTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistryTests.java deleted file mode 100644 index 072caed39..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/serviceregistry/EurekaServiceRegistryTests.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.serviceregistry; - -import java.util.Map; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.InstanceInfo; -import org.junit.jupiter.api.Test; - -import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.cloud.commons.util.InetUtilsProperties; -import org.springframework.cloud.netflix.eureka.CloudEurekaClient; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; -import org.springframework.context.ApplicationEventPublisher; - -import static com.netflix.appinfo.InstanceInfo.InstanceStatus.DOWN; -import static com.netflix.appinfo.InstanceInfo.InstanceStatus.OUT_OF_SERVICE; -import static com.netflix.appinfo.InstanceInfo.InstanceStatus.UNKNOWN; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.when; - -/** - * @author Spencer Gibb - * @author Tim Ysewyn - */ -class EurekaServiceRegistryTests { - - @Test - void eurekaClientNotShutdownInDeregister() { - EurekaServiceRegistry registry = new EurekaServiceRegistry(); - - CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class); - ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class); - - when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class)); - - EurekaRegistration registration = EurekaRegistration - .builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()))).with(eurekaClient) - .with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) - .build(); - - registry.deregister(registration); - - verifyNoInteractions(eurekaClient); - } - - @SuppressWarnings("unchecked") - @Test - void eurekaClientGetStatus() { - EurekaServiceRegistry registry = new EurekaServiceRegistry(); - - EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())); - config.setAppname("myapp"); - config.setInstanceId("1234"); - - InstanceInfo local = InstanceInfo.Builder.newBuilder().setAppName("myapp").setInstanceId("1234").setStatus(DOWN) - .build(); - - InstanceInfo remote = InstanceInfo.Builder.newBuilder().setAppName("myapp").setInstanceId("1234") - .setStatus(DOWN).setOverriddenStatus(OUT_OF_SERVICE).build(); - - CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class); - when(eurekaClient.getInstanceInfo(local.getAppName(), local.getId())).thenReturn(remote); - - ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class); - when(applicationInfoManager.getInfo()).thenReturn(local); - - EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient) - .with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) - .build(); - - Object status = registry.getStatus(registration); - - assertThat(registration.getInstanceId()).isEqualTo("1234"); - - assertThat(status).isInstanceOf(Map.class); - - Map map = (Map) status; - - assertThat(map).hasSize(2).containsEntry("status", DOWN.toString()).containsEntry("overriddenStatus", - OUT_OF_SERVICE.toString()); - } - - @SuppressWarnings("unchecked") - @Test - void eurekaClientGetStatusNoInstance() { - EurekaServiceRegistry registry = new EurekaServiceRegistry(); - - EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())); - config.setAppname("myapp"); - config.setInstanceId("1234"); - - CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class); - - when(eurekaClient.getInstanceInfo("myapp", "1234")).thenReturn(null); - - ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class); - when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class)); - - EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient) - .with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)) - .build(); - - Object status = registry.getStatus(registration); - - assertThat(registration.getInstanceId()).isEqualTo("1234"); - - assertThat(status).isInstanceOf(Map.class); - - Map map = (Map) status; - - assertThat(map).hasSize(1).containsEntry("status", UNKNOWN.toString()); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/support/ZoneUtilsTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/support/ZoneUtilsTests.java deleted file mode 100644 index e3a94e75d..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/support/ZoneUtilsTests.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.support; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Ryan Baxter - * - */ -class ZoneUtilsTests { - - @Test - void extractApproximateZoneTest() { - assertThat("foo".equals(ZoneUtils.extractApproximateZone("foo"))).isTrue(); - assertThat("bar".equals(ZoneUtils.extractApproximateZone("foo.bar"))).isTrue(); - assertThat("world.foo.bar".equals(ZoneUtils.extractApproximateZone("hello.world.foo.bar"))).isTrue(); - } - -} diff --git a/spring-cloud-netflix-eureka-client/src/test/resources/application.yml b/spring-cloud-netflix-eureka-client/src/test/resources/application.yml deleted file mode 100644 index 3e83e31a8..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/resources/application.yml +++ /dev/null @@ -1,12 +0,0 @@ -# for EurekaRibbonClientPropertyOverrideIntegrationTests -foo3: - ribbon: - NFLoadBalancerPingClassName: com.netflix.loadbalancer.DummyPing - NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList - -security: - basic: - enabled: false - user: - name: test - password: test \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-client/src/test/resources/bootstrapper.yaml b/spring-cloud-netflix-eureka-client/src/test/resources/bootstrapper.yaml deleted file mode 100644 index a08f17cb3..000000000 --- a/spring-cloud-netflix-eureka-client/src/test/resources/bootstrapper.yaml +++ /dev/null @@ -1,12 +0,0 @@ -spring: - config: - import: "optional:configserver:" - cloud: - config: - enabled: true - discovery: - service-id: eureka-configserver - enabled: true - service-registry: - auto-registration: - enabled: false \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/.flattened-pom.xml b/spring-cloud-netflix-eureka-server/.flattened-pom.xml new file mode 100644 index 000000000..e5251b89e --- /dev/null +++ b/spring-cloud-netflix-eureka-server/.flattened-pom.xml @@ -0,0 +1,212 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + .. + + org.springframework.cloud + spring-cloud-netflix-eureka-server + 4.1.0-SNAPSHOT + Spring Cloud Netflix Eureka Server + Spring Cloud Netflix + https://projects.spring.io/spring-cloud/ + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-server + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-netflix-eureka-server + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-netflix-eureka-server + + + + org.springframework.boot + spring-boot-configuration-processor + 3.2.0-SNAPSHOT + compile + true + + + org.springframework.boot + spring-boot-starter-web + 3.2.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot-starter-actuator + 3.2.0-SNAPSHOT + compile + + + org.springframework.boot + spring-boot-starter-freemarker + 3.2.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-commons + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-context + 4.1.0-SNAPSHOT + compile + true + + + org.springframework.cloud + spring-cloud-netflix-eureka-client + 4.1.0-SNAPSHOT + compile + + + com.netflix.eureka + eureka-client-jersey3 + 2.0.1 + compile + + + aopalliance + aopalliance + + + + + com.netflix.eureka + eureka-core-jersey3 + 2.0.1 + compile + + + org.glassfish.jersey.containers + jersey-container-servlet + 3.1.3 + compile + + + org.glassfish.jersey.core + jersey-server + 3.1.3 + compile + + + org.glassfish.jersey.core + jersey-client + 3.1.3 + compile + + + org.glassfish.jersey.inject + jersey-hk2 + 3.1.3 + compile + + + org.glassfish.hk2 + spring-bridge + 3.0.3 + compile + + + jakarta.inject + jakarta.inject-api + 2.0.1 + compile + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 + compile + + + org.springframework.boot + spring-boot-autoconfigure-processor + 3.2.0-SNAPSHOT + compile + true + + + diff --git a/spring-cloud-netflix-eureka-server/pom.xml b/spring-cloud-netflix-eureka-server/pom.xml deleted file mode 100644 index e8958533b..000000000 --- a/spring-cloud-netflix-eureka-server/pom.xml +++ /dev/null @@ -1,218 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - .. - - spring-cloud-netflix-eureka-server - Spring Cloud Netflix Eureka Server - https://projects.spring.io/spring-cloud/ - - 1.10.1 - 2.27.2 - - true - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-freemarker - - - org.springframework.cloud - spring-cloud-commons - - - org.springframework.cloud - spring-cloud-context - true - - - org.springframework.cloud - spring-cloud-netflix-eureka-client - - - com.netflix.eureka - eureka-client-jersey3 - - - com.netflix.eureka - eureka-core-jersey3 - - - org.glassfish.jersey.containers - jersey-container-servlet - - - org.glassfish.jersey.core - jersey-server - - - org.glassfish.jersey.core - jersey-client - - - org.glassfish.jersey.inject - jersey-hk2 - - - org.glassfish.hk2 - spring-bridge - - 3.0.3 - - - jakarta.inject - jakarta.inject-api - - 2.0.1 - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-rsa - test - - - - - - ${project.basedir}/src/main/resources - - - ${project.build.directory}/generated-resources - - - - - maven-resources-plugin - - - - copy-resources - validate - - copy-resources - - - ${basedir}/target/wro - - - src/main/wro - true - - - - - - copy-docs - prepare-package - - copy-resources - - - - ${project.build.outputDirectory}/static/docs - - - - - ${project.build.directory}/generated-docs - - - - - - - - - ro.isdc.wro4j - wro4j-maven-plugin - ${wro4j.version} - - - generate-resources - - run - - - - - ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory - ${project.build.directory}/generated-resources/static/eureka/css - ${project.build.directory}/generated-resources/static/eureka/js - ${project.build.directory}/wro/wro.xml - ${basedir}/src/main/wro/wro.properties - ${basedir}/src/main/wro - - - - - org.webjars.npm - glob - 7.2.0 - - - org.webjars.npm - jquery - 3.6.0 - - - org.webjars.npm - bootstrap - 5.1.3 - - - - - org.asciidoctor - asciidoctor-maven-plugin - - - generate-docs - prepare-package - - process-asciidoc - - - html - book - - - - - - - diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/CloudJacksonJson.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/CloudJacksonJson.java deleted file mode 100644 index e4d87a3aa..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/CloudJacksonJson.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.function.Supplier; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectReader; -import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.LeaseInfo; -import com.netflix.discovery.converters.EurekaJacksonCodec; -import com.netflix.discovery.converters.EurekaJacksonCodec.InstanceInfoDeserializer; -import com.netflix.discovery.converters.EurekaJacksonCodec.InstanceInfoSerializer; -import com.netflix.discovery.converters.wrappers.CodecWrappers.LegacyJacksonJson; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Applications; - -import org.springframework.util.ReflectionUtils; -import org.springframework.util.StringUtils; - -import static com.netflix.discovery.converters.wrappers.CodecWrappers.getCodecName; - -/** - * @author Spencer Gibb - */ -public class CloudJacksonJson extends LegacyJacksonJson { - - protected final CloudJacksonCodec codec = new CloudJacksonCodec(); - - public CloudJacksonCodec getCodec() { - return codec; - } - - @Override - public String codecName() { - return getCodecName(LegacyJacksonJson.class); - } - - @Override - public String encode(T object) { - return this.codec.writeToString(object); - } - - @Override - public void encode(T object, OutputStream outputStream) throws IOException { - this.codec.writeTo(object, outputStream); - } - - @Override - public T decode(String textValue, Class type) throws IOException { - return this.codec.readValue(type, textValue); - } - - @Override - public T decode(InputStream inputStream, Class type) throws IOException { - return this.codec.readValue(type, inputStream); - } - - static InstanceInfo updateIfNeeded(final InstanceInfo info) { - if (info.getInstanceId() == null && info.getMetadata() != null) { - String instanceId = info.getMetadata().get("instanceId"); - if (StringUtils.hasText(instanceId)) { - // backwards compatibility for Angel - if (StringUtils.hasText(info.getHostName()) && !instanceId.startsWith(info.getHostName())) { - instanceId = info.getHostName() + ":" + instanceId; - } - return new InstanceInfo.Builder(info).setInstanceId(instanceId).build(); - } - } - return info; - } - - static class CloudJacksonCodec extends EurekaJacksonCodec { - - private static final Version VERSION = new Version(1, 1, 0, null, null, null); - - @SuppressWarnings("deprecation") - CloudJacksonCodec() { - super(); - - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - - SimpleModule module = new SimpleModule("eureka1.x", VERSION); - module.addSerializer(DataCenterInfo.class, new DataCenterInfoSerializer()); - module.addSerializer(InstanceInfo.class, new CloudInstanceInfoSerializer()); - module.addSerializer(Application.class, new ApplicationSerializer()); - module.addSerializer(Applications.class, - new ApplicationsSerializer(this.getVersionDeltaKey(), this.getAppHashCodeKey())); - - // TODO: Watch if this causes problems - // module.addDeserializer(DataCenterInfo.class, - // new DataCenterInfoDeserializer()); - module.addDeserializer(LeaseInfo.class, new LeaseInfoDeserializer()); - module.addDeserializer(InstanceInfo.class, new CloudInstanceInfoDeserializer(mapper)); - module.addDeserializer(Application.class, new ApplicationDeserializer(mapper)); - module.addDeserializer(Applications.class, - new ApplicationsDeserializer(mapper, this.getVersionDeltaKey(), this.getAppHashCodeKey())); - - mapper.registerModule(module); - - HashMap, Supplier> readers = new HashMap<>(); - readers.put(InstanceInfo.class, - () -> mapper.reader().withType(InstanceInfo.class).withRootName("instance")); - readers.put(Application.class, - () -> mapper.reader().withType(Application.class).withRootName("application")); - readers.put(Applications.class, - () -> mapper.reader().withType(Applications.class).withRootName("applications")); - setField("objectReaderByClass", readers); - - HashMap, ObjectWriter> writers = new HashMap<>(); - writers.put(InstanceInfo.class, mapper.writer().withType(InstanceInfo.class).withRootName("instance")); - writers.put(Application.class, mapper.writer().withType(Application.class).withRootName("application")); - writers.put(Applications.class, mapper.writer().withType(Applications.class).withRootName("applications")); - setField("objectWriterByClass", writers); - - setField("mapper", mapper); - } - - void setField(String name, Object value) { - Field field = ReflectionUtils.findField(EurekaJacksonCodec.class, name); - ReflectionUtils.makeAccessible(field); - ReflectionUtils.setField(field, this, value); - } - - } - - static class CloudInstanceInfoSerializer extends InstanceInfoSerializer { - - @Override - public void serialize(final InstanceInfo info, JsonGenerator jgen, SerializerProvider provider) - throws IOException { - - InstanceInfo updated = updateIfNeeded(info); - super.serialize(updated, jgen, provider); - } - - } - - static class CloudInstanceInfoDeserializer extends InstanceInfoDeserializer { - - protected CloudInstanceInfoDeserializer(ObjectMapper mapper) { - super(mapper); - } - - @Override - public InstanceInfo deserialize(JsonParser jp, DeserializationContext context) throws IOException { - InstanceInfo info = super.deserialize(jp, context); - InstanceInfo updated = updateIfNeeded(info); - return updated; - } - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EnableEurekaServer.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EnableEurekaServer.java deleted file mode 100644 index c6780e4ee..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EnableEurekaServer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; - -/** - * Annotation to activate Eureka Server related configuration. - * {@link EurekaServerAutoConfiguration} - * - * @author Dave Syer - * @author Biju Kunjummen - * - */ - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Import(EurekaServerMarkerConfiguration.class) -public @interface EnableEurekaServer { - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java deleted file mode 100644 index 119b05533..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import com.netflix.appinfo.AmazonInfo; -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.shared.Application; -import com.netflix.discovery.shared.Pair; -import com.netflix.eureka.EurekaServerContext; -import com.netflix.eureka.EurekaServerContextHolder; -import com.netflix.eureka.cluster.PeerEurekaNode; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl; -import com.netflix.eureka.resources.StatusResource; -import com.netflix.eureka.util.StatusInfo; -import jakarta.servlet.http.HttpServletRequest; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -/** - * @author Spencer Gibb - * @author Gang Li - * @author Weix Sun - */ -@Controller -@RequestMapping("${eureka.dashboard.path:/}") -public class EurekaController { - - @Value("${eureka.dashboard.path:/}") - private String dashboardPath = ""; - - private final ApplicationInfoManager applicationInfoManager; - - private final EurekaProperties eurekaProperties; - - public EurekaController(ApplicationInfoManager applicationInfoManager, EurekaProperties eurekaProperties) { - this.applicationInfoManager = applicationInfoManager; - this.eurekaProperties = eurekaProperties; - } - - @RequestMapping(method = RequestMethod.GET) - public String status(HttpServletRequest request, Map model) { - populateBase(request, model); - populateApps(model); - StatusInfo statusInfo; - try { - statusInfo = new StatusResource().getStatusInfo(); - } - catch (Exception e) { - statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build(); - } - model.put("statusInfo", statusInfo); - populateInstanceInfo(model, statusInfo); - filterReplicas(model, statusInfo); - return "eureka/status"; - } - - @RequestMapping(value = "/lastn", method = RequestMethod.GET) - public String lastn(HttpServletRequest request, Map model) { - populateBase(request, model); - PeerAwareInstanceRegistryImpl registry = (PeerAwareInstanceRegistryImpl) getRegistry(); - ArrayList> lastNCanceled = new ArrayList<>(); - List> list = registry.getLastNCanceledInstances(); - for (Pair entry : list) { - lastNCanceled.add(registeredInstance(entry.second(), entry.first())); - } - model.put("lastNCanceled", lastNCanceled); - list = registry.getLastNRegisteredInstances(); - ArrayList> lastNRegistered = new ArrayList<>(); - for (Pair entry : list) { - lastNRegistered.add(registeredInstance(entry.second(), entry.first())); - } - model.put("lastNRegistered", lastNRegistered); - return "eureka/lastn"; - } - - private Map registeredInstance(String id, long date) { - HashMap map = new HashMap<>(); - map.put("id", id); - map.put("date", new Date(date)); - return map; - } - - protected void populateBase(HttpServletRequest request, Map model) { - model.put("time", new Date()); - model.put("basePath", "/"); - model.put("dashboardPath", this.dashboardPath.equals("/") ? "" : this.dashboardPath); - populateHeader(model); - populateNavbar(request, model); - } - - private void populateHeader(Map model) { - model.put("currentTime", StatusResource.getCurrentTimeAsString()); - model.put("upTime", StatusInfo.getUpTime()); - model.put("environment", eurekaProperties.getEnvironment()); - model.put("datacenter", eurekaProperties.getDatacenter()); - PeerAwareInstanceRegistry registry = getRegistry(); - model.put("registry", registry); - model.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1); - DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo(); - if (info.getName() == DataCenterInfo.Name.Amazon) { - AmazonInfo amazonInfo = (AmazonInfo) info; - model.put("amazonInfo", amazonInfo); - model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId)); - model.put("availabilityZone", amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone)); - model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId)); - } - } - - private PeerAwareInstanceRegistry getRegistry() { - return getServerContext().getRegistry(); - } - - private EurekaServerContext getServerContext() { - return EurekaServerContextHolder.getInstance().getServerContext(); - } - - private void populateNavbar(HttpServletRequest request, Map model) { - Map replicas = new LinkedHashMap<>(); - List list = getServerContext().getPeerEurekaNodes().getPeerNodesView(); - for (PeerEurekaNode node : list) { - try { - URI uri = new URI(node.getServiceUrl()); - String href = scrubBasicAuth(node.getServiceUrl()); - replicas.put(uri.getHost(), href); - } - catch (Exception ex) { - // ignore? - } - } - model.put("replicas", replicas.entrySet()); - } - - private void populateApps(Map model) { - List sortedApplications = getRegistry().getSortedApplications(); - ArrayList> apps = new ArrayList<>(); - for (Application app : sortedApplications) { - LinkedHashMap appData = new LinkedHashMap<>(); - apps.add(appData); - appData.put("name", app.getName()); - Map amiCounts = new HashMap<>(); - Map>> instancesByStatus = new HashMap<>(); - Map zoneCounts = new HashMap<>(); - for (InstanceInfo info : app.getInstances()) { - String id = info.getId(); - String url = info.getStatusPageUrl(); - InstanceInfo.InstanceStatus status = info.getStatus(); - String ami = "n/a"; - String zone = ""; - if (info.getDataCenterInfo().getName() == DataCenterInfo.Name.Amazon) { - AmazonInfo dcInfo = (AmazonInfo) info.getDataCenterInfo(); - ami = dcInfo.get(AmazonInfo.MetaDataKey.amiId); - zone = dcInfo.get(AmazonInfo.MetaDataKey.availabilityZone); - } - Integer count = amiCounts.get(ami); - if (count != null) { - amiCounts.put(ami, count + 1); - } - else { - amiCounts.put(ami, 1); - } - count = zoneCounts.get(zone); - if (count != null) { - zoneCounts.put(zone, count + 1); - } - else { - zoneCounts.put(zone, 1); - } - List> list = instancesByStatus.computeIfAbsent(status, k -> new ArrayList<>()); - list.add(new Pair<>(id, url)); - } - appData.put("amiCounts", amiCounts.entrySet()); - appData.put("zoneCounts", zoneCounts.entrySet()); - ArrayList> instanceInfos = new ArrayList<>(); - appData.put("instanceInfos", instanceInfos); - for (Map.Entry>> entry : instancesByStatus - .entrySet()) { - List> value = entry.getValue(); - InstanceInfo.InstanceStatus status = entry.getKey(); - LinkedHashMap instanceData = new LinkedHashMap<>(); - instanceInfos.add(instanceData); - instanceData.put("status", entry.getKey()); - ArrayList> instances = new ArrayList<>(); - instanceData.put("instances", instances); - instanceData.put("isNotUp", status != InstanceInfo.InstanceStatus.UP); - - // TODO - - /* - * if(status != InstanceInfo.InstanceStatus.UP){ - * buf.append(""); } - * buf.append("").append(status - * .name()).append(" (").append(value.size()).append(") - "); - * if(status != InstanceInfo.InstanceStatus.UP){ - * buf.append(""); } - */ - - for (Pair p : value) { - LinkedHashMap instance = new LinkedHashMap<>(); - instances.add(instance); - instance.put("id", p.first()); - String url = p.second(); - instance.put("url", url); - boolean isHref = url != null && url.startsWith("http"); - instance.put("isHref", isHref); - /* - * String id = p.first(); String url = p.second(); if(url != null && - * url.startsWith("http")){ - * buf.append(""); }else { url = - * null; } buf.append(id); if(url != null){ buf.append(""); } - * buf.append(", "); - */ - } - } - // out.println("" + buf.toString() + ""); - } - model.put("apps", apps); - } - - private void populateInstanceInfo(Map model, StatusInfo statusInfo) { - InstanceInfo instanceInfo = statusInfo.getInstanceInfo(); - Map instanceMap = new HashMap<>(); - instanceMap.put("ipAddr", instanceInfo.getIPAddr()); - instanceMap.put("status", instanceInfo.getStatus().toString()); - if (instanceInfo.getDataCenterInfo().getName() == DataCenterInfo.Name.Amazon) { - AmazonInfo info = (AmazonInfo) instanceInfo.getDataCenterInfo(); - instanceMap.put("availability-zone", info.get(AmazonInfo.MetaDataKey.availabilityZone)); - instanceMap.put("public-ipv4", info.get(AmazonInfo.MetaDataKey.publicIpv4)); - instanceMap.put("instance-id", info.get(AmazonInfo.MetaDataKey.instanceId)); - instanceMap.put("public-hostname", info.get(AmazonInfo.MetaDataKey.publicHostname)); - instanceMap.put("ami-id", info.get(AmazonInfo.MetaDataKey.amiId)); - instanceMap.put("instance-type", info.get(AmazonInfo.MetaDataKey.instanceType)); - } - model.put("instanceInfo", instanceMap); - } - - protected void filterReplicas(Map model, StatusInfo statusInfo) { - Map applicationStats = statusInfo.getApplicationStats(); - if (applicationStats.get("registered-replicas").contains("@")) { - applicationStats.put("registered-replicas", scrubBasicAuth(applicationStats.get("registered-replicas"))); - } - if (applicationStats.get("unavailable-replicas").contains("@")) { - applicationStats.put("unavailable-replicas", scrubBasicAuth(applicationStats.get("unavailable-replicas"))); - } - if (applicationStats.get("available-replicas").contains("@")) { - applicationStats.put("available-replicas", scrubBasicAuth(applicationStats.get("available-replicas"))); - } - model.put("applicationStats", applicationStats); - } - - private String scrubBasicAuth(String urlList) { - String[] urls = urlList.split(","); - StringBuilder filteredUrls = new StringBuilder(); - for (String u : urls) { - if (u.contains("@")) { - filteredUrls.append(u, 0, u.indexOf("//") + 2).append(u.substring(u.indexOf("@") + 1)).append(","); - } - else { - filteredUrls.append(u).append(","); - } - } - return filteredUrls.substring(0, filteredUrls.length() - 1); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java deleted file mode 100644 index 432da4579..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaDashboardProperties.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Objects; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Configuration properties for the Eureka dashboard (UI). - * - * @author Dave Syer - */ -@ConfigurationProperties("eureka.dashboard") -public class EurekaDashboardProperties { - - /** - * The path to the Eureka dashboard (relative to the servlet path). Defaults to "/". - */ - private String path = "/"; - - /** - * Flag to enable the Eureka dashboard. Default true. - */ - private boolean enabled = true; - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaDashboardProperties that = (EurekaDashboardProperties) o; - return enabled == that.enabled && Objects.equals(path, that.path); - } - - @Override - public int hashCode() { - return Objects.hash(path, enabled); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("EurekaDashboardProperties{"); - sb.append("path='").append(path).append('\''); - sb.append(", enabled=").append(enabled); - sb.append('}'); - return sb.toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaProperties.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaProperties.java deleted file mode 100644 index 483c68afa..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaProperties.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Objects; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Configuration properties for the Eureka deployment. - * - * @author Weix Sun - */ -@ConfigurationProperties("eureka") -public class EurekaProperties { - - /** - * Eureka environment. Defaults to "test". - */ - private String environment = "test"; - - /** - * Eureka datacenter. Defaults to "default". - */ - private String datacenter = "default"; - - public String getEnvironment() { - return environment; - } - - public void setEnvironment(String environment) { - this.environment = environment; - } - - public String getDatacenter() { - return datacenter; - } - - public void setDatacenter(String datacenter) { - this.datacenter = datacenter; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaProperties that = (EurekaProperties) o; - return Objects.equals(datacenter, that.datacenter) && Objects.equals(environment, that.environment); - } - - @Override - public int hashCode() { - return Objects.hash(environment, datacenter); - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("EurekaProperties{"); - sb.append("environment='").append(environment).append('\''); - sb.append(", datacenter=").append(datacenter); - sb.append('}'); - return sb.toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.java deleted file mode 100644 index ec8f135db..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.java +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.UnknownHostException; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.regex.Pattern; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.Jersey3DiscoveryClientOptionalArgs; -import com.netflix.discovery.converters.EurekaJacksonCodec; -import com.netflix.discovery.converters.wrappers.CodecWrapper; -import com.netflix.discovery.converters.wrappers.CodecWrappers; -import com.netflix.discovery.shared.transport.jersey.TransportClientFactories; -import com.netflix.discovery.shared.transport.jersey3.EurekaIdentityHeaderFilter; -import com.netflix.discovery.shared.transport.jersey3.EurekaJersey3Client; -import com.netflix.discovery.shared.transport.jersey3.EurekaJersey3ClientImpl; -import com.netflix.discovery.shared.transport.jersey3.Jersey3TransportClientFactories; -import com.netflix.eureka.DefaultEurekaServerContext; -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.EurekaServerContext; -import com.netflix.eureka.EurekaServerIdentity; -import com.netflix.eureka.cluster.PeerEurekaNode; -import com.netflix.eureka.cluster.PeerEurekaNodes; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import com.netflix.eureka.resources.DefaultServerCodecs; -import com.netflix.eureka.resources.ServerCodecs; -import com.netflix.eureka.transport.EurekaServerHttpClientFactory; -import com.netflix.eureka.transport.Jersey3DynamicGZIPContentEncodingFilter; -import com.netflix.eureka.transport.Jersey3EurekaServerHttpClientFactory; -import com.netflix.eureka.transport.Jersey3ReplicationClient; -import jakarta.servlet.Filter; -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletRequestWrapper; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.ClientRequestFilter; -import jakarta.ws.rs.core.Application; -import jakarta.ws.rs.ext.Provider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.glassfish.hk2.api.ServiceLocator; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.server.spi.Container; -import org.glassfish.jersey.server.spi.ContainerLifecycleListener; -import org.glassfish.jersey.servlet.ServletContainer; -import org.glassfish.jersey.servlet.ServletProperties; -import org.jvnet.hk2.spring.bridge.api.SpringBridge; -import org.jvnet.hk2.spring.bridge.api.SpringIntoHK2Bridge; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.cloud.client.actuator.HasFeatures; -import org.springframework.cloud.context.environment.EnvironmentChangeEvent; -import org.springframework.cloud.netflix.eureka.EurekaConstants; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.Ordered; -import org.springframework.core.env.Environment; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.type.filter.AnnotationTypeFilter; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.OncePerRequestFilter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author Gunnar Hillert - * @author Biju Kunjummen - * @author Fahim Farook - * @author Weix Sun - */ -@Configuration(proxyBeanMethods = false) -@Import(EurekaServerInitializerConfiguration.class) -@ConditionalOnBean(EurekaServerMarkerConfiguration.Marker.class) -@EnableConfigurationProperties({ EurekaDashboardProperties.class, InstanceRegistryProperties.class, - EurekaProperties.class }) -@PropertySource("classpath:/eureka/server.properties") -public class EurekaServerAutoConfiguration implements WebMvcConfigurer { - - private static final Log log = LogFactory.getLog(EurekaServerAutoConfiguration.class); - - /** - * List of packages containing Jersey resources required by the Eureka server. - */ - private static final String[] EUREKA_PACKAGES = new String[] { "com.netflix.discovery", "com.netflix.eureka" }; - - /** - * Static content pattern for dashboard elements (images, css, etc...). - */ - private static final String STATIC_CONTENT_PATTERN = "/(fonts|images|css|js)/.*"; - - @Autowired - private ApplicationInfoManager applicationInfoManager; - - @Autowired - private EurekaServerConfig eurekaServerConfig; - - @Autowired - private EurekaClientConfig eurekaClientConfig; - - @Autowired - private EurekaClient eurekaClient; - - @Autowired - private InstanceRegistryProperties instanceRegistryProperties; - - /** - * A {@link CloudJacksonJson} instance. - */ - public static final CloudJacksonJson JACKSON_JSON = new CloudJacksonJson(); - - @Bean - public HasFeatures eurekaServerFeature() { - return HasFeatures.namedFeature("Eureka Server", EurekaServerAutoConfiguration.class); - } - - @Bean - @ConditionalOnProperty(prefix = "eureka.dashboard", name = "enabled", matchIfMissing = true) - public EurekaController eurekaController(EurekaProperties eurekaProperties) { - return new EurekaController(this.applicationInfoManager, eurekaProperties); - } - - static { - CodecWrappers.registerWrapper(JACKSON_JSON); - EurekaJacksonCodec.setInstance(JACKSON_JSON.getCodec()); - } - - @Bean - public ServerCodecs serverCodecs() { - return new CloudServerCodecs(this.eurekaServerConfig); - } - - private static CodecWrapper getFullJson(EurekaServerConfig serverConfig) { - CodecWrapper codec = CodecWrappers.getCodec(serverConfig.getJsonCodecName()); - return codec == null ? CodecWrappers.getCodec(JACKSON_JSON.codecName()) : codec; - } - - private static CodecWrapper getFullXml(EurekaServerConfig serverConfig) { - CodecWrapper codec = CodecWrappers.getCodec(serverConfig.getXmlCodecName()); - return codec == null ? CodecWrappers.getCodec(CodecWrappers.XStreamXml.class) : codec; - } - - @Bean - @ConditionalOnMissingBean - public ReplicationClientAdditionalFilters replicationClientAdditionalFilters() { - return new ReplicationClientAdditionalFilters(Collections.emptySet()); - } - - @Bean - @ConditionalOnMissingBean(TransportClientFactories.class) - public Jersey3TransportClientFactories jersey3TransportClientFactories() { - return Jersey3TransportClientFactories.getInstance(); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Bean - @ConditionalOnMissingBean(EurekaServerHttpClientFactory.class) - public Jersey3EurekaServerHttpClientFactory jersey3EurekaServerHttpClientFactory() { - return new Jersey3EurekaServerHttpClientFactory(); - } - - @Bean - @ConditionalOnMissingBean(AbstractDiscoveryClientOptionalArgs.class) - public Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs() { - return new Jersey3DiscoveryClientOptionalArgs(); - } - - @Bean - public PeerAwareInstanceRegistry peerAwareInstanceRegistry(ServerCodecs serverCodecs, - EurekaServerHttpClientFactory eurekaServerHttpClientFactory) { - this.eurekaClient.getApplications(); // force initialization - return new InstanceRegistry(this.eurekaServerConfig, this.eurekaClientConfig, serverCodecs, this.eurekaClient, - eurekaServerHttpClientFactory, - this.instanceRegistryProperties.getExpectedNumberOfClientsSendingRenews(), - this.instanceRegistryProperties.getDefaultOpenForTrafficCount()); - } - - @Bean - @ConditionalOnMissingBean - public PeerEurekaNodes peerEurekaNodes(PeerAwareInstanceRegistry registry, ServerCodecs serverCodecs, - ReplicationClientAdditionalFilters replicationClientAdditionalFilters) { - return new RefreshablePeerEurekaNodes(registry, this.eurekaServerConfig, this.eurekaClientConfig, serverCodecs, - this.applicationInfoManager, replicationClientAdditionalFilters); - } - - @Bean - @ConditionalOnMissingBean - public EurekaServerContext eurekaServerContext(ServerCodecs serverCodecs, PeerAwareInstanceRegistry registry, - PeerEurekaNodes peerEurekaNodes) { - return new DefaultEurekaServerContext(this.eurekaServerConfig, serverCodecs, registry, peerEurekaNodes, - this.applicationInfoManager); - } - - @Bean - public EurekaServerBootstrap eurekaServerBootstrap(PeerAwareInstanceRegistry registry, - EurekaServerContext serverContext) { - return new EurekaServerBootstrap(this.applicationInfoManager, this.eurekaClientConfig, this.eurekaServerConfig, - registry, serverContext); - } - - /** - * Register the Jersey filter. - * @param eurekaJerseyApp an {@link Application} for the filter to be registered - * @return a jersey {@link FilterRegistrationBean} - */ - @Bean - public FilterRegistrationBean jerseyFilterRegistration(ResourceConfig eurekaJerseyApp) { - FilterRegistrationBean bean = new FilterRegistrationBean<>(); - ServletContainer servletContainer = new ServletContainer(eurekaJerseyApp); - bean.setFilter(servletContainer); - bean.setOrder(Ordered.LOWEST_PRECEDENCE); - bean.setUrlPatterns(Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*")); - - return bean; - } - - @Bean - public FilterRegistrationBean eurekaVersionFilterRegistration(ServerProperties serverProperties, - Environment env) { - final String contextPath = serverProperties.getServlet().getContextPath(); - String regex = EurekaConstants.DEFAULT_PREFIX + STATIC_CONTENT_PATTERN; - if (StringUtils.hasText(contextPath)) { - regex = contextPath + regex; - } - String debugResponseHeader = env.getProperty("eureka.server.version.filter.debug.response-header"); - boolean addDebugResponseHeader = StringUtils.hasText(debugResponseHeader); - Pattern staticPattern = Pattern.compile(regex); - FilterRegistrationBean bean = new FilterRegistrationBean<>(); - bean.setFilter(new OncePerRequestFilter() { - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - HttpServletRequest req = request; - String requestURI = request.getRequestURI(); - if (!requestURI.startsWith(EurekaConstants.DEFAULT_PREFIX + "/v2") - // don't forward static requests (images, js, etc...) to /v2 - && !staticPattern.matcher(requestURI).matches()) { - - String prefix = EurekaConstants.DEFAULT_PREFIX; - if (StringUtils.hasText(contextPath)) { - prefix = contextPath + prefix; - } - String updatedPath = EurekaConstants.DEFAULT_PREFIX + "/v2" + requestURI.substring(prefix.length()); - if (StringUtils.hasText(contextPath)) { - updatedPath = contextPath + updatedPath; - } - final String computedPath = updatedPath; - // only used if a special debug property is set, so in prod this is - // always skipped. - if (addDebugResponseHeader) { - response.addHeader(debugResponseHeader, computedPath); - } - HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) { - @Override - public String getRequestURI() { - return computedPath; - } - - @Override - public String getServletPath() { - return computedPath; - } - }; - req = wrapper; - } - filterChain.doFilter(req, response); - } - }); - bean.setOrder(0); - bean.setUrlPatterns(Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*")); - - return bean; - } - - /** - * Construct a Jersey {@link jakarta.ws.rs.core.Application} with all the resources - * required by the Eureka server. - * @param environment an {@link Environment} instance to retrieve classpath resources - * @param resourceLoader a {@link ResourceLoader} instance to get classloader from - * @return created {@link Application} object - */ - @Bean - public ResourceConfig jerseyApplication(Environment environment, ResourceLoader resourceLoader, - BeanFactory beanFactory) { - - ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false, - environment); - - // Filter to include only classes that have a particular annotation. - // - provider.addIncludeFilter(new AnnotationTypeFilter(Path.class)); - provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class)); - - // Find classes in Eureka packages (or subpackages) - // - Set> classes = new HashSet<>(); - for (String basePackage : EUREKA_PACKAGES) { - Set beans = provider.findCandidateComponents(basePackage); - for (BeanDefinition bd : beans) { - Class cls = ClassUtils.resolveClassName(bd.getBeanClassName(), resourceLoader.getClassLoader()); - classes.add(cls); - } - } - - // https://javaee.github.io/hk2/spring-bridge - - // Construct the Jersey ResourceConfig - ResourceConfig rc = new ResourceConfig(classes).property( - // Skip static content used by the webapp - ServletProperties.FILTER_STATIC_CONTENT_REGEX, EurekaConstants.DEFAULT_PREFIX + STATIC_CONTENT_PATTERN); - - rc.register(new ContainerLifecycleListener() { - @Override - public void onStartup(Container container) { - ServiceLocator serviceLocator = container.getApplicationHandler().getInjectionManager() - .getInstance(ServiceLocator.class); - SpringBridge.getSpringBridge().initializeSpringBridge(serviceLocator); - serviceLocator.getService(SpringIntoHK2Bridge.class).bridgeSpringBeanFactory(beanFactory); - } - - @Override - public void onReload(Container container) { - - } - - @Override - public void onShutdown(Container container) { - - } - }); - - return rc; - } - - @Bean - @ConditionalOnBean(name = "httpTraceFilter") - public FilterRegistrationBean traceFilterRegistration(@Qualifier("httpTraceFilter") Filter filter) { - FilterRegistrationBean bean = new FilterRegistrationBean<>(); - bean.setFilter(filter); - bean.setOrder(Ordered.LOWEST_PRECEDENCE - 10); - return bean; - } - - @Configuration(proxyBeanMethods = false) - protected static class EurekaServerConfigBeanConfiguration { - - @Bean - @ConditionalOnMissingBean - public EurekaServerConfig eurekaServerConfig(EurekaClientConfig clientConfig) { - EurekaServerConfigBean server = new EurekaServerConfigBean(); - if (clientConfig.shouldRegisterWithEureka()) { - // Set a sensible default if we are supposed to replicate - server.setRegistrySyncRetries(5); - } - return server; - } - - } - - /** - * {@link PeerEurekaNodes} which updates peers when /refresh is invoked. Peers are - * updated only if eureka.client.use-dns-for-fetching-service-urls is - * false and one of following properties have changed. - *

- *

- *
    - *
  • eureka.client.availability-zones
  • - *
  • eureka.client.region
  • - *
  • eureka.client.service-url.<zone>
  • - *
- */ - static class RefreshablePeerEurekaNodes extends PeerEurekaNodes - implements ApplicationListener { - - /* for testing */ ReplicationClientAdditionalFilters replicationClientAdditionalFilters; - - RefreshablePeerEurekaNodes(final PeerAwareInstanceRegistry registry, final EurekaServerConfig serverConfig, - final EurekaClientConfig clientConfig, final ServerCodecs serverCodecs, - final ApplicationInfoManager applicationInfoManager, - final ReplicationClientAdditionalFilters replicationClientAdditionalFilters) { - super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager); - this.replicationClientAdditionalFilters = replicationClientAdditionalFilters; - } - - @Override - protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) { - Jersey3ReplicationClient replicationClient = createReplicationClient(serverConfig, serverCodecs, - peerEurekaNodeUrl, this.replicationClientAdditionalFilters.getFilters()); - - String targetHost = hostFromUrl(peerEurekaNodeUrl); - if (targetHost == null) { - targetHost = "host"; - } - return new PeerEurekaNode(registry, targetHost, peerEurekaNodeUrl, replicationClient, serverConfig); - } - - // FIXME: 4.0 update Jersey3ReplicationClient.createReplicationClient to handle - // additional filters - private static Jersey3ReplicationClient createReplicationClient(EurekaServerConfig config, - ServerCodecs serverCodecs, String serviceUrl, Collection additionalFilters) { - String name = Jersey3ReplicationClient.class.getSimpleName() + ": " + serviceUrl + "apps/: "; - - EurekaJersey3Client jerseyClient; - try { - String hostname; - try { - hostname = new URL(serviceUrl).getHost(); - } - catch (MalformedURLException e) { - hostname = serviceUrl; - } - - String jerseyClientName = "Discovery-PeerNodeClient-" + hostname; - EurekaJersey3ClientImpl.EurekaJersey3ClientBuilder clientBuilder = new EurekaJersey3ClientImpl.EurekaJersey3ClientBuilder() - .withClientName(jerseyClientName).withUserAgent("Java-EurekaClient-Replication") - .withEncoderWrapper(serverCodecs.getFullJsonCodec()) - .withDecoderWrapper(serverCodecs.getFullJsonCodec()) - .withConnectionTimeout(config.getPeerNodeConnectTimeoutMs()) - .withReadTimeout(config.getPeerNodeReadTimeoutMs()) - .withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost()) - .withMaxTotalConnections(config.getPeerNodeTotalConnections()) - .withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds()); - - if (serviceUrl.startsWith("https://") && "true" - .equals(System.getProperty("com.netflix.eureka.shouldSSLConnectionsUseSystemSocketFactory"))) { - clientBuilder.withSystemSSLConfiguration(); - } - jerseyClient = clientBuilder.build(); - } - catch (Throwable e) { - throw new RuntimeException("Cannot Create new Replica Node :" + name, e); - } - - String ip = null; - try { - ip = InetAddress.getLocalHost().getHostAddress(); - } - catch (UnknownHostException e) { - log.warn("Cannot find localhost ip", e); - } - - Client jerseyApacheClient = jerseyClient.getClient(); - jerseyApacheClient.register(new Jersey3DynamicGZIPContentEncodingFilter(config)); - - for (ClientRequestFilter filter : additionalFilters) { - jerseyApacheClient.register(filter); - } - - EurekaServerIdentity identity = new EurekaServerIdentity(ip); - jerseyApacheClient.register(new EurekaIdentityHeaderFilter(identity)); - - return new Jersey3ReplicationClient(jerseyClient, serviceUrl); - } - - @Override - public void onApplicationEvent(final EnvironmentChangeEvent event) { - if (shouldUpdate(event.getKeys())) { - updatePeerEurekaNodes(resolvePeerUrls()); - } - } - - /* - * Check whether specific properties have changed. - */ - protected boolean shouldUpdate(final Set changedKeys) { - assert changedKeys != null; - - // if eureka.client.use-dns-for-fetching-service-urls is true, then - // service-url will not be fetched from environment. - if (this.clientConfig.shouldUseDnsForFetchingServiceUrls()) { - return false; - } - - if (changedKeys.contains("eureka.client.region")) { - return true; - } - - for (final String key : changedKeys) { - // property keys are not expected to be null. - if (key.startsWith("eureka.client.service-url.") - || key.startsWith("eureka.client.availability-zones.")) { - return true; - } - } - return false; - } - - } - - class CloudServerCodecs extends DefaultServerCodecs { - - CloudServerCodecs(EurekaServerConfig serverConfig) { - super(getFullJson(serverConfig), CodecWrappers.getCodec(CodecWrappers.JacksonJsonMini.class), - getFullXml(serverConfig), CodecWrappers.getCodec(CodecWrappers.JacksonXmlMini.class)); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerBootstrap.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerBootstrap.java deleted file mode 100644 index 8535b721d..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerBootstrap.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.converters.JsonXStream; -import com.netflix.discovery.converters.XmlXStream; -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.EurekaServerContext; -import com.netflix.eureka.EurekaServerContextHolder; -import com.netflix.eureka.V1AwareInstanceInfoConverter; -import com.netflix.eureka.aws.AwsBinder; -import com.netflix.eureka.aws.AwsBinderDelegate; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import com.netflix.eureka.util.EurekaMonitors; -import com.thoughtworks.xstream.XStream; -import jakarta.servlet.ServletContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Spencer Gibb - * @author Weix Sun - */ -public class EurekaServerBootstrap { - - private static final Log log = LogFactory.getLog(EurekaServerBootstrap.class); - - protected EurekaServerConfig eurekaServerConfig; - - protected ApplicationInfoManager applicationInfoManager; - - protected EurekaClientConfig eurekaClientConfig; - - protected PeerAwareInstanceRegistry registry; - - protected volatile EurekaServerContext serverContext; - - protected volatile AwsBinder awsBinder; - - public EurekaServerBootstrap(ApplicationInfoManager applicationInfoManager, EurekaClientConfig eurekaClientConfig, - EurekaServerConfig eurekaServerConfig, PeerAwareInstanceRegistry registry, - EurekaServerContext serverContext) { - this.applicationInfoManager = applicationInfoManager; - this.eurekaClientConfig = eurekaClientConfig; - this.eurekaServerConfig = eurekaServerConfig; - this.registry = registry; - this.serverContext = serverContext; - } - - public void contextInitialized(ServletContext context) { - try { - initEurekaServerContext(); - - context.setAttribute(EurekaServerContext.class.getName(), this.serverContext); - } - catch (Throwable e) { - log.error("Cannot bootstrap eureka server :", e); - throw new RuntimeException("Cannot bootstrap eureka server :", e); - } - } - - public void contextDestroyed(ServletContext context) { - try { - log.info("Shutting down Eureka Server.."); - context.removeAttribute(EurekaServerContext.class.getName()); - - destroyEurekaServerContext(); - destroyEurekaEnvironment(); - - } - catch (Throwable e) { - log.error("Error shutting down eureka", e); - } - log.info("Eureka Service is now shutdown..."); - } - - protected void initEurekaServerContext() throws Exception { - // For backward compatibility - JsonXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); - XmlXStream.getInstance().registerConverter(new V1AwareInstanceInfoConverter(), XStream.PRIORITY_VERY_HIGH); - - if (isAws(this.applicationInfoManager.getInfo())) { - this.awsBinder = new AwsBinderDelegate(this.eurekaServerConfig, this.eurekaClientConfig, this.registry, - this.applicationInfoManager); - this.awsBinder.start(); - } - - EurekaServerContextHolder.initialize(this.serverContext); - - log.info("Initialized server context"); - - // Copy registry from neighboring eureka node - int registryCount = this.registry.syncUp(); - this.registry.openForTraffic(this.applicationInfoManager, registryCount); - - // Register all monitoring statistics. - EurekaMonitors.registerAllStats(); - } - - /** - * Server context shutdown hook. Override for custom logic - * @throws Exception - calling {@link AwsBinder#shutdown()} or - * {@link EurekaServerContext#shutdown()} may result in an exception - */ - protected void destroyEurekaServerContext() throws Exception { - EurekaMonitors.shutdown(); - if (this.awsBinder != null) { - this.awsBinder.shutdown(); - } - if (this.serverContext != null) { - this.serverContext.shutdown(); - } - } - - /** - * Users can override to clean up the environment themselves. - * @throws Exception - shutting down Eureka servers may result in an exception - */ - protected void destroyEurekaEnvironment() throws Exception { - } - - protected boolean isAws(InstanceInfo selfInstanceInfo) { - boolean result = DataCenterInfo.Name.Amazon == selfInstanceInfo.getDataCenterInfo().getName(); - log.info("isAws returned " + result); - return result; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfigBean.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfigBean.java deleted file mode 100644 index 0c2789023..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfigBean.java +++ /dev/null @@ -1,1139 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.aws.AwsBindingStrategy; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.core.env.PropertyResolver; -import org.springframework.core.style.ToStringCreator; - -/** - * @author Dave Syer - * @author Gregor Zurowski - */ -@ConfigurationProperties(EurekaServerConfigBean.PREFIX) -public class EurekaServerConfigBean implements EurekaServerConfig { - - /** - * Eureka server configuration properties prefix. - */ - public static final String PREFIX = "eureka.server"; - - private static final int MINUTES = 60 * 1000; - - @Autowired(required = false) - PropertyResolver propertyResolver; - - private String aWSAccessId; - - private String aWSSecretKey; - - private int eIPBindRebindRetries = 3; - - private int eIPBindingRetryIntervalMs = 5 * MINUTES; - - private int eIPBindingRetryIntervalMsWhenUnbound = 1 * MINUTES; - - private boolean enableSelfPreservation = true; - - private double renewalPercentThreshold = 0.85; - - private int renewalThresholdUpdateIntervalMs = 15 * MINUTES; - - private int peerEurekaNodesUpdateIntervalMs = 10 * MINUTES; - - private int numberOfReplicationRetries = 5; - - private int peerEurekaStatusRefreshTimeIntervalMs = 30 * 1000; - - private int waitTimeInMsWhenSyncEmpty = 5 * MINUTES; - - private int peerNodeConnectTimeoutMs = 200; - - private int peerNodeReadTimeoutMs = 200; - - private int peerNodeTotalConnections = 1000; - - private int peerNodeTotalConnectionsPerHost = 500; - - private int peerNodeConnectionIdleTimeoutSeconds = 30; - - private long retentionTimeInMSInDeltaQueue = 3 * MINUTES; - - private long deltaRetentionTimerIntervalInMs = 30 * 1000; - - private long evictionIntervalTimerInMs = 60 * 1000; - - private int aSGQueryTimeoutMs = 300; - - private long aSGUpdateIntervalMs = 5 * MINUTES; - - private long aSGCacheExpiryTimeoutMs = 10 * MINUTES; // defaults to longer than the - - // asg update interval - - private long responseCacheAutoExpirationInSeconds = 180; - - private long responseCacheUpdateIntervalMs = 30 * 1000; - - private boolean useReadOnlyResponseCache = true; - - private boolean disableDelta; - - private long maxIdleThreadInMinutesAgeForStatusReplication = 10; - - private int minThreadsForStatusReplication = 1; - - private int maxThreadsForStatusReplication = 1; - - private int maxElementsInStatusReplicationPool = 10000; - - private boolean syncWhenTimestampDiffers = true; - - private int registrySyncRetries = 0; - - private long registrySyncRetryWaitMs = 30 * 1000; - - private int maxElementsInPeerReplicationPool = 10000; - - private long maxIdleThreadAgeInMinutesForPeerReplication = 15; - - private int minThreadsForPeerReplication = 5; - - private int maxThreadsForPeerReplication = 20; - - private int maxTimeForReplication = 30000; - - private boolean primeAwsReplicaConnections = true; - - private boolean disableDeltaForRemoteRegions; - - private int remoteRegionConnectTimeoutMs = 1000; - - private int remoteRegionReadTimeoutMs = 1000; - - private int remoteRegionTotalConnections = 1000; - - private int remoteRegionTotalConnectionsPerHost = 500; - - private int remoteRegionConnectionIdleTimeoutSeconds = 30; - - private boolean gZipContentFromRemoteRegion = true; - - private Map remoteRegionUrlsWithName = new HashMap<>(); - - private String[] remoteRegionUrls; - - private Map> remoteRegionAppWhitelist = new HashMap<>(); - - private int remoteRegionRegistryFetchInterval = 30; - - private int remoteRegionFetchThreadPoolSize = 20; - - private String remoteRegionTrustStore = ""; - - private String remoteRegionTrustStorePassword = "changeit"; - - private boolean disableTransparentFallbackToOtherRegion; - - private boolean batchReplication; - - private boolean rateLimiterEnabled = false; - - private boolean rateLimiterThrottleStandardClients = false; - - private Set rateLimiterPrivilegedClients = Collections.emptySet(); - - private int rateLimiterBurstSize = 10; - - private int rateLimiterRegistryFetchAverageRate = 500; - - private int rateLimiterFullFetchAverageRate = 100; - - private boolean logIdentityHeaders = true; - - private String listAutoScalingGroupsRoleName = "ListAutoScalingGroups"; - - private boolean enableReplicatedRequestCompression = false; - - private String jsonCodecName; - - private String xmlCodecName; - - private int route53BindRebindRetries = 3; - - private int route53BindingRetryIntervalMs = 5 * MINUTES; - - private long route53DomainTTL = 30; - - private AwsBindingStrategy bindingStrategy = AwsBindingStrategy.EIP; - - private int minAvailableInstancesForPeerReplication = -1; - - private int initialCapacityOfResponseCache = 1000; - - private int expectedClientRenewalIntervalSeconds = 30; - - private boolean useAwsAsgApi = true; - - private String myUrl; - - @Override - public boolean shouldEnableSelfPreservation() { - return this.enableSelfPreservation; - } - - @Override - public boolean shouldDisableDelta() { - return this.disableDelta; - } - - @Override - public boolean shouldSyncWhenTimestampDiffers() { - return this.syncWhenTimestampDiffers; - } - - @Override - public boolean shouldPrimeAwsReplicaConnections() { - return this.primeAwsReplicaConnections; - } - - @Override - public boolean shouldDisableDeltaForRemoteRegions() { - return this.disableDeltaForRemoteRegions; - } - - @Override - public boolean shouldGZipContentFromRemoteRegion() { - return this.gZipContentFromRemoteRegion; - } - - @Override - public Set getRemoteRegionAppWhitelist(String regionName) { - return this.remoteRegionAppWhitelist.get(regionName == null ? "global" : regionName.trim().toLowerCase()); - } - - @Override - public boolean disableTransparentFallbackToOtherRegion() { - return this.disableTransparentFallbackToOtherRegion; - } - - @Override - public boolean shouldBatchReplication() { - return this.batchReplication; - } - - @Override - public String getMyUrl() { - return this.myUrl; - } - - public void setMyUrl(String myUrl) { - this.myUrl = myUrl; - } - - @Override - public boolean shouldLogIdentityHeaders() { - return this.logIdentityHeaders; - } - - @Override - public String getJsonCodecName() { - return this.jsonCodecName; - } - - @Override - public String getXmlCodecName() { - return this.xmlCodecName; - } - - @Override - public boolean shouldUseReadOnlyResponseCache() { - return this.useReadOnlyResponseCache; - } - - @Override - public boolean shouldEnableReplicatedRequestCompression() { - return this.enableReplicatedRequestCompression; - } - - @Override - public String getExperimental(String name) { - if (this.propertyResolver != null) { - return this.propertyResolver.getProperty(PREFIX + ".experimental." + name, String.class, null); - } - return null; - } - - @Override - public int getInitialCapacityOfResponseCache() { - return this.initialCapacityOfResponseCache; - } - - public void setInitialCapacityOfResponseCache(int initialCapacityOfResponseCache) { - this.initialCapacityOfResponseCache = initialCapacityOfResponseCache; - } - - @Override - public int getHealthStatusMinNumberOfAvailablePeers() { - return this.minAvailableInstancesForPeerReplication; - } - - public PropertyResolver getPropertyResolver() { - return propertyResolver; - } - - public void setPropertyResolver(PropertyResolver propertyResolver) { - this.propertyResolver = propertyResolver; - } - - public String getAWSAccessId() { - return aWSAccessId; - } - - public void setAWSAccessId(String aWSAccessId) { - this.aWSAccessId = aWSAccessId; - } - - public String getAWSSecretKey() { - return aWSSecretKey; - } - - public void setAWSSecretKey(String aWSSecretKey) { - this.aWSSecretKey = aWSSecretKey; - } - - public int getEIPBindRebindRetries() { - return eIPBindRebindRetries; - } - - public void setEIPBindRebindRetries(int eIPBindRebindRetries) { - this.eIPBindRebindRetries = eIPBindRebindRetries; - } - - public int getEIPBindingRetryIntervalMs() { - return eIPBindingRetryIntervalMs; - } - - public void setEIPBindingRetryIntervalMs(int eIPBindingRetryIntervalMs) { - this.eIPBindingRetryIntervalMs = eIPBindingRetryIntervalMs; - } - - public int getEIPBindingRetryIntervalMsWhenUnbound() { - return eIPBindingRetryIntervalMsWhenUnbound; - } - - public void setEIPBindingRetryIntervalMsWhenUnbound(int eIPBindingRetryIntervalMsWhenUnbound) { - this.eIPBindingRetryIntervalMsWhenUnbound = eIPBindingRetryIntervalMsWhenUnbound; - } - - public boolean isEnableSelfPreservation() { - return enableSelfPreservation; - } - - public void setEnableSelfPreservation(boolean enableSelfPreservation) { - this.enableSelfPreservation = enableSelfPreservation; - } - - @Override - public double getRenewalPercentThreshold() { - return renewalPercentThreshold; - } - - public void setRenewalPercentThreshold(double renewalPercentThreshold) { - this.renewalPercentThreshold = renewalPercentThreshold; - } - - @Override - public int getRenewalThresholdUpdateIntervalMs() { - return renewalThresholdUpdateIntervalMs; - } - - @Override - public int getExpectedClientRenewalIntervalSeconds() { - return this.expectedClientRenewalIntervalSeconds; - } - - public void setExpectedClientRenewalIntervalSeconds(int expectedClientRenewalIntervalSeconds) { - this.expectedClientRenewalIntervalSeconds = expectedClientRenewalIntervalSeconds; - } - - public void setRenewalThresholdUpdateIntervalMs(int renewalThresholdUpdateIntervalMs) { - this.renewalThresholdUpdateIntervalMs = renewalThresholdUpdateIntervalMs; - } - - @Override - public int getPeerEurekaNodesUpdateIntervalMs() { - return peerEurekaNodesUpdateIntervalMs; - } - - public void setPeerEurekaNodesUpdateIntervalMs(int peerEurekaNodesUpdateIntervalMs) { - this.peerEurekaNodesUpdateIntervalMs = peerEurekaNodesUpdateIntervalMs; - } - - @Override - public int getNumberOfReplicationRetries() { - return numberOfReplicationRetries; - } - - public void setNumberOfReplicationRetries(int numberOfReplicationRetries) { - this.numberOfReplicationRetries = numberOfReplicationRetries; - } - - @Override - public int getPeerEurekaStatusRefreshTimeIntervalMs() { - return peerEurekaStatusRefreshTimeIntervalMs; - } - - public void setPeerEurekaStatusRefreshTimeIntervalMs(int peerEurekaStatusRefreshTimeIntervalMs) { - this.peerEurekaStatusRefreshTimeIntervalMs = peerEurekaStatusRefreshTimeIntervalMs; - } - - @Override - public int getWaitTimeInMsWhenSyncEmpty() { - return waitTimeInMsWhenSyncEmpty; - } - - public void setWaitTimeInMsWhenSyncEmpty(int waitTimeInMsWhenSyncEmpty) { - this.waitTimeInMsWhenSyncEmpty = waitTimeInMsWhenSyncEmpty; - } - - @Override - public int getPeerNodeConnectTimeoutMs() { - return peerNodeConnectTimeoutMs; - } - - public void setPeerNodeConnectTimeoutMs(int peerNodeConnectTimeoutMs) { - this.peerNodeConnectTimeoutMs = peerNodeConnectTimeoutMs; - } - - @Override - public int getPeerNodeReadTimeoutMs() { - return peerNodeReadTimeoutMs; - } - - public void setPeerNodeReadTimeoutMs(int peerNodeReadTimeoutMs) { - this.peerNodeReadTimeoutMs = peerNodeReadTimeoutMs; - } - - @Override - public int getPeerNodeTotalConnections() { - return peerNodeTotalConnections; - } - - public void setPeerNodeTotalConnections(int peerNodeTotalConnections) { - this.peerNodeTotalConnections = peerNodeTotalConnections; - } - - @Override - public int getPeerNodeTotalConnectionsPerHost() { - return peerNodeTotalConnectionsPerHost; - } - - public void setPeerNodeTotalConnectionsPerHost(int peerNodeTotalConnectionsPerHost) { - this.peerNodeTotalConnectionsPerHost = peerNodeTotalConnectionsPerHost; - } - - @Override - public int getPeerNodeConnectionIdleTimeoutSeconds() { - return peerNodeConnectionIdleTimeoutSeconds; - } - - public void setPeerNodeConnectionIdleTimeoutSeconds(int peerNodeConnectionIdleTimeoutSeconds) { - this.peerNodeConnectionIdleTimeoutSeconds = peerNodeConnectionIdleTimeoutSeconds; - } - - @Override - public long getRetentionTimeInMSInDeltaQueue() { - return retentionTimeInMSInDeltaQueue; - } - - public void setRetentionTimeInMSInDeltaQueue(long retentionTimeInMSInDeltaQueue) { - this.retentionTimeInMSInDeltaQueue = retentionTimeInMSInDeltaQueue; - } - - @Override - public long getDeltaRetentionTimerIntervalInMs() { - return deltaRetentionTimerIntervalInMs; - } - - public void setDeltaRetentionTimerIntervalInMs(long deltaRetentionTimerIntervalInMs) { - this.deltaRetentionTimerIntervalInMs = deltaRetentionTimerIntervalInMs; - } - - @Override - public long getEvictionIntervalTimerInMs() { - return evictionIntervalTimerInMs; - } - - @Override - public boolean shouldUseAwsAsgApi() { - return this.useAwsAsgApi; - } - - public void setUseAwsAsgApi(boolean useAwsAsgApi) { - this.useAwsAsgApi = useAwsAsgApi; - } - - public void setEvictionIntervalTimerInMs(long evictionIntervalTimerInMs) { - this.evictionIntervalTimerInMs = evictionIntervalTimerInMs; - } - - public int getASGQueryTimeoutMs() { - return aSGQueryTimeoutMs; - } - - public void setASGQueryTimeoutMs(int aSGQueryTimeoutMs) { - this.aSGQueryTimeoutMs = aSGQueryTimeoutMs; - } - - public long getASGUpdateIntervalMs() { - return aSGUpdateIntervalMs; - } - - public void setASGUpdateIntervalMs(long aSGUpdateIntervalMs) { - this.aSGUpdateIntervalMs = aSGUpdateIntervalMs; - } - - public long getASGCacheExpiryTimeoutMs() { - return aSGCacheExpiryTimeoutMs; - } - - public void setASGCacheExpiryTimeoutMs(long aSGCacheExpiryTimeoutMs) { - this.aSGCacheExpiryTimeoutMs = aSGCacheExpiryTimeoutMs; - } - - @Override - public long getResponseCacheAutoExpirationInSeconds() { - return responseCacheAutoExpirationInSeconds; - } - - public void setResponseCacheAutoExpirationInSeconds(long responseCacheAutoExpirationInSeconds) { - this.responseCacheAutoExpirationInSeconds = responseCacheAutoExpirationInSeconds; - } - - @Override - public long getResponseCacheUpdateIntervalMs() { - return responseCacheUpdateIntervalMs; - } - - public void setResponseCacheUpdateIntervalMs(long responseCacheUpdateIntervalMs) { - this.responseCacheUpdateIntervalMs = responseCacheUpdateIntervalMs; - } - - public boolean isUseReadOnlyResponseCache() { - return useReadOnlyResponseCache; - } - - public void setUseReadOnlyResponseCache(boolean useReadOnlyResponseCache) { - this.useReadOnlyResponseCache = useReadOnlyResponseCache; - } - - public boolean isDisableDelta() { - return disableDelta; - } - - public void setDisableDelta(boolean disableDelta) { - this.disableDelta = disableDelta; - } - - @Override - public long getMaxIdleThreadInMinutesAgeForStatusReplication() { - return maxIdleThreadInMinutesAgeForStatusReplication; - } - - public void setMaxIdleThreadInMinutesAgeForStatusReplication(long maxIdleThreadInMinutesAgeForStatusReplication) { - this.maxIdleThreadInMinutesAgeForStatusReplication = maxIdleThreadInMinutesAgeForStatusReplication; - } - - @Override - public int getMinThreadsForStatusReplication() { - return minThreadsForStatusReplication; - } - - public void setMinThreadsForStatusReplication(int minThreadsForStatusReplication) { - this.minThreadsForStatusReplication = minThreadsForStatusReplication; - } - - @Override - public int getMaxThreadsForStatusReplication() { - return maxThreadsForStatusReplication; - } - - public void setMaxThreadsForStatusReplication(int maxThreadsForStatusReplication) { - this.maxThreadsForStatusReplication = maxThreadsForStatusReplication; - } - - @Override - public int getMaxElementsInStatusReplicationPool() { - return maxElementsInStatusReplicationPool; - } - - public void setMaxElementsInStatusReplicationPool(int maxElementsInStatusReplicationPool) { - this.maxElementsInStatusReplicationPool = maxElementsInStatusReplicationPool; - } - - public boolean isSyncWhenTimestampDiffers() { - return syncWhenTimestampDiffers; - } - - public void setSyncWhenTimestampDiffers(boolean syncWhenTimestampDiffers) { - this.syncWhenTimestampDiffers = syncWhenTimestampDiffers; - } - - @Override - public int getRegistrySyncRetries() { - return registrySyncRetries; - } - - public void setRegistrySyncRetries(int registrySyncRetries) { - this.registrySyncRetries = registrySyncRetries; - } - - @Override - public long getRegistrySyncRetryWaitMs() { - return registrySyncRetryWaitMs; - } - - public void setRegistrySyncRetryWaitMs(long registrySyncRetryWaitMs) { - this.registrySyncRetryWaitMs = registrySyncRetryWaitMs; - } - - @Override - public int getMaxElementsInPeerReplicationPool() { - return maxElementsInPeerReplicationPool; - } - - public void setMaxElementsInPeerReplicationPool(int maxElementsInPeerReplicationPool) { - this.maxElementsInPeerReplicationPool = maxElementsInPeerReplicationPool; - } - - @Override - public long getMaxIdleThreadAgeInMinutesForPeerReplication() { - return maxIdleThreadAgeInMinutesForPeerReplication; - } - - public void setMaxIdleThreadAgeInMinutesForPeerReplication(long maxIdleThreadAgeInMinutesForPeerReplication) { - this.maxIdleThreadAgeInMinutesForPeerReplication = maxIdleThreadAgeInMinutesForPeerReplication; - } - - @Override - public int getMinThreadsForPeerReplication() { - return minThreadsForPeerReplication; - } - - public void setMinThreadsForPeerReplication(int minThreadsForPeerReplication) { - this.minThreadsForPeerReplication = minThreadsForPeerReplication; - } - - @Override - public int getMaxThreadsForPeerReplication() { - return maxThreadsForPeerReplication; - } - - public void setMaxThreadsForPeerReplication(int maxThreadsForPeerReplication) { - this.maxThreadsForPeerReplication = maxThreadsForPeerReplication; - } - - @Override - public int getMaxTimeForReplication() { - return maxTimeForReplication; - } - - public void setMaxTimeForReplication(int maxTimeForReplication) { - this.maxTimeForReplication = maxTimeForReplication; - } - - public boolean isPrimeAwsReplicaConnections() { - return primeAwsReplicaConnections; - } - - public void setPrimeAwsReplicaConnections(boolean primeAwsReplicaConnections) { - this.primeAwsReplicaConnections = primeAwsReplicaConnections; - } - - public boolean isDisableDeltaForRemoteRegions() { - return disableDeltaForRemoteRegions; - } - - public void setDisableDeltaForRemoteRegions(boolean disableDeltaForRemoteRegions) { - this.disableDeltaForRemoteRegions = disableDeltaForRemoteRegions; - } - - @Override - public int getRemoteRegionConnectTimeoutMs() { - return remoteRegionConnectTimeoutMs; - } - - public void setRemoteRegionConnectTimeoutMs(int remoteRegionConnectTimeoutMs) { - this.remoteRegionConnectTimeoutMs = remoteRegionConnectTimeoutMs; - } - - @Override - public int getRemoteRegionReadTimeoutMs() { - return remoteRegionReadTimeoutMs; - } - - public void setRemoteRegionReadTimeoutMs(int remoteRegionReadTimeoutMs) { - this.remoteRegionReadTimeoutMs = remoteRegionReadTimeoutMs; - } - - @Override - public int getRemoteRegionTotalConnections() { - return remoteRegionTotalConnections; - } - - public void setRemoteRegionTotalConnections(int remoteRegionTotalConnections) { - this.remoteRegionTotalConnections = remoteRegionTotalConnections; - } - - @Override - public int getRemoteRegionTotalConnectionsPerHost() { - return remoteRegionTotalConnectionsPerHost; - } - - public void setRemoteRegionTotalConnectionsPerHost(int remoteRegionTotalConnectionsPerHost) { - this.remoteRegionTotalConnectionsPerHost = remoteRegionTotalConnectionsPerHost; - } - - @Override - public int getRemoteRegionConnectionIdleTimeoutSeconds() { - return remoteRegionConnectionIdleTimeoutSeconds; - } - - public void setRemoteRegionConnectionIdleTimeoutSeconds(int remoteRegionConnectionIdleTimeoutSeconds) { - this.remoteRegionConnectionIdleTimeoutSeconds = remoteRegionConnectionIdleTimeoutSeconds; - } - - public boolean isgZipContentFromRemoteRegion() { - return gZipContentFromRemoteRegion; - } - - public void setgZipContentFromRemoteRegion(boolean gZipContentFromRemoteRegion) { - this.gZipContentFromRemoteRegion = gZipContentFromRemoteRegion; - } - - @Override - public Map getRemoteRegionUrlsWithName() { - return remoteRegionUrlsWithName; - } - - public void setRemoteRegionUrlsWithName(Map remoteRegionUrlsWithName) { - this.remoteRegionUrlsWithName = remoteRegionUrlsWithName; - } - - @Override - public String[] getRemoteRegionUrls() { - return remoteRegionUrls; - } - - public void setRemoteRegionUrls(String[] remoteRegionUrls) { - this.remoteRegionUrls = remoteRegionUrls; - } - - public Map> getRemoteRegionAppWhitelist() { - return remoteRegionAppWhitelist; - } - - public void setRemoteRegionAppWhitelist(Map> remoteRegionAppWhitelist) { - this.remoteRegionAppWhitelist = remoteRegionAppWhitelist; - } - - @Override - public int getRemoteRegionRegistryFetchInterval() { - return remoteRegionRegistryFetchInterval; - } - - public void setRemoteRegionRegistryFetchInterval(int remoteRegionRegistryFetchInterval) { - this.remoteRegionRegistryFetchInterval = remoteRegionRegistryFetchInterval; - } - - @Override - public int getRemoteRegionFetchThreadPoolSize() { - return remoteRegionFetchThreadPoolSize; - } - - public void setRemoteRegionFetchThreadPoolSize(int remoteRegionFetchThreadPoolSize) { - this.remoteRegionFetchThreadPoolSize = remoteRegionFetchThreadPoolSize; - } - - @Override - public String getRemoteRegionTrustStore() { - return remoteRegionTrustStore; - } - - public void setRemoteRegionTrustStore(String remoteRegionTrustStore) { - this.remoteRegionTrustStore = remoteRegionTrustStore; - } - - @Override - public String getRemoteRegionTrustStorePassword() { - return remoteRegionTrustStorePassword; - } - - public void setRemoteRegionTrustStorePassword(String remoteRegionTrustStorePassword) { - this.remoteRegionTrustStorePassword = remoteRegionTrustStorePassword; - } - - public boolean isDisableTransparentFallbackToOtherRegion() { - return disableTransparentFallbackToOtherRegion; - } - - public void setDisableTransparentFallbackToOtherRegion(boolean disableTransparentFallbackToOtherRegion) { - this.disableTransparentFallbackToOtherRegion = disableTransparentFallbackToOtherRegion; - } - - public boolean isBatchReplication() { - return batchReplication; - } - - public void setBatchReplication(boolean batchReplication) { - this.batchReplication = batchReplication; - } - - @Override - public boolean isRateLimiterEnabled() { - return rateLimiterEnabled; - } - - public void setRateLimiterEnabled(boolean rateLimiterEnabled) { - this.rateLimiterEnabled = rateLimiterEnabled; - } - - @Override - public boolean isRateLimiterThrottleStandardClients() { - return rateLimiterThrottleStandardClients; - } - - public void setRateLimiterThrottleStandardClients(boolean rateLimiterThrottleStandardClients) { - this.rateLimiterThrottleStandardClients = rateLimiterThrottleStandardClients; - } - - @Override - public Set getRateLimiterPrivilegedClients() { - return rateLimiterPrivilegedClients; - } - - public void setRateLimiterPrivilegedClients(Set rateLimiterPrivilegedClients) { - this.rateLimiterPrivilegedClients = rateLimiterPrivilegedClients; - } - - @Override - public int getRateLimiterBurstSize() { - return rateLimiterBurstSize; - } - - public void setRateLimiterBurstSize(int rateLimiterBurstSize) { - this.rateLimiterBurstSize = rateLimiterBurstSize; - } - - @Override - public int getRateLimiterRegistryFetchAverageRate() { - return rateLimiterRegistryFetchAverageRate; - } - - public void setRateLimiterRegistryFetchAverageRate(int rateLimiterRegistryFetchAverageRate) { - this.rateLimiterRegistryFetchAverageRate = rateLimiterRegistryFetchAverageRate; - } - - @Override - public int getRateLimiterFullFetchAverageRate() { - return rateLimiterFullFetchAverageRate; - } - - public void setRateLimiterFullFetchAverageRate(int rateLimiterFullFetchAverageRate) { - this.rateLimiterFullFetchAverageRate = rateLimiterFullFetchAverageRate; - } - - public boolean isLogIdentityHeaders() { - return logIdentityHeaders; - } - - public void setLogIdentityHeaders(boolean logIdentityHeaders) { - this.logIdentityHeaders = logIdentityHeaders; - } - - @Override - public String getListAutoScalingGroupsRoleName() { - return listAutoScalingGroupsRoleName; - } - - public void setListAutoScalingGroupsRoleName(String listAutoScalingGroupsRoleName) { - this.listAutoScalingGroupsRoleName = listAutoScalingGroupsRoleName; - } - - public boolean isEnableReplicatedRequestCompression() { - return enableReplicatedRequestCompression; - } - - public void setEnableReplicatedRequestCompression(boolean enableReplicatedRequestCompression) { - this.enableReplicatedRequestCompression = enableReplicatedRequestCompression; - } - - public void setJsonCodecName(String jsonCodecName) { - this.jsonCodecName = jsonCodecName; - } - - public void setXmlCodecName(String xmlCodecName) { - this.xmlCodecName = xmlCodecName; - } - - @Override - public int getRoute53BindRebindRetries() { - return route53BindRebindRetries; - } - - public void setRoute53BindRebindRetries(int route53BindRebindRetries) { - this.route53BindRebindRetries = route53BindRebindRetries; - } - - @Override - public int getRoute53BindingRetryIntervalMs() { - return route53BindingRetryIntervalMs; - } - - public void setRoute53BindingRetryIntervalMs(int route53BindingRetryIntervalMs) { - this.route53BindingRetryIntervalMs = route53BindingRetryIntervalMs; - } - - @Override - public long getRoute53DomainTTL() { - return route53DomainTTL; - } - - public void setRoute53DomainTTL(long route53DomainTTL) { - this.route53DomainTTL = route53DomainTTL; - } - - @Override - public AwsBindingStrategy getBindingStrategy() { - return bindingStrategy; - } - - public void setBindingStrategy(AwsBindingStrategy bindingStrategy) { - this.bindingStrategy = bindingStrategy; - } - - public int getMinAvailableInstancesForPeerReplication() { - return minAvailableInstancesForPeerReplication; - } - - public void setMinAvailableInstancesForPeerReplication(int minAvailableInstancesForPeerReplication) { - this.minAvailableInstancesForPeerReplication = minAvailableInstancesForPeerReplication; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaServerConfigBean that = (EurekaServerConfigBean) o; - return aSGCacheExpiryTimeoutMs == that.aSGCacheExpiryTimeoutMs && aSGQueryTimeoutMs == that.aSGQueryTimeoutMs - && aSGUpdateIntervalMs == that.aSGUpdateIntervalMs && Objects.equals(aWSAccessId, that.aWSAccessId) - && Objects.equals(aWSSecretKey, that.aWSSecretKey) && batchReplication == that.batchReplication - && bindingStrategy == that.bindingStrategy - && deltaRetentionTimerIntervalInMs == that.deltaRetentionTimerIntervalInMs - && disableDelta == that.disableDelta - && disableDeltaForRemoteRegions == that.disableDeltaForRemoteRegions - && disableTransparentFallbackToOtherRegion == that.disableTransparentFallbackToOtherRegion - && eIPBindingRetryIntervalMs == that.eIPBindingRetryIntervalMs - && eIPBindingRetryIntervalMsWhenUnbound == that.eIPBindingRetryIntervalMsWhenUnbound - && eIPBindRebindRetries == that.eIPBindRebindRetries - && enableReplicatedRequestCompression == that.enableReplicatedRequestCompression - && enableSelfPreservation == that.enableSelfPreservation - && evictionIntervalTimerInMs == that.evictionIntervalTimerInMs - && gZipContentFromRemoteRegion == that.gZipContentFromRemoteRegion - && Objects.equals(jsonCodecName, that.jsonCodecName) - && Objects.equals(listAutoScalingGroupsRoleName, that.listAutoScalingGroupsRoleName) - && logIdentityHeaders == that.logIdentityHeaders - && maxElementsInPeerReplicationPool == that.maxElementsInPeerReplicationPool - && maxElementsInStatusReplicationPool == that.maxElementsInStatusReplicationPool - && maxIdleThreadAgeInMinutesForPeerReplication == that.maxIdleThreadAgeInMinutesForPeerReplication - && maxIdleThreadInMinutesAgeForStatusReplication == that.maxIdleThreadInMinutesAgeForStatusReplication - && maxThreadsForPeerReplication == that.maxThreadsForPeerReplication - && maxThreadsForStatusReplication == that.maxThreadsForStatusReplication - && maxTimeForReplication == that.maxTimeForReplication - && minAvailableInstancesForPeerReplication == that.minAvailableInstancesForPeerReplication - && minThreadsForPeerReplication == that.minThreadsForPeerReplication - && minThreadsForStatusReplication == that.minThreadsForStatusReplication - && numberOfReplicationRetries == that.numberOfReplicationRetries - && peerEurekaNodesUpdateIntervalMs == that.peerEurekaNodesUpdateIntervalMs - && peerEurekaStatusRefreshTimeIntervalMs == that.peerEurekaStatusRefreshTimeIntervalMs - && peerNodeConnectionIdleTimeoutSeconds == that.peerNodeConnectionIdleTimeoutSeconds - && peerNodeConnectTimeoutMs == that.peerNodeConnectTimeoutMs - && peerNodeReadTimeoutMs == that.peerNodeReadTimeoutMs - && peerNodeTotalConnections == that.peerNodeTotalConnections - && peerNodeTotalConnectionsPerHost == that.peerNodeTotalConnectionsPerHost - && primeAwsReplicaConnections == that.primeAwsReplicaConnections - && Objects.equals(propertyResolver, that.propertyResolver) - && rateLimiterBurstSize == that.rateLimiterBurstSize && rateLimiterEnabled == that.rateLimiterEnabled - && rateLimiterFullFetchAverageRate == that.rateLimiterFullFetchAverageRate - && Objects.equals(rateLimiterPrivilegedClients, that.rateLimiterPrivilegedClients) - && rateLimiterRegistryFetchAverageRate == that.rateLimiterRegistryFetchAverageRate - && rateLimiterThrottleStandardClients == that.rateLimiterThrottleStandardClients - && registrySyncRetries == that.registrySyncRetries - && registrySyncRetryWaitMs == that.registrySyncRetryWaitMs - && Objects.equals(remoteRegionAppWhitelist, that.remoteRegionAppWhitelist) - && remoteRegionConnectionIdleTimeoutSeconds == that.remoteRegionConnectionIdleTimeoutSeconds - && remoteRegionConnectTimeoutMs == that.remoteRegionConnectTimeoutMs - && remoteRegionFetchThreadPoolSize == that.remoteRegionFetchThreadPoolSize - && remoteRegionReadTimeoutMs == that.remoteRegionReadTimeoutMs - && remoteRegionRegistryFetchInterval == that.remoteRegionRegistryFetchInterval - && remoteRegionTotalConnections == that.remoteRegionTotalConnections - && remoteRegionTotalConnectionsPerHost == that.remoteRegionTotalConnectionsPerHost - && Objects.equals(remoteRegionTrustStore, that.remoteRegionTrustStore) - && Objects.equals(remoteRegionTrustStorePassword, that.remoteRegionTrustStorePassword) - && Arrays.equals(remoteRegionUrls, that.remoteRegionUrls) - && Objects.equals(remoteRegionUrlsWithName, that.remoteRegionUrlsWithName) - && Double.compare(that.renewalPercentThreshold, renewalPercentThreshold) == 0 - && renewalThresholdUpdateIntervalMs == that.renewalThresholdUpdateIntervalMs - && responseCacheAutoExpirationInSeconds == that.responseCacheAutoExpirationInSeconds - && responseCacheUpdateIntervalMs == that.responseCacheUpdateIntervalMs - && retentionTimeInMSInDeltaQueue == that.retentionTimeInMSInDeltaQueue - && route53BindingRetryIntervalMs == that.route53BindingRetryIntervalMs - && route53BindRebindRetries == that.route53BindRebindRetries - && route53DomainTTL == that.route53DomainTTL - && syncWhenTimestampDiffers == that.syncWhenTimestampDiffers - && useReadOnlyResponseCache == that.useReadOnlyResponseCache - && waitTimeInMsWhenSyncEmpty == that.waitTimeInMsWhenSyncEmpty - && Objects.equals(xmlCodecName, that.xmlCodecName) - && initialCapacityOfResponseCache == that.initialCapacityOfResponseCache - && expectedClientRenewalIntervalSeconds == that.expectedClientRenewalIntervalSeconds - && useAwsAsgApi == that.useAwsAsgApi && Objects.equals(myUrl, that.myUrl); - } - - @Override - public int hashCode() { - return Objects.hash(aSGCacheExpiryTimeoutMs, aSGQueryTimeoutMs, aSGUpdateIntervalMs, aWSAccessId, aWSSecretKey, - batchReplication, bindingStrategy, deltaRetentionTimerIntervalInMs, disableDelta, - disableDeltaForRemoteRegions, disableTransparentFallbackToOtherRegion, eIPBindRebindRetries, - eIPBindingRetryIntervalMs, eIPBindingRetryIntervalMsWhenUnbound, enableReplicatedRequestCompression, - enableSelfPreservation, evictionIntervalTimerInMs, gZipContentFromRemoteRegion, jsonCodecName, - listAutoScalingGroupsRoleName, logIdentityHeaders, maxElementsInPeerReplicationPool, - maxElementsInStatusReplicationPool, maxIdleThreadAgeInMinutesForPeerReplication, - maxIdleThreadInMinutesAgeForStatusReplication, maxThreadsForPeerReplication, - maxThreadsForStatusReplication, maxTimeForReplication, minAvailableInstancesForPeerReplication, - minThreadsForPeerReplication, minThreadsForStatusReplication, numberOfReplicationRetries, - peerEurekaNodesUpdateIntervalMs, peerEurekaStatusRefreshTimeIntervalMs, peerNodeConnectTimeoutMs, - peerNodeConnectionIdleTimeoutSeconds, peerNodeReadTimeoutMs, peerNodeTotalConnections, - peerNodeTotalConnectionsPerHost, primeAwsReplicaConnections, propertyResolver, rateLimiterBurstSize, - rateLimiterEnabled, rateLimiterFullFetchAverageRate, rateLimiterPrivilegedClients, - rateLimiterRegistryFetchAverageRate, rateLimiterThrottleStandardClients, registrySyncRetries, - registrySyncRetryWaitMs, remoteRegionAppWhitelist, remoteRegionConnectTimeoutMs, - remoteRegionConnectionIdleTimeoutSeconds, remoteRegionFetchThreadPoolSize, remoteRegionReadTimeoutMs, - remoteRegionRegistryFetchInterval, remoteRegionTotalConnections, remoteRegionTotalConnectionsPerHost, - remoteRegionTrustStore, remoteRegionTrustStorePassword, Arrays.hashCode(remoteRegionUrls), - remoteRegionUrlsWithName, renewalPercentThreshold, renewalThresholdUpdateIntervalMs, - responseCacheAutoExpirationInSeconds, responseCacheUpdateIntervalMs, retentionTimeInMSInDeltaQueue, - route53BindRebindRetries, route53BindingRetryIntervalMs, route53DomainTTL, syncWhenTimestampDiffers, - useReadOnlyResponseCache, waitTimeInMsWhenSyncEmpty, xmlCodecName, initialCapacityOfResponseCache, - expectedClientRenewalIntervalSeconds, useAwsAsgApi, myUrl); - } - - @Override - public String toString() { - return new ToStringCreator(this).append("aSGCacheExpiryTimeoutMs", this.aSGCacheExpiryTimeoutMs) - .append("aSGQueryTimeoutMs", this.aSGQueryTimeoutMs) - .append("aSGUpdateIntervalMs", this.aSGUpdateIntervalMs).append("aWSAccessId", this.aWSAccessId) - .append("aWSSecretKey", this.aWSSecretKey).append("batchReplication", this.batchReplication) - .append("bindingStrategy", this.bindingStrategy) - .append("deltaRetentionTimerIntervalInMs", this.deltaRetentionTimerIntervalInMs) - .append("disableDelta", this.disableDelta) - .append("disableDeltaForRemoteRegions", this.disableDeltaForRemoteRegions) - .append("disableTransparentFallbackToOtherRegion", this.disableTransparentFallbackToOtherRegion) - .append("eIPBindRebindRetries", this.eIPBindRebindRetries) - .append("eIPBindingRetryIntervalMs", this.eIPBindingRetryIntervalMs) - .append("eIPBindingRetryIntervalMsWhenUnbound", this.eIPBindingRetryIntervalMsWhenUnbound) - .append("enableReplicatedRequestCompression", this.enableReplicatedRequestCompression) - .append("enableSelfPreservation", this.enableSelfPreservation) - .append("evictionIntervalTimerInMs", this.evictionIntervalTimerInMs) - .append("gZipContentFromRemoteRegion", this.gZipContentFromRemoteRegion) - .append("jsonCodecName", this.jsonCodecName) - .append("listAutoScalingGroupsRoleName", this.listAutoScalingGroupsRoleName) - .append("logIdentityHeaders", this.logIdentityHeaders) - .append("maxElementsInPeerReplicationPool", this.maxElementsInPeerReplicationPool) - .append("maxElementsInStatusReplicationPool", this.maxElementsInStatusReplicationPool) - .append("maxIdleThreadAgeInMinutesForPeerReplication", this.maxIdleThreadAgeInMinutesForPeerReplication) - .append("maxIdleThreadInMinutesAgeForStatusReplication", - this.maxIdleThreadInMinutesAgeForStatusReplication) - .append("maxThreadsForPeerReplication", this.maxThreadsForPeerReplication) - .append("maxThreadsForStatusReplication", this.maxThreadsForStatusReplication) - .append("maxTimeForReplication", this.maxTimeForReplication) - .append("minAvailableInstancesForPeerReplication", this.minAvailableInstancesForPeerReplication) - .append("minThreadsForPeerReplication", this.minThreadsForPeerReplication) - .append("minThreadsForStatusReplication", this.minThreadsForStatusReplication) - .append("numberOfReplicationRetries", this.numberOfReplicationRetries) - .append("peerEurekaNodesUpdateIntervalMs", this.peerEurekaNodesUpdateIntervalMs) - .append("peerEurekaStatusRefreshTimeIntervalMs", this.peerEurekaStatusRefreshTimeIntervalMs) - .append("peerNodeConnectTimeoutMs", this.peerNodeConnectTimeoutMs) - .append("peerNodeConnectionIdleTimeoutSeconds", this.peerNodeConnectionIdleTimeoutSeconds) - .append("peerNodeReadTimeoutMs", this.peerNodeReadTimeoutMs) - .append("peerNodeTotalConnections", this.peerNodeTotalConnections) - .append("peerNodeTotalConnectionsPerHost", this.peerNodeTotalConnectionsPerHost) - .append("primeAwsReplicaConnections", this.primeAwsReplicaConnections) - .append("propertyResolver", this.propertyResolver) - .append("rateLimiterBurstSize", this.rateLimiterBurstSize) - .append("rateLimiterEnabled", this.rateLimiterEnabled) - .append("rateLimiterFullFetchAverageRate", this.rateLimiterFullFetchAverageRate) - .append("rateLimiterPrivilegedClients", this.rateLimiterPrivilegedClients) - .append("rateLimiterRegistryFetchAverageRate", this.rateLimiterRegistryFetchAverageRate) - .append("rateLimiterThrottleStandardClients", this.rateLimiterThrottleStandardClients) - .append("registrySyncRetries", this.registrySyncRetries) - .append("registrySyncRetryWaitMs", this.registrySyncRetryWaitMs) - .append("remoteRegionAppWhitelist", this.remoteRegionAppWhitelist) - .append("remoteRegionConnectTimeoutMs", this.remoteRegionConnectTimeoutMs) - .append("remoteRegionConnectionIdleTimeoutSeconds", this.remoteRegionConnectionIdleTimeoutSeconds) - .append("remoteRegionFetchThreadPoolSize", this.remoteRegionFetchThreadPoolSize) - .append("remoteRegionReadTimeoutMs", this.remoteRegionReadTimeoutMs) - .append("remoteRegionRegistryFetchInterval", this.remoteRegionRegistryFetchInterval) - .append("remoteRegionTotalConnections", this.remoteRegionTotalConnections) - .append("remoteRegionTotalConnectionsPerHost", this.remoteRegionTotalConnectionsPerHost) - .append("remoteRegionTrustStore", this.remoteRegionTrustStore) - .append("remoteRegionTrustStorePassword", this.remoteRegionTrustStorePassword) - .append("remoteRegionUrls", this.remoteRegionUrls) - .append("remoteRegionUrlsWithName", this.remoteRegionUrlsWithName) - .append("renewalPercentThreshold", this.renewalPercentThreshold) - .append("renewalThresholdUpdateIntervalMs", this.renewalThresholdUpdateIntervalMs) - .append("responseCacheAutoExpirationInSeconds", this.responseCacheAutoExpirationInSeconds) - .append("responseCacheUpdateIntervalMs", this.responseCacheUpdateIntervalMs) - .append("retentionTimeInMSInDeltaQueue", this.retentionTimeInMSInDeltaQueue) - .append("route53BindRebindRetries", this.route53BindRebindRetries) - .append("route53BindingRetryIntervalMs", this.route53BindingRetryIntervalMs) - .append("route53DomainTTL", this.route53DomainTTL) - .append("syncWhenTimestampDiffers", this.syncWhenTimestampDiffers) - .append("useReadOnlyResponseCache", this.useReadOnlyResponseCache) - .append("waitTimeInMsWhenSyncEmpty", this.waitTimeInMsWhenSyncEmpty) - .append("xmlCodecName", this.xmlCodecName) - .append("initialCapacityOfResponseCache", this.initialCapacityOfResponseCache) - .append("expectedClientRenewalIntervalSeconds", this.expectedClientRenewalIntervalSeconds) - .append("useAwsAsgApi", this.useAwsAsgApi).append("myUrl", this.myUrl).toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfiguration.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfiguration.java deleted file mode 100644 index 0af1cfbab..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfiguration.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import com.netflix.eureka.EurekaServerConfig; -import jakarta.servlet.ServletContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.netflix.eureka.server.event.EurekaRegistryAvailableEvent; -import org.springframework.cloud.netflix.eureka.server.event.EurekaServerStartedEvent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.SmartLifecycle; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.web.context.ServletContextAware; - -/** - * @author Dave Syer - */ -@Configuration(proxyBeanMethods = false) -public class EurekaServerInitializerConfiguration implements ServletContextAware, SmartLifecycle, Ordered { - - private static final Log log = LogFactory.getLog(EurekaServerInitializerConfiguration.class); - - @Autowired - private EurekaServerConfig eurekaServerConfig; - - private ServletContext servletContext; - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private EurekaServerBootstrap eurekaServerBootstrap; - - private boolean running; - - private final int order = 1; - - @Override - public void setServletContext(ServletContext servletContext) { - this.servletContext = servletContext; - } - - @Override - public void start() { - new Thread(() -> { - try { - // TODO: is this class even needed now? - eurekaServerBootstrap.contextInitialized(EurekaServerInitializerConfiguration.this.servletContext); - log.info("Started Eureka Server"); - - publish(new EurekaRegistryAvailableEvent(getEurekaServerConfig())); - EurekaServerInitializerConfiguration.this.running = true; - publish(new EurekaServerStartedEvent(getEurekaServerConfig())); - } - catch (Exception ex) { - // Help! - log.error("Could not initialize Eureka servlet context", ex); - } - }).start(); - } - - private EurekaServerConfig getEurekaServerConfig() { - return this.eurekaServerConfig; - } - - private void publish(ApplicationEvent event) { - this.applicationContext.publishEvent(event); - } - - @Override - public void stop() { - this.running = false; - eurekaServerBootstrap.contextDestroyed(this.servletContext); - } - - @Override - public boolean isRunning() { - return this.running; - } - - @Override - public int getPhase() { - return 0; - } - - @Override - public boolean isAutoStartup() { - return true; - } - - @Override - public int getOrder() { - return this.order; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerMarkerConfiguration.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerMarkerConfiguration.java deleted file mode 100644 index 2fde952ee..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerMarkerConfiguration.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2017-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Responsible for adding in a marker bean to activate - * {@link EurekaServerAutoConfiguration}. - * - * @author Biju Kunjummen - */ -@Configuration(proxyBeanMethods = false) -public class EurekaServerMarkerConfiguration { - - @Bean - public Marker eurekaServerMarkerBean() { - return new Marker(); - } - - class Marker { - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java deleted file mode 100644 index ff903e50b..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.EurekaClient; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.discovery.shared.Application; -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.lease.Lease; -import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl; -import com.netflix.eureka.resources.ServerCodecs; -import com.netflix.eureka.transport.EurekaServerHttpClientFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.BeansException; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEvent; - -/** - * @author Spencer Gibb - */ -public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements ApplicationContextAware { - - private static final Log log = LogFactory.getLog(InstanceRegistry.class); - - private ApplicationContext ctxt; - - private final int defaultOpenForTrafficCount; - - public InstanceRegistry(EurekaServerConfig serverConfig, EurekaClientConfig clientConfig, ServerCodecs serverCodecs, - EurekaClient eurekaClient, EurekaServerHttpClientFactory eurekaServerHttpClientFactory, - int expectedNumberOfClientsSendingRenews, int defaultOpenForTrafficCount) { - super(serverConfig, clientConfig, serverCodecs, eurekaClient, eurekaServerHttpClientFactory); - - this.expectedNumberOfClientsSendingRenews = expectedNumberOfClientsSendingRenews; - this.defaultOpenForTrafficCount = defaultOpenForTrafficCount; - } - - @Override - public void setApplicationContext(ApplicationContext context) throws BeansException { - this.ctxt = context; - } - - /** - * If - * {@link PeerAwareInstanceRegistryImpl#openForTraffic(ApplicationInfoManager, int)} - * is called with a zero argument, it means that leases are not automatically - * cancelled if the instance hasn't sent any renewals recently. This happens for a - * standalone server. It seems like a bad default, so we set it to the smallest - * non-zero value we can, so that any instances that subsequently register can bump up - * the threshold. - */ - @Override - public void openForTraffic(ApplicationInfoManager applicationInfoManager, int count) { - super.openForTraffic(applicationInfoManager, count == 0 ? this.defaultOpenForTrafficCount : count); - } - - @Override - public void register(InstanceInfo info, int leaseDuration, boolean isReplication) { - handleRegistration(info, leaseDuration, isReplication); - super.register(info, leaseDuration, isReplication); - } - - @Override - public void register(final InstanceInfo info, final boolean isReplication) { - handleRegistration(info, resolveInstanceLeaseDuration(info), isReplication); - super.register(info, isReplication); - } - - @Override - public boolean cancel(String appName, String serverId, boolean isReplication) { - handleCancelation(appName, serverId, isReplication); - return super.cancel(appName, serverId, isReplication); - } - - @Override - public boolean renew(final String appName, final String serverId, boolean isReplication) { - log("renew " + appName + " serverId " + serverId + ", isReplication {}" + isReplication); - Application application = getApplication(appName); - if (application != null) { - InstanceInfo instanceInfo = application.getByInstanceId(serverId); - if (instanceInfo != null) { - publishEvent(new EurekaInstanceRenewedEvent(this, appName, serverId, instanceInfo, isReplication)); - } - } - return super.renew(appName, serverId, isReplication); - } - - @Override - protected boolean internalCancel(String appName, String id, boolean isReplication) { - handleCancelation(appName, id, isReplication); - return super.internalCancel(appName, id, isReplication); - } - - private void handleCancelation(String appName, String id, boolean isReplication) { - log("cancel " + appName + ", serverId " + id + ", isReplication " + isReplication); - publishEvent(new EurekaInstanceCanceledEvent(this, appName, id, isReplication)); - } - - private void handleRegistration(InstanceInfo info, int leaseDuration, boolean isReplication) { - log("register " + info.getAppName() + ", vip " + info.getVIPAddress() + ", leaseDuration " + leaseDuration - + ", isReplication " + isReplication); - publishEvent(new EurekaInstanceRegisteredEvent(this, info, leaseDuration, isReplication)); - } - - private void log(String message) { - if (log.isDebugEnabled()) { - log.debug(message); - } - } - - private void publishEvent(ApplicationEvent applicationEvent) { - this.ctxt.publishEvent(applicationEvent); - } - - private int resolveInstanceLeaseDuration(final InstanceInfo info) { - int leaseDuration = Lease.DEFAULT_DURATION_IN_SECS; - if (info.getLeaseInfo() != null && info.getLeaseInfo().getDurationInSecs() > 0) { - leaseDuration = info.getLeaseInfo().getDurationInSecs(); - } - return leaseDuration; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java deleted file mode 100644 index cbac21450..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryProperties.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import static org.springframework.cloud.netflix.eureka.server.InstanceRegistryProperties.PREFIX; - -/** - * @author Spencer Gibb - */ -@ConfigurationProperties(PREFIX) -public class InstanceRegistryProperties { - - /** - * Prefix for Eureka instance registry properties. - */ - public static final String PREFIX = "eureka.instance.registry"; - - /* - * Default number of expected client, defaults to 1. Setting - * expectedNumberOfClientsSendingRenews to non-zero to ensure that even an isolated - * server can adjust its eviction policy to the number of registrations (when it's - * zero, even a successful registration won't reset the rate threshold in - * InstanceRegistry.register()). - */ - @Value("${eureka.server.expectedNumberOfRenewsPerMin:1}") // for backwards - // compatibility - private int expectedNumberOfClientsSendingRenews = 1; - - /** - * Value used in determining when leases are cancelled, default to 1 for standalone. - * Should be set to 0 for peer replicated eurekas - */ - @Value("${eureka.server.defaultOpenForTrafficCount:1}") // for backwards compatibility - private int defaultOpenForTrafficCount = 1; - - public int getExpectedNumberOfClientsSendingRenews() { - return expectedNumberOfClientsSendingRenews; - } - - public void setExpectedNumberOfClientsSendingRenews(int expectedNumberOfClientsSendingRenews) { - this.expectedNumberOfClientsSendingRenews = expectedNumberOfClientsSendingRenews; - } - - public int getDefaultOpenForTrafficCount() { - return defaultOpenForTrafficCount; - } - - public void setDefaultOpenForTrafficCount(int defaultOpenForTrafficCount) { - this.defaultOpenForTrafficCount = defaultOpenForTrafficCount; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/ReplicationClientAdditionalFilters.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/ReplicationClientAdditionalFilters.java deleted file mode 100644 index 26b044717..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/ReplicationClientAdditionalFilters.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Collection; -import java.util.LinkedHashSet; - -import jakarta.ws.rs.client.ClientRequestFilter; - -/** - * @author Yuxin Bai - */ -public class ReplicationClientAdditionalFilters { - - private final Collection filters; - - public ReplicationClientAdditionalFilters(Collection filters) { - this.filters = new LinkedHashSet<>(filters); - } - - public Collection getFilters() { - return this.filters; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceCanceledEvent.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceCanceledEvent.java deleted file mode 100644 index c4f01ff6f..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceCanceledEvent.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server.event; - -import java.util.Objects; - -import org.springframework.context.ApplicationEvent; - -/** - * @author Spencer Gibb - * @author Gregor Zurowski - */ -@SuppressWarnings("serial") -public class EurekaInstanceCanceledEvent extends ApplicationEvent { - - private String appName; - - private String serverId; - - private boolean replication; - - public EurekaInstanceCanceledEvent(Object source, String appName, String serverId, boolean replication) { - super(source); - this.appName = appName; - this.serverId = serverId; - this.replication = replication; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public boolean isReplication() { - return replication; - } - - public void setReplication(boolean replication) { - this.replication = replication; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaInstanceCanceledEvent that = (EurekaInstanceCanceledEvent) o; - return this.replication == that.replication && Objects.equals(this.appName, that.appName) - && Objects.equals(this.serverId, that.serverId); - } - - @Override - public int hashCode() { - return Objects.hash(appName, serverId, replication); - } - - @Override - public String toString() { - return new StringBuilder("EurekaInstanceCanceledEvent{").append("appName='").append(appName).append("', ") - .append("serverId='").append(serverId).append("', ").append("replication=").append(replication) - .append("}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRegisteredEvent.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRegisteredEvent.java deleted file mode 100644 index c6776b7e8..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRegisteredEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server.event; - -import java.util.Objects; - -import com.netflix.appinfo.InstanceInfo; - -import org.springframework.context.ApplicationEvent; - -/** - * @author Spencer Gibb - * @author Gregor Zurowski - */ -@SuppressWarnings("serial") -public class EurekaInstanceRegisteredEvent extends ApplicationEvent { - - private InstanceInfo instanceInfo; - - private int leaseDuration; - - private boolean replication; - - public EurekaInstanceRegisteredEvent(Object source, InstanceInfo instanceInfo, int leaseDuration, - boolean replication) { - super(source); - this.instanceInfo = instanceInfo; - this.leaseDuration = leaseDuration; - this.replication = replication; - } - - public InstanceInfo getInstanceInfo() { - return instanceInfo; - } - - public void setInstanceInfo(InstanceInfo instanceInfo) { - this.instanceInfo = instanceInfo; - } - - public int getLeaseDuration() { - return leaseDuration; - } - - public void setLeaseDuration(int leaseDuration) { - this.leaseDuration = leaseDuration; - } - - public boolean isReplication() { - return replication; - } - - public void setReplication(boolean replication) { - this.replication = replication; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaInstanceRegisteredEvent that = (EurekaInstanceRegisteredEvent) o; - return this.leaseDuration == that.leaseDuration && this.replication == that.replication - && Objects.equals(this.instanceInfo, that.instanceInfo); - } - - @Override - public int hashCode() { - return Objects.hash(instanceInfo, leaseDuration, replication); - } - - @Override - public String toString() { - return new StringBuilder("EurekaInstanceRegisteredEvent{").append("instanceInfo=").append(instanceInfo) - .append(", ").append("leaseDuration=").append(leaseDuration).append(", ").append("replication=") - .append(replication).append("}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRenewedEvent.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRenewedEvent.java deleted file mode 100644 index 2999d7a5e..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaInstanceRenewedEvent.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server.event; - -import java.util.Objects; - -import com.netflix.appinfo.InstanceInfo; - -import org.springframework.context.ApplicationEvent; - -/** - * @author Spencer Gibb - * @author Gregor Zurowski - */ -@SuppressWarnings("serial") -public class EurekaInstanceRenewedEvent extends ApplicationEvent { - - private String appName; - - private String serverId; - - private InstanceInfo instanceInfo; - - private boolean replication; - - public EurekaInstanceRenewedEvent(Object source, String appName, String serverId, InstanceInfo instanceInfo, - boolean replication) { - super(source); - this.appName = appName; - this.serverId = serverId; - this.instanceInfo = instanceInfo; - this.replication = replication; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public InstanceInfo getInstanceInfo() { - return instanceInfo; - } - - public void setInstanceInfo(InstanceInfo instanceInfo) { - this.instanceInfo = instanceInfo; - } - - public boolean isReplication() { - return replication; - } - - public void setReplication(boolean replication) { - this.replication = replication; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EurekaInstanceRenewedEvent that = (EurekaInstanceRenewedEvent) o; - return Objects.equals(appName, that.appName) && Objects.equals(serverId, that.serverId) - && Objects.equals(instanceInfo, that.instanceInfo) && replication == that.replication; - } - - @Override - public int hashCode() { - return Objects.hash(appName, serverId, instanceInfo, replication); - } - - @Override - public String toString() { - return new StringBuilder("EurekaInstanceRenewedEvent{").append("appName='").append(appName).append("', ") - .append("serverId='").append(serverId).append("', ").append("instanceInfo=").append(instanceInfo) - .append(", ").append("replication=").append(replication).append("}").toString(); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaRegistryAvailableEvent.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaRegistryAvailableEvent.java deleted file mode 100644 index 06a8832fd..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaRegistryAvailableEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server.event; - -import com.netflix.eureka.EurekaServerConfig; - -import org.springframework.context.ApplicationEvent; - -/** - * @author Dave Syer - */ -@SuppressWarnings("serial") -public class EurekaRegistryAvailableEvent extends ApplicationEvent { - - /** - * @param eurekaServerConfig {@link EurekaServerConfig} event source - */ - public EurekaRegistryAvailableEvent(EurekaServerConfig eurekaServerConfig) { - super(eurekaServerConfig); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaServerStartedEvent.java b/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaServerStartedEvent.java deleted file mode 100644 index 7c158bd7b..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/EurekaServerStartedEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server.event; - -import com.netflix.eureka.EurekaServerConfig; - -import org.springframework.context.ApplicationEvent; - -/** - * @author Dave Syer - */ -@SuppressWarnings("serial") -public class EurekaServerStartedEvent extends ApplicationEvent { - - /** - * @param eurekaServerConfig {@link EurekaServerConfig} event source - */ - public EurekaServerStartedEvent(EurekaServerConfig eurekaServerConfig) { - super(eurekaServerConfig); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-netflix-eureka-server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index e6f8989cd..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/eureka/server.properties b/spring-cloud-netflix-eureka-server/src/main/resources/eureka/server.properties deleted file mode 100644 index c08e1571a..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/eureka/server.properties +++ /dev/null @@ -1,2 +0,0 @@ -server.servlet.encoding.force=false - diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.eot b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.eot deleted file mode 100644 index 0caea9169..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.eot and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.svg b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.svg deleted file mode 100644 index 51fb329e3..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.svg +++ /dev/null @@ -1,1283 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.ttf b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.ttf deleted file mode 100644 index 9953fe62e..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.ttf and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.woff b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.woff deleted file mode 100644 index eb49333f7..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/montserrat-webfont.woff and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.eot b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.eot deleted file mode 100644 index dfee0c26e..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.eot and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.svg b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.svg deleted file mode 100644 index d45f3183c..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.svg +++ /dev/null @@ -1,7875 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.ttf b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.ttf deleted file mode 100644 index 3ca066693..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.ttf and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.woff b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.woff deleted file mode 100644 index 77ba16614..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/fonts/varela_round-webfont.woff and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/404-icon.png b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/404-icon.png deleted file mode 100644 index 912f456bf..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/404-icon.png and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/homepage-bg.jpg b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/homepage-bg.jpg deleted file mode 100644 index 031843766..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/homepage-bg.jpg and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-bg.png b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-bg.png deleted file mode 100644 index 512185839..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-bg.png and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-spring-xd.png b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-spring-xd.png deleted file mode 100644 index 0cb2662d7..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/platform-spring-xd.png and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka-mobile.png b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka-mobile.png deleted file mode 100644 index fc59a236b..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka-mobile.png and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka.png b/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka.png deleted file mode 100644 index b22de1f2a..000000000 Binary files a/spring-cloud-netflix-eureka-server/src/main/resources/static/eureka/images/spring-logo-eureka.png and /dev/null differ diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/header.ftlh b/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/header.ftlh deleted file mode 100644 index dff804402..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/header.ftlh +++ /dev/null @@ -1,21 +0,0 @@ -<#import "/spring.ftl" as spring /> - - - diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/lastn.ftlh b/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/lastn.ftlh deleted file mode 100644 index b0157351a..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/lastn.ftlh +++ /dev/null @@ -1,64 +0,0 @@ -<#import "/spring.ftl" as spring /> - - - - - Eureka - Last N events - - - - - - <#include "header.ftlh"> - -
- <#include "navbar.ftlh"> - -
- -
-
- - - - - - <#if lastNCanceled?has_content> - <#list lastNCanceled as entry> - - - <#else> - - - -
TimestampLease
${entry.date?datetime}${entry.id}
No results available
-
-
- - - - - - <#if lastNRegistered?has_content> - <#list lastNRegistered as entry> - - - <#else> - - - -
TimestampLease
${entry.date?datetime}${entry.id}
No results available
-
-
-
-
- - - diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/navbar.ftlh b/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/navbar.ftlh deleted file mode 100644 index 2fe468bf0..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/navbar.ftlh +++ /dev/null @@ -1,71 +0,0 @@ -

System Status

-
-
- - <#if amazonInfo??> - - - - - - - - - - - - - - - - - - - - - -
EUREKA SERVERAMI: ${amiId!}
Zone${availabilityZone!}
instance-id${instanceId!}
Environment${environment!}
Data center${datacenter!}
-
-
- - - - - - - - - - - - - - - - - - - - - -
Current time${currentTime}
Uptime${upTime}
Lease expiration enabled${registry.leaseExpirationEnabled?c}
Renews threshold${registry.numOfRenewsPerMinThreshold}
Renews (last min)${registry.numOfRenewsInLastMin}
-
-
- -<#if isBelowRenewThreshold> - <#if !registry.selfPreservationModeEnabled> -

RENEWALS ARE LESSER THAN THE THRESHOLD. THE SELF PRESERVATION MODE IS TURNED OFF. THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS.

- <#else> -

EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

- -<#elseif !registry.selfPreservationModeEnabled> -

THE SELF PRESERVATION MODE IS TURNED OFF. THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS.

- - -

DS Replicas

- - diff --git a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/status.ftlh b/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/status.ftlh deleted file mode 100755 index 44bb48681..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/resources/templates/eureka/status.ftlh +++ /dev/null @@ -1,109 +0,0 @@ -<#import "/spring.ftl" as spring /> - - - - - - Eureka - - - - - - - - - - - <#include "header.ftlh"> -
- <#include "navbar.ftlh"> -

Instances currently registered with Eureka

- - - - - - <#if apps?has_content> - <#list apps as app> - - - - - - - - <#else> - - - - -
ApplicationAMIsAvailability ZonesStatus
${app.name} - <#list app.amiCounts as amiCount> - ${amiCount.key} (${amiCount.value})<#if amiCount_has_next>, - - - <#list app.zoneCounts as zoneCount> - ${zoneCount.key} (${zoneCount.value})<#if zoneCount_has_next>, - - - <#list app.instanceInfos as instanceInfo> - <#if instanceInfo.isNotUp> - - - ${instanceInfo.status} (${instanceInfo.instances?size}) - - <#if instanceInfo.isNotUp> - - - <#list instanceInfo.instances as instance> - <#if instance.isHref> - ${instance.id} - <#else> - ${instance.id} - <#if instance_has_next>, - - -
No instances available
- -

General Info

- - - - - - - <#list statusInfo.generalStats?keys as stat> - - - - - <#list statusInfo.applicationStats?keys as stat> - - - - - -
NameValue
${stat}${statusInfo.generalStats[stat]!""}
${stat}${statusInfo.applicationStats[stat]!""}
- -

Instance Info

- - - - - - - <#list instanceInfo?keys as key> - - - - - -
NameValue
${key}${instanceInfo[key]!""}
-
- - - diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/header.css b/spring-cloud-netflix-eureka-server/src/main/wro/header.css deleted file mode 100644 index 3ec34f39f..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/header.css +++ /dev/null @@ -1,56 +0,0 @@ -.navbar { - border-top: 4px solid #6db33f; - background-color: #34302d; - margin: 0; - padding: 0; - border-bottom: 0; - border-left: 0; - border-right: 0; -} -.navbar a.navbar-brand { - background: url("../images/spring-logo-eureka.png") -1px -1px no-repeat; - margin: 12px 0 6px; - width: 300px; - height: 46px; - display: inline-block; - text-decoration: none; - padding: 0; -} -.navbar a.navbar-brand span { - display: block; - width: 300px; - height: 46px; - background: url("../images/spring-logo-eureka.png") -1px -48px no-repeat; - opacity: 0; - transition: opacity 0.12s ease-in-out; - -moz-transition: opacity 0.12s ease-in-out; - -webkit-transition: opacity 0.12s ease-in-out; -} -.navbar a:hover.navbar-brand span { - opacity: 1; -} -.nav-link, .navbar-text { - color: #34302d; - font-family: "montserratregular", sans-serif; - text-shadow: none; - font-size: 14px; - padding: 28px 20px; - transition: all 0.15s; - -moz-transition: all 0.15s; - -webkit-transition: all 0.15s; -} -.navbar .nav-link:link { - color: #f1f1f1; - text-transform: uppercase; -} -.navbar .nav-item .nav-link:hover { - color: #f1f1f1; - background-color: #6db33f; -} -.navbar-toggler { - color: #f1f1f1; - border-width: 0; -} -table { - border-color: #34302D; -} diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/main.css b/spring-cloud-netflix-eureka-server/src/main/wro/main.css deleted file mode 100644 index 6e5226f3d..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/main.css +++ /dev/null @@ -1,102 +0,0 @@ -@import "typography.css"; -@import "header.css"; -@import "responsive.css"; - -a:link { - color: #5fa134; -} -a:hover { - color: #5fa134; -} -body { - background-color: #f1f1f1; -} -.table > thead > tr > th { - background-color: #34302D; - color: #f1f1f1; -} -.table-filter { - background-color: #34302D; - padding: 9px 12px; -} -.nav-tabs .nav-link { - color: #838789; -} -.nav-tabs .nav-link.active, .nav-tabs .nav-link.active:hover { - color: #f1f1f1; - background-color: #34302D; - border-color: #34302D; -} -.btn-default { - border-width: 2px; - transition: border 0.15s; - -webkit-transition: border 0.15s; - -moz-transition: border 0.15s; - -o-transition: border 0.15s; - -ms-transition: border 0.15s; - color: #f1f1f1; - background-color: #34302D; - border-color: #6db33f; -} -.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default { - background-color: #34302D; - border-color: #34302D; -} -.container .text-muted { - margin: 20px 0; -} -code { - font-size: 80%; -} -.xd-container { - margin-top: 40px; - margin-bottom: 100px; -} -h1 { - margin-bottom: 15px; -} -.index-page--subtitle { - font-size: 16px; - line-height: 24px; - margin: 0 0 30px; -} -.form-horizontal button.btn-inverse { - margin-left: 32px; -} -#job-params-modal .modal-dialog { - width: 90%; - margin-left: auto; - margin-right: auto; -} -[ng-cloak].splash { - display: block !important; -} -[ng-cloak] { - display: none; -} -.splash { - background: #6db33f; - color: #34302D; - display: none; -} -.error-page { - margin-top: 100px; - text-align: center; -} -.error-page .error-title { - font-size: 24px; - line-height: 24px; - margin: 30px 0 0; -} -table td { - vertical-align: middle !important; -} -table td .progress { - margin-bottom: 0; -} -table td.action-column { - width: 1px; -} -.help-block { - color: #f1f1f1; -} diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/responsive.css b/spring-cloud-netflix-eureka-server/src/main/wro/responsive.css deleted file mode 100644 index f14a0a260..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/responsive.css +++ /dev/null @@ -1,23 +0,0 @@ -@media (max-width: 768px) { - .navbar a.navbar-brand { - background: url("../images/spring-logo-eureka-mobile.png") 0 center no-repeat; - } - .homepage-billboard .homepage-subtitle { - font-size: 21px; - line-height: 21px; - } - .navbar a.navbar-brand span { - display: none; - } - .navbar { - border-top-width: 0; - } - .xd-container { - margin-top: 20px; - margin-bottom: 30px; - } - .index-page--subtitle { - margin-top: 10px; - margin-bottom: 30px; - } -} diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/typography.css b/spring-cloud-netflix-eureka-server/src/main/wro/typography.css deleted file mode 100644 index ecc48fec3..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/typography.css +++ /dev/null @@ -1,42 +0,0 @@ -@font-face { - font-family: 'varela_roundregular'; - src: url('../fonts/varela_round-webfont.eot'); - src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/varela_round-webfont.woff') format('woff'), url('../fonts/varela_round-webfont.ttf') format('truetype'), url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); - font-weight: normal; - font-style: normal; -} -@font-face { - font-family: 'montserratregular'; - src: url('../fonts/montserrat-webfont.eot'); - src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/montserrat-webfont.woff') format('woff'), url('../fonts/montserrat-webfont.ttf') format('truetype'), url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); - font-weight: normal; - font-style: normal; -} -body, h1, h2, h3, p, input { - margin: 0; - font-weight: 400; - font-family: "varela_roundregular", sans-serif; - color: #34302d; -} -h1 { - font-size: 24px; - line-height: 30px; - font-family: "montserratregular", sans-serif; -} -h2 { - font-size: 18px; - font-weight: 700; - line-height: 24px; - margin-bottom: 10px; - font-family: "montserratregular", sans-serif; -} -h3 { - font-size: 16px; - line-height: 24px; - margin-bottom: 10px; - font-weight: 700; -} -strong { - font-weight: 700; - font-family: "montserratregular", sans-serif; -} diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/wro.properties b/spring-cloud-netflix-eureka-server/src/main/wro/wro.properties deleted file mode 100644 index f6c0ecb07..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/wro.properties +++ /dev/null @@ -1,5 +0,0 @@ -#List of preProcessors -preProcessors=cssImport - -#List of postProcessors -postProcessors=jsMin \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/src/main/wro/wro.xml b/spring-cloud-netflix-eureka-server/src/main/wro/wro.xml deleted file mode 100644 index c3853b850..000000000 --- a/spring-cloud-netflix-eureka-server/src/main/wro/wro.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - webjar:bootstrap/5.1.3/dist/css/bootstrap.min.css - file:@.project.basedir.@/src/main/wro/main.css - webjar:jquery/3.6.0/jquery.min.js - webjar:bootstrap/5.1.3/dist/js/bootstrap.min.js - - \ No newline at end of file diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationContextTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationContextTests.java deleted file mode 100644 index c4e2f46f6..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationContextTests.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Collections; -import java.util.Map; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.netflix.eureka.server.ApplicationContextTests.Application; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - properties = { "spring.application.name=eureka", "server.servlet.context-path=/context", - "management.security.enabled=false", "management.endpoints.web.exposure.include=*", - "eureka.server.version.filter.debug.response-header=X-Version-Filter-Computed-Path" }) -class ApplicationContextTests { - - private static final String BASE_PATH = new WebEndpointProperties().getBasePath(); - - @LocalServerPort - private int port = 0; - - @Test - void catalogLoads() { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/context/eureka/apps", Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String computedPath = entity.getHeaders().getFirst("X-Version-Filter-Computed-Path"); - assertThat(computedPath).isEqualTo("/context/eureka/v2/apps"); - } - - @Test - void dashboardLoads() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/context/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String body = entity.getBody(); - // System.err.println(body); - assertThat(body.contains("eureka/js")).isTrue(); - assertThat(body.contains("eureka/css")).isTrue(); - // The "DS Replicas" - assertThat(body.contains("localhost")).isTrue(); - } - - @Test - void cssAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/context/eureka/css/wro.css", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void jsAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/context/eureka/js/wro.js", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void adminLoads() { - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/context" + BASE_PATH + "/env", HttpMethod.GET, - new HttpEntity<>("parameters", headers), Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class Application { - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardDisabledTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardDisabledTests.java deleted file mode 100644 index be726d1ae..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardDisabledTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Map; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.cloud.netflix.eureka.server.ApplicationContextTests.Application; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=eureka", "eureka.dashboard.enabled=false" }) -class ApplicationDashboardDisabledTests { - - @Value("${local.server.port}") - private int port = 0; - - @Test - void catalogLoads() { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void dashboardLoads() { - ResponseEntity entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port + "/", - String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardPathTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardPathTests.java deleted file mode 100644 index 9b1dfe044..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationDashboardPathTests.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Map; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.cloud.netflix.eureka.server.ApplicationContextTests.Application; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=eureka", "eureka.dashboard.path=/dashboard" }) -class ApplicationDashboardPathTests { - - @Value("${local.server.port}") - private int port = 0; - - @Test - void catalogLoads() { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void dashboardLoads() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/dashboard", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String body = entity.getBody(); - // System.err.println(body); - assertThat(body.contains("eureka/js")).isTrue(); - assertThat(body.contains("eureka/css")).isTrue(); - // The "DS Replicas" - assertThat(body.contains("

Instances currently registered with Eureka

")).isTrue(); - // The Home - assertThat(body.contains("Home")).isTrue(); - // The Lastn - assertThat(body.contains("Last")).isTrue(); - } - - @Test - void cssAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/eureka/css/wro.css", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void jsAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/eureka/js/wro.js", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationServletPathTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationServletPathTests.java deleted file mode 100644 index 5d624a368..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationServletPathTests.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Collections; -import java.util.Map; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.netflix.eureka.server.ApplicationServletPathTests.Application; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -@SpringBootTest(classes = Application.class, webEnvironment = RANDOM_PORT, - properties = { "spring.application.name=eureka", "server.servlet.context-path=/servlet", - "management.security.enabled=false", "management.endpoints.web.exposure.include=*" }) -class ApplicationServletPathTests { - - private static final String BASE_PATH = new WebEndpointProperties().getBasePath(); - - @LocalServerPort - private int port = 0; - - @Test - void catalogLoads() { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/servlet/eureka/apps", Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void dashboardLoads() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/servlet/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String body = entity.getBody(); - // System.err.println(body); - assertThat(body.contains("eureka/js")).isTrue(); - assertThat(body.contains("eureka/css")).isTrue(); - // The "DS Replicas" - assertThat(body.contains("

Instances currently registered with Eureka

")).isTrue(); - } - - @Test - void cssAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/servlet/eureka/css/wro.css", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void jsAvailable() { - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/servlet/eureka/js/wro.js", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void adminLoads() { - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/servlet" + BASE_PATH + "/env", HttpMethod.GET, - new HttpEntity<>("parameters", headers), Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class Application { - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationTests.java deleted file mode 100644 index c54ce93b1..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/ApplicationTests.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Collections; -import java.util.Map; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.discovery.converters.wrappers.CodecWrapper; -import com.netflix.eureka.resources.ServerCodecs; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.netflix.eureka.server.ApplicationTests.Application; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -@SpringBootTest(classes = Application.class, webEnvironment = RANDOM_PORT, properties = { "spring.jmx.enabled=true", - "management.security.enabled=false", "management.endpoints.web.exposure.include=*" }) -class ApplicationTests { - - private static final String BASE_PATH = new WebEndpointProperties().getBasePath(); - - @LocalServerPort - private int port = 0; - - @Autowired - private ServerCodecs serverCodecs; - - @Test - void catalogLoads() { - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate() - .getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void adminLoads() { - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - - @SuppressWarnings("rawtypes") - ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + BASE_PATH + "/env", HttpMethod.GET, - new HttpEntity<>("parameters", headers), Map.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void noDoubleSlashes() { - String basePath = "http://localhost:" + this.port + "/"; - ResponseEntity entity = new TestRestTemplate().getForEntity(basePath, String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String body = entity.getBody(); - assertThat(body).isNotNull(); - assertThat(body.contains(basePath + "/")).as("basePath contains double slashes").isFalse(); - } - - @Test - @Disabled // FIXME 4.0 - void cssParsedByLess() { - String basePath = "http://localhost:" + this.port + "/eureka/css/wro.css"; - ResponseEntity entity = new TestRestTemplate().getForEntity(basePath, String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - String body = entity.getBody(); - assertThat(body).isNotNull(); - assertThat(body.contains("spring-logo")).as("css wasn't preprocessed").isTrue(); - } - - @Test - void customCodecWorks() throws Exception { - assertThat(this.serverCodecs).as("serverCodecs is wrong type") - .isInstanceOf(EurekaServerAutoConfiguration.CloudServerCodecs.class); - CodecWrapper codec = this.serverCodecs.getFullJsonCodec(); - assertThat(codec).as("codec is wrong type").isInstanceOf(CloudJacksonJson.class); - - InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("fooapp").add("instanceId", "foo") - .build(); - String encoded = codec.encode(instanceInfo); - InstanceInfo decoded = codec.decode(encoded, InstanceInfo.class); - assertThat(decoded.getInstanceId()).as("instanceId was wrong").isEqualTo("foo"); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class Application { - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerReplicasTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerReplicasTests.java deleted file mode 100644 index c78d197df..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerReplicasTests.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2016-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.HashMap; -import java.util.Map; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.eureka.util.StatusInfo; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.springframework.cloud.netflix.eureka.server.EurekaControllerTests.setInstance; - -class EurekaControllerReplicasTests { - - String noAuthList1 = "https://test1.com"; - - String noAuthList2 = noAuthList1 + ",https://test2.com"; - - String authList1 = "https://user:pwd@test1.com"; - - String authList2 = authList1 + ",https://user2:pwd2@test2.com"; - - String combinationAuthList1 = "http://test1.com,http://user2:pwd2@test2.com"; - - String combinationAuthList2 = "http://test3.com,http://user4:pwd4@test4.com"; - - String combinationNoAuthList1 = "http://test1.com,http://test2.com"; - - String combinationNoAuthList2 = "http://test3.com,http://test4.com"; - - String totalAutoList = combinationAuthList1 + "," + combinationAuthList2; - - String totalNoAutoList = combinationNoAuthList1 + "," + combinationNoAuthList2; - - String empty = ""; - - private ApplicationInfoManager original; - - private InstanceInfo instanceInfo; - - @BeforeEach - void setup() throws Exception { - this.original = ApplicationInfoManager.getInstance(); - setInstance(mock(ApplicationInfoManager.class)); - instanceInfo = mock(InstanceInfo.class); - } - - @AfterEach - void teardown() throws Exception { - setInstance(this.original); - instanceInfo = null; - } - - @Test - void testFilterReplicasNoAuth() { - Map model = new HashMap<>(); - StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", empty) - .add("available-replicas", noAuthList1).add("unavailable-replicas", noAuthList2) - .withInstanceInfo(this.instanceInfo).build(); - EurekaController controller = new EurekaController(null, new EurekaProperties()); - - controller.filterReplicas(model, statusInfo); - - @SuppressWarnings("unchecked") - Map results = (Map) model.get("applicationStats"); - assertThat(results.get("registered-replicas")).isEqualTo(empty); - assertThat(results.get("available-replicas")).isEqualTo(noAuthList1); - assertThat(results.get("unavailable-replicas")).isEqualTo(noAuthList2); - - } - - @Test - void testFilterReplicasAuth() { - Map model = new HashMap<>(); - StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", authList2) - .add("available-replicas", authList1).add("unavailable-replicas", empty).withInstanceInfo(instanceInfo) - .build(); - EurekaController controller = new EurekaController(null, new EurekaProperties()); - - controller.filterReplicas(model, statusInfo); - - @SuppressWarnings("unchecked") - Map results = (Map) model.get("applicationStats"); - assertThat(results.get("unavailable-replicas")).isEqualTo(empty); - assertThat(results.get("available-replicas")).isEqualTo(noAuthList1); - assertThat(results.get("registered-replicas")).isEqualTo(noAuthList2); - - } - - @Test - void testFilterReplicasAuthWithCombinationList() { - Map model = new HashMap<>(); - StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", totalAutoList) - .add("available-replicas", combinationAuthList1).add("unavailable-replicas", combinationAuthList2) - .withInstanceInfo(instanceInfo).build(); - EurekaController controller = new EurekaController(null, new EurekaProperties()); - - controller.filterReplicas(model, statusInfo); - - @SuppressWarnings("unchecked") - Map results = (Map) model.get("applicationStats"); - assertThat(results.get("registered-replicas")).isEqualTo(totalNoAutoList); - assertThat(results.get("available-replicas")).isEqualTo(combinationNoAuthList1); - assertThat(results.get("unavailable-replicas")).isEqualTo(combinationNoAuthList2); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerTests.java deleted file mode 100644 index d1a3efc8f..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerTests.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.appinfo.DataCenterInfo; -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.MyDataCenterInfo; -import com.netflix.discovery.shared.Application; -import com.netflix.eureka.EurekaServerContext; -import com.netflix.eureka.EurekaServerContextHolder; -import com.netflix.eureka.cluster.PeerEurekaNode; -import com.netflix.eureka.cluster.PeerEurekaNodes; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class EurekaControllerTests { - - private ApplicationInfoManager infoManager; - - private ApplicationInfoManager original; - - @BeforeEach - void setup() throws Exception { - PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class); - when(peerEurekaNodes.getPeerNodesView()).thenReturn(Collections.emptyList()); - - InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test") - .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build(); - - this.infoManager = mock(ApplicationInfoManager.class); - this.original = ApplicationInfoManager.getInstance(); - setInstance(this.infoManager); - when(this.infoManager.getInfo()).thenReturn(instanceInfo); - - Application myapp = new Application("myapp"); - myapp.addInstance(InstanceInfo.Builder.newBuilder().setAppName("myapp") - .setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).setInstanceId("myapp:1").build()); - - ArrayList applications = new ArrayList<>(); - applications.add(myapp); - - PeerAwareInstanceRegistry registry = mock(PeerAwareInstanceRegistry.class); - when(registry.getSortedApplications()).thenReturn(applications); - - EurekaServerContext serverContext = mock(EurekaServerContext.class); - EurekaServerContextHolder.initialize(serverContext); - when(serverContext.getRegistry()).thenReturn(registry); - when(serverContext.getPeerEurekaNodes()).thenReturn(peerEurekaNodes); - when(serverContext.getApplicationInfoManager()).thenReturn(this.infoManager); - - } - - @AfterEach - void teardown() throws Exception { - setInstance(this.original); - } - - static void setInstance(ApplicationInfoManager infoManager) throws IllegalAccessException { - Field instance = ReflectionUtils.findField(ApplicationInfoManager.class, "instance"); - ReflectionUtils.makeAccessible(instance); - instance.set(null, infoManager); - } - - @Test - void testStatus() { - Map model = new HashMap<>(); - - EurekaController controller = new EurekaController(infoManager, new EurekaProperties()); - - controller.status(new MockHttpServletRequest("GET", "/"), model); - - assertThat((String) model.get("environment")).isEqualTo("test"); - assertThat((String) model.get("datacenter")).isEqualTo("default"); - - Map app = getFirst(model, "apps"); - Map instanceInfo = getFirst(app, "instanceInfos"); - Map instance = getFirst(instanceInfo, "instances"); - - assertThat((String) instance.get("id")).as("id was wrong").isEqualTo("myapp:1"); - assertThat(instance.get("url")).as("url was not null").isNull(); - assertThat((Boolean) instance.get("isHref")).as("isHref was wrong").isFalse(); - } - - @SuppressWarnings("unchecked") - Map getFirst(Map model, String key) { - List> apps = (List>) model.get(key); - assertThat(apps).as(key + " was wrong size").hasSize(1); - return apps.get(0); - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaCustomPeerNodesTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaCustomPeerNodesTests.java deleted file mode 100644 index 4ace44808..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaCustomPeerNodesTests.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.cluster.PeerEurekaNode; -import com.netflix.eureka.cluster.PeerEurekaNodes; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import com.netflix.eureka.resources.ServerCodecs; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(classes = EurekaCustomPeerNodesTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka", - "server.contextPath=/context", "management.security.enabled=false" }) -class EurekaCustomPeerNodesTests { - - @Autowired - private PeerEurekaNodes peerEurekaNodes; - - @Test - void testCustomPeerNodesShouldTakePrecedenceOverDefault() { - assertThat(peerEurekaNodes instanceof CustomEurekaPeerNodes) - .as("PeerEurekaNodes should be the user created one").isTrue(); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class Application { - - @Bean - public PeerEurekaNodes myPeerEurekaNodes(PeerAwareInstanceRegistry registry, - EurekaServerConfig eurekaServerConfig, EurekaClientConfig eurekaClientConfig, ServerCodecs serverCodecs, - ApplicationInfoManager applicationInfoManager) { - return new CustomEurekaPeerNodes(registry, eurekaServerConfig, eurekaClientConfig, serverCodecs, - applicationInfoManager); - } - - } - - private static class CustomEurekaPeerNodes extends PeerEurekaNodes { - - CustomEurekaPeerNodes(PeerAwareInstanceRegistry registry, EurekaServerConfig serverConfig, - EurekaClientConfig clientConfig, ServerCodecs serverCodecs, - ApplicationInfoManager applicationInfoManager) { - super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager); - } - - @Override - protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) { - return Mockito.mock(PeerEurekaNode.class); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfigurationTest.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfigurationTest.java deleted file mode 100644 index 6b8d07a64..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaServerInitializerConfigurationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; - -@ExtendWith(MockitoExtension.class) -class EurekaServerInitializerConfigurationTest { - - @Mock - private EurekaServerBootstrap eurekaServerBootstrapMock; - - @InjectMocks - private EurekaServerInitializerConfiguration eurekaServerInitializerConfiguration; - - private boolean callbackCalled; - - @BeforeEach - void setUp() { - callbackCalled = false; - } - - @Test - void testStopWithCallbackCallsStop() { - eurekaServerInitializerConfiguration.stop(this::setCallbackCalledTrue); - - assertThat(callbackCalled).isTrue(); - verify(eurekaServerBootstrapMock).contextDestroyed(any()); - } - - private void setCallbackCalledTrue() { - callbackCalled = true; - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTests.java deleted file mode 100644 index b982b239f..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTests.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2016-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import com.netflix.appinfo.InstanceInfo; -import com.netflix.appinfo.LeaseInfo; -import com.netflix.discovery.shared.Application; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; -import org.springframework.cloud.netflix.eureka.server.InstanceRegistryTests.TestApplication; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.SmartApplicationListener; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; - -/** - * @author Bartlomiej Slota - */ -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - value = { "spring.application.name=eureka", - "logging.level.org.springframework." + "cloud.netflix.eureka.server.InstanceRegistry=DEBUG" }) -class InstanceRegistryTests { - - private static final String APP_NAME = "MY-APP-NAME"; - - private static final String HOST_NAME = "my-host-name"; - - private static final String INSTANCE_ID = "my-host-name:8008"; - - private static final int PORT = 8008; - - @SpyBean(PeerAwareInstanceRegistry.class) - private InstanceRegistry instanceRegistry; - - @BeforeEach - void setup() { - this.testEvents.applicationEvents.clear(); - } - - @Autowired - private TestEvents testEvents; - - @Test - void testRegister() { - // creating instance info - final LeaseInfo leaseInfo = getLeaseInfo(); - final InstanceInfo instanceInfo = getInstanceInfo(APP_NAME, HOST_NAME, INSTANCE_ID, PORT, leaseInfo); - // calling tested method - instanceRegistry.register(instanceInfo, false); - // event of proper type is registered - assertThat(this.testEvents.applicationEvents.size()).isEqualTo(1); - assertThat(this.testEvents.applicationEvents.get(0) instanceof EurekaInstanceRegisteredEvent).isTrue(); - // event details are correct - final EurekaInstanceRegisteredEvent registeredEvent = (EurekaInstanceRegisteredEvent) (this.testEvents.applicationEvents - .get(0)); - assertThat(registeredEvent.getInstanceInfo()).isEqualTo(instanceInfo); - assertThat(registeredEvent.getLeaseDuration()).isEqualTo(leaseInfo.getDurationInSecs()); - assertThat(registeredEvent.getSource()).isEqualTo(instanceRegistry); - assertThat(registeredEvent.isReplication()).isFalse(); - } - - @Test - void testDefaultLeaseDurationRegisterEvent() { - // creating instance info - final InstanceInfo instanceInfo = getInstanceInfo(APP_NAME, HOST_NAME, INSTANCE_ID, PORT, null); - // calling tested method - instanceRegistry.register(instanceInfo, false); - // instance info duration is set to default - final EurekaInstanceRegisteredEvent registeredEvent = (EurekaInstanceRegisteredEvent) (this.testEvents.applicationEvents - .get(0)); - assertThat(registeredEvent.getLeaseDuration()).isEqualTo(LeaseInfo.DEFAULT_LEASE_DURATION); - } - - @Test - void testInternalCancel() { - // calling tested method - instanceRegistry.internalCancel(APP_NAME, HOST_NAME, false); - // event of proper type is registered - assertThat(this.testEvents.applicationEvents.size()).isEqualTo(1); - assertThat(this.testEvents.applicationEvents.get(0) instanceof EurekaInstanceCanceledEvent).isTrue(); - // event details are correct - final EurekaInstanceCanceledEvent registeredEvent = (EurekaInstanceCanceledEvent) (this.testEvents.applicationEvents - .get(0)); - assertThat(registeredEvent.getAppName()).isEqualTo(APP_NAME); - assertThat(registeredEvent.getServerId()).isEqualTo(HOST_NAME); - assertThat(registeredEvent.getSource()).isEqualTo(instanceRegistry); - assertThat(registeredEvent.isReplication()).isFalse(); - } - - @Test - void testRenew() { - // Creating two instances of the app - final InstanceInfo instanceInfo1 = getInstanceInfo(APP_NAME, HOST_NAME, INSTANCE_ID, PORT, null); - final InstanceInfo instanceInfo2 = getInstanceInfo(APP_NAME, HOST_NAME, "my-host-name:8009", 8009, null); - // creating application list with an app having two instances - final Application application = new Application(APP_NAME, Arrays.asList(instanceInfo1, instanceInfo2)); - // stubbing application - doReturn(application).when(instanceRegistry).getApplication(APP_NAME); - // calling tested method - instanceRegistry.renew(APP_NAME, INSTANCE_ID, false); - instanceRegistry.renew(APP_NAME, "my-host-name:8009", false); - // event of proper type is registered - assertThat(this.testEvents.applicationEvents.size()).isEqualTo(2); - assertThat(this.testEvents.applicationEvents.get(0) instanceof EurekaInstanceRenewedEvent).isTrue(); - assertThat(this.testEvents.applicationEvents.get(1) instanceof EurekaInstanceRenewedEvent).isTrue(); - // event details are correct - final EurekaInstanceRenewedEvent event1 = (EurekaInstanceRenewedEvent) (this.testEvents.applicationEvents - .get(0)); - assertThat(event1.getAppName()).isEqualTo(APP_NAME); - assertThat(event1.getServerId()).isEqualTo(INSTANCE_ID); - assertThat(event1.getSource()).isEqualTo(instanceRegistry); - assertThat(event1.getInstanceInfo()).isEqualTo(instanceInfo1); - assertThat(event1.isReplication()).isFalse(); - - final EurekaInstanceRenewedEvent event2 = (EurekaInstanceRenewedEvent) (this.testEvents.applicationEvents - .get(1)); - assertThat(event2.getInstanceInfo()).isEqualTo(instanceInfo2); - } - - private LeaseInfo getLeaseInfo() { - LeaseInfo.Builder leaseBuilder = LeaseInfo.Builder.newBuilder(); - leaseBuilder.setRenewalIntervalInSecs(10); - leaseBuilder.setDurationInSecs(15); - return leaseBuilder.build(); - } - - private InstanceInfo getInstanceInfo(String appName, String hostName, String instanceId, int port, - LeaseInfo leaseInfo) { - InstanceInfo.Builder builder = InstanceInfo.Builder.newBuilder(); - builder.setAppName(appName); - builder.setHostName(hostName); - builder.setInstanceId(instanceId); - builder.setPort(port); - builder.setLeaseInfo(leaseInfo); - return builder.build(); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class TestApplication { - - @Bean - public TestEvents testEvents() { - return new TestEvents(); - } - - } - - protected static class TestEvents implements SmartApplicationListener { - - public final List applicationEvents = new LinkedList<>(); - - @Override - public boolean supportsEventType(Class eventType) { - return EurekaInstanceRegisteredEvent.class.isAssignableFrom(eventType) - || EurekaInstanceCanceledEvent.class.isAssignableFrom(eventType) - || EurekaInstanceRenewedEvent.class.isAssignableFrom(eventType); - } - - @Override - public void onApplicationEvent(ApplicationEvent event) { - this.applicationEvents.add(event); - } - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesTests.java deleted file mode 100644 index a6ef4dfb0..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesTests.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; - -import com.netflix.appinfo.ApplicationInfoManager; -import com.netflix.discovery.EurekaClientConfig; -import com.netflix.eureka.EurekaServerConfig; -import com.netflix.eureka.cluster.PeerEurekaNodes; -import com.netflix.eureka.registry.PeerAwareInstanceRegistry; -import com.netflix.eureka.resources.ServerCodecs; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.cloud.context.environment.EnvironmentChangeEvent; -import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean; -import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Fahim Farook - */ -@SpringBootTest(classes = RefreshablePeerEurekaNodesTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka-server", - "eureka.client.service-url.defaultZone=http://localhost:8678/eureka/" }) -class RefreshablePeerEurekaNodesTests { - - @Autowired - private ConfigurableApplicationContext context; - - @Autowired - private PeerEurekaNodes peerEurekaNodes; - - @Value("${local.server.port}") - private int port = 0; - - private static final String DEFAULT_ZONE = "eureka.client.service-url.defaultZone"; - - private static final String REGION = "eureka.client.region"; - - private static final String USE_DNS = "eureka.client.use-dns-for-fetching-service-urls"; - - @Test - void notUpdatedWhenDnsIsTrue() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=true", - "eureka.client.region=unavailable-region", // to force defaultZone - "eureka.client.service-url.defaultZone=https://default-host1:8678/eureka/"); - this.context.publishEvent(new EnvironmentChangeEvent(new HashSet<>(Arrays.asList(USE_DNS, DEFAULT_ZONE)))); - - assertThat(serviceUrlMatches("https://default-host1:8678/eureka/")) - .as("PeerEurekaNodes' are updated when eureka.client.use-dns-for-fetching-service-urls is true") - .isFalse(); - } - - @Test - void updatedWhenDnsIsFalse() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", - "eureka.client.region=unavailable-region", // to force defaultZone - "eureka.client.service-url.defaultZone=https://default-host2:8678/eureka/"); - this.context.publishEvent(new EnvironmentChangeEvent(new HashSet<>(Arrays.asList(USE_DNS, DEFAULT_ZONE)))); - - assertThat(serviceUrlMatches("https://default-host2:8678/eureka/")) - .as("PeerEurekaNodes' are not updated when eureka.client.use-dns-for-fetching-service-urls is false") - .isTrue(); - } - - @Test - void updatedWhenRegionChanged() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", "eureka.client.region=region1", - "eureka.client.availability-zones.region1=region1-zone", - "eureka.client.availability-zones.region2=region2-zone", - "eureka.client.service-url.region1-zone=https://region1-zone-host:8678/eureka/", - "eureka.client.service-url.region2-zone=https://region2-zone-host:8678/eureka/"); - this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION))); - assertThat(serviceUrlMatches("https://region1-zone-host:8678/eureka/")) - .as("PeerEurekaNodes' are not updated when eureka.client.region is changed").isTrue(); - - changeProperty("eureka.client.region=region2"); - this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION))); - assertThat(serviceUrlMatches("https://region2-zone-host:8678/eureka/")) - .as("PeerEurekaNodes' are not updated when eureka.client.region is changed").isTrue(); - } - - @Test - void updatedWhenAvailabilityZoneChanged() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", "eureka.client.region=region4", - "eureka.client.availability-zones.region3=region3-zone", - "eureka.client.service-url.region4-zone=https://region4-zone-host:8678/eureka/", - "eureka.client.service-url.defaultZone=https://default-host3:8678/eureka/"); - this.context.publishEvent( - new EnvironmentChangeEvent(Collections.singleton("eureka.client.availability-zones.region3"))); - assertThat(this.peerEurekaNodes.getPeerEurekaNodes().get(0).getServiceUrl() - .equals("https://default-host3:8678/eureka/")).isTrue(); - - changeProperty("eureka.client.availability-zones.region4=region4-zone"); - this.context.publishEvent( - new EnvironmentChangeEvent(Collections.singleton("eureka.client.availability-zones.region4"))); - assertThat(serviceUrlMatches("https://region4-zone-host:8678/eureka/")) - .as("PeerEurekaNodes' are not updated when eureka.client.availability-zones are changed").isTrue(); - } - - @Test - void notUpdatedWhenIrrelevantPropertiesChanged() { - // Only way to test this is verifying whether updatePeerEurekaNodes() is invoked. - - // PeerEurekaNodes.updatePeerEurekaNodes() is not public, hence cannot verify with - // Mockito. - class VerifyablePeerEurekNode extends RefreshablePeerEurekaNodes { - - VerifyablePeerEurekNode(PeerAwareInstanceRegistry registry, EurekaServerConfig serverConfig, - EurekaClientConfig clientConfig, ServerCodecs serverCodecs, - ApplicationInfoManager applicationInfoManager) { - super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager, - new ReplicationClientAdditionalFilters(Collections.emptySet())); - } - - protected void updatePeerEurekaNodes(List newPeerUrls) { - super.updatePeerEurekaNodes(newPeerUrls); - } - - } - - // Create stubs. - final EurekaClientConfigBean configClientBean = mock(EurekaClientConfigBean.class); - when(configClientBean.isUseDnsForFetchingServiceUrls()).thenReturn(false); - final VerifyablePeerEurekNode mock = spy(new VerifyablePeerEurekNode(null, null, configClientBean, null, null)); - - mock.onApplicationEvent(new EnvironmentChangeEvent(Collections.singleton("some.irrelevant.property"))); - verify(mock, never()).updatePeerEurekaNodes(anyList()); - } - - @Test - void peerEurekaNodesIsRefreshablePeerEurekaNodes() { - assertThat(this.peerEurekaNodes).isNotNull(); - assertThat(this.peerEurekaNodes instanceof RefreshablePeerEurekaNodes) - .as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes").isTrue(); - } - - @Test - void serviceUrlsCountAsSoonAsRefreshed() { - changeProperty( - "eureka.client.service-url.defaultZone=https://defaul-host3:8678/eureka/,http://defaul-host4:8678/eureka/"); - forceUpdate(); - assertThat(this.peerEurekaNodes.getPeerEurekaNodes().size()).as("PeerEurekaNodes' peer count is incorrect.") - .isEqualTo(2); - } - - @Test - void serviceUrlsValueAsSoonAsRefreshed() { - changeProperty("eureka.client.service-url.defaultZone=https://defaul-host4:8678/eureka/"); - forceUpdate(); - assertThat(serviceUrlMatches("https://defaul-host4:8678/eureka/")) - .as("PeerEurekaNodes' new peer[0] is incorrect").isTrue(); - } - - @Test - void dashboardUpdatedAsSoonAsRefreshed() { - changeProperty("eureka.client.service-url.defaultZone=https://defaul-host5:8678/eureka/"); - forceUpdate(); - final ResponseEntity entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port + "/", - String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - final String body = entity.getBody(); - assertThat(body).isNotNull(); - assertThat(body.contains("https://defaul-host5:8678/eureka/")) - .as("DS Replicas not updated in the Eureka Server dashboard").isTrue(); - } - - @Test - void notUpdatedForRelaxedKeys() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", - "eureka.client.region=unavailable-region", // to force defaultZone - "eureka.client.service-url.defaultZone=https://defaul-host6:8678/eureka/"); - this.context.publishEvent( - new EnvironmentChangeEvent(Collections.singleton("eureka.client.serviceUrl.defaultZone"))); - assertThat(serviceUrlMatches("https://defaul-host6:8678/eureka/")) - .as("PeerEurekaNodes' are updated for keys with relaxed binding").isFalse(); - } - - /* - * Changes the value of given key in the environment. - */ - private void changeProperty(final String... pairs) { - TestPropertyValues.of(pairs).applyTo(this.context); - } - - /* - * Refreshes the context with properties satisfying to invoke update. - */ - private void forceUpdate() { - changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", - "eureka.client.region=unavailable-region"); // to force defaultZone - this.context.publishEvent( - new EnvironmentChangeEvent(Collections.singleton("eureka.client.service-url.defaultZone"))); - } - - /* - * Whether the first element in PeerEurekaNodes matches the given url. - */ - private boolean serviceUrlMatches(final String serviceUrl) { - return this.peerEurekaNodes.getPeerEurekaNodes().get(0).getServiceUrl().equals(serviceUrl); - } - - @EnableEurekaServer - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class }) - protected static class Application { - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesWithCustomFiltersTests.java b/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesWithCustomFiltersTests.java deleted file mode 100644 index 5dabe74d2..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesWithCustomFiltersTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.netflix.eureka.server; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.Collections; - -import com.netflix.eureka.cluster.PeerEurekaNodes; -import jakarta.ws.rs.client.ClientRequestContext; -import jakarta.ws.rs.client.ClientRequestFilter; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.ReflectionUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Yuxin Bai - */ -@SpringBootTest(classes = RefreshablePeerEurekaNodesWithCustomFiltersTests.Application.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka", - "server.contextPath=/context", "management.security.enabled=false" }) -class RefreshablePeerEurekaNodesWithCustomFiltersTests { - - @Autowired - private PeerEurekaNodes peerEurekaNodes; - - @Test - void testCustomPeerNodesShouldTakePrecedenceOverDefault() { - assertThat(peerEurekaNodes instanceof RefreshablePeerEurekaNodes) - .as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes").isTrue(); - RefreshablePeerEurekaNodes refreshablePeerEurekaNodes = (RefreshablePeerEurekaNodes) peerEurekaNodes; - - ReplicationClientAdditionalFilters filters = refreshablePeerEurekaNodes.replicationClientAdditionalFilters; - assertThat(filters.getFilters()) - .as("PeerEurekaNodes'should have only one filter set on replicationClientAdditionalFilters").hasSize(1); - assertThat(filters.getFilters().iterator().next() instanceof Application.CustomClientFilter) - .as("The type of the filter should be CustomClientFilter as user declared so").isTrue(); - } - - private static R getField(Class clazz, T target, String fieldName) { - Field field = ReflectionUtils.findField(clazz, fieldName); - ReflectionUtils.makeAccessible(field); - @SuppressWarnings("unchecked") - R value = (R) ReflectionUtils.getField(field, target); - return value; - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @EnableEurekaServer - protected static class Application { - - @Bean - public ReplicationClientAdditionalFilters customFilters() { - return new ReplicationClientAdditionalFilters(Collections.singletonList(new CustomClientFilter())); - } - - protected class CustomClientFilter implements ClientRequestFilter { - - @Override - public void filter(ClientRequestContext requestContext) throws IOException { - // noop - } - - } - - } - -} diff --git a/spring-cloud-netflix-eureka-server/src/test/resources/application.properties b/spring-cloud-netflix-eureka-server/src/test/resources/application.properties deleted file mode 100644 index 37328a3aa..000000000 --- a/spring-cloud-netflix-eureka-server/src/test/resources/application.properties +++ /dev/null @@ -1,7 +0,0 @@ -server.port=8761 -spring.application.name=eureka -eureka.client.registerWithEureka=false -eureka.client.fetchRegistry=false -logging.level.org.springframework.web.client=DEBUG -logging.level.com.netflix.discovery=DEBUG - diff --git a/spring-cloud-starter-netflix-eureka-client/.flattened-pom.xml b/spring-cloud-starter-netflix-eureka-client/.flattened-pom.xml new file mode 100644 index 000000000..821d07fb4 --- /dev/null +++ b/spring-cloud-starter-netflix-eureka-client/.flattened-pom.xml @@ -0,0 +1,200 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + 4.1.0-SNAPSHOT + Spring Cloud Starter Netflix Eureka Client + Spring Cloud Starter Netflix Eureka Client + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-starter-netflix-eureka-client + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-starter-netflix-eureka-client + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-netflix-eureka-client + 4.1.0-SNAPSHOT + compile + + + com.sun.jersey + jersey-client + + + com.sun.jersey + jersey-core + + + com.sun.jersey.contribs + jersey-apache-client4 + + + + + com.netflix.eureka + eureka-client + 2.0.1 + compile + + + com.sun.jersey + jersey-client + + + com.sun.jersey + jersey-core + + + com.sun.jersey.contribs + jersey-apache-client4 + + + aopalliance + aopalliance + + + + + com.netflix.eureka + eureka-core + 2.0.1 + compile + + + com.netflix.archaius + archaius-core + + + javax.servlet + servlet-api + + + commons-logging + commons-logging + + + log4j + log4j + + + blitz4j + com.netflix.blitz4j + + + com.google.code.findbugs + annotations + + + com.google.code.findbugs + jsr305 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.amazonaws + * + + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + 4.1.0-SNAPSHOT + compile + + + diff --git a/spring-cloud-starter-netflix-eureka-client/pom.xml b/spring-cloud-starter-netflix-eureka-client/pom.xml deleted file mode 100644 index 5e52ae1ff..000000000 --- a/spring-cloud-starter-netflix-eureka-client/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - - spring-cloud-starter-netflix-eureka-client - Spring Cloud Starter Netflix Eureka Client - Spring Cloud Starter Netflix Eureka Client - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - - org.springframework.cloud - spring-cloud-starter - - - org.springframework.cloud - spring-cloud-netflix-eureka-client - - - com.sun.jersey - jersey-client - - - com.sun.jersey - jersey-core - - - com.sun.jersey.contribs - jersey-apache-client4 - - - - - com.netflix.eureka - eureka-client - - - com.sun.jersey - jersey-client - - - com.sun.jersey - jersey-core - - - com.sun.jersey.contribs - jersey-apache-client4 - - - aopalliance - aopalliance - - - - - com.netflix.eureka - eureka-core - - - org.springframework.cloud - spring-cloud-starter-loadbalancer - - - \ No newline at end of file diff --git a/spring-cloud-starter-netflix-eureka-server/.flattened-pom.xml b/spring-cloud-starter-netflix-eureka-server/.flattened-pom.xml new file mode 100644 index 000000000..d74178fcc --- /dev/null +++ b/spring-cloud-starter-netflix-eureka-server/.flattened-pom.xml @@ -0,0 +1,124 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-netflix + 4.1.0-SNAPSHOT + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server + 4.1.0-SNAPSHOT + Spring Cloud Starter Netflix Eureka Server + Spring Cloud Starter Netflix Eureka Server + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-starter-netflix-eureka-server + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-netflix.git/spring-cloud-starter-netflix-eureka-server + https://github.com/spring-cloud/spring-cloud-netflix/spring-cloud-starter-netflix-eureka-server + + + + org.springframework.cloud + spring-cloud-starter + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-netflix-eureka-server + 4.1.0-SNAPSHOT + compile + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + 4.1.0-SNAPSHOT + compile + + + org.glassfish.jaxb + jaxb-runtime + 4.0.3 + compile + + + diff --git a/spring-cloud-starter-netflix-eureka-server/pom.xml b/spring-cloud-starter-netflix-eureka-server/pom.xml deleted file mode 100644 index d92607647..000000000 --- a/spring-cloud-starter-netflix-eureka-server/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - 4.0.0 - - org.springframework.cloud - spring-cloud-netflix - 4.1.0-SNAPSHOT - - spring-cloud-starter-netflix-eureka-server - Spring Cloud Starter Netflix Eureka Server - Spring Cloud Starter Netflix Eureka Server - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - - org.springframework.cloud - spring-cloud-starter - - - org.springframework.cloud - spring-cloud-netflix-eureka-server - - - org.springframework.cloud - spring-cloud-starter-loadbalancer - - - - org.glassfish.jaxb - jaxb-runtime - - - \ No newline at end of file diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml deleted file mode 100644 index c4be06887..000000000 --- a/src/checkstyle/checkstyle-suppressions.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/supplemental-ui/partials/nav-search.hbs b/supplemental-ui/partials/nav-search.hbs new file mode 100644 index 000000000..5e3795528 --- /dev/null +++ b/supplemental-ui/partials/nav-search.hbs @@ -0,0 +1,11 @@ +{{#if env.ALGOLIA_API_KEY}} + +{{/if}} diff --git a/supplemental-ui/partials/search.hbs b/supplemental-ui/partials/search.hbs new file mode 100644 index 000000000..384e505f6 --- /dev/null +++ b/supplemental-ui/partials/search.hbs @@ -0,0 +1,27 @@ + +{{#if env.ALGOLIA_API_KEY}} + +
+ + + + + + +{{/if}}