ex_rq.so
来自「berkeley db 4.6.21的源码。berkeley db是一个简单的数」· SO 代码 · 共 59 行
SO
59 行
m4_comment([$Id: ex_rq.so,v 1.7 2006/08/24 18:01:51 bostic Exp $])m4_ref_title(m4_db Replication, Ex_rep_base: putting it all together,, rep/ex_comm, xa/intro)m4_p([dnlBeyond simply initializing a replicated environment, an applicationthat uses the Base replication API must set up its communicationinfrastructure, and then make sure that incoming messages are receivedand processed.])m4_p([dnlTo initialize replication, ex_rep_base creates a m4_db environment andcalls m4_ref(rep_set_transport) to establish a send function. (Seethe main function in m4_path(ex_rep/base/rep_base.c), including itscalls to the create_env and env_init functions inm4_path(ex_rep/common/rep_common.c).)])m4_p([dnlex_rep_base opens a listening socket for incoming connections and opensan outgoing connection to every machine that it knows about (that is,all the sites listed in the m4_option(o) command line argument).Applications can structure the details of this in different ways, butex_rep_base creates a user-level thread to listen on its socket, plusa thread to loop and handle messages on each socket, in addition to thethreads needed to manage the user interface, update the database on themaster, and read from the database on the client (in other words, inaddition to the normal functionality of any database application).])m4_p([dnlOnce the initial threads have all been started and the communicationsinfrastructure is initialized, the application signals that it is readyfor replication and joins a replication group by callingm4_ref(rep_start). (Again, see the main function inm4_path(ex_rep/base/rep_base.c).)])m4_p([dnlNote the use of the optional second argument to m4_ref(rep_start) inthe client initialization code. The argument "local" is a piece ofdata, opaque to m4_db, that will be broadcast to each member of areplication group; it allows new clients to join a replication group,without knowing the location of all its members; the new client willbe contacted by the members it does not know about, who will receivethe new client's contact information that was specified in "myaddr."See m4_link(M4RELDIR/ref/rep/newsite, Connecting to a new site) for moreinformation.])m4_p([dnlThe final piece of a replicated application is the code that loops,receives, and processes messages from a given remote environment.ex_rep_base runs one of these loops in a parallel thread for eachsocket connection (see the hm_loop function inm4_path(ex_rep/base/rep_msg.c)). Other applications may want to queuemessages somehow and process them asynchronously, or select() on anumber of sockets and either look up the correct environment ID for eachor encapsulate the ID in the communications protocol.])m4_page_footer
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?