feat: PolarisServiceRegistry#deregister support idempotency. (#1243)

pull/1244/head
shedfreewu 2 years ago committed by GitHub
parent d0851bbc7b
commit 4c7a9c8288
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,5 @@
# Change Log
---
- [feat: support lossless register and deregister](https://github.com/Tencent/spring-cloud-tencent/issues/977)
- [feat: support lossless register and deregister at #977](https://github.com/Tencent/spring-cloud-tencent/pull/1242)
- [feat: PolarisServiceRegistry#deregister support idempotency.](https://github.com/Tencent/spring-cloud-tencent/pull/1243)

@ -175,7 +175,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<PolarisRegistrati
public void deregister(PolarisRegistration registration) {
LOGGER.info("De-registering from Polaris Server now...");
if (StringUtils.isEmpty(registration.getServiceId())) {
if (StringUtils.isEmpty(registration.getServiceId()) || !PolarisSDKContextManager.isRegistered) {
LOGGER.warn("No dom to de-register for polaris client...");
return;
}
@ -190,6 +190,8 @@ public class PolarisServiceRegistry implements ServiceRegistry<PolarisRegistrati
try {
ProviderAPI providerClient = polarisSDKContextManager.getProviderAPI();
providerClient.deRegister(deRegisterRequest);
PolarisSDKContextManager.isRegistered = false;
LOGGER.info("De-registration finished.");
}
catch (Exception e) {
LOGGER.error("ERR_POLARIS_DEREGISTER, de-register failed...{},", registration, e);
@ -198,8 +200,6 @@ public class PolarisServiceRegistry implements ServiceRegistry<PolarisRegistrati
if (null != heartbeatExecutor) {
heartbeatExecutor.shutdown();
}
LOGGER.info("De-registration finished.");
PolarisSDKContextManager.isRegistered = false;
}
}

@ -17,8 +17,6 @@
package com.tencent.cloud.plugin.lossless;
import java.util.concurrent.atomic.AtomicBoolean;
import com.tencent.cloud.plugin.lossless.config.LosslessProperties;
import com.tencent.cloud.polaris.context.PolarisSDKContextManager;
import com.tencent.polaris.api.pojo.BaseInstance;
@ -46,9 +44,6 @@ public class LosslessRegistryAspect {
private PolarisSDKContextManager polarisSDKContextManager;
private final AtomicBoolean doneDeregister = new AtomicBoolean(false);
public LosslessRegistryAspect(ServiceRegistry serviceRegistry, Registration registration,
LosslessProperties losslessProperties, PolarisSDKContextManager polarisSDKContextManager) {
this.serviceRegistry = serviceRegistry;
@ -86,12 +81,7 @@ public class LosslessRegistryAspect {
@Around("deregisterPointcut()")
public Object invokeDeregister(ProceedingJoinPoint joinPoint) throws Throwable {
if (doneDeregister.compareAndSet(false, true)) {
return joinPoint.proceed();
}
else {
return null;
}
return joinPoint.proceed();
}
public void executeJoinPoint(ProceedingJoinPoint joinPoint) {

Loading…
Cancel
Save