12.1.2 Specifying the Configuration File to the In-Memory Graph Server (PGX)
The in-memory graph server configuration file is parsed by the in-memory 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 in-memory graph server or specify it programmatically. This topic identifies several ways to specify the file
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 an in-memory graph server 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 in-memory 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) in-memory 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 in-memory 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 in-memory 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 ...