|
|
|
@ -20,7 +20,6 @@ package com.tencent.cloud.polaris.registry;
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import com.tencent.cloud.common.metadata.StaticMetadataManager;
|
|
|
|
|
import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
|
|
|
|
@ -42,6 +41,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.cloud.client.serviceregistry.Registration;
|
|
|
|
|
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
|
|
|
|
|
|
|
|
|
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
|
|
|
import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -53,8 +53,6 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisServiceRegistry.class);
|
|
|
|
|
|
|
|
|
|
private static final int TTL = 5;
|
|
|
|
|
|
|
|
|
|
private final PolarisDiscoveryProperties polarisDiscoveryProperties;
|
|
|
|
|
|
|
|
|
|
private final PolarisDiscoveryHandler polarisDiscoveryHandler;
|
|
|
|
@ -98,7 +96,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
|
|
|
|
|
instanceRegisterRequest.setZone(staticMetadataManager.getZone());
|
|
|
|
|
instanceRegisterRequest.setCampus(staticMetadataManager.getCampus());
|
|
|
|
|
if (null != heartbeatExecutor) {
|
|
|
|
|
instanceRegisterRequest.setTtl(TTL);
|
|
|
|
|
instanceRegisterRequest.setTtl(polarisDiscoveryProperties.getHeartbeatInterval());
|
|
|
|
|
}
|
|
|
|
|
instanceRegisterRequest.setMetadata(registration.getMetadata());
|
|
|
|
|
instanceRegisterRequest.setProtocol(polarisDiscoveryProperties.getProtocol());
|
|
|
|
@ -216,6 +214,6 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
LOGGER.error("polaris heartbeat runtime error", e);
|
|
|
|
|
}
|
|
|
|
|
}, TTL, TTL, TimeUnit.SECONDS);
|
|
|
|
|
}, polarisDiscoveryProperties.getHeartbeatInterval(), polarisDiscoveryProperties.getHeartbeatInterval(), MILLISECONDS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|