20.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 pass the path to your configuration file to the graph server (PGX) or perform it
programmatically. This topic explains the different ways to pass the configuration 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 pass the graph server (PGX) configuration JSON file from the local filesystem or from the classpath:
instance.startEngine("path/to/pgx.conf"); // file on local filesystem
instance.startEngine("classpath:/path/to/pgx.conf"); // file on current classpath
For all other protocols, you can directly pass the JSON file as an input stream:
InputStream is = ...
instance.startEngine(is);
Implicitly Using a File
If startEngine()
is called without an argument, then the graph
server (PGX) looks for a configuration file at the following places and stops 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 etc/oracle/graph/conf/pgx.conf
. Changes will be reflected
the next time you invoke the OPG4J shell CLI.
You can also change the location of the configuration file as in the following example:
./bin/opg4j --pgx_conf path/to/my/other/pgx.conf
Setting System Properties
Any graph server (PGX) engine or runtime 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 ...
You can also set nested configuration fields, as used for the enterprise scheduler
configuration using system properties. The <FIELD>
is formed as
<CONFIG_FIELD1>__<CONFIG_FIELD2>
.
Setting Environment Variables
Also, any graph server (PGX) engine or runtime parameter can be set using environment variables by adding 'PGX_' to the graph server (PGX) JVM environment. Note that setting environment variables will overwrite any other configuration. However, if both system property and an environment variable are set for the same parameter, then 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 ...