最新要闻
- 铝合金铸造工艺有哪些?铝合金铸造工艺流程
- 苦主是什么意思?苦主引申含义是什么?
- 【环球热闻】基于汉兰达开发而来 雷克萨斯TX效果图曝光:竟与奇瑞星途“撞衫”
- 微软正式放弃Win10 21H1!将无法收到任何安全更新或补丁
- 亚米级的高精度定位 高德北斗卫星日定位量已超2100亿次
- 不枉马粉苦等一场 全新马自达CX-90预告:六缸、后驱全都有
- 【全球快播报】对标迈巴赫S级!蔚来百万级豪车计划落地 售价百万
- 【当前独家】告别LCD/mini LED iPad Pro全系升级到OLED屏
- 全球快资讯:高端成了!小米12S Ultra被中国移动评为4000元以上最强旗舰
- 视点!果粉霸气!花万元同时入手小米13和13 Pro:之前用的是iPhone 14 Pro Max
- 火箭平民化!中国民营火箭朱雀二号即将首飞:人类首次挑战甲烷燃料
- 小米13系列刷新认知 卢伟冰6字评价:彻底脱胎换骨
- 快讯:3999元起!小米13今日开售:手感、续航碾压iPhone 14 Pro
- 消息称苹果要对iOS开放 iPhone等自由了:功能、应用商店向第三方放开
- 苹果推送iOS 16.2正式版:新增无边记、Apple Music唱歌
- 阿根廷3-0克罗地亚晋级决赛!梅西创纪录之夜:成现役世界杯射手王
广告
手机
iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?
警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案
- iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?
- 警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案
- 男子被关545天申国赔:获赔18万多 驳回精神抚慰金
- 3天内26名本土感染者,辽宁确诊人数已超安徽
- 广西柳州一男子因纠纷杀害三人后自首
- 洱海坠机4名机组人员被批准为烈士 数千干部群众悼念
家电
环球视点!SpringCloud-Nacos学习笔记
【资料图】
spring-cloud-alibaba版本说明
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8ESpring Boot 2.4+ 和以下版本之间变化较大,目前企业级客户老项目相关 Spring Boot 版本仍停留在 Spring Boot 2.4 以下,为了同时满足存量用户和新用户不同需求,社区以 Spring Boot 2.4 为分界线,同时维护 2.2.x 和 2021.x 两个分支迭代Nacos学习官方网址https://nacos.io/zh-cn/docs/what-is-nacos.html名字服务 (Naming Service)提供分布式系统中所有对象(Object)、实体(Entity)的“名字”到关联的元数据之间的映射管理服务,例如 ServiceName -> Endpoints Info, Distributed Lock Name -> Lock Owner/Status Info, DNS Domain Name -> IP List, 服务发现和 DNS 就是名字服务的2大场景。配置服务 (Configuration Service)在服务或者应用运行过程中,提供动态配置或者元数据以及配置管理的服务提供者。OpenAPI可以借助api去查实例,注册实例等。。(某些接口在版本更新得时候未及时更新,比如注销实例)版本对比2.X | 1.X | |
底层的通信协议 | grpc | http协议 |
注册中心数据存放位置 | \data\protocol\raft\naming_persistent_service_v2持久实例存在此目录 | ..\data\naming\data持久实例存在此目录,临时实例存在内存中 |
集群搭建 | Nacos2.x版本相比1.X新增了gRPC的通信方式,因此需要增加2个端口。新增端口是在配置的主端口(server.port)基础上,进行一定偏移量自动生成。与主端口的偏移量1000--客户端gRPC请求服务端端口,用于客户端向服务端发起连接和请求,1001--服务端gRPC请求服务端端口,用于服务间同步等 |
Nacos基本概念
服务 (Service)服务是指一个或一组软件功能(例如特定信息的检索或一组操作的执行),其目的是不同的客户端可以为不同的目的重用(例如通过跨进程的网络调用)。Nacos 支持主流的服务生态,如 Kubernetes Service、gRPC|Dubbo RPC Service 或者 Spring Cloud RESTful Service。服务注册中心 (Service Registry)服务注册中心,它是服务及其实例和元数据的数据库。服务实例在启动时注册到服务注册表,并在关闭时注销。服务和路由器的客户端查询服务注册表以查找服务的可用实例。服务注册中心可能会调用服务实例的健康检查 API 来验证它是否能够处理请求。服务元数据 (Service Metadata)服务元数据是指包括服务端点(endpoints)、服务标签、服务版本号、服务实例权重、路由规则、安全策略等描述服务的数据。服务提供方 (Service Provider)是指提供可复用和可调用服务的应用方。服务消费方 (Service Consumer)是指会发起对某个服务调用的应用方。Nacos注册中心核心功能
服务注册:Nacos Client会通过发送REST请求的方式向Nacos Server注册自己的服务,提供自身的元数据,比如ip地址、端口等信息。Nacos Server接收到注册请求后,就会把这些元数据信息存储在一个双层的内存Map中。服务心跳:在服务注册后,Nacos Client会维护一个定时心跳来持续通知Nacos Server,说明服务一直处于可用状态,防止被剔除。默认5s发送一次心跳。服务同步:Nacos Server集群之间会互相同步服务实例,用来保证服务信息的一致性。服务发现:服务消费者(Nacos Client)在调用服务提供者的服务时,会发送一个REST请求给Nacos Server,获取上面注册的服务清单,并且缓存在Nacos Client本地,同时会在Nacos Client本地开启一个定时任务定时拉取服务端最新的注册表信息更新到本地缓存服务健康检查:Nacos Server会开启一个定时任务用来检查注册服务实例的健康情况,对于超过15s没有收到客户端心跳的实例会将它的healthy属性置为false(客户端服务发现时不会发现),如果某个实例超过30秒没有收到心跳,直接剔除该实例(被剔除的实例如果恢复发送心跳则会重新注册)Nacos服务下载
https://github.com/alibaba/nacos/releasesNacos服务启动
启动脚本里默认是cluster,需要改成standlone配置文件在\conf下application.properties(说明nacos也是基于springboot 实现的)可配置:配置端口,数据源spring.datasource.platform=mysql,如果不配置数据源,默认存在内存中,集群肯定是要配置数据库的Nacos客户端引入Nacos注册中心
在1.4.1版本之后启动类不需要加EnableDiscoverClient1.引入pom父pom配置1 2当前项目pom中引入依赖4 4.0.0 56 11org.springframework.boot 7spring-boot-starter-parent 82.3.12.RELEASE 910 com.pppp.qqqq 12spring-cloud-alibaba 130.0.1-SNAPSHOT 14spring-cloud-alibaba 15pom 16Demo project for vip-spring-cloud-alibaba 17 1819 23 241.8 20Hoxton.SR12 212.2.8.RELEASE 2225 4226 4127 33org.springframework.cloud 28spring-cloud-dependencies 29${spring-cloud.version} 30pom 31import 3234 40com.alibaba.cloud 35spring-cloud-alibaba-dependencies 36${spring-cloud-alibaba.version} 37pom 38import 39
12.配置文件2 com.alibaba.cloud 3spring-cloud-starter-alibaba-nacos-discovery 4
1 server: 2 port: 8040 3 4 spring: 5 application: 6 name: mall-user #微服务名称 7 8 #配置nacos注册中心地址 9 cloud:10 nacos:11 discovery:12 server-addr: 127.0.0.1:884813 #需要在nacos中建命名空间取id过来14 namespace: 49c955cf-1cd8-46a9-9823-aeb98ed3d60215 cluster-name: qf16 group: qf17 #ephemeral: false18 #不配也可以,默认就是nacos19 username: nacos20 password: nacos其他详细配置可参考https://github.com/alibaba/spring-cloud-alibaba/wiki/Nacos-discovery3.启动客户端服务日志
c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP mall-user 192.168.31.20:8040 register finished4.注册中心界面用openApi查询实例
服务逻辑隔离
Namespace 隔离设计命名空间(Namespace)用于进行租户(用户)粒度的隔离,Namespace 的常用场景之一是不同环境的隔离,例如开发测试环境和生产环境的资源(如配置、服务)隔离等。 修改yml配置1 spring:2 application:3 name: mall-user #微服务名称4 5 cloud:6 nacos:7 discovery:8 server-addr: 127.0.0.1:8848 #配置nacos注册中心地址9 namespace: bc50d386-8870-4a26-8803-0187486c57be # dev 开发环境group服务分组不同的服务可以归类到同一分组,group也可以起到服务隔离的作用。yml中可以通过spring.cloud.nacos.discovery.group参数配置
临时实例与持久实例
配置方式
1 spring: 2 application: 3 name: mall-user #微服务名称 4 5 cloud: 6 nacos: 7 discovery: 8 server-addr: 127.0.0.1:8848 #配置nacos注册中心地址 9 namespace: bc50d386-8870-4a26-8803-0187486c57be # dev 开发环境10 ephemeral: false # 持久化实例在2.X之后同一个服务不能同时注册临时实例和持久实例持久实例存放路径\data\protocol\raft\naming_persistent_service_v2在定义上区分临时实例和持久化 实例的关键是健康检查的方式。临时实例使用客户端上报模式,而持久化实例使用服务端反向探测模式。 在大中型的公司里,这两种类型的服务往往都有。⼀些基础的组件例如数据库、缓存等,这些往往不能上报心跳,这种类型的服务在注册时,就需要作为持久化实例注册。而上层的业务服务,例如 微服务或者 Dubbo 服务,服务的 Provider 端支持添加汇报心跳的逻辑,此时就可以使用动态服务的注册方式。Nacos 1.x 中持久化及非 持久化的属性是作为实例的⼀个元数据进行存储和识别。Nacos 2.x 中继续沿用了持久化及非持久化的设定,但是有了⼀些调整。在 Nacos2.0 中将是否持久化的数据抽象至服务级别, 且不再允许⼀个服务同时存在持久化实例和非持久化实例,实例的持久化属性继承自服务的持久化属性
核心代码
//springcloud提供的服务注册的接口,如果自己写服务中心,则实现这个接口即可,在spring-cloud-commonsServiceRegistry.java1 //springcloud提供的服务注册的接口,如果自己写服务中心,则实现这个接口即可,在spring-cloud-commons 2 public interface ServiceRegistryView CodeNamingService.java{ 3 4 /** 5 * Registers the registration. A registration typically has information about an 6 * instance, such as its hostname and port. 7 * @param registration registration meta data 8 */ 9 void register(R registration);10 11 /**12 * Deregisters the registration.13 * @param registration registration meta data14 */15 void deregister(R registration);16 17 /**18 * Closes the ServiceRegistry. This is a lifecycle method.19 */20 void close();21 22 /**23 * Sets the status of the registration. The status values are determined by the24 * individual implementations.25 * @param registration The registration to update.26 * @param status The status to set.27 * @see org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint28 */29 void setStatus(R registration, String status);30 31 /**32 * Gets the status of a particular registration.33 * @param registration The registration to query.34 * @param The type of the status.35 * @return The status of the registration.36 * @see org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint37 */38 T getStatus(R registration);39 40 }
1 public static void main(String[] args) throws NacosException { 2 3 Properties properties = new Properties(); 4 properties.setProperty("serverAddr", "192.168.31.20:8848"); 5 //核心接口 6 NamingService naming = NamingFactory.createNamingService(properties); 7 //服务注册 8 naming.registerInstance("mall-user", "192.168.31.21", 8889, "ppppp"); 9 //服务发现10 System.out.println(naming.getAllInstances("mall-user"));11 }
1 /* 2 * Copyright 1999-2018 Alibaba Group Holding Ltd. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.alibaba.nacos.api.naming; 18 19 import com.alibaba.nacos.api.exception.NacosException; 20 import com.alibaba.nacos.api.naming.listener.EventListener; 21 import com.alibaba.nacos.api.naming.pojo.Instance; 22 import com.alibaba.nacos.api.naming.pojo.ListView; 23 import com.alibaba.nacos.api.naming.pojo.ServiceInfo; 24 import com.alibaba.nacos.api.selector.AbstractSelector; 25 26 import java.util.List; 27 28 /** 29 * Naming Service. 30 * 31 * @author nkorange 32 */ 33 public interface NamingService { 34 35 /** 36 * register a instance to service. 37 * 38 * @param serviceName name of service 39 * @param ip instance ip 40 * @param port instance port 41 * @throws NacosException nacos exception 42 */ 43 void registerInstance(String serviceName, String ip, int port) throws NacosException; 44 45 /** 46 * register a instance to service. 47 * 48 * @param serviceName name of service 49 * @param groupName group of service 50 * @param ip instance ip 51 * @param port instance port 52 * @throws NacosException nacos exception 53 */ 54 void registerInstance(String serviceName, String groupName, String ip, int port) throws NacosException; 55 56 /** 57 * register a instance to service with specified cluster name. 58 * 59 * @param serviceName name of service 60 * @param ip instance ip 61 * @param port instance port 62 * @param clusterName instance cluster name 63 * @throws NacosException nacos exception 64 */ 65 void registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException; 66 67 /** 68 * register a instance to service with specified cluster name. 69 * 70 * @param serviceName name of service 71 * @param groupName group of service 72 * @param ip instance ip 73 * @param port instance port 74 * @param clusterName instance cluster name 75 * @throws NacosException nacos exception 76 */ 77 void registerInstance(String serviceName, String groupName, String ip, int port, String clusterName) 78 throws NacosException; 79 80 /** 81 * register a instance to service with specified instance properties. 82 * 83 * @param serviceName name of service 84 * @param instance instance to register 85 * @throws NacosException nacos exception 86 */ 87 void registerInstance(String serviceName, Instance instance) throws NacosException; 88 89 /** 90 * register a instance to service with specified instance properties. 91 * 92 * @param serviceName name of service 93 * @param groupName group of service 94 * @param instance instance to register 95 * @throws NacosException nacos exception 96 */ 97 void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException; 98 99 /**100 * deregister instance from a service.101 *102 * @param serviceName name of service103 * @param ip instance ip104 * @param port instance port105 * @throws NacosException nacos exception106 */107 void deregisterInstance(String serviceName, String ip, int port) throws NacosException;108 109 /**110 * deregister instance from a service.111 *112 * @param serviceName name of service113 * @param groupName group of service114 * @param ip instance ip115 * @param port instance port116 * @throws NacosException nacos exception117 */118 void deregisterInstance(String serviceName, String groupName, String ip, int port) throws NacosException;119 120 /**121 * deregister instance with specified cluster name from a service.122 *123 * @param serviceName name of service124 * @param ip instance ip125 * @param port instance port126 * @param clusterName instance cluster name127 * @throws NacosException nacos exception128 */129 void deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException;130 131 /**132 * deregister instance with specified cluster name from a service.133 *134 * @param serviceName name of service135 * @param groupName group of service136 * @param ip instance ip137 * @param port instance port138 * @param clusterName instance cluster name139 * @throws NacosException nacos exception140 */141 void deregisterInstance(String serviceName, String groupName, String ip, int port, String clusterName)142 throws NacosException;143 144 /**145 * deregister instance with full instance information and default groupName.146 *147 * @param serviceName name of service148 * @param instance instance149 * @throws NacosException nacos exception150 */151 void deregisterInstance(String serviceName, Instance instance) throws NacosException;152 153 /**154 * deregister instance with full instance information.155 *156 * @param serviceName name of service157 * @param groupName group of service158 * @param instance instance information159 * @throws NacosException nacos exception160 */161 void deregisterInstance(String serviceName, String groupName, Instance instance) throws NacosException;162 163 /**164 * get all instances of a service.165 *166 * @param serviceName name of service167 * @return A list of instance168 * @throws NacosException nacos exception169 */170 ListNamingService 源码/* * Copyright 1999-2018 Alibaba Group Holding Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.alibaba.nacos.api.naming;import com.alibaba.nacos.api.exception.NacosException;import com.alibaba.nacos.api.naming.listener.EventListener;import com.alibaba.nacos.api.naming.pojo.Instance;import com.alibaba.nacos.api.naming.pojo.ListView;import com.alibaba.nacos.api.naming.pojo.ServiceInfo;import com.alibaba.nacos.api.selector.AbstractSelector;import java.util.List;/** * Naming Service. * * @author nkorange */public interface NamingService { /** * register a instance to service. * * @param serviceName name of service * @param ip instance ip * @param port instance port * @throws NacosException nacos exception */ void registerInstance(String serviceName, String ip, int port) throws NacosException; /** * register a instance to service. * * @param serviceName name of service * @param groupName group of service * @param ip instance ip * @param port instance port * @throws NacosException nacos exception */ void registerInstance(String serviceName, String groupName, String ip, int port) throws NacosException; /** * register a instance to service with specified cluster name. * * @param serviceName name of service * @param ip instance ip * @param port instance port * @param clusterName instance cluster name * @throws NacosException nacos exception */ void registerInstance(String serviceName, String ip, int port, String clusterName) throws NacosException; /** * register a instance to service with specified cluster name. * * @param serviceName name of service * @param groupName group of service * @param ip instance ip * @param port instance port * @param clusterName instance cluster name * @throws NacosException nacos exception */ void registerInstance(String serviceName, String groupName, String ip, int port, String clusterName) throws NacosException; /** * register a instance to service with specified instance properties. * * @param serviceName name of service * @param instance instance to register * @throws NacosException nacos exception */ void registerInstance(String serviceName, Instance instance) throws NacosException; /** * register a instance to service with specified instance properties. * * @param serviceName name of service * @param groupName group of service * @param instance instance to register * @throws NacosException nacos exception */ void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException; /** * deregister instance from a service. * * @param serviceName name of service * @param ip instance ip * @param port instance port * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, String ip, int port) throws NacosException; /** * deregister instance from a service. * * @param serviceName name of service * @param groupName group of service * @param ip instance ip * @param port instance port * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, String groupName, String ip, int port) throws NacosException; /** * deregister instance with specified cluster name from a service. * * @param serviceName name of service * @param ip instance ip * @param port instance port * @param clusterName instance cluster name * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, String ip, int port, String clusterName) throws NacosException; /** * deregister instance with specified cluster name from a service. * * @param serviceName name of service * @param groupName group of service * @param ip instance ip * @param port instance port * @param clusterName instance cluster name * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, String groupName, String ip, int port, String clusterName) throws NacosException; /** * deregister instance with full instance information and default groupName. * * @param serviceName name of service * @param instance instance * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, Instance instance) throws NacosException; /** * deregister instance with full instance information. * * @param serviceName name of service * @param groupName group of service * @param instance instance information * @throws NacosException nacos exception */ void deregisterInstance(String serviceName, String groupName, Instance instance) throws NacosException; /** * get all instances of a service. * * @param serviceName name of service * @return A list of instance * @throws NacosException nacos exception */ ListgetAllInstances(String serviceName) throws NacosException;171 172 /**173 * get all instances of a service.174 *175 * @param serviceName name of service176 * @param groupName group of service177 * @return A list of instance178 * @throws NacosException nacos exception179 */180 List getAllInstances(String serviceName, String groupName) throws NacosException;181 182 /**183 * Get all instances of a service.184 *185 * @param serviceName name of service186 * @param subscribe if subscribe the service187 * @return A list of instance188 * @throws NacosException nacos exception189 */190 List getAllInstances(String serviceName, boolean subscribe) throws NacosException;191 192 /**193 * Get all instances of a service.194 *195 * @param serviceName name of service196 * @param groupName group of service197 * @param subscribe if subscribe the service198 * @return A list of instance199 * @throws NacosException nacos exception200 */201 List getAllInstances(String serviceName, String groupName, boolean subscribe) throws NacosException;202 203 /**204 * Get all instances within specified clusters of a service.205 *206 * @param serviceName name of service207 * @param clusters list of cluster208 * @return A list of qualified instance209 * @throws NacosException nacos exception210 */211 List getAllInstances(String serviceName, List clusters) throws NacosException;212 213 /**214 * Get all instances within specified clusters of a service.215 *216 * @param serviceName name of service217 * @param groupName group of service218 * @param clusters list of cluster219 * @return A list of qualified instance220 * @throws NacosException nacos exception221 */222 List getAllInstances(String serviceName, String groupName, List clusters) throws NacosException;223 224 /**225 * Get all instances within specified clusters of a service.226 *227 * @param serviceName name of service228 * @param clusters list of cluster229 * @param subscribe if subscribe the service230 * @return A list of qualified instance231 * @throws NacosException nacos exception232 */233 List getAllInstances(String serviceName, List clusters, boolean subscribe) throws NacosException;234 235 /**236 * Get all instances within specified clusters of a service.237 *238 * @param serviceName name of service239 * @param groupName group of service240 * @param clusters list of cluster241 * @param subscribe if subscribe the service242 * @return A list of qualified instance243 * @throws NacosException nacos exception244 */245 List getAllInstances(String serviceName, String groupName, List clusters, boolean subscribe)246 throws NacosException;247 248 /**249 * Get qualified instances of service.250 *251 * @param serviceName name of service.252 * @param healthy a flag to indicate returning healthy or unhealthy instances253 * @return A qualified list of instance254 * @throws NacosException nacos exception255 */256 List selectInstances(String serviceName, boolean healthy) throws NacosException;257 258 /**259 * Get qualified instances of service.260 *261 * @param serviceName name of service262 * @param groupName group of service263 * @param healthy a flag to indicate returning healthy or unhealthy instances264 * @return A qualified list of instance265 * @throws NacosException nacos exception266 */267 List selectInstances(String serviceName, String groupName, boolean healthy) throws NacosException;268 269 /**270 * Get qualified instances of service.271 *272 * @param serviceName name of service273 * @param healthy a flag to indicate returning healthy or unhealthy instances274 * @param subscribe if subscribe the service275 * @return A qualified list of instance276 * @throws NacosException nacos exception277 */278 List selectInstances(String serviceName, boolean healthy, boolean subscribe) throws NacosException;279 280 /**281 * Get qualified instances of service.282 *283 * @param serviceName name of service284 * @param groupName group of service285 * @param healthy a flag to indicate returning healthy or unhealthy instances286 * @param subscribe if subscribe the service287 * @return A qualified list of instance288 * @throws NacosException nacos exception289 */290 List selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe)291 throws NacosException;292 293 /**294 * Get qualified instances within specified clusters of service.295 *296 * @param serviceName name of service297 * @param clusters list of cluster298 * @param healthy a flag to indicate returning healthy or unhealthy instances299 * @return A qualified list of instance300 * @throws NacosException nacos exception301 */302 List selectInstances(String serviceName, List clusters, boolean healthy) throws NacosException;303 304 /**305 * Get qualified instances within specified clusters of service.306 *307 * @param serviceName name of service308 * @param groupName group of service309 * @param clusters list of cluster310 * @param healthy a flag to indicate returning healthy or unhealthy instances311 * @return A qualified list of instance312 * @throws NacosException nacos exception313 */314 List selectInstances(String serviceName, String groupName, List clusters, boolean healthy)315 throws NacosException;316 317 /**318 * Get qualified instances within specified clusters of service.319 *320 * @param serviceName name of service321 * @param clusters list of cluster322 * @param healthy a flag to indicate returning healthy or unhealthy instances323 * @param subscribe if subscribe the service324 * @return A qualified list of instance325 * @throws NacosException nacos exception326 */327 List selectInstances(String serviceName, List clusters, boolean healthy, boolean subscribe)328 throws NacosException;329 330 /**331 * Get qualified instances within specified clusters of service.332 *333 * @param serviceName name of service334 * @param groupName group of service335 * @param clusters list of cluster336 * @param healthy a flag to indicate returning healthy or unhealthy instances337 * @param subscribe if subscribe the service338 * @return A qualified list of instance339 * @throws NacosException nacos exception340 */341 List selectInstances(String serviceName, String groupName, List clusters, boolean healthy,342 boolean subscribe) throws NacosException;343 344 /**345 * Select one healthy instance of service using predefined load balance strategy.346 *347 * @param serviceName name of service348 * @return qualified instance349 * @throws NacosException nacos exception350 */351 Instance selectOneHealthyInstance(String serviceName) throws NacosException;352 353 /**354 * Select one healthy instance of service using predefined load balance strategy.355 *356 * @param serviceName name of service357 * @param groupName group of service358 * @return qualified instance359 * @throws NacosException nacos exception360 */361 Instance selectOneHealthyInstance(String serviceName, String groupName) throws NacosException;362 363 /**364 * select one healthy instance of service using predefined load balance strategy.365 *366 * @param serviceName name of service367 * @param subscribe if subscribe the service368 * @return qualified instance369 * @throws NacosException nacos exception370 */371 Instance selectOneHealthyInstance(String serviceName, boolean subscribe) throws NacosException;372 373 /**374 * select one healthy instance of service using predefined load balance strategy.375 *376 * @param serviceName name of service377 * @param groupName group of service378 * @param subscribe if subscribe the service379 * @return qualified instance380 * @throws NacosException nacos exception381 */382 Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException;383 384 /**385 * Select one healthy instance of service using predefined load balance strategy.386 *387 * @param serviceName name of service388 * @param clusters a list of clusters should the instance belongs to389 * @return qualified instance390 * @throws NacosException nacos exception391 */392 Instance selectOneHealthyInstance(String serviceName, List clusters) throws NacosException;393 394 /**395 * Select one healthy instance of service using predefined load balance strategy.396 *397 * @param serviceName name of service398 * @param groupName group of service399 * @param clusters a list of clusters should the instance belongs to400 * @return qualified instance401 * @throws NacosException nacos exception402 */403 Instance selectOneHealthyInstance(String serviceName, String groupName, List clusters)404 throws NacosException;405 406 /**407 * Select one healthy instance of service using predefined load balance strategy.408 *409 * @param serviceName name of service410 * @param clusters a list of clusters should the instance belongs to411 * @param subscribe if subscribe the service412 * @return qualified instance413 * @throws NacosException nacos exception414 */415 Instance selectOneHealthyInstance(String serviceName, List clusters, boolean subscribe)416 throws NacosException;417 418 /**419 * Select one healthy instance of service using predefined load balance strategy.420 *421 * @param serviceName name of service422 * @param groupName group of service423 * @param clusters a list of clusters should the instance belongs to424 * @param subscribe if subscribe the service425 * @return qualified instance426 * @throws NacosException nacos exception427 */428 Instance selectOneHealthyInstance(String serviceName, String groupName, List clusters, boolean subscribe)429 throws NacosException;430 431 /**432 * Subscribe service to receive events of instances alteration.433 *434 * @param serviceName name of service435 * @param listener event listener436 * @throws NacosException nacos exception437 */438 void subscribe(String serviceName, EventListener listener) throws NacosException;439 440 /**441 * Subscribe service to receive events of instances alteration.442 *443 * @param serviceName name of service444 * @param groupName group of service445 * @param listener event listener446 * @throws NacosException nacos exception447 */448 void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException;449 450 /**451 * Subscribe service to receive events of instances alteration.452 *453 * @param serviceName name of service454 * @param clusters list of cluster455 * @param listener event listener456 * @throws NacosException nacos exception457 */458 void subscribe(String serviceName, List clusters, EventListener listener) throws NacosException;459 460 /**461 * Subscribe service to receive events of instances alteration.462 *463 * @param serviceName name of service464 * @param groupName group of service465 * @param clusters list of cluster466 * @param listener event listener467 * @throws NacosException nacos exception468 */469 void subscribe(String serviceName, String groupName, List clusters, EventListener listener)470 throws NacosException;471 472 /**473 * Unsubscribe event listener of service.474 *475 * @param serviceName name of service476 * @param listener event listener477 * @throws NacosException nacos exception478 */479 void unsubscribe(String serviceName, EventListener listener) throws NacosException;480 481 /**482 * unsubscribe event listener of service.483 *484 * @param serviceName name of service485 * @param groupName group of service486 * @param listener event listener487 * @throws NacosException nacos exception488 */489 void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException;490 491 /**492 * Unsubscribe event listener of service.493 *494 * @param serviceName name of service495 * @param clusters list of cluster496 * @param listener event listener497 * @throws NacosException nacos exception498 */499 void unsubscribe(String serviceName, List clusters, EventListener listener) throws NacosException;500 501 /**502 * Unsubscribe event listener of service.503 *504 * @param serviceName name of service505 * @param groupName group of service506 * @param clusters list of cluster507 * @param listener event listener508 * @throws NacosException nacos exception509 */510 void unsubscribe(String serviceName, String groupName, List clusters, EventListener listener)511 throws NacosException;512 513 /**514 * Get all service names from server.515 *516 * @param pageNo page index517 * @param pageSize page size518 * @return list of service names519 * @throws NacosException nacos exception520 */521 ListView getServicesOfServer(int pageNo, int pageSize) throws NacosException;522 523 /**524 * Get all service names from server.525 *526 * @param pageNo page index527 * @param pageSize page size528 * @param groupName group name529 * @return list of service names530 * @throws NacosException nacos exception531 */532 ListView getServicesOfServer(int pageNo, int pageSize, String groupName) throws NacosException;533 534 /**535 * Get all service names from server with selector.536 *537 * @param pageNo page index538 * @param pageSize page size539 * @param selector selector to filter the resource540 * @return list of service names541 * @throws NacosException nacos exception542 * @since 0.7.0543 */544 ListView getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;545 546 /**547 * Get all service names from server with selector.548 *549 * @param pageNo page index550 * @param pageSize page size551 * @param groupName group name552 * @param selector selector to filter the resource553 * @return list of service names554 * @throws NacosException nacos exception555 */556 ListView getServicesOfServer(int pageNo, int pageSize, String groupName, AbstractSelector selector)557 throws NacosException;558 559 /**560 * Get all subscribed services of current client.561 *562 * @return subscribed services563 * @throws NacosException nacos exception564 */565 List getSubscribeServices() throws NacosException;566 567 /**568 * get server health status.569 *570 * @return is server healthy571 */572 String getServerStatus();573 574 /**575 * Shutdown the resource service.576 *577 * @throws NacosException exception.578 */579 void shutDown() throws NacosException;580 }
-
环球视点!SpringCloud-Nacos学习笔记
spring-cloud-alibaba版本说明https: github com alibaba spring-cloud-alibaba wiki %E7%89%88%E6%9C%AC%E8%
来源: 环球视点!SpringCloud-Nacos学习笔记
铝合金铸造工艺有哪些?铝合金铸造工艺流程
苦主是什么意思?苦主引申含义是什么?
世界微速讯:上网认证(锐捷睿易篇)
当前快看:JNPF3.4.5消息模块:多渠道应用,配置灵活多样,满足更多使用场景
【环球热闻】基于汉兰达开发而来 雷克萨斯TX效果图曝光:竟与奇瑞星途“撞衫”
微软正式放弃Win10 21H1!将无法收到任何安全更新或补丁
亚米级的高精度定位 高德北斗卫星日定位量已超2100亿次
不枉马粉苦等一场 全新马自达CX-90预告:六缸、后驱全都有
【全球快播报】对标迈巴赫S级!蔚来百万级豪车计划落地 售价百万
SAP根据源码导入/ui2/cl_json类
Docker 安装,常用命令
【当前独家】告别LCD/mini LED iPad Pro全系升级到OLED屏
全球快资讯:高端成了!小米12S Ultra被中国移动评为4000元以上最强旗舰
视点!果粉霸气!花万元同时入手小米13和13 Pro:之前用的是iPhone 14 Pro Max
火箭平民化!中国民营火箭朱雀二号即将首飞:人类首次挑战甲烷燃料
小米13系列刷新认知 卢伟冰6字评价:彻底脱胎换骨
快讯:3999元起!小米13今日开售:手感、续航碾压iPhone 14 Pro
消息称苹果要对iOS开放 iPhone等自由了:功能、应用商店向第三方放开
苹果推送iOS 16.2正式版:新增无边记、Apple Music唱歌
阿根廷3-0克罗地亚晋级决赛!梅西创纪录之夜:成现役世界杯射手王
后退N帧协议(GBR)
环球新资讯:taro 编译报:模块引入顺序不一致报错
环球微动态丨主持人邀请世界首富马斯克登台后 现场嘘声一片:尴尬到家
前沿资讯!科幻美剧《西部世界》凉凉!将被彻底下线:美国都不能播了
播报:美国宣布首次实现“核聚变点火”!终于不再“赔本”了
短讯!RX 7900 XT/XTX首发开卖几分钟告罄!黄牛炒疯了:两倍溢价
每日观点:阿根廷时隔四年再战克罗地亚!半决赛现场将播放陈奕迅《孤勇者》
焦点讯息:前端入门教程:CSS标准盒模型和怪异盒模型区别
世界新资讯:卡梅隆力荐!《阿凡达:水之道》CINITY版明日点映:我国自主研发
啥?青岛海边能捡到帝王蟹引围观 网友称赚大 专家解答:不是帝王蟹
世界短讯!神舟十四号航天员摄影作品展:16个地方你认识多少?
《三体》动画爆火 “三体宇宙”能成中国版“漫威宇宙”吗?
每日短讯:Django框架:3、Django请求生命周期(重要)
环球微头条丨全年零事故率!换换智能换电解决电动车最大安全隐患
暴雪与新代理展开洽谈 魔兽等国服谁接?网易偷笑 新版号这难题无解
当前热文:一加11R参数曝光:6.7寸120Hz屏、搭载红外传感器
1*5 句话月考游寄
快资讯:女子下班回家发现2千万豪宅“塌了”:科普何为毛细管网
国际乒联服务器出问题 马龙、樊振东等信息遭泄漏
《暗黑破坏神4》IGN前瞻来了!堪称《暗黑2》超级强化版
环球新动态:被马斯克预言“倒闭” Lucid开始在华招人:明年国内销售
观速讯丨canvas处理切图并旋转图片
天天播报:MIUI 14上手:系统瘦身 更流畅了
天天快讯:不靠CG!诺兰新片《奥本海默》实拍还原第一颗原子弹爆炸场面
【时快讯】花几百亿“烧一壶开水” 美国是不是有“大病”?
国外发现马航MH370起落架残骸:或成蓄意坠毁关键证据
https代理服务器(一)问题引出
观点:路由分发 路由别名的名称空间 虚拟环境 HTTPresponse JsonResponse request对象获取文件 CBV源码剖析 模板语法传值特性
世界要闻:做7秒动画赢13W大奖?总奖池超80W、国内最火爆的3D渲染动画创作大赛开始报名!
全球今热点:iPhone 15拍照值得期待!苹果CEO库克拜访索尼传感器工厂
当前快看:iPad 10耐用性测试:惨遭一掰两半!质量堪忧
中国卫星拍的第一批太阳照片公布!你看懂了吗?
今日讯!MIUI 14脱胎换骨 张宇:梦回MIUI 9快如闪电的感觉
甄子丹主演 新大片《天龙八部之乔峰传》定档:宣传中国武侠
热资讯!字符串相关类
微动态丨Python工具箱系列(二十)
portainer安装,配置,使用
世界速递!Fiddler拦截请求、修改refer数据
全球报道:厘清企业数据治理难题,《网易数据治理白皮书》重磅发布!
天天报道:全球第一次:万兆家用宽带成了!上传、下载都是几千兆
北京小客车指标会过期?官方:谣言、不用着急买车
观焦点:口碑很差?《三体》动画豆瓣开分:几万人给五星 你看没
天天看热讯:红魔27英寸电竞显示器2K版来了:240Hz高刷卖2499元
今日播报!雷军希望的超越苹果做到了!近8成网友认为小米13比iPhone 14 Pro好看
基于zookeeper的kafka中间件
全球快讯:redis缓存穿透、缓存雪崩、缓存击穿【项目总结】
今日热议:零基础开启元宇宙|抖音快手虚拟形象直播【源码】
全球最资讯丨概率论之重要的随机变量
Zabbix技术分享——zabbix命令详解
索尼被曝测试新版PS5:性能不变、增设可拆卸光驱
全球热消息:因担心投资者被吸引到他国:欧盟再次推迟将锂列为有害物质
世界今亮点!苹果担心的事儿发生了 男子用AirTag追踪妻子被逮捕
《巫师3》次时代版体积惊人:PS5升级包超50GB
【世界播资讯】国家邮政局官方回应“快递不快”:加快恢复 邮政顺丰京东开启夜派
环球简讯:eval和ast.literal_eval区别
即时:MySQL索引必知必会
焦点速看:深入理解Whitelabel Error Page底层源码
短讯!字符串函数
【脚本项目源码】Python实现鲁迅名言查询系统
短讯!NGINX常见的变量说明
程序员也可以很浪漫,精选10个圣诞节特效及源码
天天资讯:使用Cpolar搭建一个图片网站2 (Piwigo网站环境准备及安装)
苹果笔记本是什么系统?苹果笔记本怎么安装win10系统?
关闭笔记本触摸板的方法有哪些?关闭笔记本触摸板的四种方法
柳叶刀是哪个国家的杂志?柳叶刀杂志是什么水平?
2023年元旦股市放假几天?2023年元旦股市休市时间表
消防车也要去加油站加油吗?消防车多少钱一台?
win10可以免费升级吗?免费升级win10的条件有哪些?
wlan和wifi哪个网速更快?wlan和wifi的区别是什么?
内存卡读不出来是什么原因?内存卡读不出来怎么修复?
一加8t和一加8pro哪个好?一加8t参数配置
环球微动态丨下载selenium及其适配谷歌浏览器插件chromedriver(含chrome各版本及下载地址)
19.13备库duplicate恢复新主库(二)
iPhone6多少钱?iphone6系统最高可以升级到多少?
锵锵三人行停播原因是什么?锵锵三人行女嘉宾名单大全
沙海吴邪的计划是什么?沙海吴邪的计划成功了吗?
什么边野草花什么口夕阳斜?什么边野草花什么口夕阳斜是什么诗?
九月青豆角产自什么村?九月青豆角怎么冻好吃?
天国的阶梯结局是什么?天国的阶梯演员表