📄 ex_comm.so
字号:
m4_comment([$Id: ex_comm.so,v 1.9 2006/08/24 17:59:56 bostic Exp $])m4_ref_title(m4_db Replication, Ex_rep_base: a TCP/IP based communication infrastructure,, rep/ex, rep/ex_rq)m4_p([dnlApplications which use the Base replication API must implement acommunication infrastructure. The communication infrastructureconsists of three parts: a way to map environment IDs to particularsites, the functions to get and receive messages, and the applicationarchitecture that supports the particular communication infrastructureused (for example, individual threads per communicating site, a sharedmessage handler for all sites, a hybrid solution). The communicationinfrastructure for ex_rep_base is implemented in the filem4_path(ex_rep/base/rep_net.c), and each part of that infrastructureis described as follows.])m4_p([dnlEx_rep_base maintains a table of environment ID to TCP/IP portmappings. A pointer to this table is stored in a structure pointed toby the app_private field of the m4_ref(DbEnv) object so it can beaccessed by any function that has the database environment handle.The table is represented by a machtab_t structure which contains areference to a linked list of member_t's, both of which are defined inm4_path(ex_rep/base/rep_net.c). Each member_t contains the host andport identification, the environment ID, and a file descriptor.])m4_p([dnlThis design is particular to this application and communicationinfrastructure, but provides an indication of the sort of functionalitythat is needed to maintain the application-specific state for aTCP/IP-based infrastructure. The goal of the table and its interfacesis threefold: First, it must guarantee that given an environment ID,the send function can send a message to the appropriate place. Second,when given the special environment ID m4_ref(DB_EID_BROADCAST), the sendfunction can send messages to all the machines in the group. Third,upon receipt of an incoming message, the receive function can correctlyidentify the sender and pass the appropriate environment ID to them4_ref(rep_message) method.])m4_p([dnlMapping a particular environment ID to a specific port is accomplishedby looping through the linked list until the desired environment ID isfound. Broadcast communication is implemented by looping through thelinked list and sending to each member found. Since each portcommunicates with only a single other environment, receipt of a messageon a particular port precisely identifies the sender.])m4_p([dnlThis is implemented in the quote_send, quote_send_broadcast andquote_send_one functions, which can be found inm4_path(ex_rep/base/rep_net.c).])m4_p([dnlThe example provided is merely one way to satisfy these requirements,and there are alternative implementations as well. For instance,instead of associating separate socket connections with each remoteenvironment, an application might instead label each message with asender identifier; instead of looping through a table and sending acopy of a message to each member of the replication group, theapplication could send a single message using a broadcast protocol.])m4_p([dnlThe quote_send function is passed as the callback tom4_ref(rep_set_transport); m4_db automatically sends messages as neededfor replication. The receive function is a mirror to the quote_send_onefunction. It is not a callback function (the application is responsiblefor collecting messages and calling m4_ref(rep_message) on them as isconvenient). In the sample application, all messages transmitted arem4_db messages that get handled by m4_ref(rep_message), however, thisis not always going to be the case. The application may want to passits own messages across the same channels, distinguish between its ownmessages and those of m4_db, and then pass only the m4_db ones tom4_ref(rep_message).])m4_p([dnlThe final component of the communication infrastructure is the processmodel used to communicate with all the sites in the replication group.Each site creates a thread of control that listens on its designatedsocket (as specified by the m4_option(m) command line argument) andthen creates a new channel for each site that contacts it. In addition,each site explicitly connects to the sites specified in them4_option(o) command line argument. This is a fairly standard TCP/IPprocess architecture and is implemented by the following functions (allin m4_path(ex_rep/base/rep_net.c)).])m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -