当前位置:网站首页>Micro service component sentinel console call
Micro service component sentinel console call
2022-07-03 17:44:00 【kjshuan】
02 Microservice component Sentinel ( Console version )
Step one linux To configure
Start the console command ( Pay attention to dragging the file into linux Under the opt)
#1 Open edit file vim dashboard.sh # Copy the following account number cm password ok( Be careful - You may have to hit it manually ) java -Dserver.port=8858 -Dsentinel.dashboard.auth.username=cm -Dsentinel.dashboard.auth.password=ok -jar /opt/sentinel-dashboard-1.8.1.jar #2 Authorization file name chmod 777 dashboard.sh ls ./dashboard.sh cat dashboard.sh ls /opt/ #3 Browser launch ( Enter your own address ) http://192.168.64.200:8858/#/login #4 account number cm password ok
The above content is displayed and successfully entered !!!
Sentinel It will be initialized the first time the client calls , Start sending heartbeat packets to the console , So make sure the client has access ;
Spring Cloud Alibaba Integrate Sentinel
First step To configure pom
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency>
The second step is configuration controller
@RestController @RequestMapping("/nssent") public class InitCtrl { @RequestMapping("/init") public String sayHello(){ return "Hello World"; } }
Step 3 configuration yml
server: port: 12005 spring: application: name: nessentinelctl cloud: sentinel: transport: dashboard: 192.168.64.200:8858
Step 4 start the browser to input
http://localhost:12005/nssent/init # Refresh several times Enter the following address http://192.168.64.200:8858/#/dashboard
Step 5 realize flow control
#1 stay controller Add code Custom flow control prompt
@RestController @RequestMapping("/nssent") public class InitCtrl { @RequestMapping("/init") @SentinelResource(value = "it",blockHandler = "ctlHandler") public String sayHello(){ return "Hello World"; } public String ctlHandler(BlockException ex){ return " You are under flow control o(╥﹏╥)o"; } }
install jmeter( Pressure test )
Click on jemter.bat
java Code implementation replaces jemeter test ( Pure code version )
# The first step is to import pom rely on
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.13</version> </dependency>
# The second step is to write code
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * Hello world! * */ public class App { public static void main( String[] args ) { // Create a thread pool Default 10 Threads ExecutorService pool = Executors.newFixedThreadPool(10); //for Loop execution 10 Time for (int i = 0; i < 10; i++) { pool.execute(()->{ try { CloseableHttpClient chc= HttpClients.createDefault(); HttpGet get = new HttpGet("http://localhost:12005/nssent/init"); CloseableHttpResponse response= chc.execute(get); System.out.println( Thread.currentThread().getName()+"--------->"+ EntityUtils.toString(response.getEntity())); } catch (IOException e) { throw new RuntimeException(e); } }); } } }
------------- project Writing interface -------------( Expand knowledge And sentinel irrelevant )
get length 255 byte 2048 character post 2g There is no limit to the theory
{ "high":100, "weight":60, "scene-manager":"2022-SBZL-05966", "indate":"2022-03-12", "range":"2.6-60" }
边栏推荐
- Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
- Kubernetes resource object introduction and common commands (III)
- Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
- SQL injection database operation foundation
- [set theory] order relation: summary (partial order relation | partial order set | comparable | strictly less than | covering | hasto | total order relation | quasi order relation | partial order rela
- Basic grammar of interview (Part 2)
- Managing multiple selections with MVVM - managing multiple selections with MVVM
- RDS数据库的监测页面在哪看?
- Online assignment 3 of mobile Internet technology in the 20th autumn of electronic technology [standard answer]
- 【RT-Thread】nxp rt10xx 设备驱动框架之--Pin搭建和使用
猜你喜欢
Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
Investigation on the operation prospect of the global and Chinese Anti enkephalinase market and analysis report on the investment strategy of the 14th five year plan 2022-2028
PS screen printing brush 131, many illustrators have followed suit
[RT thread] NXP rt10xx device driver framework -- RTC construction and use
Golang单元测试、Mock测试以及基准测试
聊聊支付流程的设计与实现逻辑
Leetcode 669 pruning binary search tree -- recursive method and iterative method
Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
[RT thread] NXP rt10xx device driver framework -- Audio construction and use
互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码
随机推荐
AcWing 3438. Number system conversion
1164 Good in C
Research on Swift
How to purchase Google colab members in China
STM32H7 HAL库SPI DMA发送一直处于busy的解决办法
Stm32h7 Hal library SPI DMA transmission has been in busy solution
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
PUT vs. POST for Uploading Files - RESTful API to be Built Using Zend Framework
[combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
Interviewer: why is the value nil not equal to nil?
Leetcode13. Roman numeral to integer (three solutions)
SQL injection database operation foundation
一位普通程序员一天工作清单
RDS数据库的监测页面在哪看?
[RT thread] NXP rt10xx device driver framework -- pin construction and use
Luogu: p2685 [tjoi2012] Bridge
Research Report on competitive strategy Outlook Analysis and investment strategic planning of China's smart home equipment industry, 2022-2028
远程办公工具分享|社区征文
Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)
Deops入门