PGX 20.1.1
Documentation

Admin API

This chapter shows how to use PGX Admin API to inspect the server state including sessions, graphs, tasks, memory and thread pools.

Get a Server Instance

The following code gets a pgx Instance which can be local(the code below) or remote.

import oracle.pgx.api.*;

ServerInstance instance = Pgx.getInstance(Pgx.EMBEDDED_URL);

Get Inspection Data

Inspection data is information about the server state. The following code shows how to return it.

JsonNode serverState = instance.getServerState();

This returns a JsonNode which contains all administration information(how many graphs are loaded? how many sessions? memory usage for graphs and properties, ...)

{
    "cached_graphs": [],
    "published_graphs": [],
    "sessions": [],
    "tasks": [],
    "pools": [],
    "memory": {}
}

Sessions

serverState.get("sessions") returns an array of current active sessions. Each entry contains information about a session.

     {
            "session_id": "530b5f9a-75c4-4838-9cc3-44df44b035c5",
            "source": "testServerState",
            "task_timeout_ms": 0,
            "idle_timeout_ms": 0,
            "alive_ms": 237,
            "total_analysis_time_ms": 115,
            "state": "RELEASED",
            "private_graphs": [
                {
                    "name": "anonymous_graph_1",
                    "creation_timestamp": 1589317879755,
                    "memory": {
                        "topology_bytes": 46,
                        "key_mapping_bytes": 30,
                        "persistent_property_mem_bytes": 0,
                        "transient_property_mem_bytes": 0
                    },
                    "vertices_num": 1,
                    "edges_num": 0,
                    "persistent_vertex_properties": [],
                    "persistent_edge_properties": [],
                    "transient_vertex_properties": [],
                    "transient_edge_properties": []
                }
            ],
            "published_graphs": [
                {
                    "name": "multigraph",
                    "creation_timestamp": 1589317879593,
                    "memory": {
                        "topology_bytes": 110,
                        "key_mapping_bytes": 56,
                        "persistent_property_mem_bytes": 64,
                        "transient_property_mem_bytes": 0
                    },
                    "vertices_num": 2,
                    "edges_num": 6,
                    "persistent_vertex_properties": [
                        {
                            "loaded": true,
                            "mem_size_bytes": 16,
                            "name": "tProp",
                            "type": "string"
                        }
                    ],
                    "persistent_edge_properties": [
                        {
                            "loaded": true,
                            "mem_size_bytes": 48,
                            "name": "cost",
                            "type": "double"
                        }
                    ],
                    "transient_vertex_properties": [],
                    "transient_edge_properties": []
                }
             ]
        }

The private_graphs field contains session bound graphs. published_graphs lists published graphs that the session has pointer to.

Cached Graphs

The server state contains also cached graph information serverState.get("cached_graphs") which returns a collection of graphs cached in memory. Each entry contains information about a graph

{
            "name": "sf-1589317879394",
            "creation_timestamp": 1589317879394,
            "vertex_properties": [
                {
                    "loaded": true,
                    "mem_size_bytes": 478504,
                    "name": "prop1",
                    "type": "double"
                }
            ],
            "edge_properties": [
                {
                    "loaded": true,
                    "mem_size_bytes": 1197720,
                    "name": "cost",
                    "type": "double"
                },
                {
                    "loaded": true,
                    "mem_size_bytes": 598860,
                    "name": "0",
                    "type": "integer"
                }
            ],
            "memory": {
                "topology_bytes": 3921814,
                "key_mapping_bytes": 1407466,
                "property_mem_bytes": 2275084
            },
            "vertices_num": 59813,
            "edges_num": 149715
        }

The graph info mainly contains the graph name, topology, properties(vertices and edges) and memory usage.

Published Graphs

serverState.get("published_graphs") returns a list of published graphs. Each graph entry contains information about the published graph, similar to cached_graphs

Tasks

serverState.get("tasks") returns the last 100 queued tasks. Each task has a type, the pool to be executed on (the task might be already executed) and other status fields ({Queued|Started|Done} time), and a sessionid if the task belongs to a session.

Memory

This section contains a map of available memories, the key is the hostname and the value is a list of current available memories(managed and unmanaged) .Each entry contains how much memory is free, used and the max available.

Pools

serverState.get("pools") returns information about available thread pools per host such as type, busyTime and the sessions using this pool.