本书讨论了网络计算系统中基础设施软件——中间件。本书提供了一种如何应用自适应通信环境ACE和能够运行多种硬件平台和操作系统的开发源框架,来开发和优化复杂分布系统的实际解决方案,指导软件专业人员如何开发高效、可移植和灵活的并发网络应用系统程序。全书分为三部分,内容包括网络应用面临的挑战,面向对象的中间件解决方案,自适应通信环境ACET具包,面向对象的网络编程技术,面向并发对象的网络编程等。
本书对于想了解和掌握如何应用C++和面向对象设计技术,从策略和技术上进行并发网络应用系统程序设计开发的软件工程师和研究生及高年级本科生具有很好的参考价值。
List of Figures
Foreword
About This Book
Chapter 0 Design Challenges, Middleware Solutions, and ACE
0.1 Challenges of Networked Applications
0.2 Networked Application Design Dimensions
0.3 Object-Oriented Middleware Solutions
0.4 An Overview of the ACE Toolkit
0.5 Example: A Networked Logging Service
0.6 Summary
Part I Object-Oriented Network Programming
Chapter I Communication Design Dimensions
1.1 Connectionless versus Connection-Oriented Protocols
1.2 Synchronous versus Asynchronous Message Exchange
1.3 Message Passing versus Shared Memory
1.4 Summary
Chapter 2 An Overview of the Socket API
2.1 An Overview of Operating System IPC Mechanisms
2.2 The Socket API
2.3 Limitations of the Socket API
2.4 Summary
Chapter 3 The ACE Socket Wrapper Facades
3.1 Overview
3.2 The ACE_Addr and ACE_INET_Addr Classes
3.3 The ACE_IPC_SAP Class
3.4 The ACE_SOCK Class
3.5 The ACE_SOCK_Connector Class
3.6 The ACE_SOCK_IO and ACE_SOCK_Stream Classes
3.7 The ACE_SOCK_Acceptor Class
3.8 Summary
Chapter 4 Implementing the Networked Logging Service
4.1 Overview
4.2 The ACE_Message_Block Class
4.3 The ACE_InputCDR and ACE_OutputCDR Classes
4.4 The Initial Logging Server
4.5 The Client Application
4.6 Summary
Part II Concurrent Object-Oriented Network Programming
Chapter 5 Concurrency Design Dimensions
5.1 Iterative, Concurrent, and Reactive Servers
5.2 Processes versus Threads
5.3 Process/Thread Spawning Strategies
5.4 User, Kernel, and Hybrid Threading Models
5.5 Time-Shared and Real-Time Scheduling Classes
5.6 Task- versus Message-Based Architectures
5.7 Summary
Appendix A Design Principles for ACE C++ Wrapper Facades
A.1 Overview
A.2 Use Wrapper Facades to Enhance Type Safety
A.3 Simplify for the Common Case
A.4 Use Hierarchies to Enhance Design Clarity and
Extensibility
A.5 Hide Platform Differences Whenever Possible
A.6 Optimize for Efficiency
A.7 Summary
Appendix B The Past, Present, and Future of ACE
B.1 The Evolution of ACE
B.2 The Road Ahead
B.3 Concluding Remarks
Glossary
Bibliography
Index
As I write this foreword I'm traveling through Europe, relying on the excellent European public transportation infrastructure. Being an American, I'm fascinated and amazed by this infrastructure. Wherever I land at an airport I have easy access to trains and buses that are fast, clean, reliable, on time, and perhaps most importantly, going directly to my destination. Departure and arrival announcements are available in multiple languages. Signs and directions are easy to follow, even for non-native speakers like me.
I live and work in the Boston area, and like most Americans I rely almost entirely on my automobile to get from one place to the next. Except for an occasional use of the Boston subway system, I use my car to get around because the public transportation infrastructure is too limited to get me to my destination. Since millions of others in Boston and elsewhere are in the same predicament, our highway infrastructure is now well past the point of coping with the traffic volume. I know I'd be appalled if I knew exactly how much of my life I've wasted sitting in traffic jams.
There are some interesting similarities between networked computing systems and transportation systems, the most significant of these being that the success of both depends on scalable infrastructure. Scalable transportation systems comprise not just obvious infrastructure elements, such as trains and rails or airplanes and airports. They also require scheduling, routing, maintenance, ticketing, and monitoring, for example, all of which must scale along with the physical transportation system itself. Similarly, networked computing requires not only host machines and networks the physical computing and communication infrastructure---but also software-based scheduling, routing, dispatching, configuration, versioning, authentication, authorization, and monitoring that allows the networked system to scale as necessary.
An ironic fact about infrastructure is that it's extremely difficult to do well, and yet the more transparent to the user it is, the more successful we consider it to be. Despite the rugged terrain of the Swiss Alps, for example, a few architects, engineers, and builders have applied their expertise to provide an efficient transportation system that millions of people in Switzerland use daily with ease. In fact, the system is so reliable and easy to use that you quickly take it for granted, and it becomes transparent to you. For example, when boarding the Swiss railway your focus is simply on getting from one point to another, not on the machinery used to get you there. Unless you're a tourist, you probably miss the fact that you're traversing a tunnel that took years to design and build, or ascending an incline so steep that the railway includes a cog rail to help the train climb. The rail infrastructure does flawlessly what it's supposed to do, and as a result, you don't even notice it.
This book is about infrastructure software, normally called middleware, for networked computing systems. It's called middleware because it's the "waist in the hourglass" that resides above the operating system and networks, but underneath the application. Middleware comes in a wide variety of shapes, sizes, and capabilities, ranging from J2EE application servers, asynchronous messaging systems, and CORBA ORBs to software that monitors sockets for small embedded systems. Middleware must support an ever-wider variety of applications, operating systems, networking protocols, programming languages, and data formats. Without middleware, taming the ever-increasing diversity and heterogeneity in networked computing systems would be tedious, error prone, and expensive.
Despite the variety of types of middleware, and the variety of issues that middleware addresses, different types of middleware tend to use the same patterns and common abstractions to master complexity. If you were to peek inside a scalable and flexible application server, messaging system, or CORBA ORB, for example, you would likely find that they employ similar techniques for tasks such as connection management, concurrency, synchronization, event demultiplexing, event handler dispatching, error logging, and monitoring. Just as the users of the Swiss railways far outnumber those who designed and built it, the number of users of successful middleware far exceeds the number of people who designed and built it. If you design, build, or use middleware, your success depends on knowing, understanding, and applying these common patterns and abstractions.
While many understand the need for scalability and flexibility in middleware, few can provide it as effectively as the ADAPTIVE Communication Environment (ACE) that Doug Schmidt and Steve Huston describe in this book. ACE is a widely used C++ toolkit that captures common patterns and abstractions used in a variety of highly successful middleware and networked applications. ACE has become the basis for many networked computing systems, ranging from real-time avionics applications to CORBA ORBs to mainframe peer-to-peer communication support.
Like all good middleware, ACE hides the complexity of the diverse and heterogeneous environments beneath it. What sets ACE apart from most other infrastructure middleware, however, is that even though it allows for maximum flexibility wherever needed by the application, it doesn't degrade the performance or scalability of the system. Being a long-time middleware architect myself, I know all too well that achieving both performance and flexibility in the same package is hard.
In a way, though, the flexibility and performance aspects of ACE don't surprise me. Due to my long-time association with Doug, I'm well aware that he is a pioneer in this area. The wide variety of scalable, high performing, and flexible middleware that exists today clearly bears his mark and influence. His teaming with Steve, who's a gifted C++ developer and author whose work on ACE has led to many improvements over the years, has yielded a work that's a "must read" for anyone involved in designing, building, or even using middleware. The increasing pervasiveness of the World Wide Web and of interconnected embedded systems means that the number, scale, and importance of networked computing systems will continue to grow. It's only through understanding the key patterns, techniques, classes, and lessons that Doug and Steve describe in this book that we can hope to supply the middleware infrastructure to make it all transparent, efficient, and reliable.