Commit 8c155287 by huangfusuper

解决报错信息重复打印BUG

parent c9f2ff97
...@@ -59,9 +59,14 @@ public class RequestUtil { ...@@ -59,9 +59,14 @@ public class RequestUtil {
* @return 是否成功 * @return 是否成功
*/ */
public static boolean retryRpcHost(Client client, String host, String runKey, int retryTotalCount, int thisRetryCount) throws InterruptedException { public static boolean retryRpcHost(Client client, String host, String runKey, int retryTotalCount, int thisRetryCount) throws InterruptedException {
StringRedisTemplate stringRedisTemplate = RpcSpringUtil.getBean(StringRedisTemplate.class);
log.info("------当前rpc的请求的地址为:{}-------", host); log.info("------当前rpc的请求的地址为:{}-------", host);
try { try {
client.asyncSend(host, Beat.BEAT_PING); client.asyncSend(host, Beat.BEAT_PING);
String redisFormat = String.format("与执行服务器[%s]建立成功,总共重试%s次!", host, thisRetryCount - 1);
RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
log.info("------{}rpc通道建立成功,重试了{}次------", host, thisRetryCount - 1); log.info("------{}rpc通道建立成功,重试了{}次------", host, thisRetryCount - 1);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
...@@ -70,7 +75,6 @@ public class RequestUtil { ...@@ -70,7 +75,6 @@ public class RequestUtil {
String redisFormat = String.format("rpc通道[%s]建立时出现异常,开始第%s次重试!", host, thisRetryCount); String redisFormat = String.format("rpc通道[%s]建立时出现异常,开始第%s次重试!", host, thisRetryCount);
log.error("{},rpc通道建立时出现异常,异常信息为:{},开始第{}次重试!", host, RPCLogUtil.getMessage(e), thisRetryCount); log.error("{},rpc通道建立时出现异常,异常信息为:{},开始第{}次重试!", host, RPCLogUtil.getMessage(e), thisRetryCount);
StringRedisTemplate stringRedisTemplate = RpcSpringUtil.getBean(StringRedisTemplate.class);
RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build(); RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName)); stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
...@@ -80,7 +84,7 @@ public class RequestUtil { ...@@ -80,7 +84,7 @@ public class RequestUtil {
if (thisRetryCount == retryTotalCount) { if (thisRetryCount == retryTotalCount) {
String format = String.format("与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后", host, retryTotalCount); String format = String.format("与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后", host, retryTotalCount);
StringRedisTemplate stringRedisTemplate = RpcSpringUtil.getBean(StringRedisTemplate.class);
RunLog runLog = RunLog.builder().runLog(format).isEnd(false).build(); RunLog runLog = RunLog.builder().runLog(format).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName)); stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
......
...@@ -51,9 +51,14 @@ public class ClientRpcUtil { ...@@ -51,9 +51,14 @@ public class ClientRpcUtil {
* @return 是否成功 * @return 是否成功
*/ */
public static boolean retryRpcHost(PluginClient client, String host,String runKey, int retryTotalCount, int thisRetryCount) throws InterruptedException { public static boolean retryRpcHost(PluginClient client, String host,String runKey, int retryTotalCount, int thisRetryCount) throws InterruptedException {
//redis模板
StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
log.info("------当前plugin-rpc的请求的地址为:{}-------", host); log.info("------当前plugin-rpc的请求的地址为:{}-------", host);
try { try {
client.send(host, PluginBeat.PLUGIN_RPC_REQUEST_PACKET); client.send(host, PluginBeat.PLUGIN_RPC_REQUEST_PACKET);
String redisFormat = String.format("与执行服务器[%s]建立成功,总共重试%s次!", host, thisRetryCount - 1);
RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
log.info("------{}plugin-rpc通道建立成功,重试了{}次------", host, thisRetryCount - 1); log.info("------{}plugin-rpc通道建立成功,重试了{}次------", host, thisRetryCount - 1);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
...@@ -63,7 +68,6 @@ public class ClientRpcUtil { ...@@ -63,7 +68,6 @@ public class ClientRpcUtil {
String redisFormat = String.format("与执行服务器[%s]建立通道时出现异常,开始第%s次重试!", host, thisRetryCount); String redisFormat = String.format("与执行服务器[%s]建立通道时出现异常,开始第%s次重试!", host, thisRetryCount);
log.error(format); log.error(format);
//redis模板 //redis模板
StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build(); RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName)); stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
Thread.sleep(1000 * thisRetryCount); Thread.sleep(1000 * thisRetryCount);
...@@ -73,8 +77,7 @@ public class ClientRpcUtil { ...@@ -73,8 +77,7 @@ public class ClientRpcUtil {
if(thisRetryCount == retryTotalCount){ if(thisRetryCount == retryTotalCount){
String format = String.format("与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后", host, retryTotalCount); String format = String.format("与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后", host, retryTotalCount);
//redis模板
StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
RunLog runLog = RunLog.builder().runLog(format).isEnd(false).build(); RunLog runLog = RunLog.builder().runLog(format).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName)); stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment