12.3 Publishing a Preloaded Graph
The publishing behavior for preloaded graphs can be controlled in the configuration. Unless a different behavior is configured, (only) the first loaded snapshot of a graph is published. Preloaded published graphs remain in memory even if they are not used by any session.
There are two options to control the publishing behavior:
- Set the optional flag
publish
totrue
, to publish only the graph but no future snapshots of the graph. This is the default behavior as the default value of this flag istrue
. - Set the optional flag
publish_with_snapshots
totrue
, to publish the graph and all future snapshots of the graph. The default value isfalse
.
Only one of these two flags can be set to true
at a time. However, publishing the graph with snapshots does also publish the first version of the graph.
Example 12-1 Sample Configuration File for Preloading Graphs
This example pgx.conf
specifies two graphs for loading into memory during the graph server (PGX) startup-time. my-graph
is published with snapshots while my-other-graph
is published without snapshots.
{
"enterprise_scheduler_config": {
"analysis_task_config": {
"max_threads": 32
}
},
"preload_graphs": [
{
"path": "graph-configs/my-graph.bin.json",
"name": "my-graph",
"publish": false,
"publish_with_snapshots": true
},
{
"path": "graph-configs/my-other-graph.adj.json",
"name": "my-other-graph"
}
],
"authorization": [{
"pgx_role": "GRAPH_DEVELOPER",
"pgx_permissions": [{
"preloaded_graph": "my-graph",
"grant": "read"
},
{
"preloaded_graph": "my-other-graph",
"grant": "read"
}]
},
....
]
}
The two preloaded graphs can be accessed as follows:
PgxGraph g1 = session.getGraph("my-graph"); //returns the most recent available snapshot
PgxGraph g2 = session.getGraph("my-other-graph");
Parent topic: Graphs Management