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 ``` 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 74ab609ef..b1151ab01 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 @@ -315,6 +315,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)); @@ -1218,6 +1220,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); } 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