From 0a1d949fd4873804a778716f0cc789700be746b1 Mon Sep 17 00:00:00 2001 From: xxc Date: Fri, 30 Nov 2018 22:14:55 +0800 Subject: [PATCH 1/3] Update README.md update version to 0.5.0 release --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06683c874..3e0abaff9 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ It is super easy to get started with your first project. You can download the package from the [latest stable release](https://github.com/alibaba/nacos/releases). -Take release nacos-server-0.4.0.zip for example. +Take release nacos-server-0.5.0.zip for example. ``` -unzip nacos-server-0.4.0.zip +unzip nacos-server-0.5.0.zip cd nacos/bin ``` From cce267967056c165aab126625056300069341e7c Mon Sep 17 00:00:00 2001 From: nkorange Date: Wed, 5 Dec 2018 14:11:03 +0800 Subject: [PATCH 2/3] Fix #388 --- .../main/java/com/alibaba/nacos/naming/web/ApiCommands.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/web/ApiCommands.java b/naming/src/main/java/com/alibaba/nacos/naming/web/ApiCommands.java index 0d35ea9c3..727d8d722 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/web/ApiCommands.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/web/ApiCommands.java @@ -314,6 +314,8 @@ public class ApiCommands { ipAddress.setWeight(clientBeat.getWeight()); ipAddress.setMetadata(clientBeat.getMetadata()); ipAddress.setClusterName(clusterName); + ipAddress.setServiceName(dom); + ipAddress.setInstanceId(ipAddress.generateInstanceId()); if (!virtualClusterDomain.getClusterMap().containsKey(ipAddress.getClusterName())) { doAddCluster4Dom(MockHttpRequest.buildRequest(stringMap)); @@ -1215,6 +1217,8 @@ public class ApiCommands { ipObj.put("metadata", ip.getMetadata()); ipObj.put("enabled", ip.isEnabled()); ipObj.put("weight", ip.getWeight()); + ipObj.put("clusterName", ip.getClusterName()); + ipObj.put("serviceName", ip.getServiceName()); hosts.add(ipObj); } From baf7d61a70a9dea852664ae75c79ba4231caa9f9 Mon Sep 17 00:00:00 2001 From: nkorange Date: Wed, 5 Dec 2018 15:16:43 +0800 Subject: [PATCH 3/3] #388 Add test case. --- .../test/naming/SelectInstances_ITCase.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java index 77b5b526f..2d8e8f26b 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/SelectInstances_ITCase.java @@ -190,6 +190,29 @@ public class SelectInstances_ITCase { Assert.assertTrue(verifyInstanceList(instances, instancesGet)); } + @Test + public void selectInstancesCheckClusterName() throws Exception { + + String serviceName = randomDomainName(); + naming.registerInstance(serviceName, "1.1.1.1", TEST_PORT, "c1"); + naming.registerInstance(serviceName, "1.1.1.2", TEST_PORT, "c2"); + + TimeUnit.SECONDS.sleep(8); + + List instancesGet = naming.getAllInstances(serviceName); + + Assert.assertEquals(2, instancesGet.size()); + + for (Instance instance : instancesGet) { + if (instance.getIp().equals("1.1.1.1")) { + Assert.assertEquals(instance.getClusterName(), "c1"); + } + if (instance.getIp().equals("2.2.2.2")) { + Assert.assertEquals(instance.getClusterName(), "c2"); + } + } + } + /** * 获取权重不为0的Instance