diff --git a/nacossync-console/pom.xml b/nacossync-console/pom.xml
index dd8dc7c4..a3d1b599 100644
--- a/nacossync-console/pom.xml
+++ b/nacossync-console/pom.xml
@@ -16,7 +16,7 @@
nacossync-parent
com.alibaba.nacossync
- 0.4.0
+ 0.4.1
4.0.0
diff --git a/nacossync-distribution/pom.xml b/nacossync-distribution/pom.xml
index de20b308..2fb46441 100644
--- a/nacossync-distribution/pom.xml
+++ b/nacossync-distribution/pom.xml
@@ -5,7 +5,7 @@
nacossync-parent
com.alibaba.nacossync
- 0.4.0
+ 0.4.1
4.0.0
pom
diff --git a/nacossync-test/pom.xml b/nacossync-test/pom.xml
index fab75457..9fb9b79e 100644
--- a/nacossync-test/pom.xml
+++ b/nacossync-test/pom.xml
@@ -17,7 +17,7 @@
nacossync-parent
com.alibaba.nacossync
- 0.4.0
+ 0.4.1
../pom.xml
4.0.0
@@ -39,7 +39,7 @@
com.alibaba.nacossync
nacossync-worker
- 0.4.0
+ 0.4.1
org.springframework.boot
diff --git a/nacossync-worker/pom.xml b/nacossync-worker/pom.xml
index ec1de062..c25417ed 100644
--- a/nacossync-worker/pom.xml
+++ b/nacossync-worker/pom.xml
@@ -16,11 +16,11 @@
nacossync-parent
com.alibaba.nacossync
- 0.4.0
+ 0.4.1
4.0.0
nacossync-worker
- 0.4.0
+ 0.4.1
3.4.9
4.1.0
diff --git a/nacossync-worker/src/main/java/com/alibaba/nacossync/extension/impl/EurekaSyncToNacosServiceImpl.java b/nacossync-worker/src/main/java/com/alibaba/nacossync/extension/impl/EurekaSyncToNacosServiceImpl.java
index 5052ffc8..63b66aa7 100644
--- a/nacossync-worker/src/main/java/com/alibaba/nacossync/extension/impl/EurekaSyncToNacosServiceImpl.java
+++ b/nacossync-worker/src/main/java/com/alibaba/nacossync/extension/impl/EurekaSyncToNacosServiceImpl.java
@@ -28,13 +28,14 @@
import com.alibaba.nacossync.monitor.MetricsManager;
import com.alibaba.nacossync.pojo.model.TaskDO;
import com.netflix.appinfo.InstanceInfo;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* eureka
*
@@ -70,9 +71,10 @@ public boolean delete(TaskDO taskDO) {
try {
specialSyncEventBus.unsubscribe(taskDO);
- NamingService destNamingService = nacosServerHolder.get(taskDO.getDestClusterId(), taskDO.getNameSpace());
- List allInstances = destNamingService.getAllInstances(taskDO.getServiceName());
- deleteAllInstance(taskDO, destNamingService, allInstances);
+ EurekaNamingService eurekaNamingService = eurekaServerHolder.get(taskDO.getSourceClusterId(), null);
+ NamingService destNamingService = nacosServerHolder.get(taskDO.getDestClusterId(), null);
+ List eurekaInstances = eurekaNamingService.getApplications(taskDO.getServiceName());
+ deleteAllInstanceFromEureka(taskDO, destNamingService, eurekaInstances);
} catch (Exception e) {
log.error("delete a task from eureka to nacos was failed, taskId:{}", taskDO.getTaskId(), e);
@@ -119,6 +121,17 @@ private void addValidInstance(TaskDO taskDO, NamingService destNamingService, Li
}
}
}
+
+ private void deleteAllInstanceFromEureka(TaskDO taskDO, NamingService destNamingService, List eurekaInstances)
+ throws NacosException {
+ for (InstanceInfo instance : eurekaInstances) {
+ if (needSync(instance.getMetadata())) {
+ log.info("Delete service instance from Eureka, serviceName={}, Ip={}, port={}",
+ instance.getAppName(), instance.getIPAddr(), instance.getPort());
+ destNamingService.deregisterInstance(taskDO.getServiceName(), buildSyncInstance(instance, taskDO));
+ }
+ }
+ }
private void removeInvalidInstance(TaskDO taskDO, NamingService destNamingService,
List eurekaInstances, List nacosInstances) throws NacosException {
diff --git a/nacossync-worker/src/main/java/com/alibaba/nacossync/template/processor/TaskDeleteProcessor.java b/nacossync-worker/src/main/java/com/alibaba/nacossync/template/processor/TaskDeleteProcessor.java
index bb3f22be..2f18186e 100644
--- a/nacossync-worker/src/main/java/com/alibaba/nacossync/template/processor/TaskDeleteProcessor.java
+++ b/nacossync-worker/src/main/java/com/alibaba/nacossync/template/processor/TaskDeleteProcessor.java
@@ -16,15 +16,16 @@
*/
package com.alibaba.nacossync.template.processor;
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
import com.alibaba.nacossync.dao.TaskAccessService;
-import com.alibaba.nacossync.pojo.result.BaseResult;
+import com.alibaba.nacossync.event.DeleteTaskEvent;
+import com.alibaba.nacossync.pojo.model.TaskDO;
import com.alibaba.nacossync.pojo.request.TaskDeleteRequest;
+import com.alibaba.nacossync.pojo.result.BaseResult;
import com.alibaba.nacossync.template.Processor;
+import com.google.common.eventbus.EventBus;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
/**
* @author NacosSync
@@ -36,11 +37,15 @@ public class TaskDeleteProcessor implements Processorcom.alibaba.nacossync
nacossync-parent
- 0.4.0
+ 0.4.1
nacossync-console
nacossync-worker
@@ -73,7 +73,7 @@
com.alibaba.nacossync
nacossync-worker
- 0.4.0
+ 0.4.1