diff --git a/naming/src/main/java/com/alibaba/nacos/naming/acl/AuthChecker.java b/naming/src/main/java/com/alibaba/nacos/naming/acl/AuthChecker.java index 8c73eb650..8e7b49343 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/acl/AuthChecker.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/acl/AuthChecker.java @@ -68,20 +68,20 @@ public class AuthChecker { String namespaceId = WebUtils.optional(req, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String dom = WebUtils.optional(req, "name", ""); - if (StringUtils.isEmpty(dom)) { - dom = WebUtils.optional(req, "dom", ""); + String serviceName = WebUtils.optional(req, "name", ""); + if (StringUtils.isEmpty(serviceName)) { + serviceName = WebUtils.optional(req, "serviceName", ""); } - if (StringUtils.isEmpty(dom)) { - dom = WebUtils.optional(req, "tag", ""); + if (StringUtils.isEmpty(serviceName)) { + serviceName = WebUtils.optional(req, "tag", ""); } - Service domObj = serviceManager.getService(namespaceId, dom); + Service service = serviceManager.getService(namespaceId, serviceName); - if (domObj == null) { + if (service == null) { if (!req.getRequestURI().equals(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.API_SET_ALL_WEIGHTS)) { - throw new IllegalStateException("auth failed, dom does not exist: " + dom); + throw new IllegalStateException("auth failed, service does not exist: " + serviceName); } } @@ -89,11 +89,11 @@ public class AuthChecker { String auth = req.getParameter("auth"); String userName = req.getParameter("userName"); if (StringUtils.isEmpty(auth) && StringUtils.isEmpty(token)) { - throw new IllegalArgumentException("provide 'authInfo' or 'token' to access this dom"); + throw new IllegalArgumentException("provide 'authInfo' or 'token' to access this service"); } // try valid token - if ((domObj != null && StringUtils.equals(domObj.getToken(), token))) { + if ((service != null && StringUtils.equals(service.getToken(), token))) { return; } @@ -115,7 +115,7 @@ public class AuthChecker { throw new AccessControlException("un-registered SDK app"); } - if (!domObj.getOwners().contains(authInfo.getOperator()) + if (!service.getOwners().contains(authInfo.getOperator()) && !switchDomain.masters.contains(authInfo.getOperator())) { throw new AccessControlException("dom already exists and you're not among the owners"); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java index fe15a52b8..fdd99c881 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java @@ -59,25 +59,25 @@ public class CatalogController { int pageSize = Integer.parseInt(WebUtils.required(request, "pgSize")); String keyword = WebUtils.optional(request, "keyword", StringUtils.EMPTY); - List doms = new ArrayList<>(); - int total = serviceManager.getPagedService(namespaceId, page - 1, pageSize, keyword, doms); + List services = new ArrayList<>(); + int total = serviceManager.getPagedService(namespaceId, page - 1, pageSize, keyword, services); - if (CollectionUtils.isEmpty(doms)) { + if (CollectionUtils.isEmpty(services)) { result.put("serviceList", Collections.emptyList()); result.put("count", 0); return result; } - JSONArray domArray = new JSONArray(); - for (Service dom : doms) { + JSONArray serviceJsonArray = new JSONArray(); + for (Service service : services) { ServiceView serviceView = new ServiceView(); - serviceView.setName(dom.getName()); - serviceView.setClusterCount(dom.getClusterMap().size()); - serviceView.setIpCount(dom.allIPs().size()); + serviceView.setName(service.getName()); + serviceView.setClusterCount(service.getClusterMap().size()); + serviceView.setIpCount(service.allIPs().size()); // FIXME should be optimized: int validCount = 0; - for (Instance instance : dom.allIPs()) { + for (Instance instance : service.allIPs()) { if (instance.isValid()) { validCount++; } @@ -85,10 +85,10 @@ public class CatalogController { serviceView.setHealthyInstanceCount(validCount); - domArray.add(serviceView); + serviceJsonArray.add(serviceView); } - result.put("serviceList", domArray); + result.put("serviceList", serviceJsonArray); result.put("count", total); return result; @@ -100,18 +100,18 @@ public class CatalogController { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); String serviceName = WebUtils.required(request, "serviceName"); - Service domain = serviceManager.getService(namespaceId, serviceName); - if (domain == null) { + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { throw new NacosException(NacosException.NOT_FOUND, "serivce " + serviceName + " is not found!"); } ServiceDetailView detailView = new ServiceDetailView(); - detailView.setService(domain); + detailView.setService(service); List clusters = new ArrayList<>(); - for (com.alibaba.nacos.naming.core.Cluster cluster : domain.getClusterMap().values()) { + for (com.alibaba.nacos.naming.core.Cluster cluster : service.getClusterMap().values()) { Cluster clusterView = new Cluster(); clusterView.setName(cluster.getName()); clusterView.setHealthChecker(cluster.getHealthChecker()); @@ -138,16 +138,16 @@ public class CatalogController { int page = Integer.parseInt(WebUtils.required(request, "startPg")); int pageSize = Integer.parseInt(WebUtils.required(request, "pgSize")); - Service domain = serviceManager.getService(namespaceId, serviceName); - if (domain == null) { + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { throw new NacosException(NacosException.NOT_FOUND, "serivce " + serviceName + " is not found!"); } - if (!domain.getClusterMap().containsKey(clusterName)) { + if (!service.getClusterMap().containsKey(clusterName)) { throw new NacosException(NacosException.NOT_FOUND, "cluster " + clusterName + " is not found!"); } - List instances = domain.getClusterMap().get(clusterName).allIPs(); + List instances = service.getClusterMap().get(clusterName).allIPs(); int start = (page - 1) * pageSize; int end = page * pageSize; @@ -197,22 +197,22 @@ public class CatalogController { } - @RequestMapping("/rt4Dom") - public JSONObject rt4Dom(HttpServletRequest request) { + @RequestMapping("/rt4Service") + public JSONObject rt4Service(HttpServletRequest request) { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String dom = WebUtils.required(request, "dom"); + String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME); - Service domObj = serviceManager.getService(namespaceId, dom); - if (domObj == null) { - throw new IllegalArgumentException("request dom doesn't exist"); + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { + throw new IllegalArgumentException("request service doesn't exist"); } JSONObject result = new JSONObject(); JSONArray clusters = new JSONArray(); - for (Map.Entry entry : domObj.getClusterMap().entrySet()) { + for (Map.Entry entry : service.getClusterMap().entrySet()) { JSONObject packet = new JSONObject(); HealthCheckTask task = entry.getValue().getHealthCheckTask(); @@ -228,11 +228,11 @@ public class CatalogController { return result; } - @RequestMapping("/getDomsByIP") - public JSONObject getDomsByIP(HttpServletRequest request) { + @RequestMapping("/getServicesByIP") + public JSONObject getServicesByIP(HttpServletRequest request) { String ip = WebUtils.required(request, "ip"); - Set doms = new HashSet(); + Set serviceNames = new HashSet<>(); Map> serviceNameMap = serviceManager.getAllServiceNames(); for (String namespaceId : serviceNameMap.keySet()) { @@ -242,11 +242,11 @@ public class CatalogController { for (Instance instance : instances) { if (ip.contains(":")) { if (StringUtils.equals(instance.getIp() + ":" + instance.getPort(), ip)) { - doms.add(namespaceId + UtilsAndCommons.SERVICE_GROUP_CONNECTOR + service.getName()); + serviceNames.add(namespaceId + UtilsAndCommons.SERVICE_GROUP_CONNECTOR + service.getName()); } } else { if (StringUtils.equals(instance.getIp(), ip)) { - doms.add(namespaceId + UtilsAndCommons.SERVICE_GROUP_CONNECTOR + service.getName()); + serviceNames.add(namespaceId + UtilsAndCommons.SERVICE_GROUP_CONNECTOR + service.getName()); } } } @@ -255,7 +255,7 @@ public class CatalogController { JSONObject result = new JSONObject(); - result.put("doms", doms); + result.put("doms", serviceNames); return result; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java index 1da62e69f..9837890b0 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ClusterController.java @@ -44,7 +44,7 @@ import javax.servlet.http.HttpServletRequest; public class ClusterController { @Autowired - protected ServiceManager domainsManager; + protected ServiceManager serviceManager; @RequestMapping(value = "", method = RequestMethod.PUT) public String update(HttpServletRequest request) throws Exception { @@ -58,12 +58,12 @@ public class ClusterController { String checkPort = WebUtils.required(request, "checkPort"); String useInstancePort4Check = WebUtils.required(request, "useInstancePort4Check"); - Service domain = domainsManager.getService(namespaceId, serviceName); - if (domain == null) { + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { throw new NacosException(NacosException.INVALID_PARAM, "service not found:" + serviceName); } - Cluster cluster = domain.getClusterMap().get(clusterName); + Cluster cluster = service.getClusterMap().get(clusterName); if (cluster == null) { Loggers.SRV_LOG.warn("[UPDATE-CLUSTER] cluster not exist, will create it: {}, service: {}", clusterName, serviceName); cluster = new Cluster(); @@ -93,13 +93,13 @@ public class ClusterController { cluster.setHealthChecker(abstractHealthChecker); cluster.setMetadata(UtilsAndCommons.parseMetadata(metadata)); - domain.getClusterMap().put(clusterName, cluster); + service.getClusterMap().put(clusterName, cluster); - domain.setLastModifiedMillis(System.currentTimeMillis()); - domain.recalculateChecksum(); - domain.valid(); + service.setLastModifiedMillis(System.currentTimeMillis()); + service.recalculateChecksum(); + service.valid(); - domainsManager.addOrReplaceService(domain); + serviceManager.addOrReplaceService(service); return "ok"; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java index bfa147b4b..c9b94ebd2 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/HealthController.java @@ -72,15 +72,15 @@ public class HealthController { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String dom = WebUtils.required(request, "serviceName"); + String serviceName = WebUtils.required(request, "serviceName"); String ip = WebUtils.required(request, "ip"); int port = Integer.parseInt(WebUtils.required(request, "port")); boolean valid = Boolean.valueOf(WebUtils.required(request, "valid")); String clusterName = WebUtils.optional(request, "clusterName", UtilsAndCommons.DEFAULT_CLUSTER_NAME); - if (!distroMapper.responsible(dom)) { - String server = distroMapper.mapSrv(dom); - Loggers.EVT_LOG.info("I'm not responsible for " + dom + ", proxy it to " + server); + if (!distroMapper.responsible(serviceName)) { + String server = distroMapper.mapSrv(serviceName); + Loggers.EVT_LOG.info("I'm not responsible for " + serviceName + ", proxy it to " + server); Map proxyParams = new HashMap<>(16); for (Map.Entry entry : request.getParameterMap().entrySet()) { String key = entry.getKey(); @@ -97,10 +97,10 @@ public class HealthController { HttpClient.HttpResult httpResult = HttpClient.httpPost(url, null, proxyParams); if (httpResult.code != HttpURLConnection.HTTP_OK) { - throw new IllegalArgumentException("failed to proxy health update to " + server + ", dom: " + dom); + throw new IllegalArgumentException("failed to proxy health update to " + server + ", service: " + serviceName); } } else { - Service service = serviceManager.getService(namespaceId, dom); + Service service = serviceManager.getService(namespaceId, serviceName); // Only health check "none" need update health status with api if (HealthCheckType.NONE.name().equals(service.getClusterMap().get(clusterName).getHealthChecker().getType())) { for (Instance instance : service.allIPs(Lists.newArrayList(clusterName))) { @@ -108,13 +108,13 @@ public class HealthController { instance.setValid(valid); Loggers.EVT_LOG.info((valid ? "[IP-ENABLED]" : "[IP-DISABLED]") + " ips: " + instance.getIp() + ":" + instance.getPort() + "@" + instance.getClusterName() - + ", dom: " + dom + ", msg: update thought HealthController api"); + + ", service: " + serviceName + ", msg: update thought HealthController api"); pushService.serviceChanged(namespaceId, service.getName()); break; } } } else { - throw new IllegalArgumentException("health check mode 'client' and 'server' are not supported , dom: " + dom); + throw new IllegalArgumentException("health check mode 'client' and 'server' are not supported, service: " + serviceName); } } return "ok"; diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java index fa0be1761..949833344 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java @@ -79,7 +79,7 @@ public class InstanceController { client.getClusters(), client.getSocketAddr().getAddress().getHostAddress(), 0, StringUtils.EMPTY, false, StringUtils.EMPTY, StringUtils.EMPTY, false); } catch (Exception e) { - Loggers.SRV_LOG.warn("PUSH-SERVICE: dom is not modified", e); + Loggers.SRV_LOG.warn("PUSH-SERVICE: service is not modified", e); } // overdrive the cache millis to push mode @@ -122,7 +122,7 @@ public class InstanceController { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String dom = WebUtils.required(request, CommonParams.SERVICE_NAME); + String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME); String agent = request.getHeader("Client-Version"); if (StringUtils.isBlank(agent)) { agent = request.getHeader("User-Agent"); @@ -139,7 +139,7 @@ public class InstanceController { boolean healthyOnly = Boolean.parseBoolean(WebUtils.optional(request, "healthyOnly", "false")); - return doSrvIPXT(namespaceId, dom, agent, clusters, clientIP, udpPort, env, isCheck, app, tenant, healthyOnly); + return doSrvIPXT(namespaceId, serviceName, agent, clusters, clientIP, udpPort, env, isCheck, app, tenant, healthyOnly); } @RequestMapping(value = "/instance", method = RequestMethod.GET) @@ -152,17 +152,17 @@ public class InstanceController { String ip = WebUtils.required(request, "ip"); int port = Integer.parseInt(WebUtils.required(request, "port")); - Service domain = serviceManager.getService(namespaceId, serviceName); - if (domain == null) { - throw new NacosException(NacosException.NOT_FOUND, "no dom " + serviceName + " found!"); + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { + throw new NacosException(NacosException.NOT_FOUND, "no service " + serviceName + " found!"); } List clusters = new ArrayList<>(); clusters.add(cluster); - List ips = domain.allIPs(clusters); + List ips = service.allIPs(clusters); if (ips == null || ips.isEmpty()) { - throw new IllegalStateException("no ips found for cluster " + cluster + " in dom " + serviceName); + throw new IllegalStateException("no ips found for cluster " + cluster + " in service " + serviceName); } for (Instance instance : ips) { @@ -202,10 +202,7 @@ public class InstanceController { if (StringUtils.isBlank(clientBeat.getCluster())) { clientBeat.setCluster(UtilsAndCommons.DEFAULT_CLUSTER_NAME); } - String serviceName = WebUtils.optional(request, "serviceName", StringUtils.EMPTY); - if (StringUtils.isBlank(serviceName)) { - serviceName = WebUtils.required(request, "dom"); - } + String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME); String clusterName = clientBeat.getCluster(); @@ -274,24 +271,24 @@ public class InstanceController { String key = WebUtils.required(request, "key"); - String domName; + String serviceName; String namespaceId; if (key.contains(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)) { namespaceId = key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0]; - domName = key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1]; + serviceName = key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1]; } else { namespaceId = UtilsAndCommons.DEFAULT_NAMESPACE_ID; - domName = key; + serviceName = key; } - Service dom = serviceManager.getService(namespaceId, domName); + Service service = serviceManager.getService(namespaceId, serviceName); - if (dom == null) { - throw new NacosException(NacosException.NOT_FOUND, "dom: " + domName + " not found."); + if (service == null) { + throw new NacosException(NacosException.NOT_FOUND, "service: " + serviceName + " not found."); } - List ips = dom.allIPs(); + List ips = service.allIPs(); JSONObject result = new JSONObject(); JSONArray ipArray = new JSONArray(); @@ -359,37 +356,37 @@ public class InstanceController { return instance; } - public void checkIfDisabled(Service domObj) throws Exception { - if (!domObj.getEnabled()) { - throw new Exception("domain is disabled now."); + public void checkIfDisabled(Service service) throws Exception { + if (!service.getEnabled()) { + throw new Exception("service is disabled now."); } } - public JSONObject doSrvIPXT(String namespaceId, String dom, String agent, String clusters, String clientIP, int udpPort, + public JSONObject doSrvIPXT(String namespaceId, String serviceName, String agent, String clusters, String clientIP, int udpPort, String env, boolean isCheck, String app, String tid, boolean healthyOnly) throws Exception { JSONObject result = new JSONObject(); - Service domObj = serviceManager.getService(namespaceId, dom); + Service service = serviceManager.getService(namespaceId, serviceName); - if (domObj == null) { - throw new NacosException(NacosException.NOT_FOUND, "dom not found: " + dom); + if (service == null) { + throw new NacosException(NacosException.NOT_FOUND, "service not found: " + serviceName); } - checkIfDisabled(domObj); + checkIfDisabled(service); long cacheMillis = switchDomain.getDefaultCacheMillis(); // now try to enable the push try { if (udpPort > 0 && pushService.canEnablePush(agent)) { - pushService.addClient(namespaceId, dom, + pushService.addClient(namespaceId, serviceName, clusters, agent, new InetSocketAddress(clientIP, udpPort), pushDataSource, tid, app); - cacheMillis = switchDomain.getPushCacheMillis(dom); + cacheMillis = switchDomain.getPushCacheMillis(serviceName); } } catch (Exception e) { Loggers.SRV_LOG.error("[NACOS-API] failed to added push client", e); @@ -398,28 +395,29 @@ public class InstanceController { List srvedIPs; - srvedIPs = domObj.srvIPs(Arrays.asList(StringUtils.split(clusters, ","))); + srvedIPs = service.srvIPs(Arrays.asList(StringUtils.split(clusters, ","))); // filter ips using selector: - if (domObj.getSelector() != null && StringUtils.isNotBlank(clientIP)) { - srvedIPs = domObj.getSelector().select(clientIP, srvedIPs); + if (service.getSelector() != null && StringUtils.isNotBlank(clientIP)) { + srvedIPs = service.getSelector().select(clientIP, srvedIPs); } if (CollectionUtils.isEmpty(srvedIPs)) { if (Loggers.DEBUG_LOG.isDebugEnabled()) { - Loggers.DEBUG_LOG.debug("no instance to serve for service: " + dom); + Loggers.DEBUG_LOG.debug("no instance to serve for service: " + serviceName); } result.put("hosts", new JSONArray()); - result.put("dom", dom); + result.put("dom", serviceName); + result.put("name", serviceName); result.put("cacheMillis", cacheMillis); result.put("lastRefTime", System.currentTimeMillis()); - result.put("checksum", domObj.getChecksum() + System.currentTimeMillis()); + result.put("checksum", service.getChecksum() + System.currentTimeMillis()); result.put("useSpecifiedURL", false); result.put("clusters", clusters); result.put("env", env); - result.put("metadata", domObj.getMetadata()); + result.put("metadata", service.getMetadata()); return result; } @@ -435,11 +433,11 @@ public class InstanceController { result.put("reachProtectThreshold", false); } - double threshold = domObj.getProtectThreshold(); + double threshold = service.getProtectThreshold(); if ((float) ipMap.get(Boolean.TRUE).size() / srvedIPs.size() <= threshold) { - Loggers.SRV_LOG.warn("protect threshold reached, return all ips, dom: {}", dom); + Loggers.SRV_LOG.warn("protect threshold reached, return all ips, service: {}", serviceName); if (isCheck) { result.put("reachProtectThreshold", true); } @@ -449,7 +447,7 @@ public class InstanceController { } if (isCheck) { - result.put("protectThreshold", domObj.getProtectThreshold()); + result.put("protectThreshold", service.getProtectThreshold()); result.put("reachLocalSiteCallThreshold", false); return new JSONObject(); @@ -485,14 +483,15 @@ public class InstanceController { result.put("hosts", hosts); - result.put("dom", dom); + result.put("dom", serviceName); + result.put("name", serviceName); result.put("cacheMillis", cacheMillis); result.put("lastRefTime", System.currentTimeMillis()); - result.put("checksum", domObj.getChecksum() + System.currentTimeMillis()); + result.put("checksum", service.getChecksum() + System.currentTimeMillis()); result.put("useSpecifiedURL", false); result.put("clusters", clusters); result.put("env", env); - result.put("metadata", domObj.getMetadata()); + result.put("metadata", service.getMetadata()); return result; } } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java index 8929042ae..d7a221c19 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/OperatorController.java @@ -134,14 +134,14 @@ public class OperatorController { JSONObject result = new JSONObject(); - int domCount = serviceManager.getServiceCount(); + int serviceCount = serviceManager.getServiceCount(); int ipCount = serviceManager.getInstanceCount(); int responsibleDomCount = serviceManager.getResponsibleServiceCount(); int responsibleIPCount = serviceManager.getResponsibleInstanceCount(); result.put("status", serverStatusManager.getServerStatus().name()); - result.put("serviceCount", domCount); + result.put("serviceCount", serviceCount); result.put("instanceCount", ipCount); result.put("responsibleServiceCount", responsibleDomCount); result.put("responsibleInstanceCount", responsibleIPCount); @@ -160,7 +160,7 @@ public class OperatorController { Service service = serviceManager.getService(namespaceId, dom); if (service == null) { - throw new IllegalArgumentException("dom not found"); + throw new IllegalArgumentException("service not found"); } JSONObject result = new JSONObject(); @@ -187,7 +187,7 @@ public class OperatorController { Service service = serviceManager.getService(namespaceId, dom); if (service == null) { - throw new IllegalArgumentException("dom not found"); + throw new IllegalArgumentException("service not found"); } JSONObject result = new JSONObject(); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java index 5f72cde60..ff69093d1 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/RaftController.java @@ -62,7 +62,7 @@ public class RaftController { private RaftConsistencyServiceImpl raftConsistencyService; @Autowired - private ServiceManager domainsManager; + private ServiceManager serviceManager; @Autowired private RaftCore raftCore; @@ -192,7 +192,7 @@ public class RaftController { response.setHeader("Content-Encode", "gzip"); JSONObject result = new JSONObject(); - result.put("doms", domainsManager.getServiceCount()); + result.put("services", serviceManager.getServiceCount()); result.put("peers", raftCore.getPeers()); return result; diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java index 198606d04..79561df7d 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java @@ -29,7 +29,6 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons; import com.alibaba.nacos.naming.selector.LabelSelector; import com.alibaba.nacos.naming.selector.NoneSelector; import com.alibaba.nacos.naming.selector.Selector; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -85,7 +84,7 @@ public class ServiceController { service.setSelector(parseSelector(selector)); service.setNamespaceId(namespaceId); - // now valid the dom. if failed, exception will be thrown + // now valid the service. if failed, exception will be thrown service.setLastModifiedMillis(System.currentTimeMillis()); service.recalculateChecksum(); service.valid(); @@ -158,9 +157,9 @@ public class ServiceController { UtilsAndCommons.DEFAULT_NAMESPACE_ID); String selectorString = WebUtils.optional(request, "selector", StringUtils.EMPTY); - List doms = serviceManager.getAllDomNamesList(namespaceId); + List serviceNameList = serviceManager.getAllServiceNameList(namespaceId); - if (doms == null || doms.isEmpty()) { + if (serviceNameList == null || serviceNameList.isEmpty()) { throw new NacosException(NacosException.INVALID_PARAM, "No service exist in " + namespaceId); } @@ -181,10 +180,10 @@ public class ServiceController { String[] factors = terms[0].split("\\."); switch (factors[0]) { case "INSTANCE": - doms = filterInstanceMetadata(namespaceId, doms, factors[factors.length - 1], terms[1].replace("'", "")); + serviceNameList = filterInstanceMetadata(namespaceId, serviceNameList, factors[factors.length - 1], terms[1].replace("'", "")); break; case "SERVICE": - doms = filterServiceMetadata(namespaceId, doms, factors[factors.length - 1], terms[1].replace("'", "")); + serviceNameList = filterServiceMetadata(namespaceId, serviceNameList, factors[factors.length - 1], terms[1].replace("'", "")); break; default: break; @@ -202,14 +201,14 @@ public class ServiceController { start = 0; } - if (end > doms.size()) { - end = doms.size(); + if (end > serviceNameList.size()) { + end = serviceNameList.size(); } JSONObject result = new JSONObject(); - result.put("doms", doms.subList(start, end)); - result.put("count", doms.size()); + result.put("doms", serviceNameList.subList(start, end)); + result.put("count", serviceNameList.size()); return result; @@ -225,82 +224,64 @@ public class ServiceController { String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY); String selector = WebUtils.optional(request, "selector", StringUtils.EMPTY); - Service domain = serviceManager.getService(namespaceId, serviceName); - if (domain == null) { + Service service = serviceManager.getService(namespaceId, serviceName); + if (service == null) { throw new NacosException(NacosException.INVALID_PARAM, "service " + serviceName + " not found!"); } - domain.setProtectThreshold(protectThreshold); + service.setProtectThreshold(protectThreshold); Map metadataMap = UtilsAndCommons.parseMetadata(metadata); - domain.setMetadata(metadataMap); + service.setMetadata(metadataMap); - domain.setSelector(parseSelector(selector)); + service.setSelector(parseSelector(selector)); - domain.setLastModifiedMillis(System.currentTimeMillis()); - domain.recalculateChecksum(); - domain.valid(); + service.setLastModifiedMillis(System.currentTimeMillis()); + service.recalculateChecksum(); + service.valid(); - serviceManager.addOrReplaceService(domain); + serviceManager.addOrReplaceService(service); return "ok"; } - @RequestMapping("/allDomNames") - public JSONObject allDomNames(HttpServletRequest request) throws Exception { + @RequestMapping("/names") + public JSONObject searchService(HttpServletRequest request) { + String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, StringUtils.EMPTY); + String expr = WebUtils.optional(request, "expr", StringUtils.EMPTY); boolean responsibleOnly = Boolean.parseBoolean(WebUtils.optional(request, "responsibleOnly", "false")); - Map> doms = new HashMap<>(16); + Map> services = new HashMap<>(16); + if (StringUtils.isNotBlank(namespaceId)) { + services.put(namespaceId, serviceManager.searchServices(namespaceId, ".*" + expr + ".*")); + } else { + for (String namespace : serviceManager.getAllNamespaces()) { + services.put(namespace, serviceManager.searchServices(namespace, ".*" + expr + ".*")); + } + } - Map> domMap = serviceManager.getAllServiceNames(); - - for (String namespaceId : domMap.keySet()) { - doms.put(namespaceId, new HashSet<>()); - for (String dom : domMap.get(namespaceId)) { - if (distroMapper.responsible(dom) || !responsibleOnly) { - doms.get(namespaceId).add(dom); + Map> serviceNameMap = new HashMap<>(); + for (String namespace : services.keySet()) { + serviceNameMap.put(namespace, new HashSet<>()); + for (Service service : services.get(namespace)) { + if (distroMapper.responsible(service.getName()) || !responsibleOnly) { + serviceNameMap.get(namespace).add(service.getName()); } } } JSONObject result = new JSONObject(); - result.put("doms", doms); - result.put("count", doms.size()); - - return result; - } - - @RequestMapping("/names") - public JSONObject searchService(HttpServletRequest request) { - - JSONObject result = new JSONObject(); - String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, - UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String expr = WebUtils.required(request, "expr"); - - List doms - = serviceManager.searchServices(namespaceId, ".*" + expr + ".*"); - - if (CollectionUtils.isEmpty(doms)) { - result.put("doms", Collections.emptyList()); - return result; - } - - JSONArray domArray = new JSONArray(); - for (Service dom : doms) { - domArray.add(dom.getName()); - } - - result.put("doms", domArray); + result.put("services", serviceNameMap); + result.put("count", services.size()); return result; } @RequestMapping("/serviceStatus") public String serviceStatus(HttpServletRequest request) { - //format: dom1@@checksum@@@dom2@@checksum + //format: service1@@checksum@@@service2@@checksum String statuses = WebUtils.required(request, "statuses"); String serverIP = WebUtils.optional(request, "clientIP", ""); @@ -319,22 +300,22 @@ public class ServiceController { if (entry == null || StringUtils.isEmpty(entry.getKey()) || StringUtils.isEmpty(entry.getValue())) { continue; } - String dom = entry.getKey(); + String serviceName = entry.getKey(); String checksum = entry.getValue(); - Service domain = serviceManager.getService(checksums.namespaceId, dom); + Service service = serviceManager.getService(checksums.namespaceId, serviceName); - if (domain == null) { + if (service == null) { continue; } - domain.recalculateChecksum(); + service.recalculateChecksum(); - if (!checksum.equals(domain.getChecksum())) { + if (!checksum.equals(service.getChecksum())) { if (Loggers.SRV_LOG.isDebugEnabled()) { Loggers.SRV_LOG.debug("checksum of {} is not consistent, remote: {}, checksum: {}, local: {}", - dom, serverIP, checksum, domain.getChecksum()); + serviceName, serverIP, checksum, service.getChecksum()); } - serviceManager.addUpdatedService2Queue(checksums.namespaceId, dom, serverIP, checksum); + serviceManager.addUpdatedService2Queue(checksums.namespaceId, serviceName, serverIP, checksum); } } } catch (Exception e) { @@ -349,7 +330,7 @@ public class ServiceController { String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID); - String serviceName = WebUtils.required(request, "serviceName"); + String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME); Service service = serviceManager.getService(namespaceId, serviceName); if (service == null) { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java b/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java index b5aecc0e2..02db5a1e2 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/DistroMapper.java @@ -83,13 +83,13 @@ public class DistroMapper implements ServerChangeListener { return target >= index && target <= lastIndex; } - public String mapSrv(String dom) { + public String mapSrv(String serviceName) { if (CollectionUtils.isEmpty(healthyList) || !switchDomain.distroEnabled) { return NetUtils.localServer(); } try { - return healthyList.get(distroHash(dom) % healthyList.size()); + return healthyList.get(distroHash(serviceName) % healthyList.size()); } catch (Exception e) { Loggers.SRV_LOG.warn("distro mapper failed, return localhost: " + NetUtils.localServer(), e); @@ -97,8 +97,8 @@ public class DistroMapper implements ServerChangeListener { } } - public int distroHash(String dom) { - return Math.abs(dom.hashCode() % Integer.MAX_VALUE); + public int distroHash(String serviceName) { + return Math.abs(serviceName.hashCode() % Integer.MAX_VALUE); } @Override diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java index ad94033b3..43e0d9dda 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java @@ -242,7 +242,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement stringBuilder.append(instance.toIPAddr()).append("_").append(instance.isValid()).append(","); } - Loggers.EVT_LOG.info("[IP-UPDATED] dom: {}, ips: {}", getName(), stringBuilder.toString()); + Loggers.EVT_LOG.info("[IP-UPDATED] service: {}, ips: {}", getName(), stringBuilder.toString()); } @@ -286,7 +286,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement for (String cluster : clusters) { Cluster clusterObj = clusterMap.get(cluster); if (clusterObj == null) { - throw new IllegalArgumentException("can not find cluster: " + cluster + ", dom:" + getName()); + throw new IllegalArgumentException("can not find cluster: " + cluster + ", service:" + getName()); } allIPs.addAll(clusterObj.allIPs()); @@ -308,13 +308,13 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement } @JSONField(serialize = false) - public String getDomString() { - Map domain = new HashMap(10); - Service vDom = this; + public String getServiceString() { + Map serviceObject = new HashMap(10); + Service service = this; - domain.put("name", vDom.getName()); + serviceObject.put("name", service.getName()); - List ips = vDom.allIPs(); + List ips = service.allIPs(); int invalidIPCount = 0; int ipCount = 0; for (Instance ip : ips) { @@ -325,17 +325,17 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement ipCount++; } - domain.put("ipCount", ipCount); - domain.put("invalidIPCount", invalidIPCount); + serviceObject.put("ipCount", ipCount); + serviceObject.put("invalidIPCount", invalidIPCount); - domain.put("owners", vDom.getOwners()); - domain.put("token", vDom.getToken()); + serviceObject.put("owners", service.getOwners()); + serviceObject.put("token", service.getToken()); - domain.put("protectThreshold", vDom.getProtectThreshold()); + serviceObject.put("protectThreshold", service.getProtectThreshold()); List clustersList = new ArrayList(); - for (Map.Entry entry : vDom.getClusterMap().entrySet()) { + for (Map.Entry entry : service.getClusterMap().entrySet()) { Cluster cluster = entry.getValue(); Map clusters = new HashMap(10); @@ -350,9 +350,9 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement clustersList.add(clusters); } - domain.put("clusters", clustersList); + serviceObject.put("clusters", clustersList); - return JSON.toJSONString(domain); + return JSON.toJSONString(serviceObject); } public String getToken() { @@ -390,27 +390,27 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement public void update(Service vDom) { if (!StringUtils.equals(token, vDom.getToken())) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, token: {} -> {}", getName(), token, vDom.getToken()); + Loggers.SRV_LOG.info("[DOM-UPDATE] service: {}, token: {} -> {}", getName(), token, vDom.getToken()); token = vDom.getToken(); } if (!ListUtils.isEqualList(owners, vDom.getOwners())) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, owners: {} -> {}", getName(), owners, vDom.getOwners()); + Loggers.SRV_LOG.info("[DOM-UPDATE] service: {}, owners: {} -> {}", getName(), owners, vDom.getOwners()); owners = vDom.getOwners(); } if (getProtectThreshold() != vDom.getProtectThreshold()) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, protectThreshold: {} -> {}", getName(), getProtectThreshold(), vDom.getProtectThreshold()); + Loggers.SRV_LOG.info("[DOM-UPDATE] service: {}, protectThreshold: {} -> {}", getName(), getProtectThreshold(), vDom.getProtectThreshold()); setProtectThreshold(vDom.getProtectThreshold()); } if (resetWeight != vDom.getResetWeight().booleanValue()) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, resetWeight: {} -> {}", getName(), resetWeight, vDom.getResetWeight()); + Loggers.SRV_LOG.info("[DOM-UPDATE] service: {}, resetWeight: {} -> {}", getName(), resetWeight, vDom.getResetWeight()); resetWeight = vDom.getResetWeight(); } if (enabled != vDom.getEnabled().booleanValue()) { - Loggers.SRV_LOG.info("[DOM-UPDATE] dom: {}, enabled: {} -> {}", getName(), enabled, vDom.getEnabled()); + Loggers.SRV_LOG.info("[DOM-UPDATE] service: {}, enabled: {} -> {}", getName(), enabled, vDom.getEnabled()); enabled = vDom.getEnabled(); } @@ -435,9 +435,11 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement List ips = allIPs(); StringBuilder ipsString = new StringBuilder(); - ipsString.append(getDomString()); + ipsString.append(getServiceString()); - Loggers.SRV_LOG.debug("dom to json: " + getDomString()); + if (Loggers.SRV_LOG.isDebugEnabled()) { + Loggers.SRV_LOG.debug("service to json: " + getServiceString()); + } if (!CollectionUtils.isEmpty(ips)) { Collections.sort(ips); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java index b39f731ad..75f5a8a3e 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java @@ -269,7 +269,11 @@ public class ServiceManager implements DataListener { return namesMap; } - public List getAllDomNamesList(String namespaceId) { + public Set getAllNamespaces() { + return serviceMap.keySet(); + } + + public List getAllServiceNameList(String namespaceId) { if (chooseServiceMap(namespaceId) == null) { return new ArrayList<>(); } @@ -652,7 +656,7 @@ public class ServiceManager implements DataListener { } catch (Exception e) { Loggers.SRV_LOG.error("[DOMAIN-STATUS] Exception while sending service status", e); } finally { - UtilsAndCommons.DOMAIN_SYNCHRONIZATION_EXECUTOR.schedule(this, switchDomain.getDomStatusSynchronizationPeriodMillis(), TimeUnit.MILLISECONDS); + UtilsAndCommons.DOMAIN_SYNCHRONIZATION_EXECUTOR.schedule(this, switchDomain.getServiceStatusSynchronizationPeriodMillis(), TimeUnit.MILLISECONDS); } } } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java index ea0695376..f734abcd6 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/ClientBeatProcessor.java @@ -78,7 +78,7 @@ public class ClientBeatProcessor implements Runnable { if (!instance.isMarked()) { if (!instance.isValid()) { instance.setValid(true); - Loggers.EVT_LOG.info("dom: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: client beat ok", + Loggers.EVT_LOG.info("service: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: client beat ok", cluster.getService().getName(), ip, port, cluster.getName(), UtilsAndCommons.LOCALHOST_SITE); getPushService().serviceChanged(service.getNamespaceId(), this.service.getName()); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java index d674f0eae..d2944bbea 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckCommon.java @@ -148,17 +148,17 @@ public class HealthCheckCommon { pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName()); addResult(new HealthCheckResult(vDom.getName(), ip)); - Loggers.EVT_LOG.info("dom: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } else { if (!ip.isMockValid()) { ip.setMockValid(true); - Loggers.EVT_LOG.info("dom: {} {PROBE} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {PROBE} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } } } else { - Loggers.EVT_LOG.info("dom: {} {OTHER} {IP-ENABLED} pre-valid: {}:{}@{} in {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-ENABLED} pre-valid: {}:{}@{} in {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), ip.getOKCount(), msg); } } @@ -186,15 +186,15 @@ public class HealthCheckCommon { pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName()); - Loggers.EVT_LOG.info("dom: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } else { - Loggers.EVT_LOG.info("dom: {} {PROBE} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {PROBE} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } } else { - Loggers.EVT_LOG.info("dom: {} {OTHER} {IP-DISABLED} pre-invalid: {}:{}@{} in {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {OTHER} {IP-DISABLED} pre-invalid: {}:{}@{} in {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), ip.getFailCount(), msg); } } @@ -221,12 +221,12 @@ public class HealthCheckCommon { pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName()); addResult(new HealthCheckResult(vDom.getName(), ip)); - Loggers.EVT_LOG.info("dom: {} {POS} {IP-DISABLED} invalid-now: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid-now: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } else { if (ip.isMockValid()) { ip.setMockValid(false); - Loggers.EVT_LOG.info("dom: {} {PROBE} {IP-DISABLED} invalid-now: {}:{}@{}, region: {}, msg: {}", + Loggers.EVT_LOG.info("serviceName: {} {PROBE} {IP-DISABLED} invalid-now: {}:{}@{}, region: {}, msg: {}", cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg); } @@ -242,7 +242,7 @@ public class HealthCheckCommon { private void addResult(HealthCheckResult result) { - if (!switchDomain.getIncrementalList().contains(result.getDom())) { + if (!switchDomain.getIncrementalList().contains(result.getServiceName())) { return; } @@ -252,20 +252,20 @@ public class HealthCheckCommon { } static class HealthCheckResult { - private String dom; + private String serviceName; private Instance instance; - public HealthCheckResult(String dom, Instance instance) { - this.dom = dom; + public HealthCheckResult(String serviceName, Instance instance) { + this.serviceName = serviceName; this.instance = instance; } - public String getDom() { - return dom; + public String getServiceName() { + return serviceName; } - public void setDom(String dom) { - this.dom = dom; + public void setServiceName(String serviceName) { + this.serviceName = serviceName; } public Instance getInstance() { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessor.java index 7a0ca2282..83a34c064 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckProcessor.java @@ -21,7 +21,7 @@ package com.alibaba.nacos.naming.healthcheck; public interface HealthCheckProcessor { /** - * Run check task for domain + * Run check task for service * * @param task check task */ diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckStatus.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckStatus.java index 6f9f0447b..f5ff2ddea 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckStatus.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HealthCheckStatus.java @@ -58,9 +58,9 @@ public class HealthCheckStatus { try { String clusterName = ip.getClusterName(); - String dom = ip.getServiceName(); + String serviceName = ip.getServiceName(); String datumKey = ip.getDatumKey(); - return dom + ":" + return serviceName + ":" + clusterName + ":" + datumKey; } catch (Throwable e) { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java index 2594f14fe..3795a3453 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/HttpHealthCheckProcessor.java @@ -106,7 +106,7 @@ public class HttpHealthCheckProcessor implements HealthCheckProcessor { } if (!ip.markChecking()) { - SRV_LOG.warn("http check started before last one finished, dom: {}:{}:{}", + SRV_LOG.warn("http check started before last one finished, service: {}:{}:{}", task.getCluster().getService().getName(), task.getCluster().getName(), ip.getIp()); healthCheckCommon.reEvaluateCheckRT(task.getCheckRTNormalized() * 2, task, switchDomain.getHttpHealthParams()); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java index 2f2f3fa04..756d7fcba 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/MysqlHealthCheckProcessor.java @@ -106,7 +106,7 @@ public class MysqlHealthCheckProcessor implements HealthCheckProcessor { } if (!ip.markChecking()) { - SRV_LOG.warn("mysql check started before last one finished, dom: {}:{}:{}", + SRV_LOG.warn("mysql check started before last one finished, service: {}:{}:{}", task.getCluster().getService().getName(), task.getCluster().getName(), ip.getIp()); healthCheckCommon.reEvaluateCheckRT(task.getCheckRTNormalized() * 2, task, switchDomain.getMysqlHealthParams()); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java index aa62043f0..bdf0addd3 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/healthcheck/TcpSuperSenseProcessor.java @@ -123,7 +123,7 @@ public class TcpSuperSenseProcessor implements HealthCheckProcessor, Runnable { } if (!ip.markChecking()) { - SRV_LOG.warn("tcp check started before last one finished, dom: " + SRV_LOG.warn("tcp check started before last one finished, service: " + task.getCluster().getService().getName() + ":" + task.getCluster().getName() + ":" + ip.getIp() + ":" @@ -194,7 +194,7 @@ public class TcpSuperSenseProcessor implements HealthCheckProcessor, Runnable { SocketChannel channel = (SocketChannel) key.channel(); try { if (!beat.isValid()) { - //invalid beat means this server is no longer responsible for the current dom + //invalid beat means this server is no longer responsible for the current service key.cancel(); key.channel().close(); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java index abce37b2a..ab4af2564 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java @@ -78,11 +78,11 @@ public class ServiceStatusSynchronizer implements Synchronizer { String result; try { - Loggers.SRV_LOG.info("[STATUS-SYNCHRONIZE] sync dom status from: {}, dom: {}", serverIP, key); + Loggers.SRV_LOG.info("[STATUS-SYNCHRONIZE] sync service status from: {}, service: {}", serverIP, key); result = NamingProxy.reqAPI(RunningConfig.getContextPath() + UtilsAndCommons.NACOS_NAMING_CONTEXT + "/instance/" + "listWithHealthStatus", params, serverIP); } catch (Exception e) { - Loggers.SRV_LOG.warn("[STATUS-SYNCHRONIZE] Failed to get domain status from " + serverIP, e); + Loggers.SRV_LOG.warn("[STATUS-SYNCHRONIZE] Failed to get service status from " + serverIP, e); return null; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java index 4744ebe2c..67514f8fb 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchDomain.java @@ -61,7 +61,7 @@ public class SwitchDomain implements Cloneable { public long serverStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(15); - public long domStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(5); + public long serviceStatusSynchronizationPeriodMillis = TimeUnit.SECONDS.toMillis(5); public boolean disableAddIP = false; @@ -196,7 +196,7 @@ public class SwitchDomain implements Cloneable { this.distroThreshold = distroThreshold; } - public long getPushCacheMillis(String dom) { + public long getPushCacheMillis(String serviceName) { return defaultPushCacheMillis; } @@ -208,8 +208,8 @@ public class SwitchDomain implements Cloneable { this.healthCheckEnabled = healthCheckEnabled; } - public boolean isHealthCheckEnabled(String dom) { - return healthCheckEnabled || getHealthCheckWhiteList().contains(dom); + public boolean isHealthCheckEnabled(String serviceName) { + return healthCheckEnabled || getHealthCheckWhiteList().contains(serviceName); } public boolean isDistroEnabled() { @@ -260,12 +260,12 @@ public class SwitchDomain implements Cloneable { this.serverStatusSynchronizationPeriodMillis = serverStatusSynchronizationPeriodMillis; } - public long getDomStatusSynchronizationPeriodMillis() { - return domStatusSynchronizationPeriodMillis; + public long getServiceStatusSynchronizationPeriodMillis() { + return serviceStatusSynchronizationPeriodMillis; } - public void setDomStatusSynchronizationPeriodMillis(long domStatusSynchronizationPeriodMillis) { - this.domStatusSynchronizationPeriodMillis = domStatusSynchronizationPeriodMillis; + public void setServiceStatusSynchronizationPeriodMillis(long serviceStatusSynchronizationPeriodMillis) { + this.serviceStatusSynchronizationPeriodMillis = serviceStatusSynchronizationPeriodMillis; } public boolean isDisableAddIP() { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java index 09072d6cf..e1ca12dda 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchEntry.java @@ -41,7 +41,7 @@ public class SwitchEntry { public static final String DISTRO = "distro"; public static final String CHECK = "check"; public static final String DEFAULT_HEALTH_CHECK_MODE = "defaultHealthCheckMode"; - public static final String DOM_STATUS_SYNC_PERIOD = "domStatusSynchronizationPeriodMillis"; + public static final String SERVICE_STATUS_SYNC_PERIOD = "serviceStatusSynchronizationPeriodMillis"; public static final String SERVER_STATUS_SYNC_PERIOD = "serverStatusSynchronizationPeriodMillis"; public static final String HEALTH_CHECK_TIMES = "healthCheckTimes"; public static final String DISABLE_ADD_IP = "disableAddIP"; diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java index 2baa34f03..2e3e97d34 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/SwitchManager.java @@ -56,7 +56,7 @@ public class SwitchManager implements DataListener { try { consistencyService.listen(UtilsAndCommons.getSwitchDomainKey(), this); } catch (NacosException e) { - Loggers.SRV_LOG.error("listen switch domain failed.", e); + Loggers.SRV_LOG.error("listen switch service failed.", e); } } @@ -218,14 +218,14 @@ public class SwitchManager implements DataListener { return; } - if (entry.equals(SwitchEntry.DOM_STATUS_SYNC_PERIOD)) { + if (entry.equals(SwitchEntry.SERVICE_STATUS_SYNC_PERIOD)) { Long millis = Long.parseLong(value); if (millis < SwitchEntry.MIN_DOM_SYNC_TIME_MIILIS) { - throw new IllegalArgumentException("domStatusSynchronizationPeriodMillis is too small(<5000)"); + throw new IllegalArgumentException("serviceStatusSynchronizationPeriodMillis is too small(<5000)"); } - switchDomain.setDomStatusSynchronizationPeriodMillis(millis); + switchDomain.setServiceStatusSynchronizationPeriodMillis(millis); if (!debug) { consistencyService.put(UtilsAndCommons.getSwitchDomainKey(), switchDomain); } @@ -369,7 +369,7 @@ public class SwitchManager implements DataListener { switchDomain.setMysqlHealthParams(newSwitchDomain.getMysqlHealthParams()); switchDomain.setIncrementalList(newSwitchDomain.getIncrementalList()); switchDomain.setServerStatusSynchronizationPeriodMillis(newSwitchDomain.getServerStatusSynchronizationPeriodMillis()); - switchDomain.setDomStatusSynchronizationPeriodMillis(newSwitchDomain.getDomStatusSynchronizationPeriodMillis()); + switchDomain.setServiceStatusSynchronizationPeriodMillis(newSwitchDomain.getServiceStatusSynchronizationPeriodMillis()); switchDomain.setDisableAddIP(newSwitchDomain.isDisableAddIP()); switchDomain.setSendBeatOnly(newSwitchDomain.isSendBeatOnly()); switchDomain.setLimitedUrlMap(newSwitchDomain.getLimitedUrlMap()); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java index 3acacf5a4..948cce059 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/UtilsAndCommons.java @@ -155,7 +155,7 @@ public class UtilsAndCommons { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); - t.setName("nacos.naming.domains.worker"); + t.setName("nacos.naming.service.worker"); t.setDaemon(true); return t; } @@ -166,7 +166,7 @@ public class UtilsAndCommons { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); - t.setName("nacos.naming.domains.update.processor"); + t.setName("nacos.naming.service.update.processor"); t.setDaemon(true); return t; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/monitor/MetricsMonitor.java b/naming/src/main/java/com/alibaba/nacos/naming/monitor/MetricsMonitor.java index 3dae43c46..920768d52 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/monitor/MetricsMonitor.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/monitor/MetricsMonitor.java @@ -34,7 +34,7 @@ public class MetricsMonitor { private static AtomicInteger mysqlHealthCheck = new AtomicInteger(); private static AtomicInteger httpHealthCheck = new AtomicInteger(); private static AtomicInteger tcpHealthCheck = new AtomicInteger(); - private static AtomicInteger domCount = new AtomicInteger(); + private static AtomicInteger serviceCount = new AtomicInteger(); private static AtomicInteger ipCount = new AtomicInteger(); private static AtomicLong maxPushCost = new AtomicLong(); private static AtomicLong avgPushCost = new AtomicLong(); @@ -60,8 +60,8 @@ public class MetricsMonitor { tags = new ArrayList(); tags.add(new ImmutableTag("module", "naming")); - tags.add(new ImmutableTag("name", "domCount")); - Metrics.gauge("nacos_monitor", tags, domCount); + tags.add(new ImmutableTag("name", "serviceCount")); + Metrics.gauge("nacos_monitor", tags, serviceCount); tags = new ArrayList(); tags.add(new ImmutableTag("module", "naming")); @@ -107,7 +107,7 @@ public class MetricsMonitor { } public static AtomicInteger getDomCountMonitor() { - return domCount; + return serviceCount; } public static AtomicInteger getIpCountMonitor() { diff --git a/naming/src/main/java/com/alibaba/nacos/naming/monitor/PerformanceLoggerThread.java b/naming/src/main/java/com/alibaba/nacos/naming/monitor/PerformanceLoggerThread.java index b99d7000b..9d4e62e34 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/monitor/PerformanceLoggerThread.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/monitor/PerformanceLoggerThread.java @@ -103,8 +103,8 @@ public class PerformanceLoggerThread { @Scheduled(cron = "0/15 * * * * ?") public void collectmetrics() { - int domCount = serviceManager.getServiceCount(); - MetricsMonitor.getDomCountMonitor().set(domCount); + int serviceCount = serviceManager.getServiceCount(); + MetricsMonitor.getDomCountMonitor().set(serviceCount); int ipCount = serviceManager.getInstanceCount(); MetricsMonitor.getIpCountMonitor().set(ipCount); @@ -132,13 +132,13 @@ public class PerformanceLoggerThread { @Override public void run() { try { - int domCount = serviceManager.getServiceCount(); + int serviceCount = serviceManager.getServiceCount(); int ipCount = serviceManager.getInstanceCount(); long maxPushMaxCost = getMaxPushCost(); long maxPushCost = getMaxPushCost(); long avgPushCost = getAvgPushCost(); - Loggers.PERFORMANCE_LOG.info("PERFORMANCE:" + "|" + domCount + "|" + ipCount + "|" + maxPushCost + "|" + avgPushCost); + Loggers.PERFORMANCE_LOG.info("PERFORMANCE:" + "|" + serviceCount + "|" + ipCount + "|" + maxPushCost + "|" + avgPushCost); } catch (Exception e) { Loggers.SRV_LOG.warn("[PERFORMANCE] Exception while print performance log.", e); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/push/PushService.java b/naming/src/main/java/com/alibaba/nacos/naming/push/PushService.java index 808d94fdf..877c40875 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/push/PushService.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/push/PushService.java @@ -129,7 +129,7 @@ public class PushService { } public void addClient(String namespaceId, - String dom, + String serviceName, String clusters, String agent, InetSocketAddress socketAddr, @@ -138,7 +138,7 @@ public class PushService { String app) { PushClient client = new PushService.PushClient(namespaceId, - dom, + serviceName, clusters, agent, socketAddr, @@ -213,8 +213,8 @@ public class PushService { return null; } - public static String getPushCacheKey(String dom, String clientIP, String agent) { - return dom + UtilsAndCommons.CACHE_KEY_SPLITER + agent; + public static String getPushCacheKey(String serviceName, String clientIP, String agent) { + return serviceName + UtilsAndCommons.CACHE_KEY_SPLITER + agent; } public void serviceChanged(final String namespaceId, final String serviceName) { diff --git a/naming/src/test/java/com/alibaba/nacos/naming/BaseTest.java b/naming/src/test/java/com/alibaba/nacos/naming/BaseTest.java index f2393450a..2c83653ad 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/BaseTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/BaseTest.java @@ -31,7 +31,7 @@ import org.mockito.MockitoAnnotations; public class BaseTest { @Mock - public ServiceManager domainsManager; + public ServiceManager serviceManager; @Mock public RaftPeerSet peerSet; diff --git a/naming/src/test/java/com/alibaba/nacos/naming/controllers/InstanceControllerTest.java b/naming/src/test/java/com/alibaba/nacos/naming/controllers/InstanceControllerTest.java index 78ea9a5fe..d2c203bf9 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/controllers/InstanceControllerTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/controllers/InstanceControllerTest.java @@ -69,22 +69,22 @@ public class InstanceControllerTest extends BaseTest { @Test public void registerInstance() throws Exception { - Service domain = new Service(); - domain.setName("nacos.test.1"); + Service service = new Service(); + service.setName("nacos.test.1"); Cluster cluster = new Cluster(); cluster.setName(UtilsAndCommons.DEFAULT_CLUSTER_NAME); - cluster.setService(domain); - domain.addCluster(cluster); + cluster.setService(service); + service.addCluster(cluster); Instance instance = new Instance(); instance.setIp("1.1.1.1"); instance.setPort(9999); List ipList = new ArrayList(); ipList.add(instance); - domain.updateIPs(ipList, false); + service.updateIPs(ipList, false); - Mockito.when(domainsManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(domain); + Mockito.when(serviceManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.put("/naming/instance") @@ -113,13 +113,13 @@ public class InstanceControllerTest extends BaseTest { @Test public void getInstances() throws Exception { - Service domain = new Service(); - domain.setName("nacos.test.1"); + Service service = new Service(); + service.setName("nacos.test.1"); Cluster cluster = new Cluster(); cluster.setName(UtilsAndCommons.DEFAULT_CLUSTER_NAME); - cluster.setService(domain); - domain.addCluster(cluster); + cluster.setService(service); + service.addCluster(cluster); Instance instance = new Instance(); instance.setIp("10.10.10.10"); @@ -127,9 +127,9 @@ public class InstanceControllerTest extends BaseTest { instance.setWeight(2.0); List ipList = new ArrayList(); ipList.add(instance); - domain.updateIPs(ipList, false); + service.updateIPs(ipList, false); - Mockito.when(domainsManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(domain); + Mockito.when(serviceManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/v1/ns/instances") @@ -139,7 +139,7 @@ public class InstanceControllerTest extends BaseTest { String actualValue = response.getContentAsString(); JSONObject result = JSON.parseObject(actualValue); - Assert.assertEquals("nacos.test.1", result.getString("dom")); + Assert.assertEquals("nacos.test.1", result.getString("serviceName")); JSONArray hosts = result.getJSONArray("hosts"); Assert.assertTrue(hosts != null); Assert.assertNotNull(hosts); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/core/ClusterTest.java b/naming/src/test/java/com/alibaba/nacos/naming/core/ClusterTest.java index 7676e2e53..6cbc96298 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/core/ClusterTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/core/ClusterTest.java @@ -33,12 +33,12 @@ public class ClusterTest { @Before public void before() { - Service domain = new Service(); - domain.setName("nacos.domain.1"); + Service service = new Service(); + service.setName("nacos.service.1"); cluster = new Cluster(); cluster.setName("nacos-cluster-1"); - cluster.setService(domain); + cluster.setService(service); cluster.setDefCkport(80); cluster.setDefIPPort(8080); } @@ -56,10 +56,10 @@ public class ClusterTest { healthCheckConfig.setHeaders("Client-Version:nacos-test-1"); newCluster.setHealthChecker(healthCheckConfig); - Service domain = new Service(); - domain.setName("nacos.domain.2"); + Service service = new Service(); + service.setName("nacos.service.2"); - newCluster.setService(domain); + newCluster.setService(service); cluster.update(newCluster); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java index aa0292fa0..79fc69962 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainTest.java @@ -30,32 +30,32 @@ import java.util.Map; */ public class DomainTest { - private Service domain; + private Service service; @Before public void before() { - domain = new Service(); - domain.setName("nacos.domain.1"); + service = new Service(); + service.setName("nacos.service.1"); Cluster cluster = new Cluster(); cluster.setName(UtilsAndCommons.DEFAULT_CLUSTER_NAME); - cluster.setService(domain); - domain.addCluster(cluster); + cluster.setService(service); + service.addCluster(cluster); } @Test public void updateDomain() { Service newDomain = new Service(); - newDomain.setName("nacos.domain.1"); + newDomain.setName("nacos.service.1"); newDomain.setProtectThreshold(0.7f); Cluster cluster = new Cluster(); cluster.setName(UtilsAndCommons.DEFAULT_CLUSTER_NAME); cluster.setService(newDomain); newDomain.addCluster(cluster); - domain.update(newDomain); + service.update(newDomain); - Assert.assertEquals(0.7f, domain.getProtectThreshold(), 0.0001f); + Assert.assertEquals(0.7f, service.getProtectThreshold(), 0.0001f); } @Test @@ -63,9 +63,9 @@ public class DomainTest { Cluster cluster = new Cluster(); cluster.setName("nacos-cluster-1"); - domain.addCluster(cluster); + service.addCluster(cluster); - Map clusterMap = domain.getClusterMap(); + Map clusterMap = service.getClusterMap(); Assert.assertNotNull(clusterMap); Assert.assertEquals(2, clusterMap.size()); Assert.assertTrue(clusterMap.containsKey("nacos-cluster-1")); @@ -90,9 +90,9 @@ public class DomainTest { instances.setInstanceMap(instanceMap); - domain.onChange("iplist", instances); + service.onChange("iplist", instances); - List ips = domain.allIPs(); + List ips = service.allIPs(); Assert.assertNotNull(ips); Assert.assertEquals(1, ips.size()); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainsManagerTest.java b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainsManagerTest.java index 6520f4d53..f3a560cae 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/core/DomainsManagerTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/core/DomainsManagerTest.java @@ -36,27 +36,25 @@ import java.util.List; @WebAppConfiguration public class DomainsManagerTest extends BaseTest { - private ServiceManager domainsManager; - @Before public void before() { super.before(); - domainsManager = new ServiceManager(); + serviceManager = new ServiceManager(); } @Test public void easyRemoveDom() throws Exception { - domainsManager.easyRemoveService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1"); + serviceManager.easyRemoveService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1"); } @Test public void searchDom() throws Exception { - Service domain = new Service(); - domain.setName("nacos.test.1"); + Service service = new Service(); + service.setName("nacos.test.1"); - domainsManager.chooseServiceMap(UtilsAndCommons.DEFAULT_NAMESPACE_ID).put("nacos.test.1", domain); + serviceManager.chooseServiceMap(UtilsAndCommons.DEFAULT_NAMESPACE_ID).put("nacos.test.1", service); - List list = domainsManager.searchServices(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.*"); + List list = serviceManager.searchServices(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.*"); Assert.assertNotNull(list); Assert.assertEquals(1, list.size()); Assert.assertEquals("nacos.test.1", list.get(0).getName());