Skip to content

Commit

Permalink
Fix client beat task executing when health check is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkorange committed Nov 11, 2019
1 parent b3781ad commit 3a4de81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public GlobalConfig getGlobalConfig() {
return SpringContext.getAppContext().getBean(GlobalConfig.class);
}

public SwitchDomain getSwitchDomain() {
return SpringContext.getAppContext().getBean(SwitchDomain.class);
}

public String taskKey() {
return service.getName();
}
Expand All @@ -71,6 +75,10 @@ public void run() {
return;
}

if (!getSwitchDomain().isHealthCheckEnabled()) {
return;
}

List<Instance> instances = service.allIPs(true);

// first set health status of instances:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void autoDregDomClustersTest() throws Exception {
Assert.assertEquals(1, instances.size());

instances = naming.getAllInstances(serviceName, Arrays.asList("c2"));
Assert.assertEquals(instances.size(), 1);
Assert.assertEquals(1, instances.size());

instances = naming.getAllInstances(serviceName, Arrays.asList("c1"));
Assert.assertEquals(0, instances.size());
Expand Down Expand Up @@ -146,6 +146,9 @@ public void autoDregDomTest() throws Exception {
*/
@Test
public void autoRegDomTest() throws Exception {

naming = NamingFactory.createNamingService("11.239.112.161:8848,11.239.113.204:8848,11.239.114.187:8848");

String serviceName = randomDomainName();

naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT);
Expand All @@ -156,7 +159,7 @@ public void autoRegDomTest() throws Exception {
List<Instance> instances;
instances = naming.getAllInstances(serviceName);

Assert.assertEquals(instances.size(), 2);
Assert.assertEquals(2, instances.size());

NacosNamingService namingServiceImpl = (NacosNamingService) naming;

Expand All @@ -167,7 +170,7 @@ public void autoRegDomTest() throws Exception {

instances = naming.getAllInstances(serviceName);

Assert.assertEquals(instances.size(), 1);
Assert.assertEquals(1, instances.size());
BeatInfo beatInfo = new BeatInfo();
beatInfo.setServiceName(Constants.DEFAULT_GROUP + Constants.SERVICE_INFO_SPLITER + serviceName);
beatInfo.setIp("127.0.0.1");
Expand All @@ -180,7 +183,7 @@ public void autoRegDomTest() throws Exception {

instances = naming.getAllInstances(serviceName);

Assert.assertEquals(instances.size(), 2);
Assert.assertEquals(2, instances.size());
}


Expand Down Expand Up @@ -227,7 +230,7 @@ public void autoRegDomClustersTest() throws Exception {

instances = naming.getAllInstances(serviceName);

Assert.assertEquals(instances.size(), 2);
Assert.assertEquals(2, instances.size());

instances = naming.getAllInstances(serviceName, Arrays.asList("c2"));
Assert.assertEquals(1, instances.size());
Expand Down

0 comments on commit 3a4de81

Please sign in to comment.