From 63f6d9d0ff3991e33257be6807377c7f5b7ab4a5 Mon Sep 17 00:00:00 2001 From: KomachiSion <263976490@qq.com> Date: Fri, 3 Jul 2020 13:40:46 +0800 Subject: [PATCH 1/2] reformat with new code style for nacos-address --- address/pom.xml | 16 ++--- .../alibaba/nacos/address/AddressServer.java | 4 +- .../AddressServerGeneratorManager.java | 47 +++++++------- .../component/AddressServerManager.java | 27 ++++---- .../constant/AddressServerConstants.java | 25 ++++---- .../AddressServerClusterController.java | 61 +++++++++++-------- .../controller/ServerListController.java | 26 ++++---- .../alibaba/nacos/address/misc/Loggers.java | 3 +- .../util/AddressServerParamCheckUtil.java | 19 +++--- .../META-INF/logback/nacos-included.xml | 8 +-- .../src/main/resources/application.properties | 1 - .../address/AddressServerControllerTests.java | 61 ++++++++++--------- .../nacos/address/ParamCheckUtilTests.java | 5 +- .../nacos/address/SimpleHttpTestUtils.java | 58 ++++++++++-------- 14 files changed, 193 insertions(+), 168 deletions(-) diff --git a/address/pom.xml b/address/pom.xml index 17d5430e4d2..fa755c249cf 100644 --- a/address/pom.xml +++ b/address/pom.xml @@ -15,26 +15,26 @@ ~ limitations under the License. --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> nacos-all com.alibaba.nacos 1.3.1-BETA - + 4.0.0 nacos-address jar - + nacos-address ${project.version} http://nacos.io - + UTF-8 1.8 1.8 - + junit @@ -62,7 +62,7 @@ test - + @@ -70,7 +70,7 @@ - + @@ -79,7 +79,7 @@ - + release-address diff --git a/address/src/main/java/com/alibaba/nacos/address/AddressServer.java b/address/src/main/java/com/alibaba/nacos/address/AddressServer.java index a963cda64f0..1a5049a14ea 100644 --- a/address/src/main/java/com/alibaba/nacos/address/AddressServer.java +++ b/address/src/main/java/com/alibaba/nacos/address/AddressServer.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address; import org.springframework.boot.SpringApplication; @@ -26,8 +27,9 @@ */ @SpringBootApplication(scanBasePackages = "com.alibaba.nacos") public class AddressServer { + public static void main(String[] args) { - + SpringApplication.run(AddressServer.class, args); } } diff --git a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java index a0dda0fdffb..b4b7bf53c5e 100644 --- a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java +++ b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.component; import com.alibaba.nacos.address.constant.AddressServerConstants; @@ -34,17 +35,17 @@ */ @Component public class AddressServerGeneratorManager { - + public String generateProductName(String name) { - + if (StringUtils.isBlank(name) || AddressServerConstants.DEFAULT_PRODUCT.equals(name)) { - + return AddressServerConstants.ALIWARE_NACOS_DEFAULT_PRODUCT_NAME; } - + return String.format(AddressServerConstants.ALIWARE_NACOS_PRODUCT_DOM_TEMPLATE, name); } - + /** * Note: if the parameter inputted is empty then will return the empty list. * @@ -53,13 +54,13 @@ public String generateProductName(String name) { * @param ipArray * @return */ - public List generateInstancesByIps(String serviceName, String rawProductName, String clusterName, String[] ipArray) { - if (StringUtils.isEmpty(serviceName) - || StringUtils.isEmpty(clusterName) - || ipArray == null || ipArray.length == 0) { + public List generateInstancesByIps(String serviceName, String rawProductName, String clusterName, + String[] ipArray) { + if (StringUtils.isEmpty(serviceName) || StringUtils.isEmpty(clusterName) || ipArray == null + || ipArray.length == 0) { return Collections.emptyList(); } - + List instanceList = new ArrayList<>(ipArray.length); for (String ip : ipArray) { String[] ipAndPort = generateIpAndPort(ip); @@ -73,46 +74,46 @@ public List generateInstancesByIps(String serviceName, String rawProdu instance.setEphemeral(false); instanceList.add(instance); } - + return instanceList; } - + public String[] generateIpAndPort(String ip) { - + int index = ip.indexOf(AddressServerConstants.IP_PORT_SEPARATOR); if (index != -1) { - - return new String[]{ip.substring(0, index), ip.substring(index + 1)}; + + return new String[] {ip.substring(0, index), ip.substring(index + 1)}; } - - return new String[]{ip, String.valueOf(AddressServerConstants.DEFAULT_SERVER_PORT)}; + + return new String[] {ip, String.valueOf(AddressServerConstants.DEFAULT_SERVER_PORT)}; } - + /** * @param instanceList a instance set will generate string response to client. * @return the result of response to client */ public String generateResponseIps(List instanceList) { - + StringBuilder ips = new StringBuilder(); instanceList.forEach(instance -> { ips.append(instance.getIp() + ":" + instance.getPort()); ips.append("\n"); }); - + return ips.toString(); } - + /** * @param rawServiceName the raw service name will not contains the {@Constans.DEFAULT_GROUP} * @return the nacos service name */ public String generateNacosServiceName(String rawServiceName) { - + if (rawServiceName.indexOf(Constants.DEFAULT_GROUP) != -1) { return rawServiceName; } - + return Constants.DEFAULT_GROUP + AddressServerConstants.GROUP_SERVICE_NAME_SEP + rawServiceName; } } diff --git a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java index 43be032528e..7125d1a6647 100644 --- a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java +++ b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.component; import com.alibaba.nacos.address.constant.AddressServerConstants; @@ -28,17 +29,17 @@ */ @Component public class AddressServerManager { - + public String getRawProductName(String name) { - + if (StringUtils.isBlank(name) || AddressServerConstants.DEFAULT_PRODUCT.equals(name)) { - + return AddressServerConstants.DEFAULT_PRODUCT; } - + return name; } - + /** *

