提交 8d71daf5 编写于 作者: wu-sheng's avatar wu-sheng

Improve the register flow.

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