Skip to content

Commit 144d5f7

Browse files
authored
Merge pull request #213 from nacos-group/develop
0.4.4
2 parents 8188868 + 0c1f7de commit 144d5f7

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

nacossync-console/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<parent>
1717
<artifactId>nacossync-parent</artifactId>
1818
<groupId>com.alibaba.nacossync</groupId>
19-
<version>0.4.3</version>
19+
<version>0.4.4</version>
2020
</parent>
2121
<modelVersion>4.0.0</modelVersion>
2222

nacossync-console/src/main/resources/static/js/main.1cd0c600.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nacossync-distribution/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>nacossync-parent</artifactId>
77
<groupId>com.alibaba.nacossync</groupId>
8-
<version>0.4.3</version>
8+
<version>0.4.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<packaging>pom</packaging>

nacossync-test/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<artifactId>nacossync-parent</artifactId>
1919
<groupId>com.alibaba.nacossync</groupId>
20-
<version>0.4.3</version>
20+
<version>0.4.4</version>
2121
<relativePath>../pom.xml</relativePath>
2222
</parent>
2323
<modelVersion>4.0.0</modelVersion>
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>com.alibaba.nacossync</groupId>
4141
<artifactId>nacossync-worker</artifactId>
42-
<version>0.4.3</version>
42+
<version>0.4.4</version>
4343
</dependency>
4444
<dependency>
4545
<groupId>org.springframework.boot</groupId>

nacossync-worker/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
<parent>
1717
<artifactId>nacossync-parent</artifactId>
1818
<groupId>com.alibaba.nacossync</groupId>
19-
<version>0.4.3</version>
19+
<version>0.4.4</version>
2020
</parent>
2121
<modelVersion>4.0.0</modelVersion>
2222
<artifactId>nacossync-worker</artifactId>
23-
<version>0.4.3</version>
23+
<version>0.4.4</version>
2424
<properties>
2525
<zookeeper.version>3.4.9</zookeeper.version>
2626
<curator.version>4.1.0</curator.version>

nacossync-worker/src/main/java/com/alibaba/nacossync/extension/impl/NacosSyncToNacosServiceImpl.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,27 @@ public boolean sync(TaskDO taskDO) {
103103

104104
List<Instance> sourceInstances = sourceNamingService.getAllInstances(taskDO.getServiceName(),
105105
new ArrayList<>(), false);
106-
log.info("任务Id:{},迁入实例数量:{}", taskId, sourceInstances.size());
107106
// 先删除不存在的
108107
this.removeInvalidInstance(taskDO, taskId, destNamingService, sourceInstances);
109-
108+
Set<String> latestSyncInstance = new TreeSet<>();
110109
//再次添加新实例
110+
Set<String> instanceKeys = sourceInstanceSnapshot.get(taskId);
111111
for (Instance instance : sourceInstances) {
112112
if (needSync(instance.getMetadata())) {
113-
destNamingService.registerInstance(taskDO.getServiceName(),
114-
buildSyncInstance(instance, taskDO));
115-
this.sourceInstanceSnapshot.compute(taskId, (key, value) -> {
116-
if (CollectionUtils.isEmpty(value)) {
117-
value = new TreeSet<>();
118-
}
119-
log.info("任务Id:{},已同步实例:{}", taskId, composeInstanceKey(instance));
120-
value.add(composeInstanceKey(instance));
121-
return value;
122-
});
113+
String instanceKey = composeInstanceKey(instance);
114+
if (CollectionUtils.isEmpty(instanceKeys) || !instanceKeys.contains(instanceKey)) {
115+
destNamingService.registerInstance(taskDO.getServiceName(),
116+
buildSyncInstance(instance, taskDO));
117+
}
118+
latestSyncInstance.add(instanceKey);
119+
123120
}
124121
}
122+
if (CollectionUtils.isNotEmpty(latestSyncInstance)) {
125123

124+
log.info("任务Id:{},已同步实例个数:{}", taskId, latestSyncInstance.size());
125+
sourceInstanceSnapshot.put(taskId, latestSyncInstance);
126+
}
126127
} catch (Exception e) {
127128
log.error("event process fail, taskId:{}", taskId, e);
128129
metricsManager.recordError(MetricsStatisticsType.SYNC_ERROR);

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<groupId>com.alibaba.nacossync</groupId>
2020
<artifactId>nacossync-parent</artifactId>
21-
<version>0.4.3</version>
21+
<version>0.4.4</version>
2222
<modules>
2323
<module>nacossync-console</module>
2424
<module>nacossync-worker</module>
@@ -73,7 +73,7 @@
7373
<dependency>
7474
<groupId>com.alibaba.nacossync</groupId>
7575
<artifactId>nacossync-worker</artifactId>
76-
<version>0.4.3</version>
76+
<version>0.4.4</version>
7777
</dependency>
7878
</dependencies>
7979
</dependencyManagement>

0 commit comments

Comments
 (0)