14.4 Graph Client Sessions

The graph server (PGX) assumes there may be multiple concurrent clients, and each client submits request to the shared PGX server independently.

Each session has its own workspace in PGX and is isolated from other sessions.

You can share graphs or properties among sessions.

Creating Sessions

The following methods in the ServerInstance class are used to create sessions:

PgxSession createSession(String source)
PgxSession createSession(String source, long idleTimeout, long taskTimeout, TimeUnit unit)
The preceding methods accept the following arguments:
  • source is any arbitrary string that describes the client. Currently, this string is only used for logging purposes.
  • The user can specify the idle timeout (idleTimeout) and task timeout (taskTimeout) when creating a new session. If these values are not specified, default values are used.

    See Configuration Parameters for the Graph Server (PGX) Engine for more information on graph server (PGX) configuration options.

import pypgx
session = pypgx.get_session()

Destroying Sessions

To destroy a session, simply call:

session.destroyAsync();
session.destroy();
session.destroy()

Administrators can destroy sessions by ID using the following code:

instance.killSession(sessionId);

Note:

Calling administrative methods by default requires special authorization in client/server mode.

When a session is destroyed, PGX reclaims all of the resources associated with the session. Specifically, all transient data is destroyed immediately. See Managing Transient Data for more information on transient data.

However, PGX may choose to keep the loaded graph instance in memory for caching purposes, especially if a graph instance is shared by multiple clients. In summary, every graph remains in memory until no client is using it.

Note:

A session can be destroyed automatically via the session time-out mechanism. See Configuration Parameters for the Graph Server (PGX) Engine for more information on graph server (PGX) configuration options.