提交 4b49f981 编写于 作者: 彭勇升 Buddha 提交者: GitHub

Merge pull request #484 from wu-sheng/feature/new-register-flow

Improve the register flow
...@@ -41,7 +41,7 @@ public class Config { ...@@ -41,7 +41,7 @@ public class Config {
/** /**
* application and service registry check interval * application and service registry check interval
*/ */
public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 10; public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 3;
/** /**
* discovery rest check interval * discovery rest check interval
*/ */
......
...@@ -87,7 +87,9 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList ...@@ -87,7 +87,9 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList
@Override @Override
public void run() { public void run() {
if (CONNECTED.equals(status)) { boolean shouldTry = true;
while (CONNECTED.equals(status) && shouldTry) {
shouldTry = false;
try { try {
if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) { if (RemoteDownstreamConfig.Agent.APPLICATION_ID == DictionaryUtil.nullValue()) {
if (applicationRegisterServiceBlockingStub != null) { if (applicationRegisterServiceBlockingStub != null) {
...@@ -95,6 +97,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList ...@@ -95,6 +97,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList
Application.newBuilder().addApplicationCode(Config.Agent.APPLICATION_CODE).build()); Application.newBuilder().addApplicationCode(Config.Agent.APPLICATION_CODE).build());
if (applicationMapping.getApplicationCount() > 0) { if (applicationMapping.getApplicationCount() > 0) {
RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication(0).getValue(); RemoteDownstreamConfig.Agent.APPLICATION_ID = applicationMapping.getApplication(0).getValue();
shouldTry = true;
} }
} }
} else { } else {
...@@ -119,6 +122,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList ...@@ -119,6 +122,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList
.setRegisterTime(System.currentTimeMillis()) .setRegisterTime(System.currentTimeMillis())
.setOsinfo(OSUtil.buildOSInfo()) .setOsinfo(OSUtil.buildOSInfo())
.build()); .build());
needRegisterRecover = false;
} else { } else {
if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) { if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) {
instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder() instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册