11.1.2 Passing the Configuration File to the Graph Server (PGX)
The PGX engine configuration file is parsed by the graph server at startup-time
whenever ServerInstance#startEngine
(or any of its variants) is called.
You can write the path to your configuration file to the graph server (PGX) or perform
it programmatically. This topic explains the different ways to pass the PGX engine file
to the graph server (PGX):
Programmatically
All configuration fields exist as Java enums. Example:
Map<PgxConfig.Field, Object> pgxCfg = new HashMap<>(); pgxCfg.put(PgxConfig.Field.MEMORY_CLEANUP_INTERVAL, 600); ServerInstance instance = ... instance.startEngine(pgxCfg);
All parameters not explicitly set will get default values.
Explicitly Using a File
Instead of a map, you can write the path to a PGX configuration JSON file. Example:
instance.startEngine("path/to/pgx.conf"); // file on local file system instance.startEngine("classpath:/path/to/pgx.conf"); // file on current classpath
For all other protocols, you can write directly in the input stream to a JSON file. Example:
InputStream is = ... instance.startEngine(is);
Implicitly Using a File
If startEngine()
is called without an argument, the graph server
(PGX) looks for a configuration file at the following places, stopping when it finds
the file:
-
File path found in the Java system property
pgx_conf
. Example:java -Dpgx_conf=conf/my.pgx.config.json ...
-
A file named
pgx.conf
in the root directory of the current classpath -
A file named
pgx.conf
in the root directory relative to the currentSystem.getProperty("user.dir")
directory
Note: Providing a configuration is optional. A default value for each field will be used if the field cannot be found in the given configuration file, or if no configuration file is provided.
Using the Shell in Embedded Mode
To change how the shell configures the embedded (local) graph server (PGX) instance,
edit $PGX_HOME/conf/pgx.conf
. Changes will be reflected the
next time you invoke $PGX_HOME/bin/pgx
.
You can also change the location of the configuration file as in the following example:
./bin/opg --pgx_conf path/to/my/other/pgx.conf
Setting System Properties
Any parameter can be set using Java system properties by writing
-Dpgx.<FIELD>=<VALUE>
arguments to the
JVM that the graph server (PGX) is running on. Note that setting system properties
will overwrite any other configuration. The following example sets the maximum
off-heap size to 256 GB, regardless of what any other configuration says:
java -Dpgx.max_off_heap_size=256000 ...
Setting Environment Variables
Any parameter can also be set using environment variables by adding 'PGX_' to the environment variable for the JVM in which the graph server (PGX) is executed. Note that setting environment variables will overwrite any other configuration; but if a system property and an environment variable are set for the same parameter, the system property value is used. The following example sets the maximum off-heap size to 256 GB using an environment variable:
PGX_MAX_OFF_HEAP_SIZE=256000 java ...