Skip to main content

Class GPUdb

class gpudb.GPUdb(host=None, options=None, *args, **kwargs)[source]

This is the main class to be used to provide the client functionality to interact with the server.

Usage patterns

  • Secured setup (Default)

    This code given below will set up a secured connection. The property ‘skip_ssl_cert_verification’ is set to ‘False’ by default. SSL certificate check will be enforced by default.

  • Unsecured setup

    The code given below will set up an unsecured connection to the server. The property ‘skip_ssl_cert_verification’ has been set explicitly to ‘True’. So, irrespective of whether an SSL setup is there or not all certificate checks will be bypassed.

    Another way of setting up an unsecured connection is as given by the code below. In this case, the URL is not a secured one so no SSL setup comes into play.

Construct a new GPUdb client instance. This object communicates to the database server at the given address. This class implements HA failover, which means that upon certain error conditions, this class will try to establish connection with one of the other clusters (specified by the user or known to the ring) to continue service. There are several options related to how to control that in the GPUdb.Options class that can be controlled via options.

Note

Please read the docstring of options about backward- compatibility related notes.

Parameters

host (str or list of str) –

The URL(s) of the GPUdb server. May be provided as a comma separated string or a list of strings containing head or worker rank URLs of the server clusters. Must be full and valid URLs. Example: “https://domain.com:port/path/”. If only a single URL or host is given, and no primary_url is explicitly specified via the options, then the given URL will be used as the primary URL. Default is ‘http://127.0.0.1:9191’ (implemented internally).

Note that in versions 7.0 and prior, the URL also allowed username:password@ in front of the hostname. That is now deprecated. For now, anything in the hostname separated by the @ symbol will be discarded. (But the constructor will still function). Please use the appropriate properties of the options argument to set the username and password.

options (GPUdb.Options or dict) –

Optional arguments for creating this GPUdb object. To be backward compatible to 7.0 versions, keyword arguments will be honored (only if no options is given). I.e., if options is given, no positional or keyword argument can be given. See Options for all available properties.

class HASynchronicityMode(value, names=None, module=None, type=None, start=1)[source]

Inner enumeration class to represent the high-availability synchronicity override mode that is applied to each endpoint call. Available enumerations are:

  • DEFAULT – No override; defer to the HA process for synchronizing endpoints (which has different logic for different endpoints). This is the default mode.

  • NONE – Do not replicate the endpoint calls to the backup cluster.

  • SYNCHRONOUS – Synchronize all endpoint calls

  • ASYNCHRONOUS – Do NOT synchronize any endpoint call

class HAFailoverOrder(value, names=None, module=None, type=None, start=1)[source]

Inner enumeration class to represent the high-availability failover order that is applied to ring resiliency or inter-cluster failover. The order dictates in which pattern backup clusters will be chosen when a failover needs to happen in the client API. Available enumerations are:

  • RANDOM – Randomly choose the backup cluster from the available clusters. This is the default mode.

  • SEQUENTIAL – Choose the cluster sequentially from the list of clusters (the union of the user given clusters and auto-discovered clusters).

class Options(options=None)[source]

Encapsulates the various options used to create a GPUdb object. The same object can be used on multiple GPUdb client handles and state modifications are chained together:

For backward compatibility, we will support the following options from the 7.0 GPUdb keyword arguments and map them to the following properties:

  • connection -> protocol

  • no_init_db_contact -> disable_auto_discovery

Create a default set of options for GPUdb object creation.

Parameters

options (dict or GPUdb.Options) –

Optional dictionary with options already loaded. If a GPUdb.Options object, then this will work like a copy constructor and make a full copy of the input argument.

Returns

An Options object.

class Version(version_str)[source]

An internal class to handle Kinetica Version (client API or server).

Takes in a string containing a Kinetica version and creates a GPUdb.Version object from it.

Parameters

version_str (str) –

A string containing the Kinetica version (client or server). Expect at least four components separated by a period (.). There may be additional parts after the fourth component that will be discarded.

class ValidateUrl[source]

An internal class to handle connection URL parsing

class URL(url=None, port=None, protocol=None, accept_full_urls_only=False)[source]

An internal class to handle URLs. Stores the hostname/IP address, port, protocol, path, and the full URL (as a string).

Takes in a string containing a full URL, or another URL object, and creates a URL object from it.

Parameters

url (str or GPUdb.URL) –

Either a hostname/URL string or another GPUdb.URL object to create this object for. Note that the port is not a mandatory part of the URL.

port (int) –

Optional port. If specified, will be appended to any host specified and will override the port of any URL specified.

protocol (str) –

Optional protocol. If specified, will be prepended to any host specified and will override the protocol of any URL specified.

accept_full_urls_only (bool) –

Optional argument. If False, then be flexible in the parsing; for example, if no port is given, use the default port. If True, then only accept full URLs only. Default is False.

class ClusterAddressInfo(head_rank_url, worker_rank_urls=None, host_names=None, host_manager_url=None, host_manager_port=None, is_primary_cluster=None, server_version=None, ha_status=None, logging_level=None)[source]

Inner class to keep track of all relevant information for a given Kinetica cluster. It mostly keeps track of URLs and hostnames, with some additional information like whether the cluster is primary or not.

Creates a ClusterAddressInfo object with the given information.

Parameters

head_rank_url (str or GPUdb.URL) –

Only required argument. Must be a full URL string or GPUdb.URL object. E.g. “http://1.2.3.4:8082/gpudb-0”.

worker_rank_urls (list of str or GPUdb.URL) –

Optional argument. Must be a list of fully qualified URLs. These URLs correspond to the worker ranks’ addresses.

host_names (list of str) –

Optional argument. Must be a list of strings. These strings contain hostnames or IP addresses for all the nodes/hosts in the cluster. May contain the protocol (e.g. “http://host0”).

host_manager_url (str or GPUdb.URL) –

Optional argument, mutually exclusive with host_manager_port. If given, must be a fully qualified URL for the host manager of this cluster.

host_manager_port (int) –

Optional argument, mutually exclusive with host_manager_url. If given, must be an integer in the range [1, 65535].

is_primary_cluster (bool) –

Optional boolean argument. Indicates if this cluster is to be treated as the primary cluster. Default is False.

server_version (str or GPUdb.Version) –

Optional string containing the server version. If given, will be parsed as a GPUdb.Version object. Default is None.

ha_status (str) –

Optional last-seen HA drain state for this cluster, as reported by the ‘ha_status.drained’ field of /show/system/status (e.g. “drained”, “draining”, “not_drained”). None if unknown or not applicable (e.g. a non-HA cluster). Default is None.

logging_level (int) –

Optional level at which logs should be output. Default is None.

Members