Update server health method name

This commit is contained in:
nkorange 2018-09-13 14:18:42 +08:00
parent 8b295159d1
commit 4bc2b1fa97
4 changed files with 49 additions and 44 deletions

View File

@ -194,5 +194,10 @@ public interface NamingService {
*/
List<ServiceInfo> getSubscribeServices() throws NacosException;
boolean serverHealthy();
/**
* Get server health status
*
* @return is server healthy
*/
boolean isServerHealthy();
}

View File

@ -255,7 +255,7 @@ public class NacosNamingService implements NamingService {
}
@Override
public boolean serverHealthy() {
public boolean isServerHealthy() {
return serverProxy.serverHealthy();
}
}

View File

@ -236,7 +236,7 @@ public class NamingProxy {
public boolean serverHealthy() {
try {
reqAPI(UtilAndComs.NACOS_URL_BASE + "/api/hello", new HashMap<>());
reqAPI(UtilAndComs.NACOS_URL_BASE + "/api/hello", new HashMap<>(2));
} catch (Exception e) {
return false;
}

View File

@ -72,7 +72,7 @@ public class RestAPI_ITCase {
@Test
public void dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/dom",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
@ -85,7 +85,7 @@ public class RestAPI_ITCase {
@Test
public void domCount() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/domCount",
ResponseEntity<String> response = request("/nacos/v1/ns/api/domCount",
Params.newParams().done(), String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
@ -95,7 +95,7 @@ public class RestAPI_ITCase {
@Test
public void rt4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/rt4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/rt4Dom",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
assertTrue(response.getStatusCode().is2xxSuccessful());
@ -105,7 +105,7 @@ public class RestAPI_ITCase {
@Test
public void ip4Dom2() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/ip4Dom2",
ResponseEntity<String> response = request("/nacos/v1/ns/api/ip4Dom2",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
assertTrue(response.getStatusCode().is2xxSuccessful());
@ -122,7 +122,7 @@ public class RestAPI_ITCase {
@Test
public void ip4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/ip4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/ip4Dom",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
assertTrue(response.getStatusCode().is2xxSuccessful());
@ -139,7 +139,7 @@ public class RestAPI_ITCase {
@Test
public void replaceDom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/replaceDom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/replaceDom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("token", NamingBase.TEST_TOKEN_4_DOM_1)
@ -179,7 +179,7 @@ public class RestAPI_ITCase {
@Test
public void regAndDeregService() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/regService",
ResponseEntity<String> response = request("/nacos/v1/ns/api/regService",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_2)
.appendParam("app", "test1")
@ -191,7 +191,7 @@ public class RestAPI_ITCase {
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/deRegService",
response = request("/nacos/v1/ns/api/deRegService",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_2)
.appendParam("ip", NamingBase.TEST_IP_4_DOM_2)
@ -206,7 +206,7 @@ public class RestAPI_ITCase {
@Test
public void updateDom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/updateDom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/updateDom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("token", NamingBase.TEST_TOKEN_4_DOM_1)
@ -220,7 +220,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/dom",
response = request("/nacos/v1/ns/api/dom",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
@ -243,7 +243,7 @@ public class RestAPI_ITCase {
@Test
public void hello() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/hello",
ResponseEntity<String> response = request("/nacos/v1/ns/api/hello",
Params.newParams().done(), String.class);
assertTrue(response.getStatusCode().is2xxSuccessful());
@ -252,7 +252,7 @@ public class RestAPI_ITCase {
@Test
public void replaceIP4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/replaceIP4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/replaceIP4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("cluster", "DEFAULT")
@ -262,7 +262,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/ip4Dom2",
response = request("/nacos/v1/ns/api/ip4Dom2",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
assertTrue(response.getStatusCode().is2xxSuccessful());
@ -279,7 +279,7 @@ public class RestAPI_ITCase {
@Test
public void srvAllIP() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/srvAllIP",
ResponseEntity<String> response = request("/nacos/v1/ns/api/srvAllIP",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(), String.class);
@ -299,7 +299,7 @@ public class RestAPI_ITCase {
@Test
public void srvIPXT() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/srvIPXT",
ResponseEntity<String> response = request("/nacos/v1/ns/api/srvIPXT",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(), String.class);
@ -320,7 +320,7 @@ public class RestAPI_ITCase {
public void remvIP4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/addIP4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/addIP4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("ipList", NamingBase.TEST_IP_4_DOM_1 + ":" + NamingBase.TEST_PORT2_4_DOM_1)
@ -329,7 +329,7 @@ public class RestAPI_ITCase {
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/remvIP4Dom",
response = request("/nacos/v1/ns/api/remvIP4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("ipList", NamingBase.TEST_IP_4_DOM_1 + ":" + NamingBase.TEST_PORT2_4_DOM_1)
@ -342,7 +342,7 @@ public class RestAPI_ITCase {
@Test
public void updateSwitch() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/updateSwitch",
ResponseEntity<String> response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "distroThreshold")
.appendParam("distroThreshold", "0.3")
@ -351,7 +351,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "enableAllDomNameCache")
.appendParam("enableAllDomNameCache", "false")
@ -360,7 +360,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "incrementalList")
.appendParam("incrementalList", "1.com,2.com")
@ -370,7 +370,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "healthCheckWhiteList")
.appendParam("healthCheckWhiteList", "1.com,2.com")
@ -380,7 +380,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "clientBeatInterval")
.appendParam("clientBeatInterval", "5000")
@ -389,7 +389,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "pushVersion")
.appendParam("type", "java")
@ -399,7 +399,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "pushCacheMillis")
.appendParam("millis", "30000")
@ -408,7 +408,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/updateSwitch",
response = request("/nacos/v1/ns/api/updateSwitch",
Params.newParams()
.appendParam("entry", "defaultCacheMillis")
.appendParam("millis", "3000")
@ -417,7 +417,7 @@ public class RestAPI_ITCase {
assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/switches",
response = request("/nacos/v1/ns/api/switches",
Params.newParams().done(),
String.class);
@ -442,7 +442,7 @@ public class RestAPI_ITCase {
@Test
public void checkStatus() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/checkStatus",
ResponseEntity<String> response = request("/nacos/v1/ns/api/checkStatus",
Params.newParams().done(),
String.class);
@ -453,7 +453,7 @@ public class RestAPI_ITCase {
@Test
public void allDomNames() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/allDomNames",
ResponseEntity<String> response = request("/nacos/v1/ns/api/allDomNames",
Params.newParams().done(),
String.class);
@ -468,7 +468,7 @@ public class RestAPI_ITCase {
@Test
public void searchDom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/searchDom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/searchDom",
Params.newParams()
.appendParam("expr", "nacos")
.done(),
@ -483,7 +483,7 @@ public class RestAPI_ITCase {
@Test
public void addCluster4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/addCluster4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/addCluster4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("token", NamingBase.TEST_TOKEN_4_DOM_1)
@ -496,7 +496,7 @@ public class RestAPI_ITCase {
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
response = request("/nacos/naming/api/dom",
response = request("/nacos/v1/ns/api/dom",
Params.newParams().appendParam("dom", NamingBase.TEST_DOM_1).done(), String.class);
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
@ -522,7 +522,7 @@ public class RestAPI_ITCase {
@Test
public void domList() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/domList",
ResponseEntity<String> response = request("/nacos/v1/ns/api/domList",
Params.newParams()
.appendParam("startPg", "0")
.appendParam("pgSize", "10")
@ -539,7 +539,7 @@ public class RestAPI_ITCase {
@Test
public void distroStatus() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/distroStatus",
ResponseEntity<String> response = request("/nacos/v1/ns/api/distroStatus",
Params.newParams()
.done(),
String.class);
@ -550,7 +550,7 @@ public class RestAPI_ITCase {
@Test
public void metrics() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/metrics",
ResponseEntity<String> response = request("/nacos/v1/ns/api/metrics",
Params.newParams()
.done(),
String.class);
@ -572,7 +572,7 @@ public class RestAPI_ITCase {
@Test
public void reCalculateCheckSum4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/reCalculateCheckSum4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/reCalculateCheckSum4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(),
@ -584,7 +584,7 @@ public class RestAPI_ITCase {
@Test
public void getDomString4MD5() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/getDomString4MD5",
ResponseEntity<String> response = request("/nacos/v1/ns/api/getDomString4MD5",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(),
@ -596,7 +596,7 @@ public class RestAPI_ITCase {
@Test
public void getResponsibleServer4Dom() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/getResponsibleServer4Dom",
ResponseEntity<String> response = request("/nacos/v1/ns/api/getResponsibleServer4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(),
@ -608,7 +608,7 @@ public class RestAPI_ITCase {
@Test
public void domServeStatus() throws Exception {
ResponseEntity<String> response = request("/nacos/naming/api/domServeStatus",
ResponseEntity<String> response = request("/nacos/v1/ns/api/domServeStatus",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.done(),
@ -636,7 +636,7 @@ public class RestAPI_ITCase {
private void prepareData() {
ResponseEntity<String> responseEntity = request("/nacos/naming/api/regDom",
ResponseEntity<String> responseEntity = request("/nacos/v1/ns/api/regDom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("cktype", "TCP")
@ -654,7 +654,7 @@ public class RestAPI_ITCase {
e.printStackTrace();
}
responseEntity = request("/nacos/naming/api/addIP4Dom",
responseEntity = request("/nacos/v1/ns/api/addIP4Dom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("ipList", NamingBase.TEST_IP_4_DOM_1 + ":" + NamingBase.TEST_PORT_4_DOM_1)
@ -668,7 +668,7 @@ public class RestAPI_ITCase {
private void removeData() {
ResponseEntity<String> responseEntity = request("/nacos/naming/api/remvDom",
ResponseEntity<String> responseEntity = request("/nacos/v1/ns/api/remvDom",
Params.newParams()
.appendParam("dom", NamingBase.TEST_DOM_1)
.appendParam("token", "abc")