sentinel即哨兵,相比hystrix断路器而言,它的功能更丰富。hystrix仅支持熔断,当服务消费方调用提供方发现异常后,进入熔断;sentinel不仅支持异常熔断,也支持响应超时熔断,另外还支持限流,以及针对网关的熔断和限流。此外,它还有过载处理、监控控制台(Sentinel Dashboard)等。hystrix作为组件集成到微服务中,sentinel也是如此,但它的控制台需要独立部署。

  先下载Sentinel Dashboard(下载地址https://github.com/alibaba/Sentinel/releases),目前最新版本是1.6.3,下载到本地(我的是E盘download目录下)后启动jar包:

C:\Users\wulf>e:

E:\>cd download

E:\download>java -jar sentinel-dashboard-1.6.3.jar
INFO: log base dir is: C:\Users\wulf\logs\csp\
INFO: log name use pid is: false . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE) 2019-08-23 09:08:38.125 INFO 42064 --- [ main] c.a.c.s.dashboard.DashboardApplication : Starting DashboardApplication on wulf00 with PID 42064 (E:\download\sentinel-dashboard-1.6.3.jar started by wulf in E:\download)
2019-08-23 09:08:38.137 INFO 42064 --- [ main] c.a.c.s.dashboard.DashboardApplication : No active profile set, falling back to default profiles: default
2019-08-23 09:08:38.263 INFO 42064 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6c629d6e: startup date [Fri Aug 23 09:08:38 CST 2019]; root of context hierarchy
2019-08-23 09:08:41.446 ERROR 42064 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:41.787 INFO 42064 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-23 09:08:41.817 ERROR 42064 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:41.859 INFO 42064 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-23 09:08:41.861 INFO 42064 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
2019-08-23 09:08:41.887 ERROR 42064 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:42.037 INFO 42064 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-23 09:08:42.039 INFO 42064 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3777 ms
2019-08-23 09:08:42.163 INFO 42064 --- [ost-startStop-1] c.a.c.s.dashboard.config.WebConfig : Sentinel servlet CommonFilter registered
2019-08-23 09:08:42.288 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-08-23 09:08:42.291 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-23 09:08:42.292 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-08-23 09:08:42.293 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-08-23 09:08:42.295 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'authenticationFilter' to urls: [/*]
2019-08-23 09:08:42.296 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'sentinelFilter' to urls: [/*]
2019-08-23 09:08:42.296 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-08-23 09:08:43.660 INFO 42064 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-08-23 09:08:43.930 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6c629d6e: startup date [Fri Aug 23 09:08:38 CST 2019]; root of context hierarchy
2019-08-23 09:08:44.060 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registry/machine],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<?> com.alibaba.csp.sentinel.dashboard.controller.MachineRegistryController.receiveHeartBeat(java.lang.String,java.lang.Integer,java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.067 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/logout],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result com.alibaba.csp.sentinel.dashboard.controller.AuthController.logout(javax.servlet.http.HttpServletRequest)
2019-08-23 09:08:44.068 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/login],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result com.alibaba.csp.sentinel.dashboard.controller.AuthController.login(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String)
2019-08-23 09:08:44.083 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/delete.json],methods=[DELETE]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.delete(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.084 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/rules],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.apiQueryMachineRules(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.085 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/rule],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.apiAddFlowRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity)
2019-08-23 09:08:44.088 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/save.json],methods=[PUT]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.updateIfNotNull(javax.servlet.http.HttpServletRequest,java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer,java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.Integer)
2019-08-23 09:08:44.094 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/flow/rules],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.v2.FlowControllerV2.apiQueryMachineRules(javax.servlet.http.HttpServletRequest,java.lang.String)
2019-08-23 09:08:44.095 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/flow/rule/{id}],methods=[PUT]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.v2.FlowControllerV2.apiUpdateFlowRule(javax.servlet.http.HttpServletRequest,java.lang.Long,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity)
2019-08-23 09:08:44.097 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/flow/rule],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.v2.FlowControllerV2.apiAddFlowRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity)
2019-08-23 09:08:44.099 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/flow/rule/{id}],methods=[DELETE]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.v2.FlowControllerV2.apiDeleteRule(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.106 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/app/{app}/machine/remove.json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.String> com.alibaba.csp.sentinel.dashboard.controller.AppController.removeMachineById(java.lang.String,java.lang.String,int)
2019-08-23 09:08:44.108 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/app/{app}/machines.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.domain.vo.MachineInfoVo>> com.alibaba.csp.sentinel.dashboard.controller.AppController.getMachinesByApp(java.lang.String)
2019-08-23 09:08:44.109 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/app/names.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<java.lang.String>> com.alibaba.csp.sentinel.dashboard.controller.AppController.queryApps(javax.servlet.http.HttpServletRequest)
2019-08-23 09:08:44.110 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/app/briefinfos.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.discovery.AppInfo>> com.alibaba.csp.sentinel.dashboard.controller.AppController.queryAppInfos(javax.servlet.http.HttpServletRequest)
2019-08-23 09:08:44.114 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/demo/loop],produces=[application/json]}" onto public java.lang.String com.alibaba.csp.sentinel.dashboard.controller.DemoController.loop(java.lang.String,int) throws com.alibaba.csp.sentinel.slots.block.BlockException
2019-08-23 09:08:44.115 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/demo/link],produces=[application/json]}" onto public java.lang.String com.alibaba.csp.sentinel.dashboard.controller.DemoController.link() throws com.alibaba.csp.sentinel.slots.block.BlockException
2019-08-23 09:08:44.118 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/demo/greeting],produces=[application/json]}" onto public java.lang.String com.alibaba.csp.sentinel.dashboard.controller.DemoController.greeting()
2019-08-23 09:08:44.122 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/demo/slow],produces=[application/json]}" onto public java.lang.String com.alibaba.csp.sentinel.dashboard.controller.DemoController.slow(java.lang.String,int) throws com.alibaba.csp.sentinel.slots.block.BlockException
2019-08-23 09:08:44.124 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/resource/machineResource.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.domain.vo.ResourceVo>> com.alibaba.csp.sentinel.dashboard.controller.ResourceController.fetchResourceChainListOfMachine(java.lang.String,java.lang.Integer,java.lang.String,java.lang.String)
2019-08-23 09:08:44.128 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/assign/all_server/{app}],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterAssignController.apiAssignAllClusterServersOfApp(java.lang.String,com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppFullAssignRequest)
2019-08-23 09:08:44.129 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/assign/unbind_server/{app}],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterAssignController.apiUnbindClusterServersOfApp(java.lang.String,java.util.Set<java.lang.String>)
2019-08-23 09:08:44.131 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/assign/single_server/{app}],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterAssignController.apiAssignSingleClusterServersOfApp(java.lang.String,com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppSingleServerAssignRequest)
2019-08-23 09:08:44.136 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/api/delete.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayApiController.deleteApi(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.137 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/api/list.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity>> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayApiController.queryApis(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.140 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/api/new.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayApiController.addApi(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.AddApiReqVo)
2019-08-23 09:08:44.142 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/api/save.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayApiController.updateApi(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api.UpdateApiReqVo)
2019-08-23 09:08:44.147 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/paramFlow/rules],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.ParamFlowRuleController.apiQueryAllRulesForMachine(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.149 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/paramFlow/rule],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.ParamFlowRuleController.apiAddParamFlowRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity)
2019-08-23 09:08:44.151 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/paramFlow/rule/{id}],methods=[PUT]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.ParamFlowRuleController.apiUpdateParamFlowRule(javax.servlet.http.HttpServletRequest,java.lang.Long,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity)
2019-08-23 09:08:44.153 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/paramFlow/rule/{id}],methods=[DELETE]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.ParamFlowRuleController.apiDeleteRule(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.157 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/rules],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.AuthorityRuleController.apiQueryAllRulesForMachine(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.159 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/rule],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.AuthorityRuleController.apiAddAuthorityRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity)
2019-08-23 09:08:44.164 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/rule/{id}],methods=[PUT]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.AuthorityRuleController.apiUpdateParamFlowRule(javax.servlet.http.HttpServletRequest,java.lang.Long,com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity)
2019-08-23 09:08:44.168 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/authority/rule/{id}],methods=[DELETE]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.AuthorityRuleController.apiDeleteRule(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.171 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/flow/new.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayFlowRuleController.addFlowRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.AddFlowRuleReqVo)
2019-08-23 09:08:44.172 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/flow/list.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayFlowRuleController.queryFlowRules(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.173 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/flow/delete.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayFlowRuleController.deleteFlowRule(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.174 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/gateway/flow/save.json],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.gateway.GatewayFlowRuleController.updateFlowRule(javax.servlet.http.HttpServletRequest,com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.rule.UpdateFlowRuleReqVo)
2019-08-23 09:08:44.178 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/server_state/{app}],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterServerStateWrapVO>> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterConfigController.apiGetClusterServerStateOfApp(java.lang.String)
2019-08-23 09:08:44.180 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/config/modify_single],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Boolean> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterConfigController.apiModifyClusterConfig(java.lang.String)
2019-08-23 09:08:44.181 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/state/{app}],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO>> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterConfigController.apiGetClusterStateOfApp(java.lang.String)
2019-08-23 09:08:44.185 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/client_state/{app}],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterClientStateWrapVO>> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterConfigController.apiGetClusterClientStateOfApp(java.lang.String)
2019-08-23 09:08:44.188 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cluster/state_single],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStateVO> com.alibaba.csp.sentinel.dashboard.controller.cluster.ClusterConfigController.apiGetClusterState(java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.191 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/metric/queryByAppAndResource.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<?> com.alibaba.csp.sentinel.dashboard.controller.MetricController.queryByAppAndResource(java.lang.String,java.lang.String,java.lang.Long,java.lang.Long)
2019-08-23 09:08:44.192 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/metric/queryTopResourceMetric.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<?> com.alibaba.csp.sentinel.dashboard.controller.MetricController.queryTopResourceMetric(java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.Boolean,java.lang.Long,java.lang.Long,java.lang.String)
2019-08-23 09:08:44.194 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/degrade/new.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.DegradeController.add(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer,java.lang.String,java.lang.String,java.lang.Double,java.lang.Integer,java.lang.Integer)
2019-08-23 09:08:44.198 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/degrade/delete.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.DegradeController.delete(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.199 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/degrade/rules.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.DegradeController.queryMachineRules(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.200 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/degrade/save.json],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.DegradeController.updateIfNotNull(javax.servlet.http.HttpServletRequest,java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.Double,java.lang.Integer,java.lang.Integer)
2019-08-23 09:08:44.209 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/system/delete.json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<?> com.alibaba.csp.sentinel.dashboard.controller.SystemController.delete(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.210 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/system/rules.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.SystemController.apiQueryMachineRules(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.212 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/system/new.json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.SystemController.apiAdd(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer,java.lang.Double,java.lang.Double,java.lang.Long,java.lang.Long,java.lang.Double)
2019-08-23 09:08:44.214 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/system/save.json],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.SystemController.apiUpdateIfNotNull(javax.servlet.http.HttpServletRequest,java.lang.Long,java.lang.String,java.lang.Double,java.lang.Double,java.lang.Long,java.lang.Long,java.lang.Double)
2019-08-23 09:08:44.219 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-08-23 09:08:44.221 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-08-23 09:08:44.236 INFO 42064 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2019-08-23 09:08:44.276 INFO 42064 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-08-23 09:08:44.277 INFO 42064 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-08-23 09:08:44.546 INFO 42064 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-08-23 09:08:44.590 INFO 42064 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-23 09:08:44.599 INFO 42064 --- [ main] c.a.c.s.dashboard.DashboardApplication : Started DashboardApplication in 7.26 seconds (JVM running for 9.45)
2019-08-23 09:08:45.767 ERROR 42064 --- [nio-8080-exec-2] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:45.783 INFO 42064 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-08-23 09:08:45.783 INFO 42064 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-08-23 09:08:45.812 INFO 42064 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms

  默认端口号是8080,我们在浏览器输入localhost:8080即可打开监控面板,默认用户名密码都是sentinel:

  接下来我们让服务提供方lxytrans-provider这个应用(原三板斧参见0.9.0.RELEASE版本的spring cloud alibaba nacos实例)接入到哨兵,加上sentinel相关内容:

  1、pom引入sentinel依赖:

        <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

  2、application引入sentinel dashboard地址:

#哨兵
spring.cloud.sentinel.transport.dashboard=localhost:8080

  3、controller加上注解@SentinelResource标识资源:

    @Slf4j
@RestController
static class TestController { @GetMapping("/hello")
@SentinelResource("hello")
public String hello() {
return "hello";
} @GetMapping("/hey")
@SentinelResource("hey")
public String hey() throws InterruptedException {
Thread.sleep(2000);
return "hey";
}

  打完收工。启动应用后,再访问localhost:8080,发现微服务已经接入,但是sentinel dashboard页面已然啥都木有。我们需要先访问一次接口,才能在sentinel dashboard上看到。那就先跑一把/hello和/hey,再去sentinel bashboard刷新下实时监控,接口出来了:

  我们点下“簇点链路”,在对应的资源右边点击流控进行流控规则设置,点击降级则是设置降级规则。先试下流控。上面可以看到hello有3级资源,点击我们在@SentinelResource中指定的“hello”右边对应的流控按钮:

  这里我们配置流控规则是每秒并发请求数为3,超过了就直接拒绝。点击新增按钮后跳到流控规则页面:

  流控规则页面的右上角也可以直接添加规则的。现在我们通过jmeter来跑一个,jmeter设置线程数为4(具体设置参见jmeter使用经历):

  我们看到并发调用了4次hello接口,其中一次失败了,日志打印如下:

2019-08-22 13:02:14.651 |-ERROR [http-nio-8282-exec-10] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] [175] -| Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.reflect.UndeclaredThrowableException] with root cause
com.alibaba.csp.sentinel.slots.block.flow.FlowException: null

  接下来我们通过另一个/hey接口试下降级,在“簇点链路”点击“hey”资源右边的降级按钮设置降级规则:

  这里我们配置/hey接口如果时延超过100毫秒(5个一批,两批均超时,进入降级),那么接下来的10秒内,我们将拒绝请求。10秒后允许继续请求,如果还是超时,那么继续拒绝10秒。循环往复,生生不息。点击“新增”按钮后跳往降级规则页面:

  同样的,在这个页面右上角也可以直接新增降级规则。我们在jmeter中新增一个/hey接口,禁用原来的/hello,再将线程数改为5,循环次数改为4,跑一把:

  /hey接口的时延是2秒,仔细看下这20个接口的请求时间,分4批请求,每批间隔2秒。可以发现第一批5个是正常通过的,接下第2批前4个也是正常通过的,后面11个全被拒绝了。日志打印:

2019-08-22 13:12:03.245 |-ERROR [http-nio-8282-exec-2] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] [175] -| Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.reflect.UndeclaredThrowableException] with root cause
com.alibaba.csp.sentinel.slots.block.degrade.DegradeException: null

  打完收工。注意如果应用重启后,sentinel dashboard的限流、降级配置就没了,需要重新请求一次,刷出资源后再重新配置。更多信息参考https://github.com/alibaba/Sentinel/wiki/介绍。关于服务提供方的限流、降级定制处理,参见0.9.0.RELEASE版本的spring cloud alibaba sentinel限流、降级处理实例

0.9.0.RELEASE版本的spring cloud alibaba sentinel实例的更多相关文章

  1. 0.9.0.RELEASE版本的spring cloud alibaba sentinel限流、降级处理实例

    先看服务提供方的,我们在原来的sentinel实例(参见0.9.0.RELEASE版本的spring cloud alibaba sentinel实例)上加上限流.降级处理,三板斧只需在最后那一斧co ...

  2. 0.9.0.RELEASE版本的spring cloud alibaba sentinel+feign降级处理实例

    既然用到了feign,那么主要是针对服务消费方的降级处理.我们基于0.9.0.RELEASE版本的spring cloud alibaba nacos+feign实例添油加醋,把sentinel功能加 ...

  3. 0.9.0.RELEASE版本的spring cloud alibaba sentinel+gateway网关实例

    sentinel除了让服务提供方.消费方用之外,网关也能用它来限流.我们基于上次整的网关(参见0.9.0.RELEASE版本的spring cloud alibaba nacos+gateway网关实 ...

  4. 0.9.0.RELEASE版本的spring cloud alibaba nacos实例

    简而言之,nacos与eureka的不同之处有三:后台老板.部署方式.功能.nacos是阿里的,eureka是奈飞的:nacos有自己的安装包,需要独立部署,eureka仅作为一个服务组件,引入jar ...

  5. 0.9.0.RELEASE版本的spring cloud alibaba nacos+gateway网关实例

    gateway就是用来替换zuul的,功能都差不多,我们看下它怎么来跟nacos一起玩.老套路,三板斧: 1.pom: <?xml version="1.0" encodin ...

  6. 0.9.0.RELEASE版本的spring cloud alibaba nacos+feign实例

    这里的feign依然是原来的feign,只不过将注册中心由eureka换成了nacos.服务提供方参见0.9.0.RELEASE版本的spring cloud alibaba nacos实例,消费方跟 ...

  7. Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探

    目录 Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探 1. Sentinel 是什么? 2. Sentinel 的特征: 3. Sentinel 的开源生 ...

  8. Spring Cloud Alibaba | Sentinel: 服务限流基础篇

    目录 Spring Cloud Alibaba | Sentinel: 服务限流基础篇 1. 简介 2. 定义资源 2.1 主流框架的默认适配 2.2 抛出异常的方式定义资源 2.3 返回布尔值方式定 ...

  9. Spring Cloud Alibaba | Sentinel: 服务限流高级篇

    目录 Spring Cloud Alibaba | Sentinel: 服务限流高级篇 1. 熔断降级 1.1 降级策略 2. 热点参数限流 2.1 项目依赖 2.2 热点参数规则 3. 系统自适应限 ...

随机推荐

  1. 《发际线总是和我作队》第九次作业:Beta冲刺Scrum Meeting3

    项目 内容 这个作业属于哪个课程 软件工程 这个作业的要求在哪里 实验十三 团队作业9:Beta冲刺与团队项目冲刺 团队名称 发际线总和我作队 作业学习目标 (1)掌握软件黑盒测试技术:(2)掌握软件 ...

  2. Hibernate中的Session

    我们之前也经常使用Session,通过连接服务器将需要保存的值存到服务器的session中,这是之前关于session的简单应用.现在看到Hibernate框架中也有关于Session的定义,该定义是 ...

  3. MyEclipse激活代码

    package TestCase; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...

  4. C# 6.0 中的新增功能(.NET Framework 4.6 与 Visual Studio 2015 )

    C#6.0 在 2015 年7月随着.NET Framework 4.6 一同发布,后期发布了.NET Framework 4.6.1,4.6.2. 一.自动属性初始化(Auto-property i ...

  5. 01-学习vue前的准备工作(let和const)

    es6语法:let和const es6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效 <!DOCYTPE html> <ht ...

  6. [TypeScript ] Using the Null Coalescing operator with TypeScript 3.7

    The postshows you how to use the null coalescing operator (??) instead of logical or (||) to set def ...

  7. CentOS6.5 安装ES5.5

    一.CURL查看已开启的ES es5.5:elasticsearch-5.5.2.tar.gz下载,百度云地址 https://pan.baidu.com/s/17oFOQlePLtUhhJHxEPR ...

  8. 【JQuery】操作前端控件知识笔记

    一.jQuery操作复选框checkbox 1.设置选中.取消选中.获取被选中的值.判断是否选中等 注意:操作checked.disabled.selected属性,强制建议只用prop()方法!!, ...

  9. 10分钟用Python告诉你两个机器人聊天能聊出什么火花

    欲直接下载代码文件,关注我们的公众号哦!查看历史消息即可! 现在不是讲各种各样的人工智能嘛,AI下棋,AI客服,AI玩家--其实我一直很好奇,两个AI碰上会怎样,比如一起下棋,一起打游戏-- 今天做个 ...

  10. AtCoder Grand Contest 013题解

    传送门 \(A\) 先把相同的缩一起,然后贪心就可以了 //quming #include<bits/stdc++.h> #define R register #define fp(i,a ...