Distributed Mode

The report engine can be started as a daemon to which report applications can connect to process reports. One or more engines can be started on the same machine or on a different machine, hence distributed mode.

Distributed mode offers two advantages:
  1. Vastly faster processing for short documents: The startup time of the JVM that is incurred for every report in regular mode can exceed the processing time of the report causing the overall performance to be poor. In distributed mode, the JVM is started and initialized only once. For report batches the improvement in performance is dramatic (A test has shown an increase by factor 24 so that a 500 file PDF batch completed in 17 seconds rather then in 7 minutes).
  2. Improved scalability: Formatting graphical reports is CPU intensive. However CPU is usually expensive on the server optimized for IO that is running the DVM and/or the database. The distributed mode allows offloading the report processing entirely to another, very much cheaper, machine such as a standard PC. Such a dedicated report formatting PC could be installed with Windows™ which has the additional advantage of handling fonts and printers in a user friendlier way.
To take advantage of distributed mode, you need to do the following:
  1. Place your report design documents (.4rp) on the server where the GRE daemon runs.
  2. Start the GRE daemon.
  3. Provide the remote connection details in your source code.

Place the report design documents (.4rp) on the daemon server

Your report design documents need to be on the server running the daemon.

Start the Genero Report Engine daemon

The daemon is invoked by calling the script $GREDIR/bin/greportwriter with the “–l” option and specifying the port it listens on. For example:

C:\Program Files\FourJs\Genero Studio\fgl>envcomp
C:\Program Files\FourJs\Genero Studio\fgl>cd ..\gre\bin
C:\Program Files\FourJs\Genero Studio\gre\bin>greportwriter –l 6500

If the Genero Report Engine daemon resides on a different machine than the DVM, you must start the daemon with the -l portname option. The -l option listens on the specified port and for each connection attempts to read an XML document from the socket. For example:

C:\Program Files\FourJs\Genero Studio\gre\bin>greportwriter –l 6500 

If the Genero Report Engine daemon resides on the same machine as the DVM, or if you are using SSH port forwarding, you can optionally use the -o option. The -o option provides extra security by ensuring that the daemon accepts incoming connections only if they are local. It must be used in conjunction with the -l option, for example:

C:\Program Files\FourJs\Genero Studio\gre\bin>greportwriter –l 5900 -o

Connect to a daemon using the reporting API

The API function fgl_report_configureDistributedProcessing is used to select and configure distributed processing. It takes two parameters that denote the server to use; a host name and a port. This code shows an example for a GRE daemon running on the local machine (host “localhost”):
IF NOT fgl_report_loadCurrentSettings("OrderReport.4rp") THEN   
  ...
END IF
...
CALL fgl_report_configureDistributedProcessing("localhost",6500)
RETURN fgl_report_commitCurrentSettings()
This example connects to a daemon running on the server “PrintServer”:
IF NOT fgl_report_loadCurrentSettings("OrderReport.4rp") THEN   
  ...
END IF
...
CALL fgl_report_configureDistributedProcessing("PrintServer",6500)
RETURN fgl_report_commitCurrentSettings()

Logging in distributed mode

If the GREDEBUG environment variable is set, the daemon logs messages of the specified level to the file gre.log in the home directory of the user invoking the daemon.

The API function fgl_report_setDistributedRequestingUserName can be used to set a user name in the log file in order to distinguish between log entries originating from different users. See fgl_report_setDistributedRequestingUserName.

Previewing reports in distributed mode

Important: The following instructions are not necessary if the GRE and the DVM are running on the same physical machine.
To preview a report when the GRE daemon is running on a different machine than the DVM and the output type is either "PDF", "RTF", "XLS", "XLX" or "HTML" (as specified by the fgl_report_selectDevice function), you must do two things:
  1. Start the Web server service by invoking the command grehttpd.
    Located at GREDIR/bin/grehttpd, the following options are available:
    • -p port, where port is the port number. The default port is 8080.
    • -q activates the Web server service in quiet mode.
    • -d directory, where directory specifies the Web root. There may be several. If notihing is specified, then the current working directory (".") is taken as the Web root.
    • -license prints the NanoHTTPD license
    Note: The Genero Report Engine ships with this minimal Web server, however any other web server capable of serving static files can be used.
  2. Set the GREOUTPUTDIR environment variable to the specified Web root directory in the environment of the GRE daemon (greportwriter -l).