[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-04-08 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429696#comment-16429696
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 closed pull request #630: [SCB-444]try to optimize autoDiscovery 
function
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/630
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
index b3bb4617d..0d5db0a6b 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
@@ -50,6 +50,12 @@
 
   private boolean autoDiscoveryInited = false;
 
+  private int maxRetryTimes;
+
+  public int getMaxRetryTimes() {
+return maxRetryTimes;
+  }
+
   public IpPortManager(ServiceRegistryConfig serviceRegistryConfig, 
InstanceCacheManager instanceCacheManager) {
 this.serviceRegistryConfig = serviceRegistryConfig;
 this.instanceCacheManager = instanceCacheManager;
@@ -61,6 +67,7 @@ public IpPortManager(ServiceRegistryConfig 
serviceRegistryConfig, InstanceCacheM
 }
 int initialIndex = new Random().nextInt(defaultIpPort.size());
 currentAvailableIndex = new AtomicInteger(initialIndex);
+maxRetryTimes = defaultIpPort.size();
   }
 
   // we have to do this operation after the first time setup has already done
@@ -98,6 +105,7 @@ private IpPort getAvailableAddress(int index) {
   currentAvailableIndex.set(0);
   return defaultIpPort.get(0);
 }
+maxRetryTimes = defaultIpPort.size() + endpoints.size();
 CacheEndpoint nextEndpoint = endpoints.get(index - defaultIpPort.size());
 return new URIEndpointObject(nextEndpoint.getEndpoint());
   }
diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
index dbc5e5581..91c858da6 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
@@ -33,8 +33,7 @@
 
   private RequestParam params;
 
