From 4bc2b1fa9737c08f2277668bbc843f8390055154 Mon Sep 17 00:00:00 2001 From: nkorange Date: Thu, 13 Sep 2018 14:18:42 +0800 Subject: [PATCH] Update server health method name --- .../nacos/api/naming/NamingService.java | 7 +- .../client/naming/NacosNamingService.java | 2 +- .../nacos/client/naming/net/NamingProxy.java | 2 +- .../nacos/test/naming/RestAPI_ITCase.java | 82 +++++++++---------- 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/client/src/main/java/com/alibaba/nacos/api/naming/NamingService.java b/client/src/main/java/com/alibaba/nacos/api/naming/NamingService.java index db995bae8..33922c066 100644 --- a/client/src/main/java/com/alibaba/nacos/api/naming/NamingService.java +++ b/client/src/main/java/com/alibaba/nacos/api/naming/NamingService.java @@ -194,5 +194,10 @@ public interface NamingService { */ List getSubscribeServices() throws NacosException; - boolean serverHealthy(); + /** + * Get server health status + * + * @return is server healthy + */ + boolean isServerHealthy(); } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java index 13df8c9b1..77f2b225d 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java @@ -255,7 +255,7 @@ public class NacosNamingService implements NamingService { } @Override - public boolean serverHealthy() { + public boolean isServerHealthy() { return serverProxy.serverHealthy(); } } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index 6ed9b0e3a..c33824c47 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -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; } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/RestAPI_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/RestAPI_ITCase.java index fc489b7db..622e14b75 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/RestAPI_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/RestAPI_ITCase.java @@ -72,7 +72,7 @@ public class RestAPI_ITCase { @Test public void dom() throws Exception { - ResponseEntity response = request("/nacos/naming/api/dom", + ResponseEntity 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 response = request("/nacos/naming/api/domCount", + ResponseEntity 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 response = request("/nacos/naming/api/rt4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/ip4Dom2", + ResponseEntity 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 response = request("/nacos/naming/api/ip4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/replaceDom", + ResponseEntity 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 response = request("/nacos/naming/api/regService", + ResponseEntity 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 response = request("/nacos/naming/api/updateDom", + ResponseEntity 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 response = request("/nacos/naming/api/hello", + ResponseEntity 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 response = request("/nacos/naming/api/replaceIP4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/srvAllIP", + ResponseEntity 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 response = request("/nacos/naming/api/srvIPXT", + ResponseEntity 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 response = request("/nacos/naming/api/addIP4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/updateSwitch", + ResponseEntity 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 response = request("/nacos/naming/api/checkStatus", + ResponseEntity 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 response = request("/nacos/naming/api/allDomNames", + ResponseEntity 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 response = request("/nacos/naming/api/searchDom", + ResponseEntity 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 response = request("/nacos/naming/api/addCluster4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/domList", + ResponseEntity 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 response = request("/nacos/naming/api/distroStatus", + ResponseEntity 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 response = request("/nacos/naming/api/metrics", + ResponseEntity 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 response = request("/nacos/naming/api/reCalculateCheckSum4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/getDomString4MD5", + ResponseEntity 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 response = request("/nacos/naming/api/getResponsibleServer4Dom", + ResponseEntity 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 response = request("/nacos/naming/api/domServeStatus", + ResponseEntity 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 responseEntity = request("/nacos/naming/api/regDom", + ResponseEntity 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 responseEntity = request("/nacos/naming/api/remvDom", + ResponseEntity responseEntity = request("/nacos/v1/ns/api/remvDom", Params.newParams() .appendParam("dom", NamingBase.TEST_DOM_1) .appendParam("token", "abc")