From 562cf6f5795d99a3057c227c60118acf5d34673a Mon Sep 17 00:00:00 2001 From: secbro2 Date: Tue, 24 Aug 2021 09:36:59 +0800 Subject: [PATCH] =?UTF-8?q?optimize=20the=20HashMap=E2=80=99s=20initialCap?= =?UTF-8?q?acity=20(#6714)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote/http/NamingHttpClientProxy.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java index a85e0cba8..a0cb09033 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientProxy.java @@ -149,7 +149,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { BeatInfo beatInfo = beatReactor.buildBeatInfo(groupedServiceName, instance); beatReactor.addBeatInfo(groupedServiceName, beatInfo); } - final Map params = new HashMap(16); + final Map params = new HashMap(32); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, groupedServiceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -175,7 +175,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { beatReactor.removeBeatInfo(NamingUtils.getGroupedName(serviceName, groupName), instance.getIp(), instance.getPort()); } - final Map params = new HashMap(8); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName)); params.put(CommonParams.CLUSTER_NAME, instance.getClusterName()); @@ -191,7 +191,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER .info("[UPDATE-SERVICE] {} update service {} with instance: {}", namespaceId, serviceName, instance); - final Map params = new HashMap(8); + final Map params = new HashMap(32); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -209,7 +209,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { @Override public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort, boolean healthyOnly) throws NacosException { - final Map params = new HashMap(8); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, NamingUtils.getGroupedName(serviceName, groupName)); params.put(CLUSTERS_PARAM, clusters); @@ -227,7 +227,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public Service queryService(String serviceName, String groupName) throws NacosException { NAMING_LOGGER.info("[QUERY-SERVICE] {} query service : {}, {}", namespaceId, serviceName, groupName); - final Map params = new HashMap(3); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -241,7 +241,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER.info("[CREATE-SERVICE] {} creating service : {}", namespaceId, service); - final Map params = new HashMap(6); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, service.getName()); params.put(CommonParams.GROUP_NAME, service.getGroupName()); @@ -258,7 +258,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { NAMING_LOGGER.info("[DELETE-SERVICE] {} deleting service : {} with groupName : {}", namespaceId, serviceName, groupName); - final Map params = new HashMap(6); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, serviceName); params.put(CommonParams.GROUP_NAME, groupName); @@ -271,7 +271,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public void updateService(Service service, AbstractSelector selector) throws NacosException { NAMING_LOGGER.info("[UPDATE-SERVICE] {} updating service : {}", namespaceId, service); - final Map params = new HashMap(6); + final Map params = new HashMap(16); params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, service.getName()); params.put(CommonParams.GROUP_NAME, service.getGroupName()); @@ -295,7 +295,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { if (NAMING_LOGGER.isDebugEnabled()) { NAMING_LOGGER.debug("[BEAT] {} sending beat to server: {}", namespaceId, beatInfo.toString()); } - Map params = new HashMap(8); + Map params = new HashMap(16); Map bodyMap = new HashMap(2); if (!lightBeatEnabled) { bodyMap.put("beat", JacksonUtils.toJson(beatInfo)); @@ -313,7 +313,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public boolean serverHealthy() { try { - String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap(2), + String result = reqApi(UtilAndComs.nacosUrlBase + "/operator/metrics", new HashMap(8), HttpMethod.GET); JsonNode json = JacksonUtils.toObj(result); String serverStatus = json.get("status").asText(); @@ -327,7 +327,7 @@ public class NamingHttpClientProxy extends AbstractNamingClientProxy { public ListView getServiceList(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException { - Map params = new HashMap(4); + Map params = new HashMap(16); params.put("pageNo", String.valueOf(pageNo)); params.put("pageSize", String.valueOf(pageSize)); params.put(CommonParams.NAMESPACE_ID, namespaceId);