liubao68 closed pull request #1005: [SCB-1038]Fix some bugs and logs
improvement reported by users when testing
URL: https://github.com/apache/servicecomb-java-chassis/pull/1005
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/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
index d36c55242..8547af52c 100644
---
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
+++
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
@@ -35,10 +35,10 @@
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.SCBEngine;
import org.apache.servicecomb.core.Transport;
-import org.apache.servicecomb.core.exception.ExceptionUtils;
import org.apache.servicecomb.core.provider.consumer.SyncResponseExecutor;
import org.apache.servicecomb.foundation.common.cache.VersionedCache;
import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
import org.apache.servicecomb.loadbalance.filter.ServerDiscoveryFilter;
import org.apache.servicecomb.serviceregistry.discovery.DiscoveryContext;
import org.apache.servicecomb.serviceregistry.discovery.DiscoveryFilter;
@@ -232,9 +232,7 @@ private void send(Invocation invocation, AsyncResponse
asyncResp, final LoadBala
long time = System.currentTimeMillis();
ServiceCombServer server = chosenLB.chooseServer(invocation);
if (null == server) {
-
asyncResp.consumerFail(ExceptionUtils.lbAddressNotFound(invocation.getMicroserviceName(),
- invocation.getMicroserviceVersionRule(),
- invocation.getConfigTransportName()));
+ asyncResp.consumerFail(new
InvocationException(Status.INTERNAL_SERVER_ERROR, "No available address
found."));
return;
}
chosenLB.getLoadBalancerStats().incrementNumRequests(server);
@@ -295,7 +293,7 @@ public void
onExceptionWithServer(ExecutionContext<Invocation> context, Throwabl
context.getRequest().getEndpoint(),
info.getNumberOfPastServersAttempted(),
info.getNumberOfPastAttemptsOnServer(),
- exception.getMessage());
+ ExceptionUtils.getExceptionMessageWithoutTrace(exception));
}
@Override
@@ -319,7 +317,7 @@ public void onExecutionSuccess(ExecutionContext<Invocation>
context, Response re
public void onExecutionFailed(ExecutionContext<Invocation> context,
Throwable finalException,
ExecutionInfo info) {
LOGGER.error("Invoke all server failed. Operation {}, e={}",
- context.getRequest().getInvocationQualifiedName(),
finalException.toString());
+ context.getRequest().getInvocationQualifiedName(),
ExceptionUtils.getExceptionMessageWithoutTrace(finalException));
if (orginExecutor != null) {
orginExecutor.execute(() -> {
fail(finalException);
@@ -366,7 +364,7 @@ private void fail(Throwable finalException) {
if (isFailedResponse(resp)) {
LOGGER.error("service {}, call error, msg is {}, server is {}
",
invocation.getInvocationQualifiedName(),
- ((Throwable) resp.getResult()).getMessage(),
+ ExceptionUtils.getExceptionMessageWithoutTrace((Throwable)
resp.getResult()),
s);
chosenLB.getLoadBalancerStats().incrementSuccessiveConnectionFailureCount(s);
ServiceCombLoadBalancerStats.INSTANCE.markFailure(server);
diff --git
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/SessionStickinessRule.java
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/SessionStickinessRule.java
index a489860ed..a854a831a 100644
---
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/SessionStickinessRule.java
+++
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/SessionStickinessRule.java
@@ -56,6 +56,7 @@ public SessionStickinessRule() {
}
public void setLoadBalancer(LoadBalancer loadBalancer) {
+ this.microserviceName = loadBalancer.getMicroServiceName();
this.loadBalancer = loadBalancer;
}
diff --git
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadbalanceHandler.java
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadbalanceHandler.java
index f7e263549..b20530dd4 100644
---
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadbalanceHandler.java
+++
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadbalanceHandler.java
@@ -165,10 +165,8 @@ public void send_noEndPoint(@Injectable LoadBalancer
loadBalancer) {
result.value = (Throwable) resp.getResult();
}, loadBalancer);
- Assert.assertEquals("InvocationException: code=490;msg=CommonExceptionData
[message=Cse Internal Bad Request]",
+ Assert.assertEquals("InvocationException: code=500;msg=CommonExceptionData
[message=No available address found.]",
result.value.getMessage());
- Assert.assertEquals("No available address found. microserviceName=ms,
version=null, discoveryGroupName=null",
- result.value.getCause().getMessage());
}
@Test
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services