├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── build-main.yml │ ├── build-pr.yml │ ├── build.yml │ ├── checks.yml │ ├── scripts │ └── precheck.sh │ └── stale.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── DCO ├── LICENSE ├── NOTICE ├── OWNERS ├── README.md ├── build.gradle ├── code-of-conduct.md ├── docs ├── KeyVal.adoc ├── Lease.md ├── RELEASE.adoc ├── SslConfig.md └── Watch.md ├── etc ├── eclipse-formatter-config.xml ├── eclipse.importorder ├── license-formatting.xml ├── license.txt └── pmd-ruleset.xml ├── gradle.properties ├── gradle ├── libs.versions.toml ├── publish.gradle ├── publishing-release-tasks.gradle ├── publishing-release.gradle ├── quality.gradle ├── release.gradle ├── style.gradle ├── versions.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jetcd-api └── build.gradle ├── jetcd-common ├── build.gradle └── src │ └── main │ └── java │ └── io │ └── etcd │ └── jetcd │ └── common │ ├── Service.java │ └── exception │ ├── ClosedClientException.java │ ├── ClosedKeepAliveListenerException.java │ ├── ClosedSnapshotException.java │ ├── ClosedWatcherException.java │ ├── CompactedException.java │ ├── ErrorCode.java │ ├── EtcdException.java │ └── EtcdExceptionFactory.java ├── jetcd-core ├── build.gradle └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── etcd │ │ │ └── jetcd │ │ │ ├── Auth.java │ │ │ ├── ByteSequence.java │ │ │ ├── Client.java │ │ │ ├── ClientBuilder.java │ │ │ ├── Cluster.java │ │ │ ├── Constants.java │ │ │ ├── Election.java │ │ │ ├── KV.java │ │ │ ├── KeyValue.java │ │ │ ├── Lease.java │ │ │ ├── Lock.java │ │ │ ├── Maintenance.java │ │ │ ├── Preconditions.java │ │ │ ├── Response.java │ │ │ ├── Txn.java │ │ │ ├── Watch.java │ │ │ ├── auth │ │ │ ├── AuthDisableResponse.java │ │ │ ├── AuthEnableResponse.java │ │ │ ├── AuthRoleAddResponse.java │ │ │ ├── AuthRoleDeleteResponse.java │ │ │ ├── AuthRoleGetResponse.java │ │ │ ├── AuthRoleGrantPermissionResponse.java │ │ │ ├── AuthRoleListResponse.java │ │ │ ├── AuthRoleRevokePermissionResponse.java │ │ │ ├── AuthUserAddResponse.java │ │ │ ├── AuthUserChangePasswordResponse.java │ │ │ ├── AuthUserDeleteResponse.java │ │ │ ├── AuthUserGetResponse.java │ │ │ ├── AuthUserGrantRoleResponse.java │ │ │ ├── AuthUserListResponse.java │ │ │ ├── AuthUserRevokeRoleResponse.java │ │ │ └── Permission.java │ │ │ ├── cluster │ │ │ ├── Member.java │ │ │ ├── MemberAddResponse.java │ │ │ ├── MemberListResponse.java │ │ │ ├── MemberRemoveResponse.java │ │ │ ├── MemberUpdateResponse.java │ │ │ └── Util.java │ │ │ ├── election │ │ │ ├── CampaignResponse.java │ │ │ ├── LeaderKey.java │ │ │ ├── LeaderResponse.java │ │ │ ├── NoLeaderException.java │ │ │ ├── NotLeaderException.java │ │ │ ├── ProclaimResponse.java │ │ │ └── ResignResponse.java │ │ │ ├── impl │ │ │ ├── AbstractResponse.java │ │ │ ├── AuthCredential.java │ │ │ ├── AuthImpl.java │ │ │ ├── ClientConnectionManager.java │ │ │ ├── ClientImpl.java │ │ │ ├── ClusterImpl.java │ │ │ ├── ElectionImpl.java │ │ │ ├── Impl.java │ │ │ ├── KVImpl.java │ │ │ ├── LeaseImpl.java │ │ │ ├── LockImpl.java │ │ │ ├── MaintenanceImpl.java │ │ │ └── WatchImpl.java │ │ │ ├── kv │ │ │ ├── CompactResponse.java │ │ │ ├── DeleteResponse.java │ │ │ ├── GetResponse.java │ │ │ ├── PutResponse.java │ │ │ └── TxnResponse.java │ │ │ ├── lease │ │ │ ├── LeaseGrantResponse.java │ │ │ ├── LeaseKeepAliveResponse.java │ │ │ ├── LeaseKeepAliveResponseWithError.java │ │ │ ├── LeaseRevokeResponse.java │ │ │ ├── LeaseTimeToLiveResponse.java │ │ │ └── NoSuchLeaseException.java │ │ │ ├── lock │ │ │ ├── LockResponse.java │ │ │ └── UnlockResponse.java │ │ │ ├── maintenance │ │ │ ├── AlarmMember.java │ │ │ ├── AlarmResponse.java │ │ │ ├── AlarmType.java │ │ │ ├── DefragmentResponse.java │ │ │ ├── HashKVResponse.java │ │ │ ├── MoveLeaderResponse.java │ │ │ ├── SnapshotReaderResponseWithError.java │ │ │ ├── SnapshotResponse.java │ │ │ └── StatusResponse.java │ │ │ ├── op │ │ │ ├── Cmp.java │ │ │ ├── CmpTarget.java │ │ │ ├── Op.java │ │ │ └── TxnImpl.java │ │ │ ├── options │ │ │ ├── CompactOption.java │ │ │ ├── DeleteOption.java │ │ │ ├── GetOption.java │ │ │ ├── LeaseOption.java │ │ │ ├── OptionsUtil.java │ │ │ ├── PutOption.java │ │ │ ├── TxnOption.java │ │ │ └── WatchOption.java │ │ │ ├── resolver │ │ │ ├── AbstractNameResolver.java │ │ │ ├── AbstractResolverProvider.java │ │ │ ├── DnsSrvNameResolver.java │ │ │ ├── DnsSrvResolverProvider.java │ │ │ ├── HttpNameResolver.java │ │ │ ├── HttpResolverProvider.java │ │ │ ├── HttpsNameResolver.java │ │ │ ├── HttpsResolverProvider.java │ │ │ ├── IPNameResolver.java │ │ │ └── IPResolverProvider.java │ │ │ ├── support │ │ │ ├── CloseableClient.java │ │ │ ├── Errors.java │ │ │ ├── MemorizingClientSupplier.java │ │ │ ├── Observers.java │ │ │ ├── Requests.java │ │ │ └── Util.java │ │ │ └── watch │ │ │ ├── WatchEvent.java │ │ │ ├── WatchResponse.java │ │ │ └── WatchResponseWithError.java │ └── proto │ │ ├── auth.proto │ │ ├── election.proto │ │ ├── kv.proto │ │ ├── lock.proto │ │ └── rpc.proto │ └── test │ ├── java │ └── io │ │ └── etcd │ │ └── jetcd │ │ ├── impl │ │ ├── AuthClientTest.java │ │ ├── AuthUnitTest.java │ │ ├── ClientBuilderTest.java │ │ ├── ClientConnectionManagerTest.java │ │ ├── ClusterClientTest.java │ │ ├── ClusterMembersTest.java │ │ ├── ElectionTest.java │ │ ├── KVNamespaceTest.java │ │ ├── KVTest.java │ │ ├── LeaseMemoryLeakTest.java │ │ ├── LeaseOnceErrorTest.java │ │ ├── LeaseTest.java │ │ ├── LeaseUnitTest.java │ │ ├── LoadBalancerTest.java │ │ ├── LockTest.java │ │ ├── MaintenanceTest.java │ │ ├── MaintenanceUnitTest.java │ │ ├── RetryTest.java │ │ ├── SslTest.java │ │ ├── TestUtil.java │ │ ├── TxnResponseTest.java │ │ ├── UtilTest.java │ │ ├── WatchErrorTest.java │ │ ├── WatchResumeTest.java │ │ ├── WatchTest.java │ │ ├── WatchTokenExpireTest.java │ │ ├── WatchUnitTest.java │ │ └── auth │ │ │ └── AuthTokenRefreshTest.java │ │ ├── op │ │ └── TxnTest.java │ │ └── options │ │ └── OptionsUtilTest.java │ └── resources │ ├── log4j2-test.xml │ └── ssl │ ├── .gitignore │ ├── cert │ ├── ca-config.json │ ├── ca-key.pem │ ├── ca.csr │ ├── ca.pem │ ├── client-key.pem │ ├── client.csr │ ├── client.pem │ ├── etcd0-key.pem │ ├── etcd0.csr │ ├── etcd0.pem │ ├── etcd1-key.pem │ ├── etcd1.csr │ ├── etcd1.pem │ ├── etcd2-key.pem │ ├── etcd2.csr │ ├── etcd2.pem │ ├── server-key.pem │ ├── server.csr │ └── server.pem │ └── generate-self-signed-certificates.sh ├── jetcd-ctl ├── README.md ├── build.gradle └── src │ └── main │ ├── java │ └── io │ │ └── etcd │ │ └── jetcd │ │ └── examples │ │ └── ctl │ │ ├── CommandGet.java │ │ ├── CommandPut.java │ │ ├── CommandWatch.java │ │ └── Main.java │ └── resources │ └── log4j2.xml ├── jetcd-grpc ├── build.gradle └── src │ └── main │ └── proto │ ├── auth.proto │ ├── election.proto │ ├── kv.proto │ ├── lock.proto │ └── rpc.proto ├── jetcd-launcher ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── etcd │ │ └── jetcd │ │ └── launcher │ │ ├── Etcd.java │ │ ├── EtcdCluster.java │ │ ├── EtcdClusterImpl.java │ │ └── EtcdContainer.java │ └── test │ ├── java │ └── io │ │ └── etcd │ │ └── jetcd │ │ └── launcher │ │ └── test │ │ └── EtcdClusterStartTest.java │ └── resources │ └── log4j2.xml ├── jetcd-test ├── build.gradle └── src │ └── main │ └── java │ └── io │ └── etcd │ └── jetcd │ └── test │ ├── EtcdClusterExtension.java │ ├── EtcdClusterNameResolver.java │ ├── EtcdClusterResolverProvider.java │ └── GrpcServerExtension.java └── settings.gradle /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | **Versions** 10 | - etcd: _add the etcd version here_ 11 | - jetcd: _add the jetcd version here_ 12 | - java: _add the java version here_ 13 | 14 | **Describe the bug** 15 | A clear and concise description of what the bug is. 16 | 17 | **To Reproduce** 18 | Steps or reproducer to reproduce the behavior in a form of a unit test. 19 | This section *must* be provided, if not, the issue may not get attention since the maintainers have very limited capacity. 20 | 21 | **Expected behavior** 22 | A clear and concise description of what you expected to happen. 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "19:30" 8 | timezone: Europe/Paris 9 | - package-ecosystem: "gradle" 10 | directory: "/" 11 | schedule: 12 | interval: daily 13 | time: "19:30" 14 | timezone: Europe/Paris 15 | labels: 16 | - area/dependencies 17 | ignore: 18 | - dependency-name: com.google.protobuf:protoc 19 | -------------------------------------------------------------------------------- /.github/workflows/build-main.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2023 The jetcd authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | name: Build and Publish (Snapshot) 18 | 19 | concurrency: 20 | group: ${{ github.workflow }}-${{ github.sha }} 21 | cancel-in-progress: true 22 | 23 | on: 24 | push: 25 | branches: 26 | - main 27 | workflow_dispatch: 28 | schedule: 29 | - cron: "0 0 * * *" 30 | 31 | jobs: 32 | checks: 33 | uses: ./.github/workflows/checks.yml 34 | 35 | build: 36 | needs: 37 | - checks 38 | strategy: 39 | matrix: 40 | java-version: 41 | - 11 42 | - 17 43 | - 21 44 | etcd: 45 | - quay.io/coreos/etcd:v3.5.14 46 | - quay.io/coreos/etcd:v3.4.33 47 | uses: ./.github/workflows/build.yml 48 | with: 49 | javaVersion: "${{ matrix.java-version }}" 50 | etcdImage: "${{ matrix.etcd }}" 51 | 52 | publish: 53 | runs-on: ubuntu-latest 54 | needs: 55 | - build 56 | steps: 57 | - name: 'Checkout' 58 | uses: actions/checkout@v4 59 | with: 60 | fetch-depth: 0 61 | - name: 'Set Up Java' 62 | uses: actions/setup-java@v4 63 | with: 64 | java-version: 11 65 | distribution: 'temurin' 66 | cache: 'gradle' 67 | - name: 'Collect Info' 68 | run: | 69 | ./gradlew currentVersion 70 | - name: 'Publish Snapshot' 71 | if: github.event_name != 'schedule' 72 | env: 73 | NEXUS_USERNAME: ${{ secrets.OSSRH_USERNAME }} 74 | NEXUS_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 75 | run: | 76 | ./gradlew publishToSonatype -Prelease.forceSnapshot 77 | -------------------------------------------------------------------------------- /.github/workflows/build-pr.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2023 The jetcd authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | name: Build PR 18 | 19 | concurrency: 20 | group: ${{ github.workflow }}-${{ github.event.pull_request.number }} 21 | cancel-in-progress: true 22 | 23 | permissions: 24 | contents: read 25 | 26 | on: 27 | pull_request: 28 | branches: 29 | - main 30 | workflow_dispatch: 31 | 32 | jobs: 33 | checks: 34 | uses: ./.github/workflows/checks.yml 35 | 36 | build: 37 | needs: 38 | - checks 39 | strategy: 40 | matrix: 41 | java-version: 42 | - 11 43 | - 17 44 | - 21 45 | etcd: 46 | - quay.io/coreos/etcd:v3.5.14 47 | - quay.io/coreos/etcd:v3.4.33 48 | uses: ./.github/workflows/build.yml 49 | with: 50 | javaVersion: "${{ matrix.java-version }}" 51 | etcdImage: "${{ matrix.etcd }}" 52 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | javaVersion: 7 | required: true 8 | type: string 9 | etcdImage: 10 | required: true 11 | type: string 12 | 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: 'Checkout' 19 | uses: actions/checkout@v4 20 | - name: 'Set Up Java' 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: ${{ inputs.javaVersion }} 24 | distribution: 'temurin' 25 | cache: 'gradle' 26 | - name: 'Build Project' 27 | env: 28 | ETCD_IMAGE: ${{ inputs.etcdImage }} 29 | run: | 30 | export TC_USER="$(id -u):$(id -g)" 31 | echo "tc user -> $TC_USER" 32 | 33 | ./gradlew test --info 34 | -------------------------------------------------------------------------------- /.github/workflows/checks.yml: -------------------------------------------------------------------------------- 1 | name: Checks 2 | 3 | on: 4 | workflow_call: 5 | 6 | 7 | jobs: 8 | check: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: 'Checkout' 13 | uses: actions/checkout@v4 14 | with: 15 | fetch-depth: 0 16 | - name: 'Set Up Java' 17 | uses: actions/setup-java@v4 18 | with: 19 | java-version: 11 20 | distribution: 'temurin' 21 | cache: 'gradle' 22 | - name: 'Run check task' 23 | run: | 24 | ./gradlew check -x test 25 | - name: 'Run check script' 26 | run: | 27 | bash ./.github/workflows/scripts/precheck.sh 28 | shell: bash 29 | 30 | deps: 31 | runs-on: ubuntu-latest 32 | if: github.event_name == 'pull_request' 33 | steps: 34 | - name: 'Checkout' 35 | uses: actions/checkout@v4 36 | - name: 'Dependency Review' 37 | uses: actions/dependency-review-action@v4 38 | -------------------------------------------------------------------------------- /.github/workflows/scripts/precheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | failed=0 4 | 5 | # Check trailing whitespace 6 | files=$(find . -type f \ 7 | -not -path "./.git/*" \ 8 | -not -path "*/.gradle/*" \ 9 | -not -path "*/.idea/*" \ 10 | -not -path "*/.vscode/*" \ 11 | -not -path "*/build/*" \ 12 | -not -path "*/out/*" \ 13 | -not -path "*/bin/*" \ 14 | -not -name "*.jar" \ 15 | -not -name "*.java" \ 16 | -exec grep -E -l " +$" {} \;) 17 | 18 | count=0 19 | 20 | for file in $files; do 21 | ((count++)) 22 | echo "$file" 23 | done 24 | 25 | if [ $count -ne 0 ]; then 26 | failed=1 27 | echo "Error: trailing whitespace(s) in the above $count file(s)" 28 | fi 29 | 30 | # Check newline 31 | files=$(find . -type f -size +0c \ 32 | -not -path "./.git/*" \ 33 | -not -path "*/.gradle/*" \ 34 | -not -path "*/.idea/*" \ 35 | -not -path "*/.vscode/*" \ 36 | -not -path "*/build/*" \ 37 | -not -path "*/out/*" \ 38 | -not -path "*/bin/*" \ 39 | -not -name "*.jar" \ 40 | -not -name "*.java" \ 41 | -exec bash -c 'if [[ $(tail -c1 "$0" | wc -l) -eq 0 ]]; then echo "$0"; fi' {} \;) 42 | 43 | count=0 44 | 45 | for file in $files; do 46 | ((count++)) 47 | echo "$file" 48 | done 49 | 50 | if [ $count -ne 0 ]; then 51 | failed=1 52 | echo "Error: no newline in the above $count file(s)" 53 | fi 54 | 55 | exit $failed 56 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2023 The jetcd authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | name: "Stale" 18 | 19 | on: 20 | schedule: 21 | - cron: "0 0 * * *" 22 | 23 | jobs: 24 | stale: 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/stale@v9 28 | with: 29 | repo-token: ${{ secrets.GITHUB_TOKEN }} 30 | days-before-stale: 60 31 | days-before-close: 7 32 | only-labels: 'waiting-for-feedbacks' 33 | stale-issue-label: stale 34 | exempt-issue-labels: never-stale 35 | stale-pr-label: stale 36 | exempt-pr-labels: never-stale 37 | stale-issue-message: | 38 | This issue is stale because it has been open 60 days with no activity. 39 | Remove stale label or comment or this will be closed in 7 days. 40 | stale-pr-message: | 41 | This PR is stale because it has been open 60 days with no activity. 42 | Remove stale label or comment or this will be closed in 7 days. 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.github 3 | !.gitignore 4 | !gradle/wrapper/gradle-wrapper.jar 5 | target/ 6 | target-ide/ 7 | *.iml 8 | logs/ 9 | *.releaseBackup 10 | *.versionsBackup 11 | .vscode/ 12 | .settings/ 13 | .project 14 | .env 15 | .sdkmanrc 16 | build/ 17 | bin/ 18 | out/ 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | 8 | ## [Unreleased] 9 | ### Added 10 | - [Launcher](https://github.com/etcd-io/jetcd#launcher) ([#384](https://github.com/etcd-io/jetcd/issues/384)) 11 | - _...TODO..._ 12 | 13 | 14 | ## [0.0.2] - 2018-03-27 15 | ### Added 16 | - lock support ([#259](https://github.com/etcd-io/jetcd/issues/259)) 17 | - nested txn support ([#265](https://github.com/etcd-io/jetcd/issues/265)) 18 | - move leader support ([#235](https://github.com/etcd-io/jetcd/issues/235)) 19 | - hashkv support ([#234](https://github.com/etcd-io/jetcd/issues/234)) 20 | - OSGi support ([#269](https://github.com/etcd-io/jetcd/issues/269)) 21 | 22 | ### Changed 23 | - `Client` extends AutoCloseable ([#244](https://github.com/etcd-io/jetcd/issues/244)) 24 | - improved integration test framework ([#295](https://github.com/etcd-io/jetcd/issues/295)) 25 | 26 | ### Fixed 27 | - TXN getter ([#237](https://github.com/etcd-io/jetcd/issues/237)) 28 | 29 | ### Doc 30 | - TLS support ([#245](https://github.com/etcd-io/jetcd/issues/245)) 31 | 32 | 33 | ## [0.0.1] - 2017-08-23 34 | ### Added 35 | - Initial Release 36 | 37 | ### Known Limitations 38 | - Nested transactions are not currently supported ([#143](https://github.com/etcd-io/jetcd/issues/143)) 39 | - HashKV is not currently supported ([#222](https://github.com/etcd-io/jetcd/issues/222)) 40 | -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2018 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - fanminshi # Fanmin Shi 5 | - lburgazzoli # Luca Burgazzoli 6 | - xiang90 # Xiang Li 7 | - heyitsanthony # Anthony Romano 8 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | ## etcd Community Code of Conduct 2 | 3 | etcd follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | -------------------------------------------------------------------------------- /docs/KeyVal.adoc: -------------------------------------------------------------------------------- 1 | = KeyVal 2 | 3 | 4 | * Examples: 5 | + 6 | .Retrieve All Keys 7 | [source,java] 8 | ---- 9 | ByteSequence key = ByteSequence.fromString("\0"); 10 | 11 | GetOption option = GetOption.newBuilder() 12 | .withSortField(GetOption.SortTarget.KEY) 13 | .withSortOrder(GetOption.SortOrder.DESCEND) 14 | .withRange(key) 15 | .build(); 16 | 17 | CompletableFuture futureResponse = client.getKVClient().get(key, option); 18 | 19 | GetResponse response = futureResponse.get(); 20 | Map keyValueMap = new HashMap<>(); 21 | 22 | for (KeyValue kv : response.getKvs()) { 23 | keyValueMap.put( 24 | kv.getKey().toStringUtf8(), 25 | kv.getValue().toStringUtf8() 26 | ); 27 | } 28 | ---- 29 | -------------------------------------------------------------------------------- /docs/RELEASE.adoc: -------------------------------------------------------------------------------- 1 | = Release 2 | 3 | + 4 | [source,shell] 5 | ---- 6 | $ ./gradlew currentVersion 7 | Project version: 0.7.5-SNAPSHOT 8 | 9 | $ ./gradlew release 10 | 11 | $ git tag 12 | jetcd-0.7.5 13 | 14 | $ ./gradlew currentVersion 15 | Project version: 0.7.5 16 | 17 | $ ./gradlew publish 18 | published jetcd-0.7.5 release version 19 | 20 | $ ./gradlew markNextVersion -Prelease.version=0.7.6 21 | ---- 22 | -------------------------------------------------------------------------------- /docs/SslConfig.md: -------------------------------------------------------------------------------- 1 | # How to Build Jectd Client for One TLS Secured Etcd Cluster 2 | 3 | # prepare certification files 4 | 5 | If your etcd cluster is installed using [etcdadm](https://github.com/kubernetes-sigs/etcdadm), you are likely to find 6 | certification files in the path `/etc/etcd/pki/`: `ca.crt`, `etcdctl-etcd-client.key`, `etcdctl-etcd-client.crt`. 7 | 8 | If your etcd cluster is the builtin etcd in one kubernetes cluster( 9 | using [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm/)), 10 | 11 | you can find the same files in `/etc/kubernetes/pki/etcd/`: `ca.crt`, `healthcheck-client.crt`, `healthcheck-client.key`. 12 | 13 | Because `SslContextBuilder` only support a PKCS#8 private key file in PEM format, convert `etcdctl-etcd-client.key` 14 | to `etcdctl-etcd-client.key.pem` according 15 | to [netty SslContextBuilder doc](https://netty.io/wiki/sslcontextbuilder-and-private-key.html). 16 | 17 | # build jetcd client 18 | 19 | ``` 20 | File cert = new File("ca.crt"); 21 | File keyCertChainFile = new File("etcdctl-etcd-client.crt"); 22 | File keyFile = new File("etcdctl-etcd-client.key.pem"); 23 | SslContext context = GrpcSslContexts.forClient() 24 | .trustManager(cert) 25 | .keyManager(keyCertChainFile, keyFile) 26 | .build(); 27 | Client client = Client.builder() 28 | .endpoints("https://10.168.168.66:2379") 29 | .sslContext(context) 30 | .build(); 31 | 32 | client.getClusterClient().listMember().get().getMembers().forEach(member -> { 33 | logger.info("member: {}", member); 34 | }); 35 | 36 | ``` 37 | -------------------------------------------------------------------------------- /etc/eclipse.importorder: -------------------------------------------------------------------------------- 1 | 0=java 2 | 1=javax 3 | 2=org 4 | 2=io 5 | 4=com 6 | 5= 7 | 6=\# 8 | -------------------------------------------------------------------------------- /etc/license-formatting.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | false 27 | true 28 | false 29 | 30 | 31 | -------------------------------------------------------------------------------- /etc/license.txt: -------------------------------------------------------------------------------- 1 | Copyright $YEAR The jetcd authors 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # project 3 | # 4 | gitProject = https://github.com/etcd-io/jetcd 5 | gitURL = git@github.com/etcd-io/jetcd.git 6 | 7 | # 8 | # gradle 9 | # 10 | org.gradle.parallel = true 11 | -------------------------------------------------------------------------------- /gradle/publish.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: "signing" 18 | apply plugin: "maven-publish" 19 | apply plugin: "io.github.gradle-nexus.publish-plugin" 20 | 21 | ext { 22 | if (!project.hasProperty('nexusUsername')) { 23 | nexusUsername = "$System.env.NEXUS_USERNAME" 24 | } 25 | if (!project.hasProperty('nexusPassword')) { 26 | nexusPassword = "$System.env.NEXUS_PASSWORD" 27 | } 28 | } 29 | 30 | nexusPublishing { 31 | repositories { 32 | sonatype { 33 | username = nexusUsername 34 | password = nexusPassword 35 | } 36 | } 37 | } 38 | 39 | //afterReleaseBuild.dependsOn publishToSonatype 40 | -------------------------------------------------------------------------------- /gradle/publishing-release-tasks.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'maven-publish' 18 | 19 | task pubblications { 20 | doLast { 21 | project.publishing.publications.each { publication -> 22 | println "Publication $publication.name [$publication.groupId/$publication.artifactId/$publication.version]" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /gradle/quality.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: "net.ltgt.errorprone" 18 | apply plugin: "pmd" 19 | 20 | dependencies { 21 | errorprone(libs.errorprone) 22 | errorprone(libs.errorproneAnnotations) 23 | errorproneJavac(libs.errorproneJavac) 24 | } 25 | 26 | tasks.withType(JavaCompile).configureEach { 27 | options.errorprone { 28 | excludedPaths = '.*/generated/.*' 29 | disableWarningsInGeneratedCode = true 30 | } 31 | options.deprecation = true 32 | } 33 | 34 | pmd { 35 | consoleOutput = true 36 | ruleSets = [ "${project.rootDir}/etc/pmd-ruleset.xml" ] 37 | } 38 | -------------------------------------------------------------------------------- /gradle/release.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: "pl.allegro.tech.build.axion-release" 18 | 19 | 20 | scmVersion { 21 | tag { 22 | prefix = 'jetcd-' 23 | } 24 | } 25 | 26 | allprojects { 27 | project.version = scmVersion.version 28 | } 29 | -------------------------------------------------------------------------------- /gradle/style.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: "com.diffplug.spotless" 18 | 19 | spotless { 20 | java { 21 | removeUnusedImports() 22 | trimTrailingWhitespace() 23 | indentWithSpaces(4) 24 | endWithNewline() 25 | importOrderFile(rootProject.file('etc/eclipse.importorder')) 26 | eclipse().configFile(rootProject.file('etc/eclipse-formatter-config.xml')) 27 | targetExclude("build/generated/**/*.java") 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gradle/versions.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'com.github.ben-manes.versions' 18 | 19 | dependencyUpdates.configure { 20 | 21 | def isNonStable = { String version -> 22 | return ['alpha', 'beta', 'rc', 'cr', 'm', 'ea'].any { keyword -> version.toUpperCase().contains(keyword.toUpperCase())} 23 | } 24 | 25 | rejectVersionIf { 26 | isNonStable(it.candidate.version) 27 | } 28 | } 29 | 30 | task deps { 31 | dependsOn dependencyUpdates 32 | } 33 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/jetcd/579e05b6345aca7609bcea50cf28188bbac8f966/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /jetcd-api/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | dependencies { 19 | api libs.slf4j 20 | } 21 | -------------------------------------------------------------------------------- /jetcd-common/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | dependencies { 19 | api libs.slf4j 20 | api libs.guava 21 | api libs.grpcCore 22 | 23 | testImplementation libs.bundles.testing 24 | testRuntimeOnly libs.bundles.log4j 25 | } 26 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/Service.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common; 18 | 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | 21 | public abstract class Service implements AutoCloseable { 22 | private final AtomicBoolean running; 23 | 24 | protected Service() { 25 | this.running = new AtomicBoolean(); 26 | } 27 | 28 | public void start() { 29 | if (this.running.compareAndSet(false, true)) { 30 | doStart(); 31 | } 32 | } 33 | 34 | public void stop() { 35 | if (this.running.compareAndSet(true, false)) { 36 | doStop(); 37 | } 38 | } 39 | 40 | public void restart() { 41 | stop(); 42 | start(); 43 | } 44 | 45 | @Override 46 | public void close() { 47 | stop(); 48 | } 49 | 50 | public boolean isRunning() { 51 | return running.get(); 52 | } 53 | 54 | protected abstract void doStart(); 55 | 56 | protected abstract void doStop(); 57 | } 58 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/ClosedClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | public class ClosedClientException extends EtcdException { 20 | 21 | public ClosedClientException(String reason) { 22 | super(ErrorCode.CANCELLED, reason, null); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/ClosedKeepAliveListenerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | public class ClosedKeepAliveListenerException extends EtcdException { 20 | 21 | public ClosedKeepAliveListenerException() { 22 | super(ErrorCode.CANCELLED, "KeepAliveListener has been closed", null); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/ClosedSnapshotException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | public class ClosedSnapshotException extends EtcdException { 20 | 21 | public ClosedSnapshotException() { 22 | super(ErrorCode.CANCELLED, "Snapshot has been closed", null); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/ClosedWatcherException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | public class ClosedWatcherException extends EtcdException { 20 | 21 | public ClosedWatcherException() { 22 | super(ErrorCode.CANCELLED, "Watcher has been closed", null); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/CompactedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | /** 20 | * CompactedException is thrown when a operation wants to retrieve key at a revision that has 21 | * been compacted. 22 | */ 23 | public class CompactedException extends EtcdException { 24 | 25 | private long compactedRevision; 26 | 27 | CompactedException(ErrorCode code, String message, long compactedRev) { 28 | super(code, message, null); 29 | this.compactedRevision = compactedRev; 30 | } 31 | 32 | // get the current compacted revision of etcd server. 33 | public long getCompactedRevision() { 34 | return compactedRevision; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jetcd-common/src/main/java/io/etcd/jetcd/common/exception/EtcdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.common.exception; 18 | 19 | import java.util.Objects; 20 | 21 | /** 22 | * Base exception type for all exceptions produced by the etcd service. 23 | */ 24 | public class EtcdException extends RuntimeException { 25 | 26 | private final ErrorCode code; 27 | 28 | EtcdException(ErrorCode code, String message, Throwable cause) { 29 | super(message, cause); 30 | this.code = Objects.requireNonNull(code, "Error code must not be null"); 31 | } 32 | 33 | /** 34 | * Returns the error code associated with this exception. 35 | * 36 | * @return a {@link ErrorCode} 37 | */ 38 | public ErrorCode getErrorCode() { 39 | return code; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jetcd-core/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | api project(':jetcd-grpc') 19 | api project(':jetcd-api') 20 | api project(':jetcd-common') 21 | 22 | api libs.slf4j 23 | api libs.guava 24 | api libs.failsafe 25 | 26 | //compileOnly libs.javaxAnnotation 27 | compileOnly libs.autoServiceAnnotations 28 | 29 | annotationProcessor libs.autoServiceProcessor 30 | 31 | testImplementation project(':jetcd-launcher') 32 | testImplementation project(':jetcd-test') 33 | 34 | testImplementation libs.restAssured 35 | testImplementation libs.awaitility 36 | testImplementation libs.commonsIo 37 | testImplementation libs.bundles.testing 38 | 39 | testRuntimeOnly libs.bundles.log4j 40 | } 41 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | /** 20 | * Etcd Client. 21 | * 22 | *

