Handshaking Info

This document summarizes the handshaking in the database server.
Ops:
- reinitialize
- receive_data
Receives data from:
- isip_comm_server_dialog_navigation_mgr/
Sends data to:
- isip_comm_server_dialog_navigation_mgr/
States:
- WAIT_FOR_QUERY
1) immediately changes to PROCESSING_QUERY state
[Note: This state exists to that the server knows it is not processing anything and is ready to retrieve data to process.]
- PROCESSING_QUERY
1) retrives expected keys from frame
= :db_query :input_string :maxrows :task :access_web
:time_out_duration
2) calls process_query()
a) call do_sql_query() and stores result in global variables
b) create Galaxy frame and pack result into frame
c) return created frame
3) if not enough results and access web is valid
a) change to state PROCESSING_WEB_QUERY
b) call update_tables_from_web()
c) (see below in PROCESSING_WEB_QUERY)
d) change to state PROCESSING_QUERY
e) run step (2) again to see if web returned results
4) change to state WAIT_FOR_QUERY
5) return status code of most recent sql query and return most recent results
- PROCESSING_WEB_QUERY
--- inside update_tables_from_web() ---
1) retrives expected keys from frame
= :task :query_params
2) depending on the value of "task", one of two functions is called.
without loss of generality, let process_web_address_request be called.
--- inside process_web_address_request() ---
3) retrieve values from the :query_params
4) formulate the parameters to the perl script
5) call run_command_and_wait()
--- inside run_command_and_wait() ---
a) change to WAITING_FOR_WEB_RESULT
b) (see below in WAITING_FOR_WEB_RESULT)
c) change to PROCESSING_WEB_QUERY
--- inside process_web_address_request() ---
6) [Note: The perl scripts write out their data to a flatfile in $ISIP_TMPDIR named flatmap_# where # is the unique number passed through the command-line parameters.]
A call is made to the read_and_insert_address_result() function.
--- inside read_and_insert_address_result() ---
a) The flatfile is attempted to be opened
b) the information contained within is inserted into database
--- inside process_web_address_request() ---
7) Additional copies of steps (4-6) may occur
8) return boolean value based on successfulness
--- inside update_tables_from_web() ---
9) return same value as returned in step (8)
[Note: The only data passed out of this function is a single return value. Any knowledge gained is inserted into the database. Therefore another call to the database should return the data inserted.]
- WAITING_FOR_WEB_RESULT
--- inside run_command_and_wait() ---
1) system() command is executed with the perl script + parameters
2) while the two expected files (stored in filenames[]) are not present, loop and sleep two seconds per loop.
[Note: Once the two files are present, exit loop. Since this is a certain size loop, even if the perl script malfunctions or infinite loops, there will be a continuation.]
3) upon exiting loop, control is passed back to PROCESSING_WEB_QUERY (5c)
- GET_PROCESS_ID
Unused
- WAIT_FOR_QUERY_ACK
Unused
Notes:
- This server receives data from the isip_comm_dialog_navigation_mgr if and only if it is state WAIT_FOR_QUERY.
- This server interacts with the perl script directly. It sends data to the perl script through command-line parameters. It receives data from the perl script through a flatfile written in $ISIP_TMPDIR/. This interact is not mediated through the hub at all.
- If this server receives a query from the isip_comm_dialog_navigation_mgr when it is not in WAIT_FOR_QUERY state, an error message is printed and the server remains in the state it currently is in.