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

Improve the register flow
This commit is contained in:
彭勇升 Buddha 2017-10-08 22:24:32 +08:00 committed by GitHub
commit 4b49f98180
2 changed files with 6 additions and 2 deletions

View File

@ -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
*/

View File

@ -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 = false;
} else {
if (lastSegmentTime - System.currentTimeMillis() > 60 * 1000) {
instanceDiscoveryServiceBlockingStub.heartbeat(ApplicationInstanceHeartbeat.newBuilder()