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:
PgxFuture<PgxSession> createSessionAsync(String source)
PgxFuture<PgxSession> createSessionAsync(String source, long idleTimeout, long taskTimeout, TimeUnit unit)
PGX offers blocking convenience wrappers around the preceding methods:
Creating a Session Using Java
PgxSession createSession(String source)
PgxSession createSession(String source, long idleTimeout, long taskTimeout, TimeUnit unit)
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 informtion on graph server (PGX) configuration options.
Creating a Session Using Python
import pypgx
session = pypgx.get_session()
Destroying Sessions
To destroy a session, simply call:
session.destroyAsync();
Destroying a Session Using Java
session.destroy();
Destroying a Session Using Python
session.destroy()
Administrators can destroy sessions by ID using the following code:
PgxFuture<Void> promise = instance.killSessionAsync(sessionId);
instance.killSession(sessionId); // blocking version
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 informtion on graph server (PGX) configuration options.
Parent topic: PGX Programming Guides