Merge pull request #392 from alibaba/hotfix_cluster_lost_in_instance
Hotfix cluster lost in instance
This commit is contained in:
commit
3f5955f69c
@ -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
|
||||
```
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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<Instance> 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
|
||||
|
Loading…
Reference in New Issue
Block a user