3 This directory provides a number of network services that utilize the
8 . Logging_Strategy -- Controls the output of all services that are
9 invoked along with the Logging_Strategy service. Please see below for
10 details on how to control the output.
12 . [Thr_]Server_Logging_Handler.* -- Implements server portion
13 of the ACE distributed logging service. Both multi-threaded
14 and single-threaded implementations are provided.
16 . Client_Logging_Handler.* -- Implements the client portion
17 of the ACE distributed logging service.
19 . Name_Handler.* -- Implements a distributed name service that
20 allows applications to bind, find, and unbind names in
23 . Token_Handler.* -- Implements a distributed token
24 service that allows applications to acquire and release
25 locks in a distributed system.
27 . Time_Handler.* -- Implements a distributed time service that
28 allows distributed applications to synchronize their
31 The remainder of this README file explains how these services work.
33 ==================== Logging_Strategy Service ====================
34 The Logging_Strategy Service can be used to control the output of all the
35 network services. It can be invoked with certain flags that determine
36 where the output of all the services should go.
38 The Logging_Strategy Service sets the flags in ACE_Log_Msg which in turn
39 controls all the streams through macros such as ACE_DEBUG, ACE_ERROR,
42 If default behavior is required, the Logging_Strategy Service need not be
43 invoked or it can be invoked with no paramaters. Here are the command
44 line arguments that can be given to the Logging_Strategy Service:
47 -f <flag1>|<flag2>|<flag3> (etc...)
49 where a flag can be any of the following:
51 STDERR -- Write messages to stderr.
52 LOGGER -- Write messages to the local client logger deamon.
53 OSTREAM -- Write messages to the ostream that gets created by
54 specifying a filename (see below)
55 VERBOSE -- Display messages in a verbose manner
56 SILENT -- Do not print messages at all
58 Note: If more than one flag is specified, the flags need to be 'OR'ed
59 as above syntax shows. Make sure there is no space in between the flag
64 If the OSTREAM flag is set, this can be used to specify the
65 filename where the output should be directed. Note that if the OSTREAM
66 flag is set and no filename is specified, ACE_DEFAULT_LOGFILE will be
67 used to write the output to.
71 To direct output only to STDERR, specify command line arguments as:
74 To direct output to both STDERR and a file called "mylog", specify
75 command line arguments as:
76 "-f STDERR|OSTREAM -s mylog"
78 ==================== Name Service ====================
80 This file describes the principles of the Name_Server server test
83 1. Startup configuration
86 To communicate with the server process, a client needs to know the
87 INET_Addr, where the server offers its service. Class Name_Options
88 holds all the configuration information of the Name Service. This
91 - nameserver_port : Port number where the server process expects requests
92 - nameserver_host : hostname where the server process resides
93 - namespace_dir : directory that holds the NameBinding databases
94 - process_name : name of the client process (argv[0]), NameBindings of
95 a ProcessLocal namespace are stored in file
96 "namespace_dir/process_name". NameBindings of NodeGlobal
97 namespace are stored in "namespace_dir/localnames".
98 NameBindings of Net_Local namespace are stored in file
99 "namespace_dir/globalnames" on the server host.
100 These configuration parameters are passed to the process as commandline
104 -l namespace directory
106 The main program _must_ initialize an instance of Name_Options with name
107 name_options (since the shared libraries depend on this). Main should
110 #include "ace/Name_Options.h"
112 Name_Options name_options;
114 int main(int argc, char **argv)
116 name_options.process_name(argv[0]);
117 name_options.parse_args (argc, argv);
121 See the examples in the tests subdirectory of
122 ...Name_Server/Client-Server/client and
123 ...Name_Server/Client-Server/server
126 2. Class Naming_Context
129 This is the main workhorse of the Name Service. It is used by client
130 processes as well as by the server process. It manages all accesses to
131 the appropriate NameBinding database (that is the file where
132 NameBindings are stored) and it also manages the communication between
133 a client process and the server (by using class Name_Proxy, which is a
134 private member of Naming_Context). (Note: no IPC is necessary, if a
135 client process runs on the same host as the server).
137 The strategy for all public methods of Naming_Context is common :
139 1. Transform the format of the arguments to ACE_SString (which is
140 internally used) if necessary.
142 2. check if work can be done locally : -> call the appropriate local_* method
143 otherwise call the appropriate global_* method.
145 Removing Name_Bindings from the database (either with unbind or
146 rebind) uses the ACE_Malloc class configured with the
147 ACE_MMAP_Memory_Pool. This allows memory to be reclaimed when
148 name/value tuples are unbound.
153 The Name_Server registers in its run method its Name_Acceptor
154 (instantiated with the INET_Addr) at the Reactor, to receive incoming
157 4. Class Name_Acceptor
160 The Name_Acceptor allocates in its handle_input routine a new instance
161 of class Name_Handler on the heap, and accepts connections into this
164 5. Class Name_Handler
167 The Name_Handler represents the server side of communication between
168 client and server. It interprets incoming requests to the Net_Local
169 namespace and dele- gates the requests to its own Naming_Context
170 (which is the Net_Local namespace on the current host). For
171 communication it uses the helper classes Name_Request (which up to now
172 needs not only contain the request from the client, but also the
173 appropriate reply from the server) and Name_Reply. Note that I want
174 to change the usage of these classes to make the structure of the
180 As the Name service must be able to handle wide character strings, it
181 uses ACE_WString String classes.
184 ==================== Time Service ====================
186 The following is a description of the Time Server clerk and server
189 1. Startup configuration
190 ---------------------
192 Configuring a server requires specifying the port number of the
193 server. This can be specified as a command line argument as follows:
197 A clerk communicates with one or more server processes. To communicate
198 with the server process, a client needs to know the INET_Addr, where
199 the server offers its service. The configuration parameters namely the
200 server port and server host are passed as command line arguments when
201 starting up the clerk service as follows:
203 -h <server host1>:<server port1> -h <server host2>:<server port2> ...
205 Note that multiple servers can be specified in this manner for the
206 clerk to connect to when it starts up. The server name and the port
207 number need to be concatenated and separated by a ":". In addition,
208 the timeout value can also be specified as a command line argument as
213 The timeout value specifies the time interval at which the clerk
214 should query the servers for time updates.
216 By default a Clerk does a non-blocking connect to a server. This can
217 be overridden and a Clerk can be made to do a blocking connect by
220 Here is what a config file would look like for starting up a server at
223 dynamic Time_Service Service_Object * ../lib/netsvcs:_make_ACE_TS_Server_Acceptor() "-p 20202"
225 Here is what a config file would look like for starting up a clerk
226 that needs to connect to two servers, one at tango and one at lambada:
228 dynamic Time_Server_test Service_Object *../lib/netsvcs:_make_ACE_TS_Clerk_Processor () "-h tango:20202 -h lambada:20202 -t 4"
230 2. Class TS_Server_Handler
231 -----------------------
233 TS_Server_Handler represents the server side of communication between
234 clerk and server. It interprets incoming requests for time updates,
235 gets the system time, creates a reply in response to the request and
236 then sends the reply to the clerk from which it received the request.
237 For communication it uses the helper class Time_Request.
239 3. Class TS_Server_Acceptor
240 ------------------------
242 TS_Server_Acceptor allocates in its handle_input routine a new instance
243 of class TS_Server_Handler on the heap, and accepts connections into this
246 4. Class TS_Clerk_Handler
247 ----------------------
249 TS_Clerk_Handler represents the clerk side of communication between
250 clerk and server. It generates requests for time updates every timeout
251 period and then sends these requests to all the servers it is
252 connected to asynchronously. It receives the replies to these requests
253 from the servers through its handle_input method and then adjusts the
254 time using the roundtrip estimate. It caches this time which is later
255 retrieved by TS_Clerk_Processor.
257 5. Class TS_Clerk_Processor
258 ------------------------
260 TS_Clerk_Processor creates a new instance of TS_Clerk_Handler for
261 every server connection it needs to create. It periodically calls
262 send_request() of every TS_Clerk_Handler to send a request for time
263 update to all the servers. In the process, it retrieves the latest
264 time cached by each TS_Clerk_Handler and then uses it to compute its
265 notion of the local system time.
270 Currently, updating the system time involves taking the average of all
271 the times received from the servers.