| 

Back


Re-launch Avoidance (JRAC) (version beta 1.0)

When a user in the GenomeSpace UI clicks a tool icon to launch it, and doesn't close the tool, and then later clicks the tool icon again, the tool should re-open the existing instance, and not start a second instance.

The way GenomeSpace and the tool coordinate to handle this is:

  • When the tool starts up, it open a socket on a predefined port number, and listens for an HTTP GET request.
  • When the user clicks a tool icon, the GenomeSpace UI (or another GenomeSpace tool capable of doing launches) will send a HTTP GET request to that tool's predefined port.
  • If the user does a launch on file, then the GenomeSpace UI passes the filename as a query parameter on the HTTP GET url.

These CDK classes implement and test an example of JRAC relaunch:

  • SimpleWebServer opens the server socket demon.
  • GSLoadEventListener is an Observer class that gets called when a GET request arrives.
  • GSLoadEvent is a data class that contains query params from the GET.
  • SimpleWebServerTest is JUnit test code containing the relevant pieces.


Port numbers

Port are pre-defined in GenomeSpace database and can be hardcoded in the GenomeSpace tool for use when it starts its socket listener.  The predefined port numbers neither depend on the local machine nor are configurable after the initial selection.  Port numbers currently used are:

  • 60151 (IGV)
  • 60161 (Cytoscape)
  • 60171 (Genomica)
  • 60181 (geWorkbench)

A tool should not respond to HTTP GET requests on port belonging to another tool.

Relaunch URL

The GenomeSpace UI (or another GenomeSpace tool capable of doing launches) creates a url for the HTTP GET request in the form

http://localhost:<relaunchPort>/<relaunchCommand>?<relaunchQueryParams>

<relaunchCommand> possibilities are

  • load when the tool should load file
  • echo indicating there is no file to open
  • null (i.e. <relaunchCommand> is not present in the url) also indicating there is no file to open

<relaunchQueryParams> possibilities are

  • load_file=<filename> where <filename> is a GenomeSpace filename url. If the filename url contains a file conversion query parameter.
  • callback=<javascript code> for relaunching browser based tools by passing the appropriate javascript to it.  Non browser-based tools should ignore.


For GenomeSpace Tools that need to launch other tools

These are the steps that the tool's code should perform, in order to do the launch:

  1. Get the target tool's reloadPort using a REST or CDK call to GenomeSpace ATM.
  2. If target tool's "reloadPort" is defined continue with step 3.  If missing or not defined continue with step 6.
  3. Create a relaunch url and send a HTTP GET request to it.
  4. Wait 2 seconds for reply.
  5. If a reply is received, done.
  6. If no reply, or if "reloadPort" was not defined, launch tool as usual (open browser on target tool's launch url).