tailieunhanh - Patterns in JavaTM, Volume 3 Java Enterprise Java Enterprise Design Patterns phần 6

còn sơ khai của phương pháp được gọi là nó tạo ra một kết nối mới. Điều này có thể thêm chi phí đáng kể cho các ứng dụng thực hiện cuộc gọi phương pháp từ xa thường xuyên. Nó có thể là một nút cổ chai giới hạn số lượng khách hàng một máy chủ có thể xử lý đồng thời. Ảo hóa các kết nối loại bỏ hầu hết các nguyên cần thiết cho. | 242 Chapter Six stub s method is called is that it creates a new connection. This can add significant overhead to applications that make frequent remote method calls. It can be a bottleneck that limits the number of clients a server can handle concurrently. Virtualizing the connections eliminates most of the overhead. First we will look at the Multiplexer class. public class Multiplexer private Socket actualsocket The actual connection. private DataOutputStream actualOut actual output stream private DataInputStream actualIn actual input stream private Hashtable socketTable key is connection id private ChunkBufferPool bufferPool ChunkBufferPool objects keep a collection of ChunkBuffer objects that are awaiting reuse. A Multiplexer object asks its ChunkBufferPool object for a ChunkBuffer object when it needs one. If the ChunkBufferPool object has any ChunkBuffer objects in its collection it takes one out of the collection and gives it to the Multiplexer object. If the ChunkBufferPool object does not have any ChunkBuffer objects in its collection then it creates a new one. When a ChunkBuffer object is no longer needed it is returned to the ChunkBufferPool object. This is an application of the Object Pool pattern described in Volume 1. private Queue connectionQueue new Queue When a Multiplexer object receives data associated with a new virtual connection it creates a Socket object and places it in a Queue object. It stays in the Queue until a call to the Multiplexer object s accept method takes it out of the Queue object and passes it to its caller. private ConnectionIDFactory idFactory This Multiplexer implementation delegates the creation of ConnectionID objects to a class called ConnectionIDFactory. private int connectionIDLength Multiplexer objects transmit ConnectionID objects as a sequence of bytes. The Multiplexer object on one end of an actual connection may create ConnectionID objects that are represented as a longer sequence of bytes than the other. This may

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.