-  // we can set max retry policies, now only try it twice
-  private boolean retry;
+  private int retryTimes = 0;
 
   public IpPort getIpPort() {
 return ipPort;
@@ -68,11 +67,12 @@ public void setParams(RequestParam params) {
 this.params = params;
   }
 
-  public boolean isRetry() {
-return retry;
+
+  public int getRetryTimes() {
+return retryTimes;
   }
 
-  public void setRetry(boolean retry) {
-this.retry = retry;
+  public void incrementRetryTimes() {
+++this.retryTimes;
   }
 }
diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
index ab7f59751..6173a1725 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
@@ -85,7 +85,7 @@ public void init() {
   private void retry(RequestContext requestContext, Handler 
responseHandler) {
 LOGGER.warn("invoke service [{}] failed, retry.", requestContext.getUri());
 
requestContext.setIpPort(ipPortManager.getNextAvailableAddress(requestContext.getIpPort()));
-requestContext.setRetry(true);
+requestContext.incrementRetryTimes();
 RestUtils.httpDo(requestContext, responseHandler);
   }
 
@@ -98,7 +98,7 @@ private void retry(RequestContext requestContext, 
Handler response
   HttpClientResponse response = restResponse.getResponse();
   if (response == null) {
 // 请求失败,触发请求SC的其他实例
-if (!requestContext.isRetry()) {
+if (requestContext.getRetryTimes() <= 
ipPortManager.getMaxRetryTimes()) {
   retry(requestContext, syncHandler(countDownLatch, cls, holder));
 } else {
   countDownLatch.countDown();
@@ -150,7 +150,7 @@ private void retry(RequestContext requestContext, 
Handler response
   HttpClientResponse response = restResponse.getResponse();
   if (response == null) {
 // 请求失败,触发请求SC的其他实例
-if (!requestContext.isRetry()) {
+if (

[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-04-01 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421885#comment-16421885
 ] 

ASF GitHub Bot commented on SCB-444:


yangbor commented on a change in pull request #630: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/630#discussion_r178479546
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 ##
 @@ -98,7 +98,7 @@ private void retry(RequestContext requestContext, 
Handler response
   HttpClientResponse response = restResponse.getResponse();
 
 Review comment:
   Duplicated code piece for retry, extract it as a method.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-31 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421254#comment-16421254
 ] 

ASF GitHub Bot commented on SCB-444:


mt-monster commented on a change in pull request #630: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/630#discussion_r178427894
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 ##
 @@ -50,6 +50,12 @@
 
   private boolean autoDiscoveryInited = false;
 
+  private int maxRetryTimes;
+
+  public int getMaxRetryTimes() {
+return maxRetryTimes;
 
 Review comment:
   no need ,already retry twice


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-31 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421229#comment-16421229
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #630: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/630#discussion_r178426930
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 ##
 @@ -50,6 +50,12 @@
 
   private boolean autoDiscoveryInited = false;
 
+  private int maxRetryTimes;
+
+  public int getMaxRetryTimes() {
+return maxRetryTimes;
 
 Review comment:
   Maybe maxRetryTimes should be bigger than 2. Return Max(maxRestryTime, 2)?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-31 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421220#comment-16421220
 ] 

ASF GitHub Bot commented on SCB-444:


coveralls commented on issue #630: [SCB-444]try to optimize autoDiscovery 
function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/630#issuecomment-377676963
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/16276805/badge)](https://coveralls.io/builds/16276805)
   
   Coverage increased (+0.02%) to 87.533% when pulling 
**6d7296cb1a7114d69f8f15577609406c09fdac0b on mt-monster:master** into 
**ced8fad2031e37af2b0e88548b438f66e486c2f0 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-31 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421210#comment-16421210
 ] 

ASF GitHub Bot commented on SCB-444:


mt-monster opened a new pull request #630: [SCB-444]try to optimize 
autoDiscovery function
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/630
 
 
   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` 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).
   
   ---
   
![default](https://user-images.githubusercontent.com/26559162/38161190-a5bcf4c4-34fc-11e8-961f-93fe2d9943ae.PNG)
   
   This PR is intend to optimize autoDiscovery function. as we know ,now we use 
retry at the first time sdk fail to register sc . when deployed in multi sc ( 
more than one sc instance ) enviroment , one sc instance breakup, this stategy 
exhausts lot of time to switch ip to next one , so i think it better to retry 
all the loop-ips in enviroment so that sdk can meet the health sc intance.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421168#comment-16421168
 ] 

ASF GitHub Bot commented on SCB-444:


coveralls commented on issue #625: [SCB-444]try to optimize autoDiscovery 
function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#issuecomment-377441310
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/16275715/badge)](https://coveralls.io/builds/16275715)
   
   Coverage increased (+0.04%) to 87.443% when pulling 
**2a3bc6a9a742500e8512ad7302053898e98c04ee on mt-monster:master** into 
**ae28a9faff24e773520f3452dfd80b86dfbe7aa4 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421162#comment-16421162
 ] 

ASF GitHub Bot commented on SCB-444:


mt-monster closed pull request #625: [SCB-444]try to optimize autoDiscovery 
function
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/625
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
index b3bb4617d..6b6ef39e1 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
@@ -50,6 +50,12 @@
 
   private boolean autoDiscoveryInited = false;
 
+  private int maxRetryTimes;
+
+  public int getMaxRetryTimes() {
+return maxRetryTimes;
+  }
+
   public IpPortManager(ServiceRegistryConfig serviceRegistryConfig, 
InstanceCacheManager instanceCacheManager) {
 this.serviceRegistryConfig = serviceRegistryConfig;
 this.instanceCacheManager = instanceCacheManager;
@@ -61,6 +67,7 @@ public IpPortManager(ServiceRegistryConfig 
serviceRegistryConfig, InstanceCacheM
 }
 int initialIndex = new Random().nextInt(defaultIpPort.size());
 currentAvailableIndex = new AtomicInteger(initialIndex);
+maxRetryTimes = defaultIpPort.size() + (getDiscoveredIpPort() == null ? 0 
: getDiscoveredIpPort().size());
   }
 
   // we have to do this operation after the first time setup has already done
diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
index dbc5e5581..91c858da6 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
@@ -33,8 +33,7 @@
 
   private RequestParam params;
 
-  // we can set max retry policies, now only try it twice
-  private boolean retry;
+  private int retryTimes = 0;
 
   public IpPort getIpPort() {
 return ipPort;
@@ -68,11 +67,12 @@ public void setParams(RequestParam params) {
 this.params = params;
   }
 
-  public boolean isRetry() {
-return retry;
+
+  public int getRetryTimes() {
+return retryTimes;
   }
 
-  public void setRetry(boolean retry) {
-this.retry = retry;
+  public void incrementRetryTimes() {
+++this.retryTimes;
   }
 }
diff --git 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
index ab7f59751..6173a1725 100644
--- 
a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
+++ 
b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
@@ -85,7 +85,7 @@ public void init() {
   private void retry(RequestContext requestContext, Handler 
responseHandler) {
 LOGGER.warn("invoke service [{}] failed, retry.", requestContext.getUri());
 
requestContext.setIpPort(ipPortManager.getNextAvailableAddress(requestContext.getIpPort()));
-requestContext.setRetry(true);
+requestContext.incrementRetryTimes();
 RestUtils.httpDo(requestContext, responseHandler);
   }
 
@@ -98,7 +98,7 @@ private void retry(RequestContext requestContext, 
Handler response
   HttpClientResponse response = restResponse.getResponse();
   if (response == null) {
 // 请求失败,触发请求SC的其他实例
-if (!requestContext.isRetry()) {
+if (requestContext.getRetryTimes() <= 
ipPortManager.getMaxRetryTimes()) {
   retry(requestContext, syncHandler(countDownLatch, cls, holder));
 } else {
   countDownLatch.countDown();
@@ -150,7 +150,7 @@ private void retry(RequestContext requestContext, 
Handler response
   HttpClientResponse response = restResponse.getResponse();
   if (response == null) {
 // 请求失败,触发请求SC的其他实例
-if (!requestContext.isRetry()) {
+if (requestContext.getRetryTimes() <= 
ipPortManager.getMaxRetryTimes()) {
   retry(requestContext, syncHandlerEx(countDownLatch, holder));
 } else {
   countDownLatch.countDown();
@@ -176,7 +176,7 @@ private void retry(RequestContext requestContext, 
Handler resp

[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421121#comment-16421121
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178417055
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 ##
 @@ -61,6 +67,7 @@ public IpPortManager(ServiceRegistryConfig 
serviceRegistryConfig, InstanceCacheM
 }
 int initialIndex = new Random().nextInt(defaultIpPort.size());
 currentAvailableIndex = new AtomicInteger(initialIndex);
+maxRetryTimes = defaultIpPort.size() + (getDiscoveredIpPort() == null ? 0 
: getDiscoveredIpPort().size());
 
 Review comment:
   This code is not correct. maxRetryTimes is dynamically change and you can 
not getDiscoveryIpPort when initialize IpPortManager


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421120#comment-16421120
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178416880
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 ##
 @@ -85,7 +85,7 @@ public void init() {
   private void retry(RequestContext requestContext, Handler 
responseHandler) {
 LOGGER.warn("invoke service [{}] failed, retry.", requestContext.getUri());
 
requestContext.setIpPort(ipPortManager.getNextAvailableAddress(requestContext.getIpPort()));
-requestContext.setRetry(true);
+requestContext.incrementRetryTimes(requestContext.getRetryTimes());
 
 Review comment:
   See comments above, this code is quite bad, difficult to understand


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16421119#comment-16421119
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178416755
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
 ##
 @@ -68,11 +67,12 @@ public void setParams(RequestParam params) {
 this.params = params;
   }
 
-  public boolean isRetry() {
-return retry;
+
+  public int getRetryTimes() {
+return retryTimes;
   }
 
-  public void setRetry(boolean retry) {
-this.retry = retry;
+  public void incrementRetryTimes(int retryTimes) {
+this.retryTimes = retryTimes + 1;
 
 Review comment:
   ++this.retryTimes is more simple, and you do not need a input parameter


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420360#comment-16420360
 ] 

ASF GitHub Bot commented on SCB-444:


coveralls commented on issue #625: [SCB-444]try to optimize autoDiscovery 
function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#issuecomment-377441310
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/16263393/badge)](https://coveralls.io/builds/16263393)
   
   Coverage increased (+0.04%) to 87.443% when pulling 
**92ba39066246605f7da0b20b3929c9bd4920f613 on mt-monster:master** into 
**ae28a9faff24e773520f3452dfd80b86dfbe7aa4 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420293#comment-16420293
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178256282
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 ##
 @@ -50,6 +50,11 @@
 
   private boolean autoDiscoveryInited = false;
 
+  public int getMaxRetryTimes() {
+return currentAvailableIndex.get() < 2 ? 2 : currentAvailableIndex.get();
 
 Review comment:
   This logic is not correct. Assume current index is 2, and failed, index 
becomes 0. In this situation, only retried 2 and you expect 3 times


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-30 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420285#comment-16420285
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178255323
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
 ##
 @@ -68,11 +67,12 @@ public void setParams(RequestParam params) {
 this.params = params;
   }
 
-  public boolean isRetry() {
-return retry;
+
+  public int getRetryTimes() {
+return retryTimes;
   }
 
-  public void setRetry(boolean retry) {
-this.retry = retry;
+  public void setRetryTimes(int retryTimes) {
 
 Review comment:
   using a incrementRetryTimes makes logic simpler


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420213#comment-16420213
 ] 

ASF GitHub Bot commented on SCB-444:


mt-monster commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178240182
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 ##
 @@ -488,7 +488,7 @@ public HeartbeatResponse heartbeat(String microserviceId, 
String microserviceIns
 RestUtils.put(ipPort,
 String.format(Const.REGISTRY_API.MICROSERVICE_HEARTBEAT, 
microserviceId, microserviceInstanceId),
 new 
RequestParam().setTimeout(ServiceRegistryConfig.INSTANCE.getHeartBeatRequestTimeout()),
-syncHandler(countDownLatch, HttpClientResponse.class, holder));
+syncHandlerForHeartbeat(countDownLatch, HttpClientResponse.class, 
holder));
 
 Review comment:
   ok. i fix it 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420143#comment-16420143
 ] 

ASF GitHub Bot commented on SCB-444:


coveralls commented on issue #625: [SCB-444]try to optimize autoDiscovery 
function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#issuecomment-377441310
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/16260856/badge)](https://coveralls.io/builds/16260856)
   
   Coverage increased (+0.01%) to 87.413% when pulling 
**595db4046f2fbfb90b488fa1838c51550fe63c79 on mt-monster:master** into 
**ae28a9faff24e773520f3452dfd80b86dfbe7aa4 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420134#comment-16420134
 ] 

ASF GitHub Bot commented on SCB-444:


coveralls commented on issue #625: [SCB-444]try to optimize autoDiscovery 
function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#issuecomment-377441310
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/16260758/badge)](https://coveralls.io/builds/16260758)
   
   Coverage decreased (-0.1%) to 87.305% when pulling 
**595db4046f2fbfb90b488fa1838c51550fe63c79 on mt-monster:master** into 
**ae28a9faff24e773520f3452dfd80b86dfbe7aa4 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420059#comment-16420059
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178219957
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
 ##
 @@ -488,7 +488,7 @@ public HeartbeatResponse heartbeat(String microserviceId, 
String microserviceIns
 RestUtils.put(ipPort,
 String.format(Const.REGISTRY_API.MICROSERVICE_HEARTBEAT, 
microserviceId, microserviceInstanceId),
 new 
RequestParam().setTimeout(ServiceRegistryConfig.INSTANCE.getHeartBeatRequestTimeout()),
-syncHandler(countDownLatch, HttpClientResponse.class, holder));
+syncHandlerForHeartbeat(countDownLatch, HttpClientResponse.class, 
holder));
 
 Review comment:
   Do not duplicate this code as mentioned above. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420057#comment-16420057
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178219907
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/IpPortManager.java
 ##
 @@ -50,6 +50,10 @@
 
   private boolean autoDiscoveryInited = false;
 
+  public ArrayList getDefaultIpPort() {
+return defaultIpPort;
 
 Review comment:
   You can add a method such as getMaxRetryTimes based on available ips(not 
defaultIpPort), and minimum value is 2. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420056#comment-16420056
 ] 

ASF GitHub Bot commented on SCB-444:


liubao68 commented on a change in pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/625#discussion_r178219780
 
 

 ##
 File path: 
service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/RequestContext.java
 ##
 @@ -75,4 +77,12 @@ public boolean isRetry() {
   public void setRetry(boolean retry) {
 this.retry = retry;
   }
+
+  public int getRetryTimes() {
 
 Review comment:
   You can make this as a default retry mechanism, and remove setRetry. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-444) try to optimize autodiscovery function

2018-03-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/SCB-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16418333#comment-16418333
 ] 

ASF GitHub Bot commented on SCB-444:


mt-monster opened a new pull request #625: [SCB-444]try to optimize 
autoDiscovery function
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/625
 
 
   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` 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 PR is intend to optimize autoDiscovery function.  as we know ,now we 
use retry at the first time sdk fail to register sc . when deployed in multi sc 
( more than one sc instance ) enviroment , one sc instance breakup, this 
stategy exhausts lot of time to switch ip to next one , so  i think it better 
to retry  all the loop-ips in enviroment so that sdk can meet the health sc 
intance.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> try to optimize autodiscovery function
> --
>
> Key: SCB-444
> URL: https://issues.apache.org/jira/browse/SCB-444
> Project: Apache ServiceComb
>  Issue Type: Improvement
>  Components: Java-Chassis
>Affects Versions: java-chassis-1.0.0-m2
>Reporter: WeiChao
>Assignee: TaoMeng
>Priority: Minor
> Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)