-
Notifications
You must be signed in to change notification settings - Fork 828
[SCB-2892]add dynamic config for etcd #4595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
8abfdff
添加etcd注册发现代码,添加测试模块
SweetWuXiaoMei ee26b4c
feat(registry-etcd,demo-etcd): implement the basic discovery function…
93e4cc8
fix(registry-etcd,demo-etcd): complete etcd registry function
SweetWuXiaoMei af6a984
Merge branch 'apache:master' into dev_czd_etcd
SweetWuXiaoMei c31c000
fix(registry-etcd,demo-etcd): fix pr probleam
SweetWuXiaoMei 1cf63d2
Merge remote-tracking branch 'origin' into dev_czd_etcd
SweetWuXiaoMei 2c64e42
Merge remote-tracking branch 'origin/dev_czd_etcd' into dev_czd_etcd
SweetWuXiaoMei cf55f27
refactor(registry-etcd): Refactor the EtcdDiscovery class and update …
SweetWuXiaoMei fae1f3b
fix(registry-etcd): Support Etcd authentication and optimize the inst…
SweetWuXiaoMei 3686491
fix(provider): fix the content returned by sayHello interface
SweetWuXiaoMei 4915a8c
refactor(registry-etcd): Refactor the EtcdDiscovery class
SweetWuXiaoMei cc6c800
refactor(registry-etcd): Refactor the EtcdDiscovery class and update …
SweetWuXiaoMei 0cdcbca
restore runnable version
SweetWuXiaoMei 2c06dc9
feat(config): Add etcd configuration support
SweetWuXiaoMei 323495a
Merge branch 'master' into dev_czd_etcd
SweetWuXiaoMei 19d612f
Removed redundant annotations in MuteExceptionUtil Removed redundant …
SweetWuXiaoMei ce033dc
refactor:delete unused {}
SweetWuXiaoMei e7c3970
refactor:restore protobuf version
SweetWuXiaoMei 6ce7fc3
refactor:support arm architecter
SweetWuXiaoMei ff0fe3c
build(docker): restore openjdk:17-alpine
SweetWuXiaoMei b4f8c56
test(etcd): add log and remove test
SweetWuXiaoMei 39e9873
test(etcd): test whether location is etcd
SweetWuXiaoMei af2cda2
test(etcd): test
SweetWuXiaoMei 003bf61
test(etcd): test
SweetWuXiaoMei cb3912b
test(etcd): test
SweetWuXiaoMei cd55528
test(demo-etcd): Update the test case to verify the source of the con…
SweetWuXiaoMei e099d8d
fix(config-etcd): Fix configuration update exception information
SweetWuXiaoMei 3120ae0
refactor(registry-etcd): Refactor the EtcdDiscovery class and add asy…
SweetWuXiaoMei d09eb57
feat(config-etcd): Add configuration parameters and optimize the Etcd…
SweetWuXiaoMei 9ab3442
refactor(config-etcd): Remove the unused Charset import package. The …
SweetWuXiaoMei 13c8de0
fix(service-registry): Fix etcd service version acquisition problem
SweetWuXiaoMei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
demo/demo-etcd/test-client/src/main/java/org/apache/servicecomb/samples/EtcdConfigIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.servicecomb.samples; | ||
|
|
||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| import org.apache.servicecomb.demo.CategorizedTestCase; | ||
| import org.apache.servicecomb.demo.TestMgr; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.client.RestOperations; | ||
| import org.springframework.web.client.RestTemplate; | ||
|
|
||
| import io.etcd.jetcd.ByteSequence; | ||
| import io.etcd.jetcd.Client; | ||
|
|
||
| @Component | ||
| public class EtcdConfigIT implements CategorizedTestCase { | ||
| RestOperations template = new RestTemplate(); | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(EtcdConfigIT.class); | ||
|
|
||
| @Override | ||
| public void testRestTransport() throws Exception { | ||
|
|
||
| testEnvironment(); | ||
| testApplication(); | ||
| testService(); | ||
| testVersion(); | ||
| testTag(); | ||
| testOverride(); | ||
| } | ||
|
|
||
| private void testOverride() { | ||
|
|
||
| putValue("/servicecomb/config/environment/production/application2.properties", | ||
| "testValue=t1"); | ||
| putValue("/servicecomb/config/application/production/demo-etcd/application2.properties", | ||
| "testValue=t2"); | ||
| testGetConfig("testValue", "t2"); | ||
| putValue("/servicecomb/config/service/production/demo-etcd/provider/application2.properties", | ||
| "testValue=t3"); | ||
| testGetConfig("testValue", "t3"); | ||
| putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application2.properties", | ||
| "testValue=t4"); | ||
| testGetConfig("testValue", "t4"); | ||
| putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application2.properties", | ||
| "testValue=t5"); | ||
| testGetConfig("testValue", "t5"); | ||
| } | ||
|
|
||
| private void testEnvironment() { | ||
|
|
||
| putValue("/servicecomb/config/environment/production/application.properties", | ||
| "test1=env"); | ||
| putValue("/servicecomb/config/environment/production/application.properties", | ||
| "test1=env1"); | ||
| testGetConfig("test1", "env1"); | ||
| } | ||
|
|
||
| private void testApplication() { | ||
|
|
||
| putValue("/servicecomb/config/application/production/demo-etcd/application.properties", | ||
| "test2=applition"); | ||
| putValue("/servicecomb/config/application/production/demo-etcd/application.properties", | ||
| "test2=applition2"); | ||
| testGetConfig("test2", "applition2"); | ||
| } | ||
|
|
||
| private void testService() { | ||
|
|
||
| putValue("/servicecomb/config/service/production/demo-etcd/provider/application.properties", | ||
| "test3=service"); | ||
| putValue("/servicecomb/config/service/production/demo-etcd/provider/application.properties", | ||
| "test3=service3"); | ||
| testGetConfig("test3", "service3"); | ||
| } | ||
|
|
||
| private void testVersion() { | ||
|
|
||
| putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties", | ||
| "test3=version"); | ||
| putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties", | ||
| "test4=version4"); | ||
| testGetConfig("test4", "version4"); | ||
| } | ||
|
|
||
| private void testTag() { | ||
|
|
||
| putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application.properties", | ||
| "test5=tag"); | ||
| putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application.properties", | ||
| "test5=tag5"); | ||
| testGetConfig("test5", "tag5"); | ||
| } | ||
|
|
||
|
|
||
| public void putValue(String key, String value) { | ||
| try (Client client = Client.builder().endpoints("http://localhost:2379").build()) { | ||
|
|
||
| client.getKVClient().put( | ||
| ByteSequence.from(key, StandardCharsets.UTF_8), | ||
| ByteSequence.from(value, StandardCharsets.UTF_8) | ||
| ).get(); | ||
|
|
||
| LOGGER.info("Value set successfully"); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
|
|
||
| private void testGetConfig(String key, String expectValue) { | ||
|
|
||
| String result = template | ||
| .getForObject(Config.GATEWAY_URL + "/getConfig?key=" + key, String.class); | ||
| TestMgr.check(expectValue, result); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
| ~ contributor license agreements. See the NOTICE file distributed with | ||
| ~ this work for additional information regarding copyright ownership. | ||
| ~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| ~ (the "License"); you may not use this file except in compliance with | ||
| ~ the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, software | ||
| ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| ~ See the License for the specific language governing permissions and | ||
| ~ limitations under the License. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>dynamic-config</artifactId> | ||
| <groupId>org.apache.servicecomb</groupId> | ||
| <version>3.3.0-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <artifactId>config-etcd</artifactId> | ||
| <name>Java Chassis::Dynamic Config::Zookeeper</name> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.servicecomb</groupId> | ||
| <artifactId>foundation-config</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.servicecomb</groupId> | ||
| <artifactId>foundation-vertx</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.etcd</groupId> | ||
| <artifactId>jetcd-core</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test case for priority? e.g. service configuration override application configuration