Commit 4fdf3519 by huangfusuper

修正NUM字段

parent da85a076
......@@ -9,6 +9,7 @@ import com.byit.rpc.remoting.invoker.route.LoadBalance;
import com.byit.rpc.util.RPCLogUtil;
import com.byit.rpc.util.RpcException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.TreeSet;
......@@ -31,7 +32,11 @@ public class ClientRpcUtil {
for (String ignored : address) {
String routeHost = loadBalance.rpcInvokerRouter.route(pluginRpcRequestPacket.getJobName(), address);
String extension = pluginRpcRequestPacket.getExtension();
String runKey = KeyUtil.generateRunKey(Integer.parseInt(extension));
String runKey = null;
if(StringUtils.isNoneBlank(extension)){
runKey = KeyUtil.generateRunKey(Integer.parseInt(extension));
}
boolean retryRpcHost = retryRpcHost(client, routeHost, runKey, 3, 1);
if (retryRpcHost) {
return routeHost;
......@@ -57,7 +62,9 @@ public class ClientRpcUtil {
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));
if (StringUtils.isNoneBlank(runKey)) {
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
}
log.info("------{}plugin-rpc通道建立成功,重试了{}次------", host, thisRetryCount - 1);
return true;
} catch (Exception e) {
......@@ -68,7 +75,10 @@ public class ClientRpcUtil {
log.error(format);
//redis模板
RunLog runLog = RunLog.builder().runLog(redisFormat).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
if (StringUtils.isNoneBlank(runKey)) {
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
}
Thread.sleep(1000 * thisRetryCount);
retryRpcHost(client, host,runKey, retryTotalCount, ++thisRetryCount);
}
......@@ -78,8 +88,9 @@ public class ClientRpcUtil {
String format = String.format("与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后", host, retryTotalCount);
RunLog runLog = RunLog.builder().runLog(format).isEnd(false).build();
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
if (StringUtils.isNoneBlank(runKey)) {
stringRedisTemplate.opsForList().rightPush(runKey, JSON.toJSONString(runLog, WriteClassName));
}
log.error(format);
}
return false;
......
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