没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
MEAP Edition
Manning Early Access Program
Netty in Action
Version 5
Copyright 2013 Manning Publications
For more information on this and other Manning titles go to
www.manning.com
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
http://www.manning-sandbox.com/forum.jspa?forumID=857
brief contents
PART 1: GETTING STARTED
1. Netty and Java NIO APIs
2. Your first Netty application
3. Netty from the ground up
PART 2: CORE FUNCTIONS/PARTS
4. Transports
5. Buffers
6. ChannelHandler
7. Codec
8. Provided ChannelHandlers and Codecs
9. Bootstrapping Netty applications
PART 3: NETTY BY EXAMPLE
10. Unit-test your code
11. WebSockets
12. SPDY
13. Broadcasting events via UDP
PART 4: ADVANCED TOPICS
14. Implement a custom codec
15. Choosing the right thread model
16. Deregister/re-register with EventLoop
17. Case studies
Appendix A: The community how to get involved
Appendix B: Related books
Appendix C: Related projects
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
http://www.manning-sandbox.com/forum.jspa?forumID=857
1
Netty and Java NIO APIs
This chapter covers
Netty architecture
Why we need non-blocking IO (NIO)
Blocking versus non-blocking IO
Known problems with the JDKs NIO implementation and Nettys solutions
This chapter introduces Netty, but its focus is Javas non-blocking IO (NIO) API. If youre new
to networking on the JVM, this chapter is an ideal place to begin, but its also a good refresher
for the seasoned Java developer. If youre familiar with NIO and NIO.2, feel free to skip ahead
to chapter 2, which dives into Netty after you get it running on your machine.
Netty is a NIO client-server framework, which enables quick and easy development of
network applications, such as protocol servers and clients. Netty offers you a new way to
develop your network applications, which makes it easy and scalable. It achieves this by
abstracting away the complexity involved and by providing an easy-to-use API that decouples
business-logic from the network-handling code. Because its built for NIO, the entire Netty API
is asynchronous.
Generally, network applications have scalability issues, whether theyre based on Netty or
other NIO APIs. A key component of Netty is its asynchronous nature, and this chapter
discusses synchronous (blocking) and asynchronous (non-blocking) IO to illustrate why and
how asynchronous code solves scalability problems.
For those new to networking, this chapter gives you an understanding of networking
applications, in general, and how Netty helps implement them. It explains how to use
fundamental Java networking APIs, discusses both its strengths and weaknesses, and shows
how Netty addresses Java issues, such as the
Epoll bug or memory leaks.
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
http://www.manning-sandbox.com/forum.jspa?forumID=857
1
By the end of the chapter, youll understand what Netty is and what it offers, and youll gain
enough understanding about Javas NIO and asynchronous processing to enable you to work
through the other chapters of this book.
1.1 Why Netty?
In the words of David Wheeler, all problems in computer science can be solved by another
level of indirection.
1
As an NIO client-server framework, Netty offers one such level of
indirection. Netty simplifies network programming of TCP or UDP servers but you can still
access and use the low-level APIs because Netty provides high-level abstractions.
1.1.1 Not all networking frameworks are alike
With Netty, quick and easy doesnt mean that a resulting application suffers from
maintainability or performance issues. The experiences earned from the implementation of
protocols such as FTP, SMTP, HTTP, WebSocket, SPDY and various binary and text-based
legacy protocols led Nettys founders to take great care in its design. As a result, Netty
successfully delivers ease of development, performance, stability, and flexibility without
compromise.
High-profile companies and open-source projects including RedHat, Twitter, Infinispan, and
HornetQ, Vert.x, Finagle, Akka, Apache Cassandra, Elasticsearch, and others use and
contribute to Netty. Its also fair to say that some of the features of Netty are a result of the
needs of these projects. Over the years, Netty has become more widely known and is one of
the most-used networking frameworks for the JVM, as evident by its use in several popular
open- and closed-source projects. In fact, Netty was awarded the Dukes Choice Award
2
in
2011.
Also in 2011, Netty founder Trustin Lee left RedHat to join Twitter. At this point, the Netty
project became independent of any company in an effort to simplify contributions to it. Both
Red Hat and Twitter use Netty, so it should come as no surprise that these two companies are
the biggest contributors to Netty at the time of writing. Adoption of Netty continues to
increases, as does the number of individual contributors. The community of Netty users is
active and the project remains vibrant.
1.1.2 Netty boasts a rich feature set
As you work through the chapters of this book, youll learn about and use many of Nettys
features. Figure 1.1 highlights some of the supported transports and protocols to give you a
brief overview of the Netty architecture.
1
Add citation
2
Add citation
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
http://www.manning-sandbox.com/forum.jspa?forumID=857
2
剩余264页未读,继续阅读
wukjong_1988
- 粉丝: 6
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页