home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / inetray / poo < prev    next >
Encoding:
Text File  |  1992-06-26  |  10.7 KB  |  242 lines

  1. ======================================================================
  2.                     P O O 
  3.                     doc: Thu Apr  2 11:59:51 1992
  4.                     dlm: Fri Jun 26 15:32:58 1992
  5.                     (c) 1992 ant@ips.id.ethz.ch
  6.                     uE-Info: 120 0 T 0 0 72 3 2 8 ofnI
  7. ======================================================================
  8.  
  9. This file describes some interna of the inetray-packet. It's name
  10. derives from Principles of Operation.
  11.  
  12. Overview
  13. --------
  14. The program inetray is responsible for dispatching and scheduling the
  15. rayshade requests. In the usual terminology it acts as the client
  16. requesting services from a number of remotely running servers. It does
  17. that using SUN RPC. Rendering requests do not block, therefore inetray also
  18. listens continuously on a socket to check for incoming results. The data
  19. which is received from the workers is written to the file whenever this
  20. is possible.
  21.  
  22. The program rpc.inetrayd serves two purposes: it services a number of
  23. rpc-requests dealing with initialization and management. Whenever it
  24. receives a rendering request, it spawns of a worker child and continues
  25. to service rpc requests (a restricted number).
  26. The worker now renders a part of a frame and then directly contacts the
  27. dispatcher to send it the result. This is done using a XDR/TCP
  28. connection.
  29.  
  30. inetray.start is a simple RPC daemon servicing requests.
  31.  
  32. Authentication & Security
  33. -------------------------
  34. If the servers (rpc.inetrayd) are started as root, they try to change to
  35. the user id supplied to them. This is usually the user id of the user
  36. running the dispatcher (inetray). Any user, however can set a different
  37. user id for servers started by inetray.start. No server can run as root
  38. (uid == 0).
  39. If the uid is illegal on the server it exits with an error message in
  40. the syslog.
  41. No server ever produces an output file. This therefore limits the
  42. security concerns to changing the access time of files. Of course it is
  43. possible that there are loopholes in this concept; I just haven't found
  44. one yet.
  45. If the server is not started as root, it will continue to run under the
  46. uid it was started as. One has to check the permissions of the accessed
  47. files for reading access for that user.
  48. The actual usernames under which the servers are running is diplayed by
  49. both inetray and inetray.ping.
  50.  
  51. Session Keys
  52. ------------
  53. Whenever a started server receives the first request, a session key is
  54. sent with that. Once a sessions key is installed, only requests with the
  55. same key are serviced. In practice this means that only the person who
  56. issued a inetray call can kill the running servers and workers. The key
  57. is stored in the file .inetray.key in the current directory where
  58. inetray was issued. An eventually existing file is renamed to
  59. .inetray.key.old.
  60. inetray displays the current session key on startup.
  61. inetray.ping uses the special key 0. Therefore, if servers hang after a
  62. inetray.ping, they can be killed with inetray.kill 0.
  63. The program inetray.kill needs a session key supplied with. If one is
  64. given as an argument, this takes precedence. If no key is supplied,
  65. inetray.kill looks for one in the file .inetray.key.
  66.  
  67. Pathnames
  68. ---------
  69. Since servers can be running on machines with totally different
  70. filesystems but must access the inputfiles locally, some pathname
  71. substitution is supported.
  72. All filenames are transferred as is to the servers. Therefore, absolute
  73. pathnames must exist on all machines (even the client, where the
  74. inputfile is first processed to check for errors).
  75. From the working directory where the client is started the home-part is
  76. stripped if possible. This stripped directory is then sent to the server
  77. which in turn adds the home directory of the uid it is to run as. Note
  78. that if nothing was stripped on the client-side, then nothing is added
  79. on the server-side. Note also that the right directory is chosen even when
  80. the server cannot run under that user id. The server tries to chdir to
  81. the directory so constructed. If that fails it continues to run in the
  82. current directory.
  83. The working directories of the servers are displayed by both inetray and
  84. inetray.ping.
  85.  
  86. Port Numbers
  87. ------------
  88. The rendered portions of a frame are sent back using a XDR/TCP
  89. connection. The portnumber for this is defined in config.h (RESULTPORT)
  90. but can be overridden for each user in the .inetrayrc file.
  91.  
  92. Registering Servers
  93. -------------------
  94. Whenever inetray or inetray.ping are started, they try to register ready
  95. servers.
  96. First, the servers started by inetray.start are started; the servers
  97. started by inetd are started automatically when an INIT-request arrives. 
  98. The order in which the machines are contacted is the following:
  99.     1: All simple hosts given in the Use List (if any)
  100.     2: All directed broadcasts addresses in the Use List (if any)
  101.     3: The Local Network (if option N=0 is not set in the Use List)
  102. After starting, an INIT-request is sent to all machines. Servers that are
  103. to be started by inetd, are started automatically when they receive an
  104. INIT-request. The same order applies.
  105. Servers reply by opening a TCP-connection on the result-port and sending
  106. back status info.
  107.  
  108. Work Scheduling
  109. ---------------
  110. A frame is divided into blocks encompassing > 1 lines. This is done
  111. according to a simple heuristics the parameters of which can be
  112. controlled by editing config.h and/or overriding those values in a
  113. .inetrayrc file (see INSTALL/Appendix B for details).
  114. After n workers have been registered, the block size is calculated as
  115. follows: blockSize = ySize / blocksPerServer / n. After that, the size
  116. is checked against the lower and upper limit (MINBLOCKSIZE resp.
  117. MAXBLOCKSIZE). If it exceeds a limit, it is adjusted accordingly. After
  118. that, the size of the last, possibly incomplete, block is calculated and
  119. the information printed.
  120.  
  121. In early versions (up to [0.2.0]), a simple round robin scheduling has
  122. been used: subseqent machines got subsequent blocks to trace; whenever
  123. the end of a frame was reached, the whole process started over with only
  124. the non-terminated blocks.
  125. This could lead to quite bad behaviour in the end. Consider for example
  126. the example file mole.ray. Early blocks (bottom half) take much longer
  127. to trace than later ones. If now one machine is heavily loaded, it won't
  128. ever complete its block. This means that there will one early block be
  129. outstanding for a very long time wich will inhibit concurrent writing.
  130. Furthermore, with a little bit of bad luck, this block will be the last
  131. one outstanding which will mean that a lot of machines will calculate
  132. just one block in the end. This block will take a long time to
  133. calculate.
  134. Starting with version [0.2.1] there is a rescheduling inserted in the
  135. middle of a frame. The number of machines which did not yet return a
  136. result is counted and the first n blocks (n being the number of those
  137. machines) not yet calculated are given priority over other blocks. These
  138. blocks are exactly those residing on those slow machines. Hopefully,
  139. these are distributed to faster machines like this.
  140. I my setting, this modification lead to quite a decrease in time needed
  141. to complete the last block.
  142. Notes: - The scheme presented here also works nicely if workers crash
  143.      during the first half of a frame (which they seem to tend to
  144.      do).
  145.  
  146. Concurrent Servers & RPC Program Numbers
  147. ----------------------------------------
  148. It is possible for one machine to have more than one server (and worker)
  149. running at a time. This feature is implemented to allow multiprocessor
  150. machines to have as many workers as processors running. A machine
  151. starting more than one worker cannot start it using inetd. Concurrent
  152. servers have different RPC Program Numbers. The first server gets the
  153. program number IRNUM defined in prognum.h. Subsequent servers get
  154. subsequent program numbers.
  155. Like that, registering with the portmapper works correctly. It must be
  156. noted, though, that all broadcasts to servers now must be broadcast for
  157. all program numbers.
  158.  
  159. Error Logging
  160. -------------
  161. All daemons (rpc.inetrayd and inetray.start) log their errors using
  162. syslog-calls, unless NOASYNCIO_QUIRK has been set during compilation, in
  163. that case, errors are written to a temp-file (see SUPPORT for details).
  164. If error are logged with the syslogd, the use the LOG_ERR level of the
  165. daemon facility. 
  166. Additionally, rpc.inetrayd logs some info on LOG_NOTICE level.
  167. Please note that also all errors produced by the rayshade routines are
  168. logged. This is done using a funny redirection of the stderr to the
  169. syslog using socketpairs and async IO. For this to work under AUX I had
  170. to implement the socketpair() syscall there, since the one built in does
  171. not work (at least in our version).
  172.  
  173. Error Termination
  174. -----------------
  175. Roughly once every minute, every server checks if the dispatcher is
  176. still running. If that's not the case, it kills it's associated worker
  177. if it has one and then exits with an entry in the syslog.
  178.  
  179. rpc.inetrayd startup
  180. --------------------
  181. The server can be started up by inetd or inetray.start (or, for
  182. debugging purposes, by hand). It checks its number of arguments to
  183. decide how it was started up. If it is called without any arguments, it
  184. assumes that it is started by inetd. Therefore you have to supply the
  185. necessary arguments if you want to start it by hand. It requires two
  186. arguments a worker id and a user id. The first server always gets id 0.
  187. The effects of the userid are described above.
  188. Before accepting RPC requests, the server redirects its own stderr to
  189. the syslog using a socketpair and asyncronous IO (unless NOASYNCIO_QUIRK
  190. was set during compilation).
  191.  
  192. rpc.inetrayd requests
  193. ---------------------
  194. The parameter and result definitions are defined in inetray.x
  195.  
  196. INIT:        - exit if already active
  197.             - set session key
  198.             - set user id
  199.             - chdir to appropriate dir
  200.             - set flag to perform raytrace init when TRACEBLOCK is called
  201.               for the first time
  202.             - setup result socket and send back status info
  203.         - DOES NOT RETURN ANYTHING
  204.     
  205. STARTFRAME:    - exit if not initialized
  206.         - check session key
  207.         - get old worker status (clean process table)
  208.         - set flag to perform RSStartFrame when TRACEBLOCK is
  209.           called for the first time (deferred StartFrame) if
  210.           it's the first STARTFRAME in this session. If not,
  211.           then do RSStartFrame immediately.
  212.         - return
  213.  
  214. TRACEBLOCK:    - exit if not initialized
  215.         - check session key
  216.         - get old worker status (clean proc tab)
  217.         - execute deferred init & startFrame if applicable
  218.         - fork new worker:
  219.             worker:    - set nicevalue
  220.                 - Raytrace one block
  221.                 - send back result
  222.                 - exit
  223.             server: - return
  224.  
  225. KILL:        - exit if not initialized
  226.             - check key
  227.             - kill started worker if exists
  228.         - return
  229.  
  230. WAIT:        - exit if not initialized
  231.             - check key
  232.             - wait for worker (get status)
  233.         - return
  234.  
  235. TERMINATE:    - check key
  236.         - KILL
  237.         - WAIT
  238.         - clean up
  239.         - exit
  240.         - DOES NOT RETURN ANYTHING
  241.         
  242.