You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/05/21 15:33:25 UTC
[GitHub] [servicecomb-java-chassis] jungan21 opened a new pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
jungan21 opened a new pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769
Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
---
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r429002182
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,32 +53,36 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
- ServerUtil.init();
- ClientUtil.init();
-
- try {
- this.multicastSocket = new MulticastSocket();
- } catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
- }
-
- Function<ServiceRegistry, ServiceRegistryClient> registryClientConstructor =
- serviceRegistry -> new ZeroConfigRegistryClientImpl(new ZeroConfigRegistryService(),
- multicastSocket, new RestTemplate());
-
- ServiceRegistryConfig.INSTANCE.setServiceRegistryClientConstructor(registryClientConstructor);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
Review comment:
I see. let me change default value to true
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428830667
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,24 +52,23 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
+
+ if (enable) {
ServerUtil.init();
ClientUtil.init();
try {
this.multicastSocket = new MulticastSocket();
} catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
+ LOGGER.error("Failed to create MulticastSocket object", e);
Review comment:
agreed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428833396
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,24 +52,23 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
+
+ if (enable) {
Review comment:
agreed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] coveralls commented on pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#issuecomment-632182070
[](https://coveralls.io/builds/30948222)
Coverage increased (+0.008%) to 84.62% when pulling **c8a47d13c47afc1084e703cc5dde706c773579dc on jungan21:master** into **b78c6671f61b2c2e5515bd15548a7a674ecaf58f on apache:master**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#issuecomment-632182070
[](https://coveralls.io/builds/30952570)
Coverage decreased (-0.01%) to 84.602% when pulling **e40a463c5264bb5c74ec03236faec9278f05fc64 on jungan21:master** into **b78c6671f61b2c2e5515bd15548a7a674ecaf58f on apache:master**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#issuecomment-632182070
[](https://coveralls.io/builds/30960030)
Coverage increased (+0.003%) to 84.615% when pulling **bf47d27eb229a16e2700246783223b56fc1b1356 on jungan21:master** into **b78c6671f61b2c2e5515bd15548a7a674ecaf58f on apache:master**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
liubao68 merged pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] wujimin commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
wujimin commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428802019
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,24 +52,23 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
+
+ if (enable) {
Review comment:
better to be: not enabled then return
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428996111
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,32 +53,36 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
- ServerUtil.init();
- ClientUtil.init();
-
- try {
- this.multicastSocket = new MulticastSocket();
- } catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
- }
-
- Function<ServiceRegistry, ServiceRegistryClient> registryClientConstructor =
- serviceRegistry -> new ZeroConfigRegistryClientImpl(new ZeroConfigRegistryService(),
- multicastSocket, new RestTemplate());
-
- ServiceRegistryConfig.INSTANCE.setServiceRegistryClientConstructor(registryClientConstructor);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
Review comment:
I think default value to 'true' is better. Because when users use zeroconfig, they have to add pom dependency implicitly. It is false when zeroconfig module is not included. I set 'local/service center' default to 'true'. see https://github.com/apache/servicecomb-java-chassis/blob/master/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] wujimin commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
wujimin commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428802763
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,24 +52,23 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
+
+ if (enable) {
ServerUtil.init();
ClientUtil.init();
try {
this.multicastSocket = new MulticastSocket();
} catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
+ LOGGER.error("Failed to create MulticastSocket object", e);
Review comment:
better to throw exception and prevent bootup
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428996111
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,32 +53,36 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
- ServerUtil.init();
- ClientUtil.init();
-
- try {
- this.multicastSocket = new MulticastSocket();
- } catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
- }
-
- Function<ServiceRegistry, ServiceRegistryClient> registryClientConstructor =
- serviceRegistry -> new ZeroConfigRegistryClientImpl(new ZeroConfigRegistryService(),
- multicastSocket, new RestTemplate());
-
- ServiceRegistryConfig.INSTANCE.setServiceRegistryClientConstructor(registryClientConstructor);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
Review comment:
I think default value to 'true' is better. Because when users use zeroconfig, they have to add pom dependency implicitly. It is falst when zeroconfig module is not included. I set 'local/service center' default to 'true'. see https://github.com/apache/servicecomb-java-chassis/blob/master/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1769: [SCB-1922]Use DynamicPropertyFacotry way to read environment variables
Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1769:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1769#discussion_r428996111
##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/ZeroConfigRegistryApplicationListener.java
##########
@@ -52,32 +53,36 @@
private static final Logger LOGGER = LoggerFactory
.getLogger(ZeroConfigRegistryApplicationListener.class);
- private ApplicationContext applicationContext;
private MulticastSocket multicastSocket;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// same mechanism as Local registry to enable the Zero Config registry
- String flag = System.getProperty(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_FLAG);
- if (flag != null && flag.equals(ZeroConfigRegistryConstants.ZERO_CONFIG_REGISTRY_ENABLE_FLAG)) {
- this.applicationContext = applicationContext;
- BeanUtils.setContext(applicationContext);
- ServerUtil.init();
- ClientUtil.init();
-
- try {
- this.multicastSocket = new MulticastSocket();
- } catch (IOException e) {
- LOGGER.error("Failed create MulticastSocket object", e);
- }
-
- Function<ServiceRegistry, ServiceRegistryClient> registryClientConstructor =
- serviceRegistry -> new ZeroConfigRegistryClientImpl(new ZeroConfigRegistryService(),
- multicastSocket, new RestTemplate());
-
- ServiceRegistryConfig.INSTANCE.setServiceRegistryClientConstructor(registryClientConstructor);
+ boolean enable = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.zeroconfig.enabled", false).get();
Review comment:
I think default value to 'true' is better. Because when users use zeroconfig, they have to add pom dependency implicitly. It is false when zeroconfig module is not included. I set 'local/service center' default to 'true'. see https://github.com/apache/servicecomb-java-chassis/blob/master/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
and this is [documents in progress](https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/upgrading/2_0_1T2_1_0/)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org