Skip to content

Commit d6a3ecf

Browse files
committed
fix readme by thrift
1 parent b555cc7 commit d6a3ecf

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

springboot-rpc-thrift-sample/README.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,49 @@
2525
> - TMemoryTransport 将内存用于I/O的方式进行传输;
2626
2727
##### Thrift支持多种的服务模型
28+
2829
> - TSimpleServer 单线程模型,一般用于调试;
2930
>
3031
> - ThreadPoolServer 多线程服务模式,使用标准的阻塞IO;
3132
>
32-
> - TNonblockingServer 多线程服务模型,使用非阻塞式IO(需要使用TFramedTransport传输方式);
33+
> - TNonblockingServer 单线程服务模型,使用非阻塞式IO(需要使用TFramedTransport传输方式);
34+
35+
36+
### 三、Thrift各种Server实现?
37+
38+
##### TSimpleServer单线程服务模型
39+
40+
> - TSimpleServer是一个单线程阻塞I/O的Server,它循环监听新请求的到来并 对请求进行处理;
41+
>
42+
> - TSimpleServer一次只能接受处理一个Sokect连接,效率低,一般用于调试和学习;
3343
34-
##### Thrift服务端最佳选择
35-
> - 传输协议格式使用:TcompactProtocol;
44+
<img src="https://raw.githubusercontent.com/ipipman/JavaSpringBootSamples/master/ReadmeMaterial/thrift/811607996045_.pic_hd.jpg" width = "580" height = "340" alt="图片名称" align=center />
45+
46+
47+
##### TNonblockingServer单线程非阻塞I/O模型
48+
49+
> - TNonblokingServer 是一个单线程NIO的Server,通过Selector循环监听所有Sokect,每次selector结束时,处理所有就绪的状态Sokect;
3650
>
37-
> - 数据传输方式使用:TFramedTransport;
51+
> - 虽然连接是NIO可以同时接收多个Sokect连接,但是处理任务时依然是阻塞的;
52+
53+
<img src="https://raw.githubusercontent.com/ipipman/JavaSpringBootSamples/master/ReadmeMaterial/thrift/781607995925_.pic_hd.jpg" width = "540" height = "760" alt="图片名称" align=center />
54+
55+
#### ThreadPoolServer多线程阻塞I/O模型
56+
57+
> - TThreadPoolServer模式采用阻塞Sokect方式工作,主线程负责阻塞监听是否有新的Sokect连接,业务交由一个线程池进行处理;
3858
>
39-
> - 服务模型:TNonblockingServer;
59+
> - 该模式处理能力受限与线程池的处理能力,并发请求数大于线程数时会阻塞新的待处理请求;
4060
41-
### 二、如何使用Thrift?
61+
<img src="https://raw.githubusercontent.com/ipipman/JavaSpringBootSamples/master/ReadmeMaterial/thrift/791607995943_.pic_hd.jpg" width = "600" height = "400" alt="图片名称" align=center />
62+
63+
#### THsHaServer
64+
65+
> - THsHaServer是一个TNonbloking的子类,在TNonblockingServer模式中,采用一个线程处理所有Sokect监听和业务处理,造成效率地下,而THsHaServer模式使用了一个线程池来专门处理业务;
66+
67+
<img src="https://raw.githubusercontent.com/ipipman/JavaSpringBootSamples/master/ReadmeMaterial/thrift/801607996017_.pic_hd.jpg" width = "580" height = "760" alt="图片名称" align=center />
68+
69+
70+
### 三、如何使用Thrift?
4271
#### 1.在使用Thrift框架前,需要先针对业务设计IDL描述文件,然后生成对应的Java接口文件后完成对应的接口实现类。
4372
##### IDL语法参考:[http://zanphpdoc.zanphp.io/nova/IDL_syntax.html](http://zanphpdoc.zanphp.io/nova/IDL_syntax.html "http://zanphpdoc.zanphp.io/nova/IDL_syntax.html")
4473
```java
@@ -175,9 +204,3 @@ public class ThriftClient {
175204
}
176205
}
177206
```
178-
179-
180-
181-
182-
183-

0 commit comments

Comments
 (0)