* if the name is empty then return the default {@UtilAndCommons#DEFAULT_CLUSTER_NAME}, @@ -49,30 +50,30 @@ public String getRawProductName(String name) { * @return */ public String getDefaultClusterNameIfEmpty(String name) { - + if (StringUtils.isEmpty(name) || AddressServerConstants.DEFAULT_GET_CLUSTER.equals(name)) { return AddressServerConstants.DEFAULT_GET_CLUSTER; } - + return name; } - + public String getRawClusterName(String name) { - + return getDefaultClusterNameIfEmpty(name); } - + /** * @param ips multi ip will separator by the ',' * @return */ public String[] splitIps(String ips) { - + if (StringUtils.isBlank(ips)) { - + return new String[0]; } - + return ips.split(AddressServerConstants.MULTI_IPS_SEPARATOR); } } diff --git a/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java b/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java index c12984ab3de..3377ccfee49 100644 --- a/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java +++ b/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.constant; import com.alibaba.nacos.naming.misc.UtilsAndCommons; @@ -25,52 +26,52 @@ * @since 1.1.0 */ public interface AddressServerConstants { - - + + /** * the default server port when create the Instance object. */ int DEFAULT_SERVER_PORT = 8848; - + /** * when post ips is not given the product,then use the default. */ String DEFAULT_PRODUCT = "nacos"; - + /** * the separator between ip and port. */ String IP_PORT_SEPARATOR = ":"; - + /** * the separator for {@Service#name} between raw service name and group */ String GROUP_SERVICE_NAME_SEP = "@@"; - + /** * when post ips is not given the cluster,then use the default. */ String DEFAULT_GET_CLUSTER = "serverlist"; - + /** * post multi ip will use the "," to separator */ String MULTI_IPS_SEPARATOR = ","; - + /** * the default product name when deploy nacos with naming and config */ String ALIWARE_NACOS_DEFAULT_PRODUCT_NAME = "nacos.as.default"; - + /** * when the config and naming will separate deploy,then must specify product name by the client。 */ String ALIWARE_NACOS_PRODUCT_DOM_TEMPLATE = "nacos.as.%s"; - + /** * the url for address server prefix */ String ADDRESS_SERVER_REQUEST_URL = - UtilsAndCommons.NACOS_SERVER_CONTEXT + UtilsAndCommons.NACOS_SERVER_VERSION + "/as"; - + UtilsAndCommons.NACOS_SERVER_CONTEXT + UtilsAndCommons.NACOS_SERVER_VERSION + "/as"; + } diff --git a/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java b/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java index 49f0748a3be..b3d2ceeb189 100644 --- a/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java +++ b/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.controller; import com.alibaba.nacos.address.component.AddressServerGeneratorManager; @@ -45,16 +46,16 @@ @RestController @RequestMapping({AddressServerConstants.ADDRESS_SERVER_REQUEST_URL + "/nodes"}) public class AddressServerClusterController { - + @Autowired private ServiceManager serviceManager; - + @Autowired private AddressServerManager addressServerManager; - + @Autowired private AddressServerGeneratorManager addressServerGeneratorManager; - + /** * @param product Ip list of products to be associated * @param cluster Ip list of product cluster to be associated @@ -63,21 +64,21 @@ public class AddressServerClusterController { */ @RequestMapping(value = "", method = RequestMethod.POST) public ResponseEntity postCluster(@RequestParam(required = false) String product, - @RequestParam(required = false) String cluster, - @RequestParam(name = "ips") String ips) { - + @RequestParam(required = false) String cluster, @RequestParam(name = "ips") String ips) { + //1. prepare the storage name for product and cluster String productName = addressServerGeneratorManager.generateProductName(product); String clusterName = addressServerManager.getDefaultClusterNameIfEmpty(cluster); - + //2. prepare the response name for product and cluster to client String rawProductName = addressServerManager.getRawProductName(product); String rawClusterName = addressServerManager.getRawClusterName(cluster); - Loggers.addressLogger.info("put cluster node,the cluster name is " + cluster + "; the product name=" + product + "; the ip list=" + ips); + Loggers.addressLogger.info("put cluster node,the cluster name is " + cluster + "; the product name=" + product + + "; the ip list=" + ips); ResponseEntity responseEntity; try { String serviceName = addressServerGeneratorManager.generateNacosServiceName(productName); - + Cluster clusterObj = new Cluster(); clusterObj.setName(clusterName); clusterObj.setHealthChecker(new AbstractHealthChecker.None()); @@ -85,21 +86,24 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product String[] ipArray = addressServerManager.splitIps(ips); String checkResult = AddressServerParamCheckUtil.checkIps(ipArray); if (AddressServerParamCheckUtil.CHECK_OK.equals(checkResult)) { - List instanceList = addressServerGeneratorManager.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray); + List instanceList = addressServerGeneratorManager + .generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray); for (Instance instance : instanceList) { serviceManager.registerInstance(Constants.DEFAULT_NAMESPACE_ID, serviceName, instance); } - responseEntity = ResponseEntity.ok("product=" + rawProductName + ",cluster=" + rawClusterName + "; put success with size=" + instanceList.size()); + responseEntity = ResponseEntity + .ok("product=" + rawProductName + ",cluster=" + rawClusterName + "; put success with size=" + + instanceList.size()); } else { responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(checkResult); } } catch (Exception e) { responseEntity = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); } - + return responseEntity; } - + /** * @param product Ip list of products to be associated * @param cluster Ip list of product cluster to be associated @@ -108,25 +112,26 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product */ @RequestMapping(value = "", method = RequestMethod.DELETE) public ResponseEntity deleteCluster(@RequestParam(required = false) String product, - @RequestParam(required = false) String cluster, - @RequestParam String ips) { + @RequestParam(required = false) String cluster, @RequestParam String ips) { //1. prepare the storage name for product and cluster String productName = addressServerGeneratorManager.generateProductName(product); String clusterName = addressServerManager.getDefaultClusterNameIfEmpty(cluster); - + //2. prepare the response name for product and cluster to client String rawProductName = addressServerManager.getRawProductName(product); String rawClusterName = addressServerManager.getRawClusterName(cluster); - ResponseEntity responseEntity = ResponseEntity.status(HttpStatus.OK).body("product=" + rawProductName + ", cluster=" + rawClusterName + " delete success."); + ResponseEntity responseEntity = ResponseEntity.status(HttpStatus.OK) + .body("product=" + rawProductName + ", cluster=" + rawClusterName + " delete success."); try { - + String serviceName = addressServerGeneratorManager.generateNacosServiceName(productName); Service service = serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, serviceName); - + if (service == null) { - responseEntity = ResponseEntity.status(HttpStatus.NOT_FOUND).body("product=" + rawProductName + " not found."); + responseEntity = ResponseEntity.status(HttpStatus.NOT_FOUND) + .body("product=" + rawProductName + " not found."); } else { - + if (StringUtils.isBlank(ips)) { // delete all ips from the cluster responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body("ips must not be empty."); @@ -135,19 +140,21 @@ public ResponseEntity deleteCluster(@RequestParam(required = false) String produ String[] ipArray = addressServerManager.splitIps(ips); String checkResult = AddressServerParamCheckUtil.checkIps(ipArray); if (AddressServerParamCheckUtil.CHECK_OK.equals(checkResult)) { - List instanceList = addressServerGeneratorManager.generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray); - serviceManager.removeInstance(Constants.DEFAULT_NAMESPACE_ID, serviceName, false, instanceList.toArray(new Instance[instanceList.size()])); + List instanceList = addressServerGeneratorManager + .generateInstancesByIps(serviceName, rawProductName, clusterName, ipArray); + serviceManager.removeInstance(Constants.DEFAULT_NAMESPACE_ID, serviceName, false, + instanceList.toArray(new Instance[instanceList.size()])); } else { responseEntity = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(checkResult); } } } } catch (Exception e) { - + responseEntity = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getCause()); } - + return responseEntity; } - + } diff --git a/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java b/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java index c75adb7b6bb..9cd5335d71b 100644 --- a/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java +++ b/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.controller; import com.alibaba.nacos.address.component.AddressServerGeneratorManager; @@ -35,36 +36,37 @@ */ @RestController public class ServerListController { - + @Autowired private ServiceManager serviceManager; - + @Autowired private AddressServerGeneratorManager addressServerBuilderManager; - + /** * @param product will get Ip list of that products to be associated * @param cluster will get Ip list of that product cluster to be associated * @return */ @RequestMapping(value = "/{product}/{cluster}", method = RequestMethod.GET) - public ResponseEntity getCluster(@PathVariable String product, - @PathVariable String cluster) { - + public ResponseEntity getCluster(@PathVariable String product, @PathVariable String cluster) { + String productName = addressServerBuilderManager.generateProductName(product); String serviceName = addressServerBuilderManager.generateNacosServiceName(productName); Service service = serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, serviceName); if (service == null) { - + return ResponseEntity.status(HttpStatus.NOT_FOUND).body("product=" + product + " not found."); } - + if (!service.getClusterMap().containsKey(cluster)) { - - return ResponseEntity.status(HttpStatus.NOT_FOUND).body("product=" + product + ",cluster=" + cluster + " not found."); + + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body("product=" + product + ",cluster=" + cluster + " not found."); } - + Cluster clusterObj = service.getClusterMap().get(cluster); - return ResponseEntity.status(HttpStatus.OK).body(addressServerBuilderManager.generateResponseIps(clusterObj.allIPs(false))); + return ResponseEntity.status(HttpStatus.OK) + .body(addressServerBuilderManager.generateResponseIps(clusterObj.allIPs(false))); } } diff --git a/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java b/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java index a450ff1982f..aac543a3e5c 100644 --- a/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java +++ b/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.misc; import org.slf4j.Logger; @@ -23,6 +24,6 @@ * @date 2019-07-04 4:34 PM */ public class Loggers { - + public static final Logger addressLogger = LoggerFactory.getLogger("com.alibaba.nacos.address.main"); } diff --git a/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java b/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java index f4f26b71d2a..af6b1216a10 100644 --- a/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java +++ b/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address.util; import java.util.regex.Matcher; @@ -26,19 +27,19 @@ * @since 1.1.0 */ public class AddressServerParamCheckUtil { - + public static final String CHECK_OK = "ok"; - + public static final String ILLEGAL_IP_PREFIX = "illegal ip: "; - + private static final String IP_REGEX = "(2(5[0-5]{1}|[0-4]\\d{1})|[0-1]?\\d{1,2})(\\.(2(5[0-5]{1}|[0-4]\\d{1})|[0-1]?\\d{1,2})){3}"; - + private static final Pattern IP_PATTERN = Pattern.compile(IP_REGEX); - + public static String checkIps(String... ips) { - + if (ips == null || ips.length == 0) { - + return CHECK_OK; } // illegal response @@ -50,11 +51,11 @@ public static String checkIps(String... ips) { } illegalResponse.append(ip + ","); } - + if (illegalResponse.length() == 0) { return CHECK_OK; } - + return ILLEGAL_IP_PREFIX + illegalResponse.substring(0, illegalResponse.length() - 1); } } diff --git a/address/src/main/resources/META-INF/logback/nacos-included.xml b/address/src/main/resources/META-INF/logback/nacos-included.xml index 14324efe205..8dcb6627b96 100644 --- a/address/src/main/resources/META-INF/logback/nacos-included.xml +++ b/address/src/main/resources/META-INF/logback/nacos-included.xml @@ -16,12 +16,12 @@ --> - + - + + class="ch.qos.logback.core.rolling.RollingFileAppender"> ${LOG_HOME}/nacos-address.log true @@ -36,7 +36,7 @@ UTF-8 - + diff --git a/address/src/main/resources/application.properties b/address/src/main/resources/application.properties index 6acfc72c546..b0b2c55fcd0 100644 --- a/address/src/main/resources/application.properties +++ b/address/src/main/resources/application.properties @@ -13,6 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # - server.port=8080 server.servlet.context-path=/ diff --git a/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java b/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java index a7c5d7d20c1..f3663beb334 100644 --- a/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java +++ b/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address; import org.junit.Ignore; @@ -26,37 +27,40 @@ */ @Ignore public class AddressServerControllerTests { - + private static final String PRODUCT_NACOS = "nacos"; + private static final String PRODUCT_CONFIG = "config"; + private static final String PRODUCT_NAMING = "naming"; + private static final String DEFAULT_URL_CLUSTER = "serverlist"; - + private static final String GET_SERVERLIST_URL_FORMART = "http://127.0.0.1:8080/%s/%s"; - + //-----------------product=nacos,cluster=DEFAULT -------------------// - + /** * test the default product and cluster */ @Test public void postCluster() { - + String ips = "127.0.0.100,127.0.0.102,127.0.0.104"; HashMap params = new HashMap<>(); params.put("ips", ips); String response = SimpleHttpTestUtils.doPost("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void getCluster() { - + String getUrl = String.format(GET_SERVERLIST_URL_FORMART, PRODUCT_NACOS, DEFAULT_URL_CLUSTER); String response = SimpleHttpTestUtils.doGet(getUrl, new HashMap<>(), "UTF-8"); System.err.println(response); } - + @Test public void deleteCluster() { HashMap deleteIp = new HashMap<>(); @@ -64,7 +68,7 @@ public void deleteCluster() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", deleteIp, "UTF-8"); System.err.println(response); } - + @Test public void deleteClusterWithSpecIp() { HashMap params = new HashMap<>(); @@ -72,26 +76,26 @@ public void deleteClusterWithSpecIp() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void putCluster() { - + String ips = "127.0.0.114"; HashMap params = new HashMap<>(); params.put("ips", ips); String response = SimpleHttpTestUtils.doPut("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + //-----------------product=config,cluster=cluster01 -------------------// - + /** * test with product */ - + @Test public void postClusterWithProduct() { - + String ips = "127.0.0.101,127.0.0.102,127.0.0.103"; HashMap params = new HashMap<>(); params.put("ips", ips); @@ -99,7 +103,7 @@ public void postClusterWithProduct() { String response = SimpleHttpTestUtils.doPost("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void getClusterWithProduct() { HashMap params = new HashMap<>(); @@ -107,7 +111,7 @@ public void getClusterWithProduct() { String response = SimpleHttpTestUtils.doGet(getUrl, params, "UTF-8"); System.err.println(response); } - + @Test public void deleteClusterWithProduct() { HashMap params = new HashMap<>(); @@ -115,7 +119,7 @@ public void deleteClusterWithProduct() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void deleteClusterWithProductAndIp() { HashMap params = new HashMap<>(); @@ -124,10 +128,10 @@ public void deleteClusterWithProductAndIp() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void putClusterWithProduct() { - + String ips = "127.0.0.196"; HashMap params = new HashMap<>(); params.put("ips", ips); @@ -135,16 +139,15 @@ public void putClusterWithProduct() { String response = SimpleHttpTestUtils.doPut("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - - + //-----------------product=naming,cluster=cluster01 -------------------// - + /** * test with product and cluster */ @Test public void postClusterWithProductAndCluster() { - + String ips = "127.0.0.100,127.0.0.200,127.0.0.31"; HashMap params = new HashMap<>(); params.put("ips", ips); @@ -153,7 +156,7 @@ public void postClusterWithProductAndCluster() { String response = SimpleHttpTestUtils.doPost("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void getClusterWithProductAndCluster() { HashMap params = new HashMap<>(); @@ -161,7 +164,7 @@ public void getClusterWithProductAndCluster() { String response = SimpleHttpTestUtils.doGet(getUrl, params, "UTF-8"); System.err.println(response); } - + @Test public void deleteClusterWithProductAndCluster() { HashMap params = new HashMap<>(); @@ -170,7 +173,7 @@ public void deleteClusterWithProductAndCluster() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void deleteClusterWithProductAndClusterAndIp() { HashMap params = new HashMap<>(); @@ -180,10 +183,10 @@ public void deleteClusterWithProductAndClusterAndIp() { String response = SimpleHttpTestUtils.doDelete("http://127.0.0.1:8080/nacos/v1/as/nodes", params, "UTF-8"); System.err.println(response); } - + @Test public void putClusterWithProductAndCluster() { - + String ips = "127.0.0.171"; HashMap params = new HashMap<>(); params.put("ips", ips); diff --git a/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java b/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java index ef9eaebd9ec..ac97e1497e6 100644 --- a/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java +++ b/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address; import com.alibaba.nacos.address.util.AddressServerParamCheckUtil; @@ -23,12 +24,12 @@ * @date 2019-06-19 11:31 AM */ public class ParamCheckUtilTests { - + @Test public void checkIps() { String[] ips = {"127.0.0.1"}; System.out.println(AddressServerParamCheckUtil.checkIps(ips)); - + String[] illlegalIps = {"127.100.19", "127.0.0.1"}; System.err.println(AddressServerParamCheckUtil.checkIps(illlegalIps)); } diff --git a/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java b/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java index cae710fbd25..d95233c4123 100644 --- a/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java +++ b/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.alibaba.nacos.address; import com.alibaba.nacos.common.utils.IoUtils; @@ -31,40 +32,43 @@ * @date 2019-06-18 2:40 PM */ public class SimpleHttpTestUtils { - + private static final String REQUEST_METHOD_DELETE = "DELETE"; + private static final String REQUEST_METHOD_PUT = "PUT"; + private static final String REQUEST_METHOD_POST = "POST"; + private static final String REQUEST_METHOD_GET = "GET"; - + /** * 连接超时 */ - private static int CONNECT_TIME_OUT = 2000; - + private static final int CONNECT_TIME_OUT = 2000; + /** * 读取数据超时 */ - private static int READ_TIME_OUT = 2000; - + private static final int READ_TIME_OUT = 2000; + /** * 请求编码 */ public static String REQUEST_ENCODING = "UTF-8"; - + /** * 接收编码 */ public static String RESPONSE_ENCODING = "UTF-8"; - + public static final short OK = 200; - + public static final short Bad_Request = 400; - + public static final short Internal_Server_Error = 500; - + public static final short PARAM_ERROR_NO_ANALYSESOR = 1000; - + /** *

      * 发送带参数的GET的HTTP请求
@@ -77,7 +81,7 @@ public class SimpleHttpTestUtils {
     public static String doGet(String reqUrl, Map paramMap, String recvEncoding) {
         return doRequest(reqUrl, paramMap, REQUEST_METHOD_GET, recvEncoding);
     }
-
+    
     /**
      * 
      * 发送带参数的POST的HTTP请求
@@ -90,7 +94,7 @@ public static String doGet(String reqUrl, Map paramMap, String r
     public static String doPost(String reqUrl, Map paramMap, String recvEncoding) {
         return doRequest(reqUrl, paramMap, REQUEST_METHOD_POST, recvEncoding);
     }
-
+    
     /**
      * 
      * 发送带参数的 PUT 的 HTTP 请求
@@ -103,7 +107,7 @@ public static String doPost(String reqUrl, Map paramMap, String
     public static String doPut(String reqUrl, Map paramMap, String recvEncoding) {
         return doRequest(reqUrl, paramMap, REQUEST_METHOD_PUT, recvEncoding);
     }
-
+    
     /**
      * 
      * 发送带参数的 DELETE 的 HTTP 请求
@@ -116,13 +120,15 @@ public static String doPut(String reqUrl, Map paramMap, String r
     public static String doDelete(String reqUrl, Map paramMap, String recvEncoding) {
         return doRequest(reqUrl, paramMap, REQUEST_METHOD_DELETE, recvEncoding);
     }
-
-    private static String doRequest(String reqUrl, Map paramMap, String reqMethod, String recvEncoding) {
-
+    
+    private static String doRequest(String reqUrl, Map paramMap, String reqMethod,
+            String recvEncoding) {
+        
         return doExecute(reqUrl, paramMap, reqMethod, recvEncoding);
     }
-
-    private static String doExecute(String reqUrl, Map paramMap, String reqMethod, String recvEncoding) {
+    
+    private static String doExecute(String reqUrl, Map paramMap, String reqMethod,
+            String recvEncoding) {
         HttpURLConnection urlCon = null;
         String responseContent = null;
         try {
@@ -134,13 +140,13 @@ private static String doExecute(String reqUrl, Map paramMap, Str
                     params.append(URLEncoder.encode(element.getValue(), REQUEST_ENCODING));
                     params.append("&");
                 }
-
+                
                 if (params.length() > 0) {
                     params = params.deleteCharAt(params.length() - 1);
                 }
-
-                if (params.length() > 0 &&
-                        (REQUEST_METHOD_GET.equals(reqMethod) || REQUEST_METHOD_DELETE.equals(reqMethod))) {
+                
+                if (params.length() > 0 && (REQUEST_METHOD_GET.equals(reqMethod) || REQUEST_METHOD_DELETE
+                        .equals(reqMethod))) {
                     reqUrl = reqUrl + "?" + params.toString();
                 }
             }
@@ -169,7 +175,7 @@ private static String doExecute(String reqUrl, Map paramMap, Str
             responseContent = tempStr.toString();
             rd.close();
             in.close();
-
+            
             urlCon.getResponseMessage();
         } catch (IOException e) {
             e.printStackTrace();
@@ -178,5 +184,5 @@ private static String doExecute(String reqUrl, Map paramMap, Str
         }
         return responseContent;
     }
-
+    
 }

From 45d8f97be9e370ed22940369aab0534284244cc2 Mon Sep 17 00:00:00 2001
From: KomachiSion <263976490@qq.com>
Date: Fri, 3 Jul 2020 13:52:44 +0800
Subject: [PATCH 2/2] Use new code style for nacos-address module.

---
 .../AddressServerGeneratorManager.java        | 22 ++++++++----
 .../component/AddressServerManager.java       | 15 ++++----
 .../constant/AddressServerConstants.java      | 12 +++----
 .../AddressServerClusterController.java       | 13 ++++---
 .../controller/ServerListController.java      |  7 ++--
 .../alibaba/nacos/address/misc/Loggers.java   |  4 ++-
 .../util/AddressServerParamCheckUtil.java     |  8 ++++-
 .../address/AddressServerControllerTests.java | 14 --------
 .../nacos/address/ParamCheckUtilTests.java    |  4 ---
 .../nacos/address/SimpleHttpTestUtils.java    | 36 +++++++------------
 10 files changed, 66 insertions(+), 69 deletions(-)

diff --git a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java
index b4b7bf53c5e..32fb0b88fed 100644
--- a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java
+++ b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerGeneratorManager.java
@@ -36,6 +36,12 @@
 @Component
 public class AddressServerGeneratorManager {
     
+    /**
+     * Generate product name.
+     *
+     * @param name name
+     * @return product
+     */
     public String generateProductName(String name) {
         
         if (StringUtils.isBlank(name) || AddressServerConstants.DEFAULT_PRODUCT.equals(name)) {
@@ -49,10 +55,10 @@ public String generateProductName(String name) {
     /**
      * Note: if the parameter inputted is empty then will return the empty list.
      *
-     * @param serviceName
-     * @param clusterName
-     * @param ipArray
-     * @return
+     * @param serviceName service name
+     * @param clusterName cluster name
+     * @param ipArray array of ips
+     * @return instance list
      */
     public List generateInstancesByIps(String serviceName, String rawProductName, String clusterName,
             String[] ipArray) {
@@ -78,7 +84,7 @@ public List generateInstancesByIps(String serviceName, String rawProdu
         return instanceList;
     }
     
-    public String[] generateIpAndPort(String ip) {
+    private String[] generateIpAndPort(String ip) {
         
         int index = ip.indexOf(AddressServerConstants.IP_PORT_SEPARATOR);
         if (index != -1) {
@@ -90,6 +96,8 @@ public String[] generateIpAndPort(String ip) {
     }
     
     /**
+     * Generate response ips.
+     *
      * @param instanceList a instance set will generate string response to client.
      * @return the result of response to client
      */
@@ -105,7 +113,9 @@ public String generateResponseIps(List instanceList) {
     }
     
     /**
-     * @param rawServiceName the raw service name will not contains the {@Constans.DEFAULT_GROUP}
+     * Generate nacos service name.
+     *
+     * @param rawServiceName the raw service name will not contains the {@link Constants#DEFAULT_GROUP}.
      * @return the nacos service name
      */
     public String generateNacosServiceName(String rawServiceName) {
diff --git a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java
index 7125d1a6647..20880cd801c 100644
--- a/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java
+++ b/address/src/main/java/com/alibaba/nacos/address/component/AddressServerManager.java
@@ -17,6 +17,7 @@
 package com.alibaba.nacos.address.component;
 
 import com.alibaba.nacos.address.constant.AddressServerConstants;
+import com.alibaba.nacos.naming.misc.UtilsAndCommons;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
@@ -41,13 +42,11 @@ public String getRawProductName(String name) {
     }
     
     /**
-     * 

- * if the name is empty then return the default {@UtilAndCommons#DEFAULT_CLUSTER_NAME}, - *

- * or return the source name by input + * If the name is empty then return the default {@link UtilsAndCommons#DEFAULT_CLUSTER_NAME}, or return the source + * name by input. * - * @param name - * @return + * @param name name + * @return default cluster name */ public String getDefaultClusterNameIfEmpty(String name) { @@ -64,8 +63,10 @@ public String getRawClusterName(String name) { } /** + * Split ips. + * * @param ips multi ip will separator by the ',' - * @return + * @return array of ip */ public String[] splitIps(String ips) { diff --git a/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java b/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java index 3377ccfee49..fc565dd806f 100644 --- a/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java +++ b/address/src/main/java/com/alibaba/nacos/address/constant/AddressServerConstants.java @@ -19,7 +19,7 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons; /** - * Uniform constant parameter naming for address servers and default values ​​for related parameters + * Uniform constant parameter naming for address servers and default values ​​for related parameters. * * @author pbting * @date 2019-06-17 7:23 PM @@ -44,7 +44,7 @@ public interface AddressServerConstants { String IP_PORT_SEPARATOR = ":"; /** - * the separator for {@Service#name} between raw service name and group + * the separator for service name between raw service name and group. */ String GROUP_SERVICE_NAME_SEP = "@@"; @@ -54,22 +54,22 @@ public interface AddressServerConstants { String DEFAULT_GET_CLUSTER = "serverlist"; /** - * post multi ip will use the "," to separator + * post multi ip will use the "," to separator. */ String MULTI_IPS_SEPARATOR = ","; /** - * the default product name when deploy nacos with naming and config + * the default product name when deploy nacos with naming and config. */ String ALIWARE_NACOS_DEFAULT_PRODUCT_NAME = "nacos.as.default"; /** - * when the config and naming will separate deploy,then must specify product name by the client。 + * when the config and naming will separate deploy,then must specify product name by the client. */ String ALIWARE_NACOS_PRODUCT_DOM_TEMPLATE = "nacos.as.%s"; /** - * the url for address server prefix + * the url for address server prefix. */ String ADDRESS_SERVER_REQUEST_URL = UtilsAndCommons.NACOS_SERVER_CONTEXT + UtilsAndCommons.NACOS_SERVER_VERSION + "/as"; diff --git a/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java b/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java index b3d2ceeb189..68cf60c4a6a 100644 --- a/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java +++ b/address/src/main/java/com/alibaba/nacos/address/controller/AddressServerClusterController.java @@ -39,8 +39,9 @@ import java.util.List; /** + * Address server cluster controller. + * * @author pbting - * @date 2019-06-10 9:59 AM * @since 1.1.0 */ @RestController @@ -57,10 +58,12 @@ public class AddressServerClusterController { private AddressServerGeneratorManager addressServerGeneratorManager; /** + * Create new cluster. + * * @param product Ip list of products to be associated * @param cluster Ip list of product cluster to be associated * @param ips will post ip list. - * @return + * @return result of create new cluster */ @RequestMapping(value = "", method = RequestMethod.POST) public ResponseEntity postCluster(@RequestParam(required = false) String product, @@ -73,7 +76,7 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product //2. prepare the response name for product and cluster to client String rawProductName = addressServerManager.getRawProductName(product); String rawClusterName = addressServerManager.getRawClusterName(cluster); - Loggers.addressLogger.info("put cluster node,the cluster name is " + cluster + "; the product name=" + product + Loggers.ADDRESS_LOGGER.info("put cluster node,the cluster name is " + cluster + "; the product name=" + product + "; the ip list=" + ips); ResponseEntity responseEntity; try { @@ -105,10 +108,12 @@ public ResponseEntity postCluster(@RequestParam(required = false) String product } /** + * Delete cluster. + * * @param product Ip list of products to be associated * @param cluster Ip list of product cluster to be associated * @param ips will delete ips. - * @return + * @return delete result */ @RequestMapping(value = "", method = RequestMethod.DELETE) public ResponseEntity deleteCluster(@RequestParam(required = false) String product, diff --git a/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java b/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java index 9cd5335d71b..c41ccef9461 100644 --- a/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java +++ b/address/src/main/java/com/alibaba/nacos/address/controller/ServerListController.java @@ -30,8 +30,9 @@ import org.springframework.web.bind.annotation.RestController; /** + * Server list controller. + * * @author pbting - * @date 2019-06-18 5:04 PM * @since 1.1.0 */ @RestController @@ -44,9 +45,11 @@ public class ServerListController { private AddressServerGeneratorManager addressServerBuilderManager; /** + * Get cluster. + * * @param product will get Ip list of that products to be associated * @param cluster will get Ip list of that product cluster to be associated - * @return + * @return result of get */ @RequestMapping(value = "/{product}/{cluster}", method = RequestMethod.GET) public ResponseEntity getCluster(@PathVariable String product, @PathVariable String cluster) { diff --git a/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java b/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java index aac543a3e5c..416fede114b 100644 --- a/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java +++ b/address/src/main/java/com/alibaba/nacos/address/misc/Loggers.java @@ -20,10 +20,12 @@ import org.slf4j.LoggerFactory; /** + * Loggers holder. + * * @author pbting * @date 2019-07-04 4:34 PM */ public class Loggers { - public static final Logger addressLogger = LoggerFactory.getLogger("com.alibaba.nacos.address.main"); + public static final Logger ADDRESS_LOGGER = LoggerFactory.getLogger("com.alibaba.nacos.address.main"); } diff --git a/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java b/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java index af6b1216a10..e13d1a0baaf 100644 --- a/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java +++ b/address/src/main/java/com/alibaba/nacos/address/util/AddressServerParamCheckUtil.java @@ -20,7 +20,7 @@ import java.util.regex.Pattern; /** - * Provides a unified tool class for address server parameter verification + * Provides a unified tool class for address server parameter verification. * * @author pbting * @date 2019-06-19 11:19 AM @@ -36,6 +36,12 @@ public class AddressServerParamCheckUtil { private static final Pattern IP_PATTERN = Pattern.compile(IP_REGEX); + /** + * Check ips. + * + * @param ips ips + * @return 'ok' if check passed, otherwise illegal ip + */ public static String checkIps(String... ips) { if (ips == null || ips.length == 0) { diff --git a/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java b/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java index f3663beb334..6a8b9e4f8f2 100644 --- a/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java +++ b/address/src/test/java/com/alibaba/nacos/address/AddressServerControllerTests.java @@ -21,10 +21,6 @@ import java.util.HashMap; -/** - * @author pbting - * @date 2019-06-18 2:37 PM - */ @Ignore public class AddressServerControllerTests { @@ -40,9 +36,6 @@ public class AddressServerControllerTests { //-----------------product=nacos,cluster=DEFAULT -------------------// - /** - * test the default product and cluster - */ @Test public void postCluster() { @@ -89,10 +82,6 @@ public void putCluster() { //-----------------product=config,cluster=cluster01 -------------------// - /** - * test with product - */ - @Test public void postClusterWithProduct() { @@ -142,9 +131,6 @@ public void putClusterWithProduct() { //-----------------product=naming,cluster=cluster01 -------------------// - /** - * test with product and cluster - */ @Test public void postClusterWithProductAndCluster() { diff --git a/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java b/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java index ac97e1497e6..2fb9e410ebd 100644 --- a/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java +++ b/address/src/test/java/com/alibaba/nacos/address/ParamCheckUtilTests.java @@ -19,10 +19,6 @@ import com.alibaba.nacos.address.util.AddressServerParamCheckUtil; import org.junit.Test; -/** - * @author pbting - * @date 2019-06-19 11:31 AM - */ public class ParamCheckUtilTests { @Test diff --git a/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java b/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java index d95233c4123..c0c6f11a695 100644 --- a/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java +++ b/address/src/test/java/com/alibaba/nacos/address/SimpleHttpTestUtils.java @@ -27,10 +27,6 @@ import java.net.URLEncoder; import java.util.Map; -/** - * @author pbting - * @date 2019-06-18 2:40 PM - */ public class SimpleHttpTestUtils { private static final String REQUEST_METHOD_DELETE = "DELETE"; @@ -42,37 +38,35 @@ public class SimpleHttpTestUtils { private static final String REQUEST_METHOD_GET = "GET"; /** - * 连接超时 + * 连接超时. */ private static final int CONNECT_TIME_OUT = 2000; /** - * 读取数据超时 + * 读取数据超时. */ private static final int READ_TIME_OUT = 2000; /** - * 请求编码 + * 请求编码. */ - public static String REQUEST_ENCODING = "UTF-8"; + public static final String REQUEST_ENCODING = "UTF-8"; /** - * 接收编码 + * 接收编码. */ - public static String RESPONSE_ENCODING = "UTF-8"; + public static final String RESPONSE_ENCODING = "UTF-8"; public static final short OK = 200; - public static final short Bad_Request = 400; + public static final short BAD_REQUEST = 400; - public static final short Internal_Server_Error = 500; + public static final short INTERNAL_SERVER_ERROR = 500; public static final short PARAM_ERROR_NO_ANALYSESOR = 1000; /** - *

-     * 发送带参数的GET的HTTP请求
-     * 
+ * 发送带参数的GET的HTTP请求. * * @param reqUrl HTTP请求URL * @param paramMap 参数映射表 @@ -83,9 +77,7 @@ public static String doGet(String reqUrl, Map paramMap, String r } /** - *
-     * 发送带参数的POST的HTTP请求
-     * 
+ * 发送带参数的POST的HTTP请求. * * @param reqUrl HTTP请求URL * @param paramMap 参数映射表 @@ -96,9 +88,7 @@ public static String doPost(String reqUrl, Map paramMap, String } /** - *
-     * 发送带参数的 PUT 的 HTTP 请求
-     * 
+ * 发送带参数的 PUT 的 HTTP 请求. * * @param reqUrl HTTP请求URL * @param paramMap 参数映射表 @@ -109,9 +99,7 @@ public static String doPut(String reqUrl, Map paramMap, String r } /** - *
-     * 发送带参数的 DELETE 的 HTTP 请求
-     * 
+ * 发送带参数的 DELETE 的 HTTP 请求. * * @param reqUrl HTTP请求URL * @param paramMap 参数映射表