23 | * The implementation may throw unchecked ConnectException or AuthFailedException on 24 | * initialization (or when invoking *Client methods if configured to initialize lazily). 25 | */ 26 | public interface Client extends AutoCloseable { 27 | 28 | /** 29 | * Returns the {@link Auth} client. 30 | * 31 | * @return the client. 32 | */ 33 | Auth getAuthClient(); 34 | 35 | /** 36 | * Returns the {@link KV} client. 37 | * 38 | * @return the client. 39 | */ 40 | KV getKVClient(); 41 | 42 | /** 43 | * Returns the {@link Cluster} client. 44 | * 45 | * @return the client. 46 | */ 47 | Cluster getClusterClient(); 48 | 49 | /** 50 | * Returns the {@link Maintenance} client. 51 | * 52 | * @return the client. 53 | */ 54 | Maintenance getMaintenanceClient(); 55 | 56 | /** 57 | * Returns the {@link Lease} client. 58 | * 59 | * @return the client. 60 | */ 61 | Lease getLeaseClient(); 62 | 63 | /** 64 | * Returns the {@link Watch} client. 65 | * 66 | * @return the client. 67 | */ 68 | Watch getWatchClient(); 69 | 70 | /** 71 | * Returns the {@link Lock} client. 72 | * 73 | * @return the client. 74 | */ 75 | Lock getLockClient(); 76 | 77 | /** 78 | * Returns the {@link Election} client. 79 | * 80 | * @return the client. 81 | */ 82 | Election getElectionClient(); 83 | 84 | @Override 85 | void close(); 86 | 87 | /** 88 | * Returns a new {@link ClientBuilder}. 89 | * 90 | * @return the builder. 91 | */ 92 | static ClientBuilder builder() { 93 | return new ClientBuilder(); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | import io.grpc.Metadata; 20 | 21 | /** 22 | * Constants of Etcd. 23 | */ 24 | public class Constants { 25 | public static final ByteSequence NULL_KEY = ByteSequence.from(new byte[] { '\0' }); 26 | 27 | public static final Metadata.Key REQUIRE_LEADER_KEY = Metadata.Key.of( 28 | "hasleader", 29 | Metadata.ASCII_STRING_MARSHALLER); 30 | 31 | public static final String REQUIRE_LEADER_VALUE = "true"; 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/KeyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | import io.etcd.jetcd.support.Util; 20 | 21 | /** 22 | * Etcd key value pair. 23 | */ 24 | public class KeyValue { 25 | 26 | private final io.etcd.jetcd.api.KeyValue kv; 27 | private final ByteSequence unprefixedKey; 28 | private final ByteSequence value; 29 | 30 | public KeyValue(io.etcd.jetcd.api.KeyValue kv, ByteSequence namespace) { 31 | this.kv = kv; 32 | this.value = ByteSequence.from(kv.getValue()); 33 | 34 | this.unprefixedKey = ByteSequence.from( 35 | kv.getKey().isEmpty() 36 | ? kv.getKey() 37 | : Util.unprefixNamespace(kv.getKey(), namespace)); 38 | } 39 | 40 | /** 41 | * Returns the key 42 | * 43 | * @return the key. 44 | */ 45 | public ByteSequence getKey() { 46 | return unprefixedKey; 47 | } 48 | 49 | /** 50 | * Returns the value 51 | * 52 | * @return the value. 53 | */ 54 | public ByteSequence getValue() { 55 | return value; 56 | } 57 | 58 | /** 59 | * Returns the create revision. 60 | * 61 | * @return the create revision. 62 | */ 63 | public long getCreateRevision() { 64 | return kv.getCreateRevision(); 65 | } 66 | 67 | /** 68 | * Returns the mod revision. 69 | * 70 | * @return the mod revision. 71 | */ 72 | public long getModRevision() { 73 | return kv.getModRevision(); 74 | } 75 | 76 | /** 77 | * Returns the version. 78 | * 79 | * @return the version. 80 | */ 81 | public long getVersion() { 82 | return kv.getVersion(); 83 | } 84 | 85 | /** 86 | * Returns the lease. 87 | * 88 | * @return the lease. 89 | */ 90 | public long getLease() { 91 | return kv.getLease(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/Lock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | import java.util.concurrent.CompletableFuture; 20 | 21 | import io.etcd.jetcd.lock.LockResponse; 22 | import io.etcd.jetcd.lock.UnlockResponse; 23 | import io.etcd.jetcd.support.CloseableClient; 24 | 25 | /** 26 | * Interface of Lock talking to etcd. 27 | */ 28 | public interface Lock extends CloseableClient { 29 | 30 | /** 31 | * Acquire a lock with the given name. 32 | * 33 | * @param name 34 | * the identifier for the distributed shared lock to be acquired. 35 | * @param leaseId 36 | * the ID of the lease that will be attached to ownership of the 37 | * lock. If the lease expires or is revoked and currently holds the 38 | * lock, the lock is automatically released. Calls to Lock with the 39 | * same lease will be treated as a single acquistion; locking twice 40 | * with the same lease is a no-op. 41 | * @return the lock response 42 | */ 43 | CompletableFuture lock(ByteSequence name, long leaseId); 44 | 45 | /** 46 | * Release the lock identified by the given key. 47 | * 48 | * @param lockKey 49 | * key is the lock ownership key granted by Lock. 50 | * @return the unlock response 51 | */ 52 | CompletableFuture unlock(ByteSequence lockKey); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/Preconditions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | public class Preconditions { 20 | 21 | public static void checkArgument(boolean expression, String errorMessage) { 22 | if (!expression) { 23 | throw new IllegalArgumentException(errorMessage); 24 | } 25 | } 26 | 27 | public static void checkState(boolean expression, String errorMessage) { 28 | if (!expression) { 29 | throw new IllegalStateException(errorMessage); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd; 18 | 19 | /** 20 | * represents a generic Jetcd response. 21 | */ 22 | public interface Response { 23 | 24 | /** 25 | * Returns the response header 26 | * 27 | * @return the header. 28 | */ 29 | Header getHeader(); 30 | 31 | interface Header { 32 | 33 | /** 34 | * Returns the cluster id 35 | * 36 | * @return the cluster id. 37 | */ 38 | long getClusterId(); 39 | 40 | /** 41 | * Returns the member id 42 | * 43 | * @return the member id. 44 | */ 45 | long getMemberId(); 46 | 47 | /** 48 | * Returns the revision id 49 | * 50 | * @return the revision. 51 | */ 52 | long getRevision(); 53 | 54 | /** 55 | * Returns the raft term 56 | * 57 | * @return theraft term. 58 | */ 59 | long getRaftTerm(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthDisableResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * AuthDisableResponse returned by {@link Auth#authDisable()} contains a header. 24 | */ 25 | public class AuthDisableResponse extends AbstractResponse { 26 | 27 | public AuthDisableResponse(io.etcd.jetcd.api.AuthDisableResponse response) { 28 | super(response, response.getHeader()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthEnableResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * AuthEnableResponse returned by {@link Auth#authEnable()} call contains a header. 24 | */ 25 | public class AuthEnableResponse extends AbstractResponse { 26 | 27 | public AuthEnableResponse(io.etcd.jetcd.api.AuthEnableResponse response) { 28 | super(response, response.getHeader()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleAddResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthRoleAddResponse returned by {@link Auth#roleAdd(ByteSequence)} contains 25 | * a header. 26 | */ 27 | public class AuthRoleAddResponse extends AbstractResponse { 28 | 29 | public AuthRoleAddResponse(io.etcd.jetcd.api.AuthRoleAddResponse response) { 30 | super(response, response.getHeader()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleDeleteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthRoleDeleteResponse returned by {@link Auth#roleDelete(ByteSequence)} 25 | * contains a header. 26 | */ 27 | public class AuthRoleDeleteResponse extends AbstractResponse { 28 | 29 | public AuthRoleDeleteResponse(io.etcd.jetcd.api.AuthRoleDeleteResponse response) { 30 | super(response, response.getHeader()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleGetResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import io.etcd.jetcd.Auth; 23 | import io.etcd.jetcd.ByteSequence; 24 | import io.etcd.jetcd.impl.AbstractResponse; 25 | 26 | /** 27 | * AuthRoleGetResponse returned by {@link Auth#roleGet(ByteSequence)} contains 28 | * a header and a list of permissions. 29 | */ 30 | public class AuthRoleGetResponse extends AbstractResponse { 31 | 32 | private List permissions; 33 | 34 | public AuthRoleGetResponse(io.etcd.jetcd.api.AuthRoleGetResponse response) { 35 | super(response, response.getHeader()); 36 | } 37 | 38 | private static Permission toPermission(io.etcd.jetcd.api.Permission perm) { 39 | ByteSequence key = ByteSequence.from(perm.getKey()); 40 | ByteSequence rangeEnd = ByteSequence.from(perm.getRangeEnd()); 41 | 42 | Permission.Type type; 43 | switch (perm.getPermType()) { 44 | case READ: 45 | type = Permission.Type.READ; 46 | break; 47 | case WRITE: 48 | type = Permission.Type.WRITE; 49 | break; 50 | case READWRITE: 51 | type = Permission.Type.READWRITE; 52 | break; 53 | default: 54 | type = Permission.Type.UNRECOGNIZED; 55 | } 56 | 57 | return new Permission(type, key, rangeEnd); 58 | } 59 | 60 | public synchronized List getPermissions() { 61 | if (permissions == null) { 62 | permissions = getResponse().getPermList().stream().map(AuthRoleGetResponse::toPermission) 63 | .collect(Collectors.toList()); 64 | } 65 | 66 | return permissions; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleGrantPermissionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthRoleGrantPermissionResponse returned by 25 | * {@link Auth#roleGrantPermission(ByteSequence, ByteSequence, ByteSequence, Permission.Type)} contains a 26 | * header. 27 | */ 28 | public class AuthRoleGrantPermissionResponse extends AbstractResponse { 29 | 30 | public AuthRoleGrantPermissionResponse(io.etcd.jetcd.api.AuthRoleGrantPermissionResponse response) { 31 | super(response, response.getHeader()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Auth; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * AuthRoleListResponse returned by {@link Auth#roleList()} contains a header and 26 | * a list of roles. 27 | */ 28 | public class AuthRoleListResponse extends AbstractResponse { 29 | 30 | public AuthRoleListResponse(io.etcd.jetcd.api.AuthRoleListResponse response) { 31 | super(response, response.getHeader()); 32 | } 33 | 34 | /** 35 | * Returns a list of roles. 36 | * 37 | * @return the roles. 38 | */ 39 | public List getRoles() { 40 | return getResponse().getRolesList(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthRoleRevokePermissionResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | /** 22 | * AuthRoleRevokePermissionResponse 23 | */ 24 | public class AuthRoleRevokePermissionResponse extends AbstractResponse { 25 | 26 | public AuthRoleRevokePermissionResponse(io.etcd.jetcd.api.AuthRoleRevokePermissionResponse response) { 27 | super(response, response.getHeader()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserAddResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthUserAddResponse returned by {@link Auth#userAdd(ByteSequence, ByteSequence)} contains a 25 | * header. 26 | */ 27 | public class AuthUserAddResponse extends AbstractResponse { 28 | 29 | public AuthUserAddResponse(io.etcd.jetcd.api.AuthUserAddResponse response) { 30 | super(response, response.getHeader()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserChangePasswordResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | /** 22 | * AuthUserChangePasswordResponse 23 | */ 24 | public class AuthUserChangePasswordResponse extends AbstractResponse { 25 | 26 | public AuthUserChangePasswordResponse(io.etcd.jetcd.api.AuthUserChangePasswordResponse response) { 27 | super(response, response.getHeader()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserDeleteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthUserDeleteResponse returned by {@link Auth#userDelete(ByteSequence)} contains a header. 25 | */ 26 | public class AuthUserDeleteResponse extends AbstractResponse { 27 | 28 | public AuthUserDeleteResponse(io.etcd.jetcd.api.AuthUserDeleteResponse response) { 29 | super(response, response.getHeader()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserGetResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Auth; 22 | import io.etcd.jetcd.ByteSequence; 23 | import io.etcd.jetcd.impl.AbstractResponse; 24 | 25 | /** 26 | * AuthUserGetResponse returned by {@link Auth#userGet(ByteSequence)} contains a header and 27 | * a list of roles associated with the user. 28 | */ 29 | public class AuthUserGetResponse extends AbstractResponse { 30 | 31 | public AuthUserGetResponse(io.etcd.jetcd.api.AuthUserGetResponse response) { 32 | super(response, response.getHeader()); 33 | } 34 | 35 | /** 36 | * Returns a list of roles. 37 | * 38 | * @return the roles. 39 | */ 40 | public List getRoles() { 41 | return getResponse().getRolesList(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserGrantRoleResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | /** 22 | * AuthUserGrantRoleResponse 23 | */ 24 | public class AuthUserGrantRoleResponse extends AbstractResponse { 25 | 26 | public AuthUserGrantRoleResponse(io.etcd.jetcd.api.AuthUserGrantRoleResponse response) { 27 | super(response, response.getHeader()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Auth; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * AuthUserListResponse returned by {@link Auth#userList()} contains a header and 26 | * a list of users. 27 | */ 28 | public class AuthUserListResponse extends AbstractResponse { 29 | 30 | public AuthUserListResponse(io.etcd.jetcd.api.AuthUserListResponse response) { 31 | super(response, response.getHeader()); 32 | } 33 | 34 | /** 35 | * Returns a list of users. 36 | * 37 | * @return the users. 38 | */ 39 | public List getUsers() { 40 | return getResponse().getUsersList(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/AuthUserRevokeRoleResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.Auth; 20 | import io.etcd.jetcd.ByteSequence; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | /** 24 | * AuthUserRevokeRoleResponse returned by {@link Auth#userRevokeRole(ByteSequence, ByteSequence)} 25 | * contains a header. 26 | */ 27 | public class AuthUserRevokeRoleResponse extends AbstractResponse { 28 | 29 | public AuthUserRevokeRoleResponse(io.etcd.jetcd.api.AuthUserRevokeRoleResponse response) { 30 | super(response, response.getHeader()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/auth/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.auth; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | 21 | /** 22 | * represents a permission over a range of keys. 23 | */ 24 | public class Permission { 25 | 26 | private final Type permType; 27 | private final ByteSequence key; 28 | private final ByteSequence rangeEnd; 29 | 30 | public enum Type { 31 | READ, WRITE, READWRITE, UNRECOGNIZED, 32 | } 33 | 34 | public Permission(Type permType, ByteSequence key, ByteSequence rangeEnd) { 35 | this.permType = permType; 36 | this.key = key; 37 | this.rangeEnd = rangeEnd; 38 | } 39 | 40 | /** 41 | * Returns the type of Permission: READ, WRITE, READWRITE, or UNRECOGNIZED. 42 | * 43 | * @return the permission type. 44 | */ 45 | public Type getPermType() { 46 | return permType; 47 | } 48 | 49 | public ByteSequence getKey() { 50 | return key; 51 | } 52 | 53 | public ByteSequence getRangeEnd() { 54 | return rangeEnd; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/Member.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.net.URI; 20 | import java.util.List; 21 | 22 | import io.etcd.jetcd.support.Util; 23 | 24 | public class Member { 25 | 26 | private final io.etcd.jetcd.api.Member member; 27 | 28 | public Member(io.etcd.jetcd.api.Member member) { 29 | this.member = member; 30 | } 31 | 32 | /** 33 | * Returns the member ID for this member. 34 | * 35 | * @return the id. 36 | */ 37 | public long getId() { 38 | return member.getID(); 39 | } 40 | 41 | /** 42 | * Returns the human-readable name of the member, ff the member is not started, the name will be an empty string. 43 | * 44 | * @return the name. 45 | */ 46 | public String getName() { 47 | return member.getName(); 48 | } 49 | 50 | /** 51 | * Returns the list of URLs the member exposes to the cluster for communication. 52 | * 53 | * @return the peer url 54 | */ 55 | public List getPeerURIs() { 56 | return Util.toURIs(member.getPeerURLsList()); 57 | } 58 | 59 | /** 60 | * Returns list of URLs the member exposes to clients for communication, if the member is not started, clientURLs will 61 | * be empty. 62 | * 63 | * @return the client URIs. 64 | */ 65 | public List getClientURIs() { 66 | return Util.toURIs(member.getClientURLsList()); 67 | } 68 | 69 | /** 70 | * Returns if the member is raft learner 71 | * 72 | * @return if the member is raft learner 73 | */ 74 | public boolean isLearner() { 75 | return member.getIsLearner(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/MemberAddResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Cluster; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * MemberAddResponse returned by {@link Cluster#addMember(List, boolean)} 26 | * contains a header, added member, and list of members after adding the new member. 27 | */ 28 | public class MemberAddResponse extends AbstractResponse { 29 | 30 | private final Member member; 31 | private List members; 32 | 33 | public MemberAddResponse(io.etcd.jetcd.api.MemberAddResponse response) { 34 | super(response, response.getHeader()); 35 | member = new Member(response.getMember()); 36 | } 37 | 38 | /** 39 | * Returns the member information for the added member. 40 | * 41 | * @return the member information. 42 | */ 43 | public Member getMember() { 44 | return member; 45 | } 46 | 47 | /** 48 | * Returns a list of all members after adding the new member. 49 | * 50 | * @return the list of members. 51 | */ 52 | public synchronized List getMembers() { 53 | if (members == null) { 54 | members = Util.toMembers(getResponse().getMembersList()); 55 | } 56 | 57 | return members; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/MemberListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Cluster; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * MemberListResponse returned by {@link Cluster#listMember()} 26 | * contains a header and a list of members. 27 | */ 28 | public class MemberListResponse extends AbstractResponse { 29 | 30 | private List members; 31 | 32 | public MemberListResponse(io.etcd.jetcd.api.MemberListResponse response) { 33 | super(response, response.getHeader()); 34 | } 35 | 36 | /** 37 | * Returns a list of members. empty list if none. 38 | * 39 | * @return the list of members. 40 | */ 41 | public synchronized List getMembers() { 42 | if (members == null) { 43 | members = Util.toMembers(getResponse().getMembersList()); 44 | } 45 | 46 | return members; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/MemberRemoveResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Cluster; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * MemberRemoveResponse returned by {@link Cluster#removeMember(long)} 26 | * contains a header and a list of member the removal of the member. 27 | */ 28 | public class MemberRemoveResponse extends AbstractResponse { 29 | 30 | private List members; 31 | 32 | public MemberRemoveResponse(io.etcd.jetcd.api.MemberRemoveResponse response) { 33 | super(response, response.getHeader()); 34 | } 35 | 36 | /** 37 | * Returns a list of all members after removing the member. 38 | * 39 | * @return the list of members. 40 | */ 41 | public synchronized List getMembers() { 42 | if (members == null) { 43 | members = Util.toMembers(getResponse().getMembersList()); 44 | } 45 | 46 | return members; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/MemberUpdateResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.util.List; 20 | 21 | import io.etcd.jetcd.Cluster; 22 | import io.etcd.jetcd.impl.AbstractResponse; 23 | 24 | /** 25 | * MemberUpdateResponse returned by {@link Cluster#updateMember(long, List)} 26 | * contains a header and a list of members after the member update. 27 | */ 28 | public class MemberUpdateResponse extends AbstractResponse { 29 | 30 | private List members; 31 | 32 | public MemberUpdateResponse(io.etcd.jetcd.api.MemberUpdateResponse response) { 33 | super(response, response.getHeader()); 34 | } 35 | 36 | /** 37 | * Return a list of all members after updating the member. 38 | * 39 | * @return the list of members. 40 | */ 41 | public synchronized List getMembers() { 42 | if (members == null) { 43 | members = Util.toMembers(getResponse().getMembersList()); 44 | } 45 | 46 | return members; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/cluster/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.cluster; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | /** 23 | * Util class for Cluster models. 24 | */ 25 | final class Util { 26 | private Util() { 27 | } 28 | 29 | /** 30 | * Converts a list of API member to a List of client side member. 31 | */ 32 | static List toMembers(List members) { 33 | return members.stream().map(Member::new).collect(Collectors.toList()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/CampaignResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | public class CampaignResponse extends AbstractResponse { 23 | private final LeaderKey leaderKey; 24 | 25 | public CampaignResponse(io.etcd.jetcd.api.CampaignResponse response) { 26 | super(response, response.getHeader()); 27 | 28 | this.leaderKey = new LeaderKey( 29 | ByteSequence.from(getResponse().getLeader().getName()), 30 | ByteSequence.from(getResponse().getLeader().getKey()), 31 | getResponse().getLeader().getRev(), 32 | getResponse().getLeader().getLease()); 33 | } 34 | 35 | /** 36 | * Returns the resources used for holding leadership of the election. 37 | * 38 | * @return the leader. 39 | */ 40 | public LeaderKey getLeader() { 41 | return leaderKey; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/LeaderKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | 21 | public class LeaderKey { 22 | private final ByteSequence name; 23 | private final ByteSequence key; 24 | private final long revision; 25 | private final long lease; 26 | 27 | public LeaderKey(ByteSequence name, ByteSequence key, long revision, long lease) { 28 | this.name = name; 29 | this.key = key; 30 | this.revision = revision; 31 | this.lease = lease; 32 | } 33 | 34 | /** 35 | * Returns the election identifier that corresponds to the leadership key. 36 | * 37 | * @return the name. 38 | */ 39 | public ByteSequence getName() { 40 | return name; 41 | } 42 | 43 | /** 44 | * Returns the opaque key representing the ownership of the election. If the key 45 | * is deleted, then leadership is lost. 46 | * 47 | * @return the key. 48 | */ 49 | public ByteSequence getKey() { 50 | return key; 51 | } 52 | 53 | /** 54 | * Returns the creation revision of the key. It can be used to test for ownership 55 | * of an election during transactions by testing the key's creation revision 56 | * matches rev. 57 | * 58 | * @return the revision. 59 | */ 60 | public long getRevision() { 61 | return revision; 62 | } 63 | 64 | /** 65 | * Returns the lease ID of the election leader. 66 | * 67 | * @return the lese id. 68 | */ 69 | public long getLease() { 70 | return lease; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/LeaderResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | import io.etcd.jetcd.KeyValue; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | public class LeaderResponse extends AbstractResponse { 24 | private final KeyValue kv; 25 | 26 | public LeaderResponse(io.etcd.jetcd.api.LeaderResponse response, ByteSequence namespace) { 27 | super(response, response.getHeader()); 28 | this.kv = new KeyValue(getResponse().getKv(), namespace); 29 | } 30 | 31 | /** 32 | * Returns the key-value pair representing the latest leader update. 33 | * 34 | * @return the kv. 35 | */ 36 | public KeyValue getKv() { 37 | return kv; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/NoLeaderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | /** 20 | * Signals that leader for given election does not exist. 21 | */ 22 | public class NoLeaderException extends RuntimeException { 23 | } 24 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/NotLeaderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | /** 20 | * Signals that candidate is not a leader at the moment. 21 | */ 22 | public class NotLeaderException extends RuntimeException { 23 | } 24 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/ProclaimResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class ProclaimResponse extends AbstractResponse { 22 | public ProclaimResponse(io.etcd.jetcd.api.ProclaimResponse response) { 23 | super(response, response.getHeader()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/election/ResignResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.election; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class ResignResponse extends AbstractResponse { 22 | public ResignResponse(io.etcd.jetcd.api.ResignResponse response) { 23 | super(response, response.getHeader()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/impl/AbstractResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.impl; 18 | 19 | import io.etcd.jetcd.Response; 20 | import io.etcd.jetcd.api.ResponseHeader; 21 | 22 | public class AbstractResponse implements Response { 23 | 24 | private final R response; 25 | private final ResponseHeader responseHeader; 26 | private final Header header; 27 | 28 | public AbstractResponse(R response, ResponseHeader responseHeader) { 29 | this.response = response; 30 | this.responseHeader = responseHeader; 31 | 32 | this.header = new HeaderImpl(); 33 | } 34 | 35 | @Override 36 | public Header getHeader() { 37 | return header; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return response.toString(); 43 | } 44 | 45 | protected final R getResponse() { 46 | return this.response; 47 | } 48 | 49 | protected final ResponseHeader getResponseHeader() { 50 | return this.responseHeader; 51 | } 52 | 53 | private class HeaderImpl implements Response.Header { 54 | 55 | @Override 56 | public long getClusterId() { 57 | return responseHeader.getClusterId(); 58 | } 59 | 60 | @Override 61 | public long getMemberId() { 62 | return responseHeader.getMemberId(); 63 | } 64 | 65 | @Override 66 | public long getRevision() { 67 | return responseHeader.getRevision(); 68 | } 69 | 70 | @Override 71 | public long getRaftTerm() { 72 | return responseHeader.getRaftTerm(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/kv/CompactResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.kv; 18 | 19 | import io.etcd.jetcd.api.CompactionResponse; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | public class CompactResponse extends AbstractResponse { 23 | 24 | public CompactResponse(CompactionResponse response) { 25 | super(response, response.getHeader()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/kv/DeleteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.kv; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import io.etcd.jetcd.ByteSequence; 23 | import io.etcd.jetcd.KeyValue; 24 | import io.etcd.jetcd.api.DeleteRangeResponse; 25 | import io.etcd.jetcd.impl.AbstractResponse; 26 | 27 | public class DeleteResponse extends AbstractResponse { 28 | 29 | private final ByteSequence namespace; 30 | 31 | private List prevKvs; 32 | 33 | public DeleteResponse(DeleteRangeResponse deleteRangeResponse, ByteSequence namespace) { 34 | super(deleteRangeResponse, deleteRangeResponse.getHeader()); 35 | this.namespace = namespace; 36 | } 37 | 38 | /** 39 | * Returns the number of keys deleted by the delete range request. 40 | * 41 | * @return number of deleted items. 42 | */ 43 | public long getDeleted() { 44 | return getResponse().getDeleted(); 45 | } 46 | 47 | /** 48 | * Returns previous key-value pairs. 49 | * 50 | * @return previous kv, 51 | */ 52 | public synchronized List getPrevKvs() { 53 | if (prevKvs == null) { 54 | prevKvs = getResponse().getPrevKvsList().stream().map(kv -> new KeyValue(kv, namespace)) 55 | .collect(Collectors.toList()); 56 | } 57 | 58 | return prevKvs; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/kv/GetResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.kv; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import io.etcd.jetcd.ByteSequence; 23 | import io.etcd.jetcd.KeyValue; 24 | import io.etcd.jetcd.api.RangeResponse; 25 | import io.etcd.jetcd.impl.AbstractResponse; 26 | 27 | public class GetResponse extends AbstractResponse { 28 | 29 | private final ByteSequence namespace; 30 | 31 | private List kvs; 32 | 33 | public GetResponse(RangeResponse rangeResponse, ByteSequence namespace) { 34 | super(rangeResponse, rangeResponse.getHeader()); 35 | this.namespace = namespace; 36 | } 37 | 38 | /** 39 | * Returns a list of key-value pairs matched by the range request. 40 | * 41 | * @return kvs. 42 | */ 43 | public synchronized List getKvs() { 44 | if (kvs == null) { 45 | kvs = getResponse().getKvsList().stream().map(kv -> new KeyValue(kv, namespace)).collect(Collectors.toList()); 46 | } 47 | 48 | return kvs; 49 | } 50 | 51 | /** 52 | * Returns if there are more keys to return in the requested range. 53 | * 54 | * @return more. 55 | */ 56 | public boolean isMore() { 57 | return getResponse().getMore(); 58 | } 59 | 60 | /** 61 | * Returns the number of keys within the range requested. 62 | * Note this value is never affected by filtering options (limit, min or max created or modified revisions) 63 | * Count is the count for keys on the range part of a request. 64 | * Filters for limit and created or modified revision ranges restrict the 65 | * returned KVs, but not the count. 66 | * 67 | * @return count. 68 | */ 69 | public long getCount() { 70 | return getResponse().getCount(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/kv/PutResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.kv; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | import io.etcd.jetcd.KeyValue; 21 | import io.etcd.jetcd.impl.AbstractResponse; 22 | 23 | public class PutResponse extends AbstractResponse { 24 | 25 | private final ByteSequence namespace; 26 | 27 | public PutResponse(io.etcd.jetcd.api.PutResponse putResponse, ByteSequence namespace) { 28 | super(putResponse, putResponse.getHeader()); 29 | this.namespace = namespace; 30 | } 31 | 32 | /** 33 | * Returns previous key-value pair. 34 | * 35 | * @return prev kv. 36 | */ 37 | public KeyValue getPrevKv() { 38 | return new KeyValue(getResponse().getPrevKv(), namespace); 39 | } 40 | 41 | /** 42 | * Returns whether a previous key-value pair is present. 43 | * 44 | * @return if has prev kv. 45 | */ 46 | public boolean hasPrevKv() { 47 | return getResponse().hasPrevKv(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/LeaseGrantResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class LeaseGrantResponse extends AbstractResponse { 22 | 23 | public LeaseGrantResponse(io.etcd.jetcd.api.LeaseGrantResponse response) { 24 | super(response, response.getHeader()); 25 | } 26 | 27 | /** 28 | * Returns the lease ID for the granted lease. 29 | * 30 | * @return the id. 31 | */ 32 | public long getID() { 33 | return getResponse().getID(); 34 | } 35 | 36 | /** 37 | * Returns the server chosen lease time-to-live in seconds. 38 | * 39 | * @return the ttl. 40 | */ 41 | public long getTTL() { 42 | return getResponse().getTTL(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/LeaseKeepAliveResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class LeaseKeepAliveResponse extends AbstractResponse { 22 | 23 | public LeaseKeepAliveResponse(io.etcd.jetcd.api.LeaseKeepAliveResponse response) { 24 | super(response, response.getHeader()); 25 | } 26 | 27 | /** 28 | * Returns the lease ID from the keep alive request. 29 | * 30 | * @return the id. 31 | */ 32 | public long getID() { 33 | return getResponse().getID(); 34 | } 35 | 36 | /** 37 | * Returns the new time-to-live for the lease. 38 | * 39 | * @return the ttl. 40 | */ 41 | public long getTTL() { 42 | return getResponse().getTTL(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/LeaseKeepAliveResponseWithError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | import io.etcd.jetcd.common.exception.EtcdException; 20 | 21 | public class LeaseKeepAliveResponseWithError { 22 | 23 | public LeaseKeepAliveResponse leaseKeepAliveResponse; 24 | public EtcdException error; 25 | 26 | public LeaseKeepAliveResponseWithError(LeaseKeepAliveResponse leaseKeepAliveResponse) { 27 | this.leaseKeepAliveResponse = leaseKeepAliveResponse; 28 | } 29 | 30 | public LeaseKeepAliveResponseWithError(EtcdException e) { 31 | this.error = e; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/LeaseRevokeResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class LeaseRevokeResponse extends AbstractResponse { 22 | 23 | public LeaseRevokeResponse(io.etcd.jetcd.api.LeaseRevokeResponse revokeResponse) { 24 | super(revokeResponse, revokeResponse.getHeader()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/LeaseTimeToLiveResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import io.etcd.jetcd.ByteSequence; 23 | import io.etcd.jetcd.impl.AbstractResponse; 24 | 25 | public class LeaseTimeToLiveResponse extends AbstractResponse { 26 | 27 | private List keys; 28 | 29 | public LeaseTimeToLiveResponse(io.etcd.jetcd.api.LeaseTimeToLiveResponse response) { 30 | super(response, response.getHeader()); 31 | } 32 | 33 | /** 34 | * Returns the lease ID from the keep alive request. 35 | * 36 | * @return the lease id. 37 | */ 38 | public long getID() { 39 | return getResponse().getID(); 40 | } 41 | 42 | /** 43 | * Returns the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds. 44 | * 45 | * @return the ttl. 46 | */ 47 | public long getTTL() { 48 | return getResponse().getTTL(); 49 | } 50 | 51 | /** 52 | * Returns the initial granted time in seconds upon lease creation/renewal. 53 | * 54 | * @return the granted ttl. 55 | */ 56 | public long getGrantedTTL() { 57 | return getResponse().getGrantedTTL(); 58 | } 59 | 60 | /** 61 | * Returns the list of keys attached to this lease. 62 | * 63 | * @return the keys. 64 | */ 65 | public synchronized List getKeys() { 66 | if (keys == null) { 67 | keys = getResponse().getKeysList().stream().map(ByteSequence::from).collect(Collectors.toList()); 68 | } 69 | 70 | return keys; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lease/NoSuchLeaseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lease; 18 | 19 | /** 20 | * Signals that the lease client do not have this lease. 21 | */ 22 | public class NoSuchLeaseException extends Exception { 23 | 24 | public NoSuchLeaseException(long leaseId) { 25 | super("No such lease: " + leaseId); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lock/LockResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lock; 18 | 19 | import io.etcd.jetcd.ByteSequence; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | import io.etcd.jetcd.support.Util; 22 | 23 | public class LockResponse extends AbstractResponse { 24 | 25 | private final ByteSequence unprefixedKey; 26 | 27 | public LockResponse(io.etcd.jetcd.api.lock.LockResponse response, ByteSequence namespace) { 28 | super(response, response.getHeader()); 29 | this.unprefixedKey = ByteSequence.from(Util.unprefixNamespace(getResponse().getKey(), namespace)); 30 | } 31 | 32 | /** 33 | * Returns the key that will exist on etcd for the duration that the Lock caller 34 | * owns the lock. Users should not modify this key or the lock may exhibit 35 | * undefined behavior. 36 | * 37 | * @return the key. 38 | */ 39 | public ByteSequence getKey() { 40 | return unprefixedKey; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/lock/UnlockResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.lock; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | public class UnlockResponse extends AbstractResponse { 22 | 23 | public UnlockResponse(io.etcd.jetcd.api.lock.UnlockResponse response) { 24 | super(response, response.getHeader()); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/AlarmMember.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | public class AlarmMember { 20 | 21 | private long memberId; 22 | private AlarmType alarmType; 23 | 24 | public AlarmMember(long memberId, AlarmType alarmType) { 25 | this.memberId = memberId; 26 | this.alarmType = alarmType; 27 | } 28 | 29 | /** 30 | * Returns the ID of the member associated with the raised alarm. 31 | * 32 | * @return the member id. 33 | */ 34 | public long getMemberId() { 35 | return memberId; 36 | } 37 | 38 | /** 39 | * 40 | * Returns the type of alarm which has been raised. 41 | * 42 | * @return the alarm type. 43 | */ 44 | public AlarmType getAlarmType() { 45 | return alarmType; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/AlarmResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import java.util.List; 20 | import java.util.stream.Collectors; 21 | 22 | import io.etcd.jetcd.Maintenance; 23 | import io.etcd.jetcd.impl.AbstractResponse; 24 | 25 | /** 26 | * AlarmResponse returned by {@link Maintenance#listAlarms()} contains a header 27 | * and a list of AlarmMember. 28 | */ 29 | public class AlarmResponse extends AbstractResponse { 30 | 31 | private List alarms; 32 | 33 | public AlarmResponse(io.etcd.jetcd.api.AlarmResponse response) { 34 | super(response, response.getHeader()); 35 | } 36 | 37 | private static AlarmMember toAlarmMember(io.etcd.jetcd.api.AlarmMember alarmMember) { 38 | AlarmType type; 39 | switch (alarmMember.getAlarm()) { 40 | case NONE: 41 | type = AlarmType.NONE; 42 | break; 43 | case NOSPACE: 44 | type = AlarmType.NOSPACE; 45 | break; 46 | default: 47 | type = AlarmType.UNRECOGNIZED; 48 | } 49 | return new AlarmMember(alarmMember.getMemberID(), type); 50 | } 51 | 52 | /** 53 | * Returns a list of alarms associated with the alarm request. 54 | * 55 | * @return the alarms. 56 | */ 57 | public synchronized List getAlarms() { 58 | if (alarms == null) { 59 | alarms = getResponse().getAlarmsList().stream().map(AlarmResponse::toAlarmMember).collect(Collectors.toList()); 60 | } 61 | 62 | return alarms; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/AlarmType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | /** 20 | * represents type of alarm which can be raised. 21 | */ 22 | public enum AlarmType { 23 | NONE, // default, used to query if any alarm is active 24 | NOSPACE, // space quota is exhausted 25 | UNRECOGNIZED, 26 | } 27 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/DefragmentResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import io.etcd.jetcd.Maintenance; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * DefragmentResponse returned by {@link Maintenance#defragmentMember(String)} contains a header. 24 | */ 25 | public class DefragmentResponse extends AbstractResponse { 26 | 27 | public DefragmentResponse(io.etcd.jetcd.api.DefragmentResponse response) { 28 | super(response, response.getHeader()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/HashKVResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import io.etcd.jetcd.Maintenance; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * HashKVResponse returned by {@link Maintenance#hashKV(String, long)}. 24 | */ 25 | public class HashKVResponse extends AbstractResponse { 26 | 27 | public HashKVResponse(io.etcd.jetcd.api.HashKVResponse response) { 28 | super(response, response.getHeader()); 29 | } 30 | 31 | /** 32 | * Returns the hash value computed from the responding member's MVCC keys up to a given revision. 33 | * 34 | * @return the response hash. 35 | */ 36 | public int getHash() { 37 | return getResponse().getHash(); 38 | } 39 | 40 | /** 41 | * Returns the compacted revision of key-value store when hash begins. 42 | * 43 | * @return if compacted. 44 | */ 45 | public long getCompacted() { 46 | return getResponse().getCompactRevision(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/MoveLeaderResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import io.etcd.jetcd.Maintenance; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * MoveLeaderResponse returned by {@link Maintenance#moveLeader(long)}. 24 | */ 25 | public class MoveLeaderResponse extends AbstractResponse { 26 | 27 | public MoveLeaderResponse(io.etcd.jetcd.api.MoveLeaderResponse response) { 28 | super(response, response.getHeader()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/SnapshotReaderResponseWithError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | public class SnapshotReaderResponseWithError { 20 | 21 | public SnapshotResponse snapshotResponse; 22 | public Exception error; 23 | 24 | public SnapshotReaderResponseWithError(SnapshotResponse snapshotResponse) { 25 | this.snapshotResponse = snapshotResponse; 26 | } 27 | 28 | public SnapshotReaderResponseWithError(Exception e) { 29 | this.error = e; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/SnapshotResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import io.etcd.jetcd.impl.AbstractResponse; 20 | 21 | import com.google.protobuf.ByteString; 22 | 23 | public class SnapshotResponse extends AbstractResponse { 24 | 25 | public SnapshotResponse(io.etcd.jetcd.api.SnapshotResponse response) { 26 | super(response, response.getHeader()); 27 | } 28 | 29 | /** 30 | * Returns the remaining bytes. 31 | * 32 | * @return the remaining bytes. 33 | */ 34 | public long getRemainingBytes() { 35 | return getResponse().getRemainingBytes(); 36 | } 37 | 38 | /** 39 | * Returns the blob. 40 | * 41 | * @return the blob. 42 | */ 43 | public ByteString getBlob() { 44 | return getResponse().getBlob(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/maintenance/StatusResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.maintenance; 18 | 19 | import io.etcd.jetcd.Maintenance; 20 | import io.etcd.jetcd.impl.AbstractResponse; 21 | 22 | /** 23 | * StatusResponse returned by {@link Maintenance#statusMember(String)} contains 24 | * a header, version, dbSize, current leader, raftIndex, and raftTerm. 25 | */ 26 | public class StatusResponse extends AbstractResponse { 27 | 28 | public StatusResponse(io.etcd.jetcd.api.StatusResponse response) { 29 | super(response, response.getHeader()); 30 | } 31 | 32 | /** 33 | * Returns the cluster protocol version used by the responding member. 34 | * 35 | * @return the version. 36 | */ 37 | public String getVersion() { 38 | return getResponse().getVersion(); 39 | } 40 | 41 | /** 42 | * Returns the size of the backend database, in bytes, of the responding member. 43 | * 44 | * @return the db sie. 45 | */ 46 | public long getDbSize() { 47 | return getResponse().getDbSize(); 48 | } 49 | 50 | /** 51 | * Returns the member ID which the responding member believes is the current leader. 52 | * 53 | * @return the leader. 54 | */ 55 | public long getLeader() { 56 | return getResponse().getLeader(); 57 | } 58 | 59 | /** 60 | * Returns the current raft index of the responding member. 61 | * 62 | * @return the raft index. 63 | */ 64 | public long getRaftIndex() { 65 | return getResponse().getRaftIndex(); 66 | } 67 | 68 | /** 69 | * Returns the current raft term of the responding member. 70 | * 71 | * @return the raft term. 72 | */ 73 | public long getRaftTerm() { 74 | return getResponse().getRaftTerm(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/options/CompactOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.options; 18 | 19 | public final class CompactOption { 20 | public static final CompactOption DEFAULT = builder().build(); 21 | 22 | private final boolean physical; 23 | 24 | private CompactOption(boolean physical) { 25 | this.physical = physical; 26 | } 27 | 28 | public boolean isPhysical() { 29 | return physical; 30 | } 31 | 32 | /** 33 | * Returns the builder. 34 | * 35 | * @deprecated use {@link #builder()} 36 | * @return the builder 37 | */ 38 | @SuppressWarnings("InlineMeSuggester") 39 | @Deprecated 40 | public static Builder newBuilder() { 41 | return builder(); 42 | } 43 | 44 | public static Builder builder() { 45 | return new Builder(); 46 | } 47 | 48 | public static final class Builder { 49 | private boolean physical = false; 50 | 51 | private Builder() { 52 | } 53 | 54 | /** 55 | * make compact RPC call wait until 56 | * the compaction is physically applied to the local database 57 | * such that compacted entries are totally removed from the 58 | * backend database. 59 | * 60 | * @param physical whether the compact should wait until physically applied 61 | * @return builder 62 | */ 63 | public Builder withCompactPhysical(boolean physical) { 64 | this.physical = physical; 65 | return this; 66 | } 67 | 68 | public CompactOption build() { 69 | return new CompactOption(this.physical); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/options/LeaseOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.options; 18 | 19 | public class LeaseOption { 20 | public static final LeaseOption DEFAULT = builder().build(); 21 | 22 | private final boolean attachedKeys; 23 | 24 | private LeaseOption(boolean attachedKeys) { 25 | this.attachedKeys = attachedKeys; 26 | } 27 | 28 | public boolean isAttachedKeys() { 29 | return attachedKeys; 30 | } 31 | 32 | /** 33 | * Returns the builder. 34 | * 35 | * @deprecated use {@link #builder()} 36 | * @return the builder 37 | */ 38 | @SuppressWarnings("InlineMeSuggester") 39 | @Deprecated 40 | public static Builder newBuilder() { 41 | return builder(); 42 | } 43 | 44 | public static Builder builder() { 45 | return new Builder(); 46 | } 47 | 48 | public static final class Builder { 49 | 50 | private boolean attachedKeys; 51 | 52 | private Builder() { 53 | } 54 | 55 | /** 56 | * requests lease timeToLive API to return attached keys of given lease ID. 57 | * 58 | * @return builder. 59 | */ 60 | public Builder withAttachedKeys() { 61 | this.attachedKeys = true; 62 | return this; 63 | } 64 | 65 | public LeaseOption build() { 66 | return new LeaseOption(this.attachedKeys); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/options/TxnOption.java: -------------------------------------------------------------------------------- 1 | package io.etcd.jetcd.options; 2 | 3 | public final class TxnOption { 4 | public static final TxnOption DEFAULT = builder().build(); 5 | 6 | private final boolean autoRetry; 7 | 8 | private TxnOption(final boolean autoRetry) { 9 | this.autoRetry = autoRetry; 10 | } 11 | 12 | /** 13 | * Whether to treat a txn operation as idempotent from the point of view of automated retries. 14 | * 15 | * @return true if automated retries should happen. 16 | */ 17 | public boolean isAutoRetry() { 18 | return autoRetry; 19 | } 20 | 21 | /** 22 | * Returns the builder. 23 | * 24 | * @return the builder 25 | */ 26 | public static TxnOption.Builder builder() { 27 | return new TxnOption.Builder(); 28 | } 29 | 30 | public static final class Builder { 31 | private boolean autoRetry = false; 32 | 33 | private Builder() { 34 | } 35 | 36 | /** 37 | * When autoRetry is set, the txn operation is treated as idempotent from the point of view of automated retries. 38 | * Note under some failure scenarios true may make a txn operation be attempted and/or execute more than once, where 39 | * a first attempt executed but its result status did not reach the client; by default (autoRetry=false), 40 | * the client won't retry since it is not safe to assume on such a failure the operation did not happen. 41 | * Requesting withAutoRetry means the client is explicitly asking for retry nevertheless. 42 | * 43 | * @return builder 44 | */ 45 | public Builder withAutoRetry() { 46 | this.autoRetry = true; 47 | return this; 48 | } 49 | 50 | public TxnOption build() { 51 | return new TxnOption(autoRetry); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/AbstractResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.URI; 20 | import java.util.Objects; 21 | 22 | import io.grpc.NameResolver; 23 | import io.grpc.NameResolverProvider; 24 | 25 | public abstract class AbstractResolverProvider extends NameResolverProvider { 26 | private final String scheme; 27 | private final int priority; 28 | 29 | public AbstractResolverProvider(String scheme, int priority) { 30 | this.scheme = scheme; 31 | this.priority = priority; 32 | } 33 | 34 | @Override 35 | protected boolean isAvailable() { 36 | return true; 37 | } 38 | 39 | @Override 40 | protected int priority() { 41 | return priority; 42 | } 43 | 44 | @Override 45 | public String getDefaultScheme() { 46 | return scheme; 47 | } 48 | 49 | @Override 50 | public NameResolver newNameResolver(URI targetUri, NameResolver.Args args) { 51 | return Objects.equals(scheme, targetUri.getScheme()) 52 | ? createResolver(targetUri, args) 53 | : null; 54 | } 55 | 56 | protected abstract NameResolver createResolver(URI targetUri, NameResolver.Args args); 57 | } 58 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/DnsSrvResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.URI; 20 | 21 | import io.grpc.NameResolver; 22 | import io.grpc.NameResolverProvider; 23 | 24 | import com.google.auto.service.AutoService; 25 | 26 | @AutoService(NameResolverProvider.class) 27 | public class DnsSrvResolverProvider extends AbstractResolverProvider { 28 | public DnsSrvResolverProvider() { 29 | super(DnsSrvNameResolver.SCHEME, 5); 30 | } 31 | 32 | @Override 33 | protected NameResolver createResolver(URI targetUri, NameResolver.Args args) { 34 | return new DnsSrvNameResolver(targetUri); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/HttpNameResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.InetSocketAddress; 20 | import java.net.URI; 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import io.etcd.jetcd.common.exception.ErrorCode; 25 | import io.etcd.jetcd.common.exception.EtcdExceptionFactory; 26 | import io.grpc.Attributes; 27 | import io.grpc.EquivalentAddressGroup; 28 | 29 | import com.google.common.base.Strings; 30 | 31 | public class HttpNameResolver extends AbstractNameResolver { 32 | public static final String SCHEME = "http"; 33 | 34 | private final URI address; 35 | 36 | public HttpNameResolver(URI targetUri) { 37 | super(targetUri); 38 | 39 | this.address = targetUri; 40 | } 41 | 42 | @Override 43 | protected List computeAddressGroups() { 44 | if (address == null) { 45 | throw EtcdExceptionFactory.newEtcdException( 46 | ErrorCode.INVALID_ARGUMENT, 47 | "Unable to resolve endpoint " + getTargetUri()); 48 | } 49 | 50 | return Collections.singletonList( 51 | new EquivalentAddressGroup( 52 | new InetSocketAddress( 53 | address.getHost(), 54 | address.getPort() != -1 ? address.getPort() : ETCD_CLIENT_PORT), 55 | Strings.isNullOrEmpty(getServiceAuthority()) 56 | ? Attributes.newBuilder() 57 | .set(EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE, address.toString()) 58 | .build() 59 | : Attributes.EMPTY)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/HttpResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.URI; 20 | 21 | import io.grpc.NameResolver; 22 | import io.grpc.NameResolverProvider; 23 | 24 | import com.google.auto.service.AutoService; 25 | 26 | @AutoService(NameResolverProvider.class) 27 | public class HttpResolverProvider extends AbstractResolverProvider { 28 | public HttpResolverProvider() { 29 | super(HttpNameResolver.SCHEME, 5); 30 | } 31 | 32 | @Override 33 | protected NameResolver createResolver(URI targetUri, NameResolver.Args args) { 34 | return new HttpNameResolver(targetUri); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/HttpsNameResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.InetSocketAddress; 20 | import java.net.URI; 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import io.etcd.jetcd.common.exception.ErrorCode; 25 | import io.etcd.jetcd.common.exception.EtcdExceptionFactory; 26 | import io.grpc.Attributes; 27 | import io.grpc.EquivalentAddressGroup; 28 | 29 | import com.google.common.base.Strings; 30 | 31 | public class HttpsNameResolver extends AbstractNameResolver { 32 | public static final String SCHEME = "https"; 33 | 34 | private final URI address; 35 | 36 | public HttpsNameResolver(URI targetUri) { 37 | super(targetUri); 38 | 39 | this.address = targetUri; 40 | } 41 | 42 | @Override 43 | protected List computeAddressGroups() { 44 | if (address == null) { 45 | throw EtcdExceptionFactory.newEtcdException( 46 | ErrorCode.INVALID_ARGUMENT, 47 | "Unable to resolve endpoint " + getTargetUri()); 48 | } 49 | 50 | return Collections.singletonList( 51 | new EquivalentAddressGroup( 52 | new InetSocketAddress( 53 | address.getHost(), 54 | address.getPort() != -1 ? address.getPort() : ETCD_CLIENT_PORT), 55 | Strings.isNullOrEmpty(getServiceAuthority()) 56 | ? Attributes.newBuilder() 57 | .set(EquivalentAddressGroup.ATTR_AUTHORITY_OVERRIDE, address.toString()) 58 | .build() 59 | : Attributes.EMPTY)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/HttpsResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.URI; 20 | 21 | import io.grpc.NameResolver; 22 | import io.grpc.NameResolverProvider; 23 | 24 | import com.google.auto.service.AutoService; 25 | 26 | @AutoService(NameResolverProvider.class) 27 | public class HttpsResolverProvider extends AbstractResolverProvider { 28 | public HttpsResolverProvider() { 29 | super(HttpsNameResolver.SCHEME, 5); 30 | } 31 | 32 | @Override 33 | protected NameResolver createResolver(URI targetUri, NameResolver.Args args) { 34 | return new HttpsNameResolver(targetUri); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/resolver/IPResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.resolver; 18 | 19 | import java.net.URI; 20 | 21 | import io.grpc.NameResolver; 22 | import io.grpc.NameResolverProvider; 23 | 24 | import com.google.auto.service.AutoService; 25 | 26 | @AutoService(NameResolverProvider.class) 27 | public class IPResolverProvider extends AbstractResolverProvider { 28 | public IPResolverProvider() { 29 | super(IPNameResolver.SCHEME, 5); 30 | } 31 | 32 | @Override 33 | protected NameResolver createResolver(URI targetUri, NameResolver.Args args) { 34 | return new IPNameResolver(targetUri); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/support/CloseableClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.support; 18 | 19 | public interface CloseableClient extends AutoCloseable { 20 | 21 | /** 22 | * close the client and release its resources. 23 | */ 24 | @Override 25 | default void close() { 26 | // noop 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/support/MemorizingClientSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.support; 18 | 19 | import java.util.Objects; 20 | import java.util.function.Supplier; 21 | 22 | public class MemorizingClientSupplier implements Supplier, CloseableClient { 23 | final Supplier delegate; 24 | volatile boolean initialized; 25 | T value; 26 | 27 | public MemorizingClientSupplier(Supplier delegate) { 28 | this.delegate = Objects.requireNonNull(delegate); 29 | } 30 | 31 | @Override 32 | public T get() { 33 | // A 2-field variant of Double Checked Locking. 34 | if (!initialized) { 35 | synchronized (this) { 36 | if (!initialized) { 37 | T t = delegate.get(); 38 | value = t; 39 | initialized = true; 40 | return t; 41 | } 42 | } 43 | } 44 | return value; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Suppliers.memoize(" 50 | + (initialized ? "" : delegate) 51 | + ")"; 52 | } 53 | 54 | @Override 55 | public void close() { 56 | if (initialized) { 57 | synchronized (this) { 58 | if (initialized) { 59 | if (value != null) { 60 | value.close(); 61 | value = null; 62 | } 63 | initialized = false; 64 | } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/watch/WatchEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.watch; 18 | 19 | import io.etcd.jetcd.KeyValue; 20 | 21 | /** 22 | * Watch event, return by watch, contain put, delete event. 23 | */ 24 | public class WatchEvent { 25 | 26 | private final KeyValue keyValue; 27 | private final KeyValue prevKV; 28 | private final EventType eventType; 29 | 30 | public WatchEvent(KeyValue keyValue, KeyValue prevKV, EventType eventType) { 31 | this.keyValue = keyValue; 32 | this.prevKV = prevKV; 33 | this.eventType = eventType; 34 | } 35 | 36 | public KeyValue getKeyValue() { 37 | return keyValue; 38 | } 39 | 40 | public KeyValue getPrevKV() { 41 | return prevKV; 42 | } 43 | 44 | public EventType getEventType() { 45 | return eventType; 46 | } 47 | 48 | public enum EventType { 49 | PUT, DELETE, UNRECOGNIZED, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jetcd-core/src/main/java/io/etcd/jetcd/watch/WatchResponseWithError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.watch; 18 | 19 | import io.etcd.jetcd.common.exception.EtcdException; 20 | 21 | public class WatchResponseWithError { 22 | 23 | private WatchResponse watchResponse; 24 | private EtcdException exception; 25 | 26 | private WatchResponseWithError() { 27 | 28 | } 29 | 30 | public WatchResponseWithError(WatchResponse watchResponse) { 31 | this.watchResponse = watchResponse; 32 | } 33 | 34 | public WatchResponseWithError(EtcdException e) { 35 | this.exception = e; 36 | } 37 | 38 | public WatchResponse getWatchResponse() { 39 | return watchResponse; 40 | } 41 | 42 | public EtcdException getException() { 43 | return exception; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jetcd-core/src/main/proto/auth.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2021 The jetcd authors 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package authpb; 20 | 21 | option java_multiple_files = true; 22 | option java_package = "io.etcd.jetcd.api"; 23 | 24 | // User is a single entry in the bucket authUsers 25 | message User { 26 | bytes name = 1; 27 | bytes password = 2; 28 | repeated string roles = 3; 29 | } 30 | 31 | // Permission is a single entity 32 | message Permission { 33 | enum Type { 34 | READ = 0; 35 | WRITE = 1; 36 | READWRITE = 2; 37 | } 38 | Type permType = 1; 39 | 40 | bytes key = 2; 41 | bytes range_end = 3; 42 | } 43 | 44 | // Role is a single entry in the bucket authRoles 45 | message Role { 46 | bytes name = 1; 47 | 48 | repeated Permission keyPermission = 2; 49 | } 50 | -------------------------------------------------------------------------------- /jetcd-core/src/main/proto/kv.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2021 The jetcd authors 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package mvccpb; 20 | 21 | option java_multiple_files = true; 22 | option java_package = "io.etcd.jetcd.api"; 23 | 24 | message KeyValue { 25 | // key is the key in bytes. An empty key is not allowed. 26 | bytes key = 1; 27 | // create_revision is the revision of last creation on this key. 28 | int64 create_revision = 2; 29 | // mod_revision is the revision of last modification on this key. 30 | int64 mod_revision = 3; 31 | // version is the version of the key. A deletion resets 32 | // the version to zero and any modification of the key 33 | // increases its version. 34 | int64 version = 4; 35 | // value is the value held by the key, in bytes. 36 | bytes value = 5; 37 | // lease is the ID of the lease that attached to key. 38 | // When the attached lease expires, the key will be deleted. 39 | // If lease is 0, then no lease is attached to the key. 40 | int64 lease = 6; 41 | } 42 | 43 | message Event { 44 | enum EventType { 45 | PUT = 0; 46 | DELETE = 1; 47 | } 48 | // type is the kind of event. If type is a PUT, it indicates 49 | // new data has been stored to the key. If type is a DELETE, 50 | // it indicates the key was deleted. 51 | EventType type = 1; 52 | // kv holds the KeyValue for the event. 53 | // A PUT event contains current kv pair. 54 | // A PUT event with kv.Version=1 indicates the creation of a key. 55 | // A DELETE/EXPIRE event contains the deleted key with 56 | // its modification revision set to the revision of deletion. 57 | KeyValue kv = 2; 58 | 59 | // prev_kv holds the key-value pair before the event happens. 60 | KeyValue prev_kv = 3; 61 | } 62 | -------------------------------------------------------------------------------- /jetcd-core/src/test/java/io/etcd/jetcd/impl/ClusterClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.impl; 18 | 19 | import java.util.concurrent.ExecutionException; 20 | import java.util.concurrent.TimeUnit; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.Timeout; 24 | import org.junit.jupiter.api.extension.RegisterExtension; 25 | 26 | import io.etcd.jetcd.Client; 27 | import io.etcd.jetcd.test.EtcdClusterExtension; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | @Timeout(value = 30, unit = TimeUnit.SECONDS) 32 | public class ClusterClientTest { 33 | @RegisterExtension 34 | public static final EtcdClusterExtension cluster = EtcdClusterExtension.builder() 35 | .withNodes(3) 36 | .withPrefix("cluster") 37 | .build(); 38 | 39 | @Test 40 | public void testMemberList() throws ExecutionException, InterruptedException { 41 | try (Client client = TestUtil.client(cluster).build()) { 42 | assertThat(client.getClusterClient().listMember().get().getMembers()).hasSize(3); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jetcd-core/src/test/java/io/etcd/jetcd/impl/RetryTest.java: -------------------------------------------------------------------------------- 1 | package io.etcd.jetcd.impl; 2 | 3 | import java.time.Duration; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.TimeUnit; 6 | import java.util.concurrent.atomic.AtomicReference; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.Timeout; 10 | 11 | import io.etcd.jetcd.Client; 12 | import io.etcd.jetcd.ClientBuilder; 13 | import io.grpc.StatusRuntimeException; 14 | 15 | import static io.etcd.jetcd.impl.TestUtil.bytesOf; 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | import static org.awaitility.Awaitility.await; 18 | 19 | @Timeout(value = 30, unit = TimeUnit.SECONDS) 20 | public class RetryTest { 21 | @Test 22 | public void testReconnect() throws Exception { 23 | ClientBuilder builder = Client.builder() 24 | .endpoints("http://127.0.0.1:9999") 25 | .connectTimeout(Duration.ofMillis(250)) 26 | .waitForReady(false) 27 | .retryMaxAttempts(5) 28 | .retryDelay(250); 29 | 30 | AtomicReference error = new AtomicReference<>(); 31 | 32 | try (Client client = builder.build()) { 33 | CompletableFuture unused = client.getKVClient().put(bytesOf("sample_key"), bytesOf("sample_value")).whenComplete( 34 | (r, t) -> { 35 | if (t != null) { 36 | error.set(t); 37 | } 38 | }); 39 | 40 | await().untilAsserted(() -> { 41 | assertThat(error.get()).isNotNull(); 42 | assertThat(error.get()).hasCauseInstanceOf(StatusRuntimeException.class); 43 | assertThat(error.get().getCause()).hasMessage("UNAVAILABLE: io exception"); 44 | }); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jetcd-core/src/test/java/io/etcd/jetcd/impl/UtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.impl; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.Timeout; 23 | 24 | import io.etcd.jetcd.support.Errors; 25 | import io.grpc.Status; 26 | import io.grpc.StatusException; 27 | 28 | import static org.assertj.core.api.Assertions.assertThat; 29 | 30 | @Timeout(value = 30, unit = TimeUnit.SECONDS) 31 | class UtilTest { 32 | 33 | @Test 34 | public void testAuthStoreExpired() { 35 | Status authExpiredStatus = Status.INVALID_ARGUMENT 36 | .withDescription(Errors.ERROR_AUTH_STORE_OLD); 37 | Status status = Status.fromThrowable(new StatusException(authExpiredStatus)); 38 | assertThat(Errors.isAuthStoreExpired(status)).isTrue(); 39 | } 40 | 41 | @Test 42 | public void testAuthErrorIsRetryable() { 43 | Status authErrorStatus = Status.UNAUTHENTICATED 44 | .withDescription("etcdserver: invalid auth token"); 45 | Status status = Status.fromThrowable(new StatusException(authErrorStatus)); 46 | assertThat(Errors.isRetryableForNoSafeRedoOp(status)).isTrue(); 47 | assertThat(Errors.isRetryableForSafeRedoOp(status)).isTrue(); 48 | } 49 | 50 | @Test 51 | public void testUnavailableErrorIsRetryable() { 52 | Status status = Status.fromThrowable(new StatusException(Status.UNAVAILABLE)); 53 | assertThat(Errors.isRetryableForNoSafeRedoOp(status)).isFalse(); 54 | assertThat(Errors.isRetryableForSafeRedoOp(status)).isTrue(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jetcd-core/src/test/java/io/etcd/jetcd/options/OptionsUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.options; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import io.etcd.jetcd.ByteSequence; 22 | 23 | import static org.assertj.core.api.Assertions.assertThat; 24 | 25 | public class OptionsUtilTest { 26 | 27 | static void check(byte[] prefix, byte[] expectedPrefixEndOf) { 28 | ByteSequence actual = OptionsUtil.prefixEndOf(ByteSequence.from(prefix)); 29 | assertThat(actual).isEqualTo(ByteSequence.from(expectedPrefixEndOf)); 30 | } 31 | 32 | @Test 33 | void aaPlus1() { 34 | check(new byte[] { (byte) 'a', (byte) 'a' }, new byte[] { (byte) 'a', (byte) 'b' }); 35 | } 36 | 37 | @Test 38 | void axffPlus1() { 39 | check(new byte[] { (byte) 'a', (byte) 0xff }, new byte[] { (byte) 'b' }); 40 | } 41 | 42 | @Test 43 | void xffPlus1() { 44 | check(new byte[] { (byte) 0xff }, new byte[] { (byte) 0x00 }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/log4j2-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/.gitignore: -------------------------------------------------------------------------------- 1 | cfssl/ 2 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/ca-config.json: -------------------------------------------------------------------------------- 1 | {"signing":{"default":{"expiry":"43800h","usages":["signing","key encipherment","server auth","client auth"]}}} 2 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/ca-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAtNqcp33TX+bufma9g7G3OT7jkirXscX/yP+IEnff4yc2EhjI 3 | Z0GHkp4wTpcYEuEMNLv5mJtwQ5Nq7sAokWrKjrCCCNX+dHUBL8MLFRYL6Tn0kKZ1 4 | 5ApVHsuD31J27q6I4nqAPBo0uKoVkaYrTwq3VtbuMf3OIy5Dgm6YsG2zHl5QN/x4 5 | forPi0GqphhIQwIr8p99WNCblzTFwiUYvn+CHBS03DF4ozAjda1ozWAlbsIpxTNE 6 | W9Gh901U5zQSJOMz8Mqtpn8MBcnNr8QtgTbQB90zyv4Q65Md7gj0wbxFQl22ZjA5 7 | AdRpn2MwYHyF/6B30Izt2ia/uCfZ9h7tMEFGhQIDAQABAoIBAFzPU1Ug3Th56ioz 8 | z02mBcD65Q49rjMsyPb9K3dOzTZlCPqAfVd/6XL0exXZtCD8HKdzT8NhAVusa1Pa 9 | iPcXNpvDOPgP2WUqJlG8ZhOMHNCzTS5uPlGoe8Yx6prQVvhl2RlghC5TxHp/zlHQ 10 | VKlbdnq6EcLV3NNxCnQFDZZ8tU7/epJE71ub5zKyxhe9u43DvhTVrKH9jKlIRXqm 11 | tgGH73UOwr0mvwMZHzVuGNKLlAevO+1yjHWSoUQuBdJHnLfQSKYmf1tYhr1Xhe61 12 | nAoj7NrqZjyCCaQR3gkIVxGhfRNS83T9SvX7Z4WSO7+2HCL7LT4xDB5ksnwtzZ58 13 | WLQ6QIECgYEA1gzvZXydxXb4LdP6k7MdPKq2l9YdF+n240BRJ4feNoxQADIe4tiR 14 | p3C9EP6k/WIkohgzKeYVFwzxHyB3YerQxrvRL9svbXjo+IuGJ8WRuA9YGKe1pTtm 15 | 2VmGma86gAsMkQFLr60VIyKbNCvAqK8gR+RPbckNSv+12o5m8DFlaSsCgYEA2Ewu 16 | bpaqhXZASViKrmKYHhqykUvRm0ByYptPjYcGvNkZSiFaeD5g135h/Det9AVIfnHx 17 | x1aQxLaa+hj2ygzpQiqhB+N8qlGzvu22/6U8bIBCW2PEmTDQ6QilrHkcFitCetRS 18 | 4KDwQOCyDZtjO+AItfDhl9HihcOlzhvj5jd31w8CgYEAgASkeTIauir5K4+IYiXR 19 | 6qK/Kfho1hCcFDY3U0kzYbRxdGyFhG66TkZjDXL/AnxcJIYMs5ZkLrES1Ob5/5oM 20 | 248hAVo592NFEsF/rvG+wTKMIdLMFNJ+JKgilG/0sPfqwB7iQWNnLOhZos44H6r9 21 | x4GI78Q7Kwvcm6ZncmhYmpkCgYB78IM2qSzC1vSVUp/8ttA1h9TEfu53iKFCsX4P 22 | Ocz5j2j3Wk9N0WiKcofRD1KlHhXhJoeFUqwXnA8HuiBHvMg4OtcU/xxjN/fIMsyG 23 | hncuMPxVA8EWiqtarLLKNoeKiHVKjrmCr5Wbh2VfeKePGpvDLWkHJqQnQ+mRRdf8 24 | BdKsrwKBgQCvSywAGnhFwdEI49ZpSaGbj5dmPcEhrhKY23nFFVg5aBcC5GlPvA03 25 | fzkyOMzpDVxuEBU9uasz7C1uNoKaT+SgXNTMYWMYOMFngw36ynci5YP5c20OIeZX 26 | 8GPrf24IlSm9avKdXFj5XKUraEQYlYldc3s3CYNW6QKQKVD81vpLAQ== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/ca.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICUjCCAToCAQAwDTELMAkGA1UEAxMCQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IB 3 | DwAwggEKAoIBAQC02pynfdNf5u5+Zr2Dsbc5PuOSKtexxf/I/4gSd9/jJzYSGMhn 4 | QYeSnjBOlxgS4Qw0u/mYm3BDk2ruwCiRasqOsIII1f50dQEvwwsVFgvpOfSQpnXk 5 | ClUey4PfUnburojieoA8GjS4qhWRpitPCrdW1u4x/c4jLkOCbpiwbbMeXlA3/Hh+ 6 | is+LQaqmGEhDAivyn31Y0JuXNMXCJRi+f4IcFLTcMXijMCN1rWjNYCVuwinFM0Rb 7 | 0aH3TVTnNBIk4zPwyq2mfwwFyc2vxC2BNtAH3TPK/hDrkx3uCPTBvEVCXbZmMDkB 8 | 1GmfYzBgfIX/oHfQjO3aJr+4J9n2Hu0wQUaFAgMBAAGgADANBgkqhkiG9w0BAQsF 9 | AAOCAQEAGTFvmMbEnEYbdOCn8m1RURLC8OFlAJsDGr7BScoVel5ntcFcQmDU6aIU 10 | VwmKf3YEyxTbnjkhljPzGKqByZqlNFyQFK87fKehEn7/ypOQDi5ZO2GVJFquMYdl 11 | o2FQJPs+KAfJ2MRvmiSVPpt+AgTj16tUbXwnp+xXKFn0DVejK3ZQ+x1ijsGe32ls 12 | 2JZ/0k8n2JSmejmhPcM2XBC8v0X1raK3t8o8t5aJnldWHWZEcC+aOtcqVXj7PfL+ 13 | KCiyzVijIHpN/OYxkcc9V4kKehD9hZyXxIu5bqHcwI5tG/zj5SWkqT3T/jvkgGiJ 14 | fscT+HGA57BDRp9ASTyMOg6R1AGdKA== 15 | -----END CERTIFICATE REQUEST----- 16 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC6jCCAdKgAwIBAgIUagxK7aarnd92Pn3j2dopAzAkw8AwDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjANMQswCQYDVQQDEwJDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 5 | ALTanKd901/m7n5mvYOxtzk+45Iq17HF/8j/iBJ33+MnNhIYyGdBh5KeME6XGBLh 6 | DDS7+ZibcEOTau7AKJFqyo6wggjV/nR1AS/DCxUWC+k59JCmdeQKVR7Lg99Sdu6u 7 | iOJ6gDwaNLiqFZGmK08Kt1bW7jH9ziMuQ4JumLBtsx5eUDf8eH6Kz4tBqqYYSEMC 8 | K/KffVjQm5c0xcIlGL5/ghwUtNwxeKMwI3WtaM1gJW7CKcUzRFvRofdNVOc0EiTj 9 | M/DKraZ/DAXJza/ELYE20AfdM8r+EOuTHe4I9MG8RUJdtmYwOQHUaZ9jMGB8hf+g 10 | d9CM7domv7gn2fYe7TBBRoUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1Ud 11 | EwEB/wQFMAMBAf8wHQYDVR0OBBYEFDqMCCludua33DlJFXpakv7pNNITMA0GCSqG 12 | SIb3DQEBCwUAA4IBAQAA0r18j24AtfbEOh/brll1HljswkEElVY+fJvizl/jPflP 13 | YhJm1ICu8iPUwz31CgxxIEUgQYCbrVuUO2XKn0F3bQtxCXMiLwEt1kgaTRPQvQHB 14 | hiSZGOV4MUHCZIclwtmzyo71E6qE+ViyHqt+ncwY5vUWv0OGXYDiGUXTNmdtHTnv 15 | NX7ot05/zUR7bnjK0BYzuz2RndmVnveHEIP5wOZdOocRkufh7YLFRsBsssvffTR8 16 | 7Cj+zDnsGlycaX0EcsOQRWJ45RqrSJr4K/ZVvSq49N8zW9MgCfqbemRgKn+zewzg 17 | 0VanvfwDBU0dDiKevuwqfL5O0jhfyx4woTjRur6d 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/client-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAwfVqkxVi07R7S22s4Zk4IDEV561C+llXsJ5tNaFaFy2dxV42 3 | NDkhbIbggewoSUYaQUnWTWUL59mEj6ATfN5kUQoQ21YWVxlBfIO2ZXEVzlqalx24 4 | tP2lv47i4T02S/I7imp9vfBNcM0rTE0lav+uLoeuPYIt9yXe4arNL0l+A+qQ/sD7 5 | +phgAC4VvWgRc6bx7xSRlTKnPNjba2dcRg+cuTePyXXssLko8z+r/ui55WozUZmP 6 | VubJSZ0pp6CSHYekr0jgfbqe5vxiLsvtlvyPGjD8xRVI35nTOQWb33AkPqdzY/uy 7 | eazMhV5glNxtvLWxGdhZFlkBWaF1bNHqhSqIrwIDAQABAoIBAQCXxgYOcFa0GO+9 8 | 92Wn5zCfKCne75qQsmbHA0GsDMWli4GA1xcNSINaHDUEFZr0s5GJ81BpoZ9uXqy3 9 | guic9p2DOKA2MigrIc03tQ1+Vb5dilKb25sUrcMMoa/x1udtCHEFAA3DGo5OrY2r 10 | GFcmYkqXiH6VDRAQ7KZ66h/DV/vu7TpzTegwINajeaJLcrwPVDbApeArNXLeBaSn 11 | jy03hh6FknSk4PROv4l/Q7EufCwFhn0/Iw3bC+d//t4Ye5gipdwHFiAi+yz6Qaxv 12 | wNH6YcycmNAK3cj6IGG1SihRgKlkv5Y+TT52rOxGtCoD0xn/1NokYEWTN2GE4K2Z 13 | rtogwaJhAoGBAObHISUNrxvGNOZY3KZMm/SSyxzACZcgPngj5mfBRix8gHmGI8dq 14 | zXzVd1dshs2rV4p7W+SyXP7AQDyUXBYsCQYxQs4FPRzNqxFuBcifodzPhDbw5jKV 15 | sRodZZ7hrMBlInNGvqfd7EHES+l7+l6HV+ZTFSohzUFFwWJ+xKrxWeGfAoGBANco 16 | IficU6KfMqsIK1Eau0S9j6S9VLjGpRZLCKqQqTNRRZ/z/dJE6HOJ/wT8JPBoFfNI 17 | dtbEBLbS860eAG0n9hofRD2BX9JPy8seFiGORU+nlQh2YcF2L307S1ZiD41V26o9 18 | LeHXA50PtmLKSO2z/zDKNvsfMSYEHq4Ytx+4k57xAoGALKA7D5A62VMVralnWZ0c 19 | 10l/j1qvQBMTIWZHyq58JGQa7+T5jDlh7Q7WWgh5dNH6RqQeG/ZFt1lz0oMZ34u6 20 | XwEtmus2axh2SROOeMItqaZTOdCRoxyBN7yRhwy6vCWSaNo4SfvHENyllUvNGXRw 21 | kfBk+lW4/DNB9wrueuPa7p8CgYAQVgu+RKBVCKFgOw6O6eiuH3Z4m6eDIBIIz0mp 22 | KbKvIsyWiIANJw4/N4sVZc+oMT75adccF2YEO6Ak1NJTd2VINneH8/rCjSx8D5y+ 23 | j37TvXWjXtmtRrv0VjwyIt/ra0lyc5K4QwsTMc43UgSXh8MogTILfyLMMCPkNBwz 24 | XGBZAQKBgCaDmlWU/nYIjous/6yc7uR1cxmBcYqdc2ls17eLrNiwqMzv4HQgX3y8 25 | eGwyw5D0IutE7uJ3u6rdCdK9bAaZ+OhmPedEjHC1bFEgq8DBfhM9TcIwHUzpJ5Eo 26 | ObDyuEX1T8QjouLS3BVwQFit1eEGtoONF2ALIv0nQXXtokqDX7bF 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/client.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICdDCCAVwCAQAwETEPMA0GA1UEAxMGY2xpZW50MIIBIjANBgkqhkiG9w0BAQEF 3 | AAOCAQ8AMIIBCgKCAQEAwfVqkxVi07R7S22s4Zk4IDEV561C+llXsJ5tNaFaFy2d 4 | xV42NDkhbIbggewoSUYaQUnWTWUL59mEj6ATfN5kUQoQ21YWVxlBfIO2ZXEVzlqa 5 | lx24tP2lv47i4T02S/I7imp9vfBNcM0rTE0lav+uLoeuPYIt9yXe4arNL0l+A+qQ 6 | /sD7+phgAC4VvWgRc6bx7xSRlTKnPNjba2dcRg+cuTePyXXssLko8z+r/ui55Woz 7 | UZmPVubJSZ0pp6CSHYekr0jgfbqe5vxiLsvtlvyPGjD8xRVI35nTOQWb33AkPqdz 8 | Y/uyeazMhV5glNxtvLWxGdhZFlkBWaF1bNHqhSqIrwIDAQABoB4wHAYJKoZIhvcN 9 | AQkOMQ8wDTALBgNVHREEBDACggAwDQYJKoZIhvcNAQELBQADggEBABh+0NRr9F/N 10 | RoTAMpdcpbwWxENKMSi1zXkXaPsoPgDpdF93ywUk0xdKYu5GW2mhk7c+1AF+Wkej 11 | DMyS5jCucocfpnCDjvLMfoavDkhLmEm7diR/cEiun29GjxA3CrbrI4ume4p18FgM 12 | eAbuZDLX3G3V2Zmzl9B+2ai5OfBOaWnWsyV2pdxFjjFbr1LzKFljq6iPW/Vbalpi 13 | BvsNrXBzf75EVDcGB/DDJhVoqakaIZPQlCuNTFuOFdImZ0G63VHAPpshGfwlbIH5 14 | YByyOxlHSFscFNeyzC76ZiW9T5UZtrsMt4ZHfNcHbWdj6A2BR+0YsxZHYnhX3WRH 15 | NfMBYzpo22o= 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDOjCCAiKgAwIBAgIUXFxuTNjW+7j3Wqhpope4E1hmzlAwDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjARMQ8wDQYDVQQDEwZjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK 5 | AoIBAQDB9WqTFWLTtHtLbazhmTggMRXnrUL6WVewnm01oVoXLZ3FXjY0OSFshuCB 6 | 7ChJRhpBSdZNZQvn2YSPoBN83mRRChDbVhZXGUF8g7ZlcRXOWpqXHbi0/aW/juLh 7 | PTZL8juKan298E1wzStMTSVq/64uh649gi33Jd7hqs0vSX4D6pD+wPv6mGAALhW9 8 | aBFzpvHvFJGVMqc82NtrZ1xGD5y5N4/JdeywuSjzP6v+6LnlajNRmY9W5slJnSmn 9 | oJIdh6SvSOB9up7m/GIuy+2W/I8aMPzFFUjfmdM5BZvfcCQ+p3Nj+7J5rMyFXmCU 10 | 3G28tbEZ2FkWWQFZoXVs0eqFKoivAgMBAAGjgY0wgYowDgYDVR0PAQH/BAQDAgWg 11 | MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0G 12 | A1UdDgQWBBQYzLyhq/htZOvaBJu2WWKFdNnPFjAfBgNVHSMEGDAWgBQ6jAgpbnbm 13 | t9w5SRV6WpL+6TTSEzALBgNVHREEBDACggAwDQYJKoZIhvcNAQELBQADggEBAFmT 14 | 6YFLQP7Dbt+834V7437OJjjpm4Ekm+94wG9XA/eUMIjiavcRRqYGSPfTBcs0TEd8 15 | NyHlCmEd84MbRl49AJs2e24CkuMC1SkJO3cEE6a3EXd27VLj1jVmoYQetGQMVnAg 16 | HQGhAs2PcAxiHu3Y+x2mUZCNEidcSfsFJr85kACBl+HsGCo0F4FYDjFoO0mwLmHT 17 | EuYF/SWrHe3/lKMuQsvbYqPBZheW0LUSLAxS0JBO4ql1TVeZvgMEwv0BHyKM1aqj 18 | 03SBpJwVeBcryXtEr0v0hK5+YWqD+rXpvJBmUWFY08HJBhNZi66MMo3IM8k9C9Gc 19 | secOJiwWgArAMHGaxdo= 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd0-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAvnRz794+Hun80HSIGaJBRT3krbWtkuHxKffAkK6B6BkGUu81 3 | QKfIzsDLHExcRCtFbW3nw241lzJ/Dd4OoQr2t7ibm8joy+nq5sS4ILTvZbIqBujC 4 | 0E6qZcgHS2TEBKWvWCA51rn+sCdWGOHMS9mQTwxgCiUJo/8msEWTK6tHtFgpNTFt 5 | jxc6rk6yUrNiLngyvSjYJWWrsunxvwL2jedyWEkXlpnb1TxVWtUbUSkQDRAAGW41 6 | wdikIC5FgSAwEXjGJxN2PuVyMJJpOl7y08VAAnv/AgUBx3Y56NPhp+gSpTHtvAwm 7 | Hk02ZqWu8Pk/W51316YahqKrvODvfoKMkOlHDwIDAQABAoIBAQCPkYOQD01uyl48 8 | 2Yt7H1fqlWScGfc1YUMFqvCrYBEnYC3nONFA4vo5+RVjSKDI9oGIoy/xn1OgnX0v 9 | e/Q1K+mdxvjub34lsTjVKvfOF/bbB3os6StqEdLblPUCvXwSML/EQ8618lFugsih 10 | Sx1RFDl3jVGcdB0XVhDZEimF4sDTzc+3vziNguYpy9GfBzSD0Qe7ZHndnofLtODr 11 | 3lbetQMNnC8KSBLQCFCuAsPoQ8Pn2L6HnGptsuBqbpbWDr3Ly7V4gNc4vvkR17K7 12 | yLpO4LDATao5ZcFBsB1H828Ro3DpM6d3nJG7acpLsttEE6SUqq4xdjo05SM8P10S 13 | Iy7oXbYxAoGBAM0AO4D1v9/OBtdMjPsVolx5EgvFbLti96oh6y/wFKXQ5k3ala+d 14 | LQgQV8Xu2spvXFk2erhqqFu19j+QtUayP2MF5tssqG7CYQmyCF7HJ+8/SlwzQZmr 15 | PRosPeR8ewENbRFONfD8DjfGAVK+ECBVj5ATNVk/391O/oQATIHM7esZAoGBAO3V 16 | 1lwhOnEbn6JhvD0o9rE/6qRsE0FbBD32DHhpVOlrdFHyqJZ8/lkr23PJMDYFRg2p 17 | dA/febWbECmw0UkRZ8d1uvv5cSt+EO6CHhhuvl4Mf+pvtQixs+H2losVzfzTZNO/ 18 | f2d8cbdfzkAmVa7kOxuHQC/grSKWBSb/Fo6IUzBnAoGAfcZDu8aLN3P/bH7SDIbk 19 | e5nogYJaSMnaq+5tjpbdBDMb6e5PYlSruUPVpmH6qLMUVMQBHT6LFuGYOL2/CqX4 20 | D/giAJzwpivqP3mUexnznW0WYWUtPWv7bCByxMm+6hFjtndmzvjGfF+mli54VG5K 21 | S5oNZDm1TuHVdAV+6zBhVJkCgYBcwRO7lH3tVL+aHZHDLHGhSPMisr+DspJh886D 22 | O1kRO4X+26siHZc4gaExc9oohz/93gNUmWwnBlV0XPASFgaqRGDrGionsx+5VOeV 23 | 0cLOfQN6E5y/ykYELx4hGhzeqDbfWgS/AEp9IJEYdZre/UWMA+Bli7MaFPXncn6C 24 | keoXqwKBgCp1yTAnMXT17+oZGav1PNXrr214els5x9lv8gvLTGckwrwpfi3CcZds 25 | D2NWYc6gPO0T/embqEY2FwYjZSf4tjpAA30zJj5Cc7sIRXQI5nTmcRs+EFeT0vpl 26 | kUj2uwUaS4RR2V163zvvVVFdHDrSlwNTEdpvhxg/DSVmySu70y3N 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd0.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICeDCCAWACAQAwEDEOMAwGA1UEAxMFZXRjZDAwggEiMA0GCSqGSIb3DQEBAQUA 3 | A4IBDwAwggEKAoIBAQC+dHPv3j4e6fzQdIgZokFFPeStta2S4fEp98CQroHoGQZS 4 | 7zVAp8jOwMscTFxEK0VtbefDbjWXMn8N3g6hCva3uJubyOjL6ermxLggtO9lsioG 5 | 6MLQTqplyAdLZMQEpa9YIDnWuf6wJ1YY4cxL2ZBPDGAKJQmj/yawRZMrq0e0WCk1 6 | MW2PFzquTrJSs2IueDK9KNglZauy6fG/AvaN53JYSReWmdvVPFVa1RtRKRANEAAZ 7 | bjXB2KQgLkWBIDAReMYnE3Y+5XIwkmk6XvLTxUACe/8CBQHHdjno0+Gn6BKlMe28 8 | DCYeTTZmpa7w+T9bnXfXphqGoqu84O9+goyQ6UcPAgMBAAGgIzAhBgkqhkiG9w0B 9 | CQ4xFDASMBAGA1UdEQQJMAeCBWV0Y2QwMA0GCSqGSIb3DQEBCwUAA4IBAQAgwXBh 10 | A0p0cCl4i/NbruIEFhzFkVDHWGC1EneT9hd6989GZLeJXBw3k0Ik+wrMiR24zOnW 11 | b7PmCjDbzfDCByEOJ4nwqcnPol5Oq2ZZl2rdPR4DYUim2pezC/yp7OaMj9R3afxL 12 | KccnmnJE7zxbBKQ13+5ul7p6LFYgl0wzub4zLmn3k0RRF9oDz65LXNF3U4qLUHKM 13 | g1WoleBGzriUpN+rMQJvtie9YynO/63nlxq6Kum3QRISdsMFOtQsD7iQKJCtmhYX 14 | j+QLyTXn9grgPhDr9r6NsQX9K/CGS2iQIcIolzAgGIOaGjRZ8J8V7O4WMLvDLRKb 15 | OLTX8JKT0fDquxoe 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd0.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDPjCCAiagAwIBAgIUSU4fnfpaqAL+/w27jBUT0Pj2dB0wDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjAQMQ4wDAYDVQQDEwVldGNkMDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC 5 | ggEBAL50c+/ePh7p/NB0iBmiQUU95K21rZLh8Sn3wJCugegZBlLvNUCnyM7AyxxM 6 | XEQrRW1t58NuNZcyfw3eDqEK9re4m5vI6Mvp6ubEuCC072WyKgbowtBOqmXIB0tk 7 | xASlr1ggOda5/rAnVhjhzEvZkE8MYAolCaP/JrBFkyurR7RYKTUxbY8XOq5OslKz 8 | Yi54Mr0o2CVlq7Lp8b8C9o3nclhJF5aZ29U8VVrVG1EpEA0QABluNcHYpCAuRYEg 9 | MBF4xicTdj7lcjCSaTpe8tPFQAJ7/wIFAcd2OejT4afoEqUx7bwMJh5NNmalrvD5 10 | P1udd9emGoaiq7zg736CjJDpRw8CAwEAAaOBkjCBjzAOBgNVHQ8BAf8EBAMCBaAw 11 | HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYD 12 | VR0OBBYEFKz27QgKqK6n50TZfD/xFRkPv2hpMB8GA1UdIwQYMBaAFDqMCCludua3 13 | 3DlJFXpakv7pNNITMBAGA1UdEQQJMAeCBWV0Y2QwMA0GCSqGSIb3DQEBCwUAA4IB 14 | AQATiJa7T4zMHHVRHfkvEYusN+7uwOwgwKg3hYgkuwGRaialf2tcsZ4Z5buDmD0p 15 | 1J28hjJ4+QMX6UrVflV2hDCx2OskwXPgkqUEraN6SpYAr+YsJARDTYSAsvygMwGy 16 | 50RuqeWk1zjf9QoF131C0/m8ZdMO/OvMM0F+3JPOooxvZN3xP7BIJX5eLt5j9c7I 17 | IUhAkQUiJBZUGryGe5eW353lFoDcFr0FRW0YNp6ZchCq69T5ezhheOzcBfaQLqr+ 18 | 2VYh3ZrGb4nwn8oVWHgX0VWQXlkBTVpIduNfbwWceebW4+CGL2qPibj6UoPx7Fwv 19 | cVItGulgVUh2JQ2IChMr9yRc 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd1-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA2hQWwYB25WvpX73ObbrPDGQvAfxSWW7LakMeIYWDYwDjVoDN 3 | lU9YI7lKb19ypKCwlTE1rniP6h8mkpB1kF7JKJgiBgyw2NsQVjA3+pO6I8dT02WP 4 | LS+fCAkY/kjNedDWI91HxtBvX5kDEHIw+4faQrJFtINI78AVWUHPWoapktUMncU2 5 | jj8XOZf6/kNW1uyl51Lklwn7P26ZKMcwqtpjh18swbsiByFGwHo4IK7RsBwc1r9C 6 | Bqd8b/94UtdMWbz+qRPqfH5mHp65RKc3K+yUuxi6DGjz0hl2ON5GfxaWp6cCeL+o 7 | y3ubyp+5vK2Q2zBzSa95XpNbWUt/DVCthZnzVQIDAQABAoIBAGm06R7cfUVRnGq7 8 | H0+TCH+SJDMLMoOFL/aPGBDZnckkig3JG12veyK90vXPR0vDVDTNCJ9Mcz3h4ZmT 9 | iljziQAzVfKmviYvcWjFsKy2ZLipCtniVZdqiOSlPEct1OOiNdpmjT8yk3m8On8D 10 | Svjxbft8XEtWg8kqy25bdv4DXjj8RJiUXL9G1wk0n9PIRBGjsZXtA0/JpI1pPFR0 11 | Z/KmFZyDd/aBXPRmPzkSpNU+d2eNphPbb72gowC/HXVtN6VVDAQH9fLT8z8jrBDT 12 | 0xQLcNP8TXv8PyxUkDiCGL1wDxF0+YKE0CJiOgTeS1e4z4otEfzCvyRX1zyZPKGD 13 | IW7sLAECgYEA/iXde8zIAkBT9jiubrG6nlXpx92ApK2wDhiTuE3kCREj/kYlH2Dp 14 | QwpPDs2AIope4O9OPY4mTqa1L++AuPrNsF/1vFjvv4CEQYIq44YKFyv5BWS8i2wC 15 | jMzC/Fpdzm4y0usQ84FQ/915qN3zFWbuNpW7x4gS4Zgtf60OkpdURlUCgYEA26ru 16 | 3essEbnGLI/xPo0bHe8UcBG3AxKrMkiIiMlJa4yqd9MygZNLn9Jb4ovlnGUMOFaK 17 | 1Shfx1M+5vp7Nbdt+jNkUrgMF3RYDwJNnpIQczuDltXmdAPGmDbkgTZOtbGA7UJA 18 | KXpnHEKRcjHN2mruEBuKUfidR9wLo1cCP6lp+QECgYEA59OYbiZFR7BwJkhb7QNY 19 | LLhHsRW/E/iPgLwwe00pto+ZGofXswDOpmWP6fvQZzF7DImeAA5bqSDuY9R/wbyd 20 | xcYyvOUPhMrxWWQoRTTunWZyF9ZlGnSi+taJAnJX4UaqO7VK2CRcw5i+MiiLZTlo 21 | EAiTqpXYS0pqLm2ovlUl/aUCgYEAv/EHUW/5jO+II04PXTnM9QYAFMDV6mB4qLJK 22 | Y0OG3OwH1DX9zs0W6mrUEQtusY519BBitUjXEANEVm2OFWzXMyWOxty87A2kGFFJ 23 | 44H7z8S0Aaub98mI0V49ok4Czq5wWmBmUhf7Wu0ry92K4wxGQlreLSwQukajALG5 24 | bEkrKQECgYA8XVVGB0gzugeWEZdZVoJEhxsxvmvVcErZay8XTv4PFBFuV7AMIdc7 25 | Gh8KpeFG1ofxw+TXaaNkVrF1rjODEJTEQbfRZWlWgFUnQUB20Zh+0NLoLze+v0/O 26 | AcNkqdMnHlZXYr4sOLNDy+Yd+T0ID/V2Emd9pQ5HRup0d2SkwpPJjA== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd1.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICeDCCAWACAQAwEDEOMAwGA1UEAxMFZXRjZDEwggEiMA0GCSqGSIb3DQEBAQUA 3 | A4IBDwAwggEKAoIBAQDaFBbBgHbla+lfvc5tus8MZC8B/FJZbstqQx4hhYNjAONW 4 | gM2VT1gjuUpvX3KkoLCVMTWueI/qHyaSkHWQXskomCIGDLDY2xBWMDf6k7ojx1PT 5 | ZY8tL58ICRj+SM150NYj3UfG0G9fmQMQcjD7h9pCskW0g0jvwBVZQc9ahqmS1Qyd 6 | xTaOPxc5l/r+Q1bW7KXnUuSXCfs/bpkoxzCq2mOHXyzBuyIHIUbAejggrtGwHBzW 7 | v0IGp3xv/3hS10xZvP6pE+p8fmYenrlEpzcr7JS7GLoMaPPSGXY43kZ/FpanpwJ4 8 | v6jLe5vKn7m8rZDbMHNJr3lek1tZS38NUK2FmfNVAgMBAAGgIzAhBgkqhkiG9w0B 9 | CQ4xFDASMBAGA1UdEQQJMAeCBWV0Y2QxMA0GCSqGSIb3DQEBCwUAA4IBAQCclrM5 10 | wuVYAogzJHth6Si4b0I/IWL3VX+dn9EWSudFh1EnuUVHaLgK/E366zuwtp8GJul6 11 | EAsMVGAdgCyj/vaKVSZkkSnE+jMS3ijN+0zbzEC+idsE7ydDQQOqcaL10B6b00Qa 12 | TKApOesExUQ7jXn1rnJ9LPkzTxsUN4l9Z/RkEUfKuNClQK64Yw6e+/7ofnujslQ4 13 | OPviTZvU1qzo2FXoXl7PmO+Zb2w2wAAijK7wsoepj75fpWsHF1y5c7OMOj7vaJP8 14 | GppRsjeoQ+KtPjfhATEDoZvbW5gTKRnKd7O/VUzeRUK3rTrrIofjj3Gc4xCFwgiB 15 | sr4Z/F4eyDSaJinQ 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd1.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDPjCCAiagAwIBAgIUW1tG0utvpYyPLtGuC5HZrOREia4wDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjAQMQ4wDAYDVQQDEwVldGNkMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC 5 | ggEBANoUFsGAduVr6V+9zm26zwxkLwH8Ulluy2pDHiGFg2MA41aAzZVPWCO5Sm9f 6 | cqSgsJUxNa54j+ofJpKQdZBeySiYIgYMsNjbEFYwN/qTuiPHU9Nljy0vnwgJGP5I 7 | zXnQ1iPdR8bQb1+ZAxByMPuH2kKyRbSDSO/AFVlBz1qGqZLVDJ3FNo4/FzmX+v5D 8 | VtbspedS5JcJ+z9umSjHMKraY4dfLMG7IgchRsB6OCCu0bAcHNa/QganfG//eFLX 9 | TFm8/qkT6nx+Zh6euUSnNyvslLsYugxo89IZdjjeRn8WlqenAni/qMt7m8qfubyt 10 | kNswc0mveV6TW1lLfw1QrYWZ81UCAwEAAaOBkjCBjzAOBgNVHQ8BAf8EBAMCBaAw 11 | HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYD 12 | VR0OBBYEFKlB29qaRRAjtJYu5E95TKBe2AjhMB8GA1UdIwQYMBaAFDqMCCludua3 13 | 3DlJFXpakv7pNNITMBAGA1UdEQQJMAeCBWV0Y2QxMA0GCSqGSIb3DQEBCwUAA4IB 14 | AQBA9nK6LkC0ziZkT9FxpuqErqVDMz3U0YnPWY1mBRrYfNevadDdVBkq7XKk7S3k 15 | PSnW3h1LCz7YSn9IKoZo11ej8oUcX5xL2DW+m/H3kKol8jVgxVFdLZH1c5rAUB/b 16 | v1ehalsn+q1ttY6ADvHI2sQpctkzrwnx5NXdF4ew9flkD4+PDcIKW+3R/ldwG5Pn 17 | Glngyl6aRyPxvgEh5ejd4pVIAh0LjJ8NFCGWcdobhpr3RSj8Evk/LoQwZ2mX+VqY 18 | pZElg0ZTKfpG3cgHu+rcaTLDftus3m5Mg+JA0jiraV7hmwfi5P8LcNlUALQq8I12 19 | Puw3CbuuLNLtgcr5cjWhnjZQ 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd2-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAl2R0DY5Uea7W+Jzg3CcLRkE1NpTxn+BRuzUvLopj4TMEK+CS 3 | b8c8sKswWD1xYZ6R12+dES0GLoHYF6oqG6Lf5z1ArCB7ocxqM5iXueF9HXsdyWKN 4 | 1deOW8aNjnW5CTxFvQfu8T839++DPhTlpSw5GzSe+DdrotU+Q8VRnhNOligQANKl 5 | YLyZH62jb2Sxj0FcVgOiq64RZNL3Nqcjp502kpsY8QGPpXUx2/fgq2L2pBR/N6CS 6 | 8SUNUqwpiU2yu3HLAcghRvhHrxbY1DYSeKVyrf4R7OewJ0MbGPrAlDRk/mGytjf4 7 | mmy7l4qbu9NNE28yfpYZEkEH4TrL1rNbiv0ICQIDAQABAoIBAFZhAXpumDJpmMx3 8 | LjFOsbcfI46GAys2YUvQd6A1Y/GtGxcx5juS0UT4F/hw7k1FnW7vhw2yw9ErUrGF 9 | 7Mqh7uDQaSMM0Z2qtXnE+eUcDDgS9BbgfY7ik543trLu5mmnkx7c9O9/I576cMau 10 | Q60vg1HLf1yeunJI+2LNpdjsqS0ww+YjZdWI4Te2DNu+khxCWOnqUvb9Z95jPiSM 11 | 1lZ39lKOfPMRxnYz3QToFrgeTwaJLfyVXQTRcL4cVuOiVaVvdhKGbKAjidIyGLJ/ 12 | +bwJRgrTMzQq7oW1jnCvehgd+/46WgXc58WiyvMMrg+PM4zT/fe9kBCwdrLtBRKf 13 | B9/P4dUCgYEAwPqoZflFIdZCm0HBYecZosQwyvg3bmDS048M6Yg6foy8/B7Mza1H 14 | fI2EOu4Aq8kd7s6PS1U080uKV+8IqnA+xYlzkLatB2jxnZ3wmfBoQnbgSCvT/tj2 15 | k4fyr19o0oy6OE+wK5ChpuKabPz6tCzFPKNwjJn88CPFPETDLH4d0O8CgYEAyNUV 16 | JBobRtbKUgCUhHu6H3P3N576IDoqu5LFBD2r0TFeo8NFAca0pvVZAuwIpbLZj11U 17 | qaqA410wM9+H+P5646nhNkdofdD66KgLNULmkBT8g+8jIgYv91fBuxj1QD88hmoE 18 | A5lJKdJRW1jLeOwW2ABoK6Dog+oLKf0Un2sFxocCgYAR/EqNlnnW+X0jszEuyrcc 19 | 8GQLxq6D3wpHJWHysfuhp8RFSymTUb8D4LyeMWhmmkvr4dyBDOPueO/f2itYlzWC 20 | e5kFt8DQm/tI0VuHPVy6NRIaJ9uOOPJiNZ1sstu2I9+HOAYXSVeHkj8KQVmsSS/o 21 | wuLOd9uXFf5f65i1INvuiQKBgA30kJWDouWXQ1PTan6SQmqxGjqpN2RJ5nJGTp5u 22 | 0qOktJjYltD6x87aOac0U52AAhIuQBXSHUavUQwpuj8ZH9z2DwpAiAhGH0lPdAft 23 | cCwO6UUZtu1EVMzxMisYHuKqAkCs2T6OxkC7tp+MWgc7EJNN4+80LTQNbV0rkuVJ 24 | AIu9AoGBALeJz4r5H5qa79IS+5KxFK7LP2sBPrTGh8/Jw6utAh3r4ObS11HvrP9R 25 | bgvLzSt903Oh1pzhOzrktVRXozPKOiV4XrzTJNGkmpHemPmkIA10QeRqnQ3ElBXB 26 | LrpQrJOlhfb4L8IT4D8V8jZ8iJAT3I7fruACvYnXunHAl1BSZ/ov 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd2.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICeDCCAWACAQAwEDEOMAwGA1UEAxMFZXRjZDIwggEiMA0GCSqGSIb3DQEBAQUA 3 | A4IBDwAwggEKAoIBAQCXZHQNjlR5rtb4nODcJwtGQTU2lPGf4FG7NS8uimPhMwQr 4 | 4JJvxzywqzBYPXFhnpHXb50RLQYugdgXqiobot/nPUCsIHuhzGozmJe54X0dex3J 5 | Yo3V145bxo2OdbkJPEW9B+7xPzf374M+FOWlLDkbNJ74N2ui1T5DxVGeE06WKBAA 6 | 0qVgvJkfraNvZLGPQVxWA6KrrhFk0vc2pyOnnTaSmxjxAY+ldTHb9+CrYvakFH83 7 | oJLxJQ1SrCmJTbK7ccsByCFG+EevFtjUNhJ4pXKt/hHs57AnQxsY+sCUNGT+YbK2 8 | N/iabLuXipu7000TbzJ+lhkSQQfhOsvWs1uK/QgJAgMBAAGgIzAhBgkqhkiG9w0B 9 | CQ4xFDASMBAGA1UdEQQJMAeCBWV0Y2QyMA0GCSqGSIb3DQEBCwUAA4IBAQAABR1E 10 | 4NrulaFTTlQyiohr7DrW7fHLRZFZwq2PK8w4u28zfIXFKh/M9+EJaAsF7OpY9kjW 11 | ZXvpKMn1u+BcDpIt+MauZyUCp9sj0M4BGAKpNMxKJVAuumgrUG9iaWxGcGu2u6U8 12 | rhIa8+xlriCOmW4QQLyyQBGkOlnBK1/YEj9qyXz2PRqjjMwQ7RmzlYUHeTE8N+TI 13 | kZtA8cR75R8nySfjvr+jW1UeM3ZQ1BfzkmMQ72LOr/u31S1HutgoqaTTsIgK24dc 14 | yC/Oy8WwPrvSrXmdCR/hRVCfOLHxOVTWIQ5p6Uict6dhyABjvOPoJTo80CT+U49z 15 | gijmOtBAjz4lDuOy 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/etcd2.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDPjCCAiagAwIBAgIUSM+33y5sG57ZtOrewUkyncGJL4EwDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjAQMQ4wDAYDVQQDEwVldGNkMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC 5 | ggEBAJdkdA2OVHmu1vic4NwnC0ZBNTaU8Z/gUbs1Ly6KY+EzBCvgkm/HPLCrMFg9 6 | cWGekddvnREtBi6B2BeqKhui3+c9QKwge6HMajOYl7nhfR17HclijdXXjlvGjY51 7 | uQk8Rb0H7vE/N/fvgz4U5aUsORs0nvg3a6LVPkPFUZ4TTpYoEADSpWC8mR+to29k 8 | sY9BXFYDoquuEWTS9zanI6edNpKbGPEBj6V1Mdv34Kti9qQUfzegkvElDVKsKYlN 9 | srtxywHIIUb4R68W2NQ2Enilcq3+EeznsCdDGxj6wJQ0ZP5hsrY3+Jpsu5eKm7vT 10 | TRNvMn6WGRJBB+E6y9azW4r9CAkCAwEAAaOBkjCBjzAOBgNVHQ8BAf8EBAMCBaAw 11 | HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYD 12 | VR0OBBYEFFq8/ISab/kVRgR5i3wGDPTFpujHMB8GA1UdIwQYMBaAFDqMCCludua3 13 | 3DlJFXpakv7pNNITMBAGA1UdEQQJMAeCBWV0Y2QyMA0GCSqGSIb3DQEBCwUAA4IB 14 | AQBWyBvQbHnS3hNxjEDGVn7Uijg1wThZ5recHcHnho9diEVRAvVXU+9oMZVhujcP 15 | rKpOqPxa0rnUjUv67/qtsTgKiX7m0SL9Gf9oWqpyvadsyyJ9pmaDl4vvsNWDhvdd 16 | wlBzO8k7pLbTWx2C+Fabw4DUo1q8TL18mUj38Gb8ibsYjNR9IwQ+hSnipoEIl6T5 17 | eUZtthLTQow+0NKEw/YME7hI6WQtlPqxorSc8a8pUDBaxKZHYwoaSrDUaJRfomIb 18 | 1XkWIoc+/b4uPZ18dQjZstPKb1cE0HrWgxWqInW0UvWyWbNk3+43Hbv1HG0ynWUQ 19 | 61odZh3V9jcpqhoAgRlNfYXd 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/server-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEApJ4wzg52P2YdQSSjKzMPs9j89E5LPbWGyBOVup/sJy4jcE2I 3 | Npu8wFWj9OpJ0r39Ke8am4e5y5iPg9upvhZrXxkI2BQepFwid5FbQXtdHwt/FPrE 4 | IKInVxjuigKPZqJVDIwfr0nxO4TZEsBEOOIsBThweK+oDCAUZhNfEue3dAF10PDT 5 | odUOsxdOKqNSbfn1w3FyPWWsKq1oT4vtR5kX75M4T5u3VwCcVXXutG+J8ko1ehhj 6 | WN1pycXezhHM8dxcY0PpfsJwocJi+uV18DV8KaXMFwOC4zYJFiytiQXlPlnH9oOO 7 | i1JOeMfmJF+PaJAiAKBr4G3tTsC59UxoN1E13QIDAQABAoIBABxrOt233W4ggNho 8 | LMsea42O3kyG37JtjjEoQGcRiMFS08dleyiCRlml70Iu2EPLjNMadit3iPm/Areu 9 | ymUIlcy7E63J+2hAh6rAq1Joq7DaWTwT9pvzonsE0Nl+i6caSzh5UFcAmua9joQQ 10 | MTboxNS546DSIl7FgwAERBuNaTxbZUAzMdtJsnDZnM0zd/HxeB/TS+myzfQgGtKS 11 | iTpzvEt4h0wzsFvHP7610cTe+J4p+nM/Kt9CArExWRIPTYfVcHRlw2CDEh6cQCbP 12 | xS+p3Z52YM5huHbC2yED45GlxAEk3ZM41lUuwDx8mYBIfRGyhABh0d9YxnQsriOj 13 | okxb/7kCgYEAxfQmB70ArEplkaL1uv+vCS94uNf3MRwm0aG9hCT5bT1cFh+GwE1r 14 | nWoR416fjn5TIHp9+kTzrsuTha2Xognt49jveFdy0rg0b2oQatN38/xbEVJJsIyS 15 | VwJVoSSp0ZncWWP0oATg0lSf/nBSgH0p/uQoj0Y5XtXyJwtxRSkZr0MCgYEA1OOd 16 | iqCNTAqQwSChHu8B4hhaBof9N/hCddrNjiz3COMSGUGeNOlHn29n1bGpHvORKCiF 17 | aPpHitxvwF0naGzdZ1j/mLL0JRedRnJJqYNOfuR6lEkgTVO2nTft7vzVlzg5N+dx 18 | 45LF5Wsj1SEc0jrrR78RlSpqAXCit0pL9KuxZF8CgYEAiUc0rH8lHVaGs4XoleNE 19 | 9sDGHqIe2h7kyNI6xI6Dr38zAmCgqXHHZKYve5eeXUo7ybVI8iupNpoVV0o4cvYh 20 | 1LYX9EPo7Ds0meNbOUon0Ls8SHnhgp8pyU9kJNlxL1tdVVydQ+++Hf7z6ZbpkBO8 21 | 8Pg3LI0Nsjf6s5sa1VSYbFMCgYBRXzcmd7vKZvdxemFbi4uyuhAfEves3w24MowD 22 | XhiGoxSV5sjr/IbN4C1WNvQnyn2fVe24dIHIB/4HDxQzC/mMuS3pVe2QB/irpp+V 23 | VYU5Z2ebKmBYbjkM2wXtJWMWy/zC64pSrBVMXalym5eCm9a2s8eqtm2SY1Uurg1e 24 | VgoWDQKBgFw7Ft7Y1F7QK97fXQ6+yPmQidFsSIn5TqUVbE2PEBg8A/8Rw7ELgADZ 25 | 1/cXT14IbLyzqJa17xJSaIe8COEqWHN5NWUNt2Z0irkptzLNRu48F+VyHjCoUtJo 26 | CZWwwtPtJ9aUZY0finRAkG7a2bf9Ntld+LcLYk4i6EM6iYuyIdbl 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICfDCCAWQCAQAwETEPMA0GA1UEAxMGc2VydmVyMIIBIjANBgkqhkiG9w0BAQEF 3 | AAOCAQ8AMIIBCgKCAQEApJ4wzg52P2YdQSSjKzMPs9j89E5LPbWGyBOVup/sJy4j 4 | cE2INpu8wFWj9OpJ0r39Ke8am4e5y5iPg9upvhZrXxkI2BQepFwid5FbQXtdHwt/ 5 | FPrEIKInVxjuigKPZqJVDIwfr0nxO4TZEsBEOOIsBThweK+oDCAUZhNfEue3dAF1 6 | 0PDTodUOsxdOKqNSbfn1w3FyPWWsKq1oT4vtR5kX75M4T5u3VwCcVXXutG+J8ko1 7 | ehhjWN1pycXezhHM8dxcY0PpfsJwocJi+uV18DV8KaXMFwOC4zYJFiytiQXlPlnH 8 | 9oOOi1JOeMfmJF+PaJAiAKBr4G3tTsC59UxoN1E13QIDAQABoCYwJAYJKoZIhvcN 9 | AQkOMRcwFTATBgNVHREEDDAKgghldGNkLXNzbDANBgkqhkiG9w0BAQsFAAOCAQEA 10 | MFvQKL/k3YNvT2JydCcXFBhihC0OMSGIin5WTd+GtbHxlwcBtR+px7AgU6Jo9SKY 11 | m0+TDT9cCO3kBP2AlRba90UDyh8zhHPH2RVXTVaelLp/pUvUZlsb+Z22rALNfA8d 12 | +c82ZAKwW638ZRKI0MterT70aFaM7NvHBgL26Gh3UXNMeux0BnkMF0hJ46Urtnk+ 13 | AtejI3t8jb1vW1QmpERSv+u/f7C7k0xzsqaDULAULBqepreo5jNfUW2uGVT0Uj7X 14 | FrwT/Sm4Lny2+aaINeeG44RrcVN8QyCjJrxGNBTL1XfP7okIhSs+Ob8iPDA7+X55 15 | 4ctuopK9cCuHYbsBMamO4A== 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/cert/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDQjCCAiqgAwIBAgIUW5QzcoADhrxbaNY3rSEwTlHKrf4wDQYJKoZIhvcNAQEL 3 | BQAwDTELMAkGA1UEAxMCQ0EwHhcNMjMwNTI4MTM0ODAwWhcNMjgwNTI2MTM0ODAw 4 | WjARMQ8wDQYDVQQDEwZzZXJ2ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK 5 | AoIBAQCknjDODnY/Zh1BJKMrMw+z2Pz0Tks9tYbIE5W6n+wnLiNwTYg2m7zAVaP0 6 | 6knSvf0p7xqbh7nLmI+D26m+FmtfGQjYFB6kXCJ3kVtBe10fC38U+sQgoidXGO6K 7 | Ao9molUMjB+vSfE7hNkSwEQ44iwFOHB4r6gMIBRmE18S57d0AXXQ8NOh1Q6zF04q 8 | o1Jt+fXDcXI9ZawqrWhPi+1HmRfvkzhPm7dXAJxVde60b4nySjV6GGNY3WnJxd7O 9 | Eczx3FxjQ+l+wnChwmL65XXwNXwppcwXA4LjNgkWLK2JBeU+Wcf2g46LUk54x+Yk 10 | X49okCIAoGvgbe1OwLn1TGg3UTXdAgMBAAGjgZUwgZIwDgYDVR0PAQH/BAQDAgWg 11 | MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0G 12 | A1UdDgQWBBQRFGGLGHncqlv0eEhHt3s9yVgI9jAfBgNVHSMEGDAWgBQ6jAgpbnbm 13 | t9w5SRV6WpL+6TTSEzATBgNVHREEDDAKgghldGNkLXNzbDANBgkqhkiG9w0BAQsF 14 | AAOCAQEAGlQGl6As0y9GCT4wTWbt1uT8AVfDMpUuzhPVJzRKRQbP+zc8HKHwR+N1 15 | PrAJTD4ifPee5FzpoiZ2FdX40Vjnoj6ISzkca8JUsVSy6oaamGb+zmnuWgiFK0sG 16 | aE0//Dfy8HwxOI2qx9/Zule+HMGadcZaSUmXjInTaB9AyZmnNUpGunxHsN49YLuP 17 | /al/6CLgENZgFpFeWnZZnaZqFIvVHXG8/M6Af5FHifqTTCLdg1tYIoaeh4mN43NC 18 | ndm6zjpRJ78oLo8NL1LGeeUhNyhih0Iq5h7C4RnBHdb3uS9jWTFUvEqKlwB1h4tn 19 | 8XGTzpQR0NFt7f40h94v7UEKPV371A== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /jetcd-core/src/test/resources/ssl/generate-self-signed-certificates.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2017 The jetcd authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | export SCRIPT_PATH=$(dirname "$(readlink -f "$0")") 19 | export ROOT=$SCRIPT_PATH 20 | export CERT_HOME=$ROOT/cert/ 21 | 22 | mkdir -p "$CERT_HOME" 23 | cd "$CERT_HOME" || exit 24 | 25 | echo '{"CN":"CA","key":{"algo":"rsa","size":2048}}' | cfssl gencert -initca - | cfssljson -bare ca - 26 | echo '{"signing":{"default":{"expiry":"43800h","usages":["signing","key encipherment","server auth","client auth"]}}}' > ca-config.json 27 | 28 | export ADDRESS=etcd-ssl 29 | export NAME=server 30 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | \ 31 | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | \ 32 | cfssljson -bare $NAME 33 | 34 | 35 | export ADDRESS=etcd0 36 | export NAME=etcd0 37 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | \ 38 | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | \ 39 | cfssljson -bare $NAME 40 | 41 | 42 | export ADDRESS=etcd1 43 | export NAME=etcd1 44 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | \ 45 | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | \ 46 | cfssljson -bare $NAME 47 | 48 | 49 | export ADDRESS=etcd2 50 | export NAME=etcd2 51 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | \ 52 | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | \ 53 | cfssljson -bare $NAME 54 | 55 | export ADDRESS= 56 | export NAME=client 57 | echo '{"CN":"'$NAME'","hosts":[""],"key":{"algo":"rsa","size":2048}}' | \ 58 | cfssl gencert -config=ca-config.json -ca=ca.pem -ca-key=ca-key.pem -hostname="$ADDRESS" - | \ 59 | cfssljson -bare $NAME 60 | -------------------------------------------------------------------------------- /jetcd-ctl/README.md: -------------------------------------------------------------------------------- 1 | ### jetcd-ctl 2 | 3 | Download and start an etcd node from [instruction](https://github.com/etcd-io/etcd/releases/latest) 4 | 5 | Put `foo` `bar` into the cluster: 6 | 7 | ```bash 8 | $ gradle run --args="put foo bar" 9 | 21:39:06.126|INFO |CommandPut - OK 10 | ``` 11 | 12 | Put `foo` `bar2` into the cluster: 13 | 14 | ```bash 15 | $ gradle run --args="put foo bar2" 16 | 21:39:06.126|INFO |CommandPut - OK 17 | ``` 18 | 19 | Get the key `foo`: 20 | 21 | ```bash 22 | $ gradle run --args="get foo" 23 | 21:41:00.265|INFO |CommandGet - foo 24 | 21:41:00.267|INFO |CommandGet - bar2 25 | ``` 26 | 27 | Get the key `foo` at etcd revision 2: 28 | 29 | ```bash 30 | $ gradle run --args="get foo --rev=2" 31 | 21:42:03.371|INFO |CommandGet - foo 32 | 21:42:03.373|INFO |CommandGet - bar 33 | ``` 34 | 35 | Watch `foo` since revision 2: 36 | 37 | ```bash 38 | $ gradle run --args="watch foo --rev=2" 39 | 21:35:09.162|INFO |CommandWatch - type=PUT, key=foo, value=bar 40 | 21:35:09.164|INFO |CommandWatch - type=PUT, key=foo, value=bar2 41 | ``` 42 | -------------------------------------------------------------------------------- /jetcd-ctl/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2023 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id "application" 19 | 20 | alias(libs.plugins.shadow) 21 | } 22 | 23 | project.tasks.publish.enabled = false 24 | 25 | dependencies { 26 | implementation project(':jetcd-core') 27 | implementation libs.picocli 28 | 29 | runtimeOnly libs.bundles.log4j 30 | } 31 | 32 | // disable standard jar task so we can have a single uber jar as result 33 | jar.enabled = false 34 | 35 | shadowJar { 36 | archiveBaseName.set('jetcdctl') 37 | archiveClassifier.set('') 38 | archiveVersion.set('') 39 | 40 | mergeServiceFiles() 41 | } 42 | 43 | application { 44 | mainClass = 'io.etcd.jetcd.examples.ctl.Main' 45 | } 46 | -------------------------------------------------------------------------------- /jetcd-ctl/src/main/java/io/etcd/jetcd/examples/ctl/CommandGet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.examples.ctl; 18 | 19 | import java.nio.charset.StandardCharsets; 20 | 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import io.etcd.jetcd.ByteSequence; 25 | import io.etcd.jetcd.Client; 26 | import io.etcd.jetcd.kv.GetResponse; 27 | import io.etcd.jetcd.options.GetOption; 28 | 29 | import picocli.CommandLine; 30 | 31 | @CommandLine.Command(name = "get", description = "Gets the key") 32 | class CommandGet implements Runnable { 33 | private static final Logger LOGGER = LoggerFactory.getLogger(CommandGet.class); 34 | 35 | @CommandLine.ParentCommand 36 | Main main; 37 | 38 | @CommandLine.Parameters(index = "0", arity = "1", description = "key") 39 | String key; 40 | 41 | @CommandLine.Option(names = "--rev", description = "Revision to start watching", defaultValue = "0") 42 | Long rev; 43 | 44 | @Override 45 | public void run() { 46 | try (Client client = Client.builder().endpoints(main.endpoints).build()) { 47 | GetResponse getResponse = client.getKVClient().get( 48 | ByteSequence.from(key, StandardCharsets.UTF_8), 49 | GetOption.builder().withRevision(rev).build()).get(); 50 | 51 | if (getResponse.getKvs().isEmpty()) { 52 | // key does not exist 53 | return; 54 | } 55 | 56 | LOGGER.info(key); 57 | LOGGER.info(getResponse.getKvs().get(0).getValue().toString(StandardCharsets.UTF_8)); 58 | } catch (Exception e) { 59 | LOGGER.warn(e.getMessage()); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /jetcd-ctl/src/main/java/io/etcd/jetcd/examples/ctl/CommandPut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.examples.ctl; 18 | 19 | import java.nio.charset.StandardCharsets; 20 | 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import io.etcd.jetcd.ByteSequence; 25 | import io.etcd.jetcd.Client; 26 | 27 | import picocli.CommandLine; 28 | 29 | @CommandLine.Command(name = "put", description = "Puts the given key into the store") 30 | class CommandPut implements Runnable { 31 | private static final Logger LOGGER = LoggerFactory.getLogger(CommandPut.class); 32 | 33 | @CommandLine.ParentCommand 34 | Main main; 35 | 36 | @CommandLine.Parameters(index = "0", arity = "1", description = "key") 37 | String key; 38 | @CommandLine.Parameters(index = "1", arity = "1", description = "value") 39 | String val; 40 | 41 | @Override 42 | public void run() { 43 | try (Client client = Client.builder().endpoints(main.endpoints).build()) { 44 | client.getKVClient().put( 45 | ByteSequence.from(key, StandardCharsets.UTF_8), 46 | ByteSequence.from(val, StandardCharsets.UTF_8)).get(); 47 | 48 | LOGGER.info("OK"); 49 | } catch (Exception e) { 50 | LOGGER.warn(e.getMessage()); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jetcd-ctl/src/main/java/io/etcd/jetcd/examples/ctl/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.examples.ctl; 18 | 19 | import picocli.CommandLine; 20 | 21 | @CommandLine.Command(name = "jetcdctl", version = "1.0", mixinStandardHelpOptions = true, subcommands = { 22 | CommandWatch.class, 23 | CommandGet.class, 24 | CommandPut.class 25 | }) 26 | public class Main implements Runnable { 27 | @CommandLine.Option(names = { "--endpoints" }, description = "gRPC endpoints", defaultValue = "http://127.0.0.1:2379") 28 | String endpoints; 29 | 30 | @Override 31 | public void run() { 32 | } 33 | 34 | public static void main(String[] args) { 35 | int exitCode = new CommandLine(new Main()).execute(args); 36 | System.exit(exitCode); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jetcd-ctl/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /jetcd-grpc/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | alias(libs.plugins.protobuf) 19 | } 20 | 21 | dependencies { 22 | api libs.slf4j 23 | api libs.vertxGrpc 24 | api libs.bundles.grpc 25 | api libs.bundles.javax 26 | } 27 | 28 | protobuf { 29 | protoc { 30 | artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}" 31 | } 32 | plugins { 33 | grpc { 34 | artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.grpc.get()}" 35 | } 36 | vertx { 37 | artifact = "io.vertx:vertx-grpc-protoc-plugin:${libs.versions.vertx.get()}" 38 | } 39 | } 40 | generateProtoTasks { 41 | all()*.plugins { 42 | grpc 43 | vertx 44 | } 45 | } 46 | } 47 | 48 | //sourceSets { 49 | // main { 50 | // java { 51 | // srcDirs "${projectDir}/build/generated/source/proto/main/java" 52 | // srcDirs "${projectDir}/build/generated/source/proto/main/grpc" 53 | // srcDirs "${projectDir}/build/generated/source/proto/main/vertx" 54 | // } 55 | // } 56 | //} 57 | -------------------------------------------------------------------------------- /jetcd-grpc/src/main/proto/auth.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2021 The jetcd authors 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package authpb; 20 | 21 | option java_multiple_files = true; 22 | option java_package = "io.etcd.jetcd.api"; 23 | 24 | // User is a single entry in the bucket authUsers 25 | message User { 26 | bytes name = 1; 27 | bytes password = 2; 28 | repeated string roles = 3; 29 | } 30 | 31 | // Permission is a single entity 32 | message Permission { 33 | enum Type { 34 | READ = 0; 35 | WRITE = 1; 36 | READWRITE = 2; 37 | } 38 | Type permType = 1; 39 | 40 | bytes key = 2; 41 | bytes range_end = 3; 42 | } 43 | 44 | // Role is a single entry in the bucket authRoles 45 | message Role { 46 | bytes name = 1; 47 | 48 | repeated Permission keyPermission = 2; 49 | } 50 | -------------------------------------------------------------------------------- /jetcd-grpc/src/main/proto/kv.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016-2021 The jetcd authors 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | syntax = "proto3"; 18 | 19 | package mvccpb; 20 | 21 | option java_multiple_files = true; 22 | option java_package = "io.etcd.jetcd.api"; 23 | 24 | message KeyValue { 25 | // key is the key in bytes. An empty key is not allowed. 26 | bytes key = 1; 27 | // create_revision is the revision of last creation on this key. 28 | int64 create_revision = 2; 29 | // mod_revision is the revision of last modification on this key. 30 | int64 mod_revision = 3; 31 | // version is the version of the key. A deletion resets 32 | // the version to zero and any modification of the key 33 | // increases its version. 34 | int64 version = 4; 35 | // value is the value held by the key, in bytes. 36 | bytes value = 5; 37 | // lease is the ID of the lease that attached to key. 38 | // When the attached lease expires, the key will be deleted. 39 | // If lease is 0, then no lease is attached to the key. 40 | int64 lease = 6; 41 | } 42 | 43 | message Event { 44 | enum EventType { 45 | PUT = 0; 46 | DELETE = 1; 47 | } 48 | // type is the kind of event. If type is a PUT, it indicates 49 | // new data has been stored to the key. If type is a DELETE, 50 | // it indicates the key was deleted. 51 | EventType type = 1; 52 | // kv holds the KeyValue for the event. 53 | // A PUT event contains current kv pair. 54 | // A PUT event with kv.Version=1 indicates the creation of a key. 55 | // A DELETE/EXPIRE event contains the deleted key with 56 | // its modification revision set to the revision of deletion. 57 | KeyValue kv = 2; 58 | 59 | // prev_kv holds the key-value pair before the event happens. 60 | KeyValue prev_kv = 3; 61 | } 62 | -------------------------------------------------------------------------------- /jetcd-launcher/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | api libs.slf4j 19 | api libs.guava 20 | api libs.commonsCompress 21 | api libs.testcontainers 22 | 23 | testImplementation libs.awaitility 24 | testImplementation libs.commonsIo 25 | testImplementation libs.bundles.testing 26 | 27 | testRuntimeOnly libs.bundles.log4j 28 | } 29 | -------------------------------------------------------------------------------- /jetcd-launcher/src/main/java/io/etcd/jetcd/launcher/EtcdCluster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.launcher; 18 | 19 | import java.net.URI; 20 | import java.util.List; 21 | import java.util.concurrent.TimeUnit; 22 | 23 | import org.testcontainers.lifecycle.Startable; 24 | 25 | public interface EtcdCluster extends Startable { 26 | 27 | default void restart(long delay, TimeUnit unit) throws InterruptedException { 28 | stop(); 29 | 30 | if (delay > 0) { 31 | unit.sleep(delay); 32 | } 33 | 34 | start(); 35 | } 36 | 37 | String clusterName(); 38 | 39 | List clientEndpoints(); 40 | 41 | List peerEndpoints(); 42 | 43 | List containers(); 44 | } 45 | -------------------------------------------------------------------------------- /jetcd-launcher/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /jetcd-test/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | dependencies { 18 | api project(':jetcd-api') 19 | api project(':jetcd-launcher') 20 | 21 | api libs.slf4j 22 | api libs.guava 23 | api libs.bundles.grpc 24 | api libs.bundles.grpcTest 25 | 26 | api libs.junit 27 | api libs.autoServiceAnnotations 28 | 29 | annotationProcessor libs.autoServiceProcessor 30 | 31 | testRuntimeOnly libs.bundles.log4j 32 | } 33 | -------------------------------------------------------------------------------- /jetcd-test/src/main/java/io/etcd/jetcd/test/EtcdClusterResolverProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.etcd.jetcd.test; 18 | 19 | import java.net.URI; 20 | 21 | import io.grpc.NameResolver; 22 | import io.grpc.NameResolverProvider; 23 | 24 | import com.google.auto.service.AutoService; 25 | 26 | @AutoService(NameResolverProvider.class) 27 | public class EtcdClusterResolverProvider extends NameResolverProvider { 28 | @Override 29 | protected boolean isAvailable() { 30 | return true; 31 | } 32 | 33 | @Override 34 | protected int priority() { 35 | return 6; 36 | } 37 | 38 | @Override 39 | public String getDefaultScheme() { 40 | return EtcdClusterNameResolver.SCHEME; 41 | } 42 | 43 | @Override 44 | public NameResolver newNameResolver(URI targetUri, NameResolver.Args args) { 45 | return EtcdClusterNameResolver.SCHEME.equals(targetUri.getScheme()) 46 | ? new EtcdClusterNameResolver(targetUri) 47 | : null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2021 The jetcd authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | rootProject.name = "jetcd" 18 | 19 | // modules 20 | include ':jetcd-grpc' 21 | include ':jetcd-api' 22 | include ':jetcd-common' 23 | include ':jetcd-launcher' 24 | include ':jetcd-test' 25 | include ':jetcd-core' 26 | include ':jetcd-ctl' 27 | --------------------------------------------------------------------------------