Package com.gpudb

Class GPUdbBase

  • Direct Known Subclasses:
    GPUdb

    public abstract class GPUdbBase
    extends Object
    Base class for the GPUdb API that provides general functionality not specific to any particular GPUdb request. This class is never instantiated directly; its functionality is accessed via instances of the GPUdb class. Usage patterns: 1. Unsecured setup
             String url = "http://your_server_ip_or_FQDN:9191";
    
             GPUdb.Options options = new GPUdb.Options();
             options.setUsername("user");
             options.setPassword("password");
    
             GPUdb gpudb = new GPUdb( url, options );
    
     
    2. Secured setup If options.setBypassSslCertCheck( true ) is set, then all forms of certificate checking whether self-signed or one issued by a known CA will be bypassed and an unsecured connection will be set up. A) This setup will enforce checking the truststore and the connection will fail if a mismatch is found
             String url = "https://your_server_ip_or_FQDN:8082/gpudb-0";
    
             GPUdb.Options options = new GPUdb.Options();
             options.setUsername("user");
             options.setPassword("password");
             options.setTrustStoreFilePath("/path/to/truststore.jks");
             options.setTrustStorePassword("password_for_truststore");
    
             GPUdb gpudb = new GPUdb( url, options );
     
    B) This setup will not enforce checking the truststore and the connection will succeed since the truststore will not be verified. if options.setBypassSslCertCheck(true) is there, then all other checks will be left out and the connection will succeed unless there are other errors like wrong credentials, non-responsive server etc. If a truststore (only for self-signed certificates) has to be used, one can set options.setTrustStoreFilePath("/path/to/truststore.jks") and options.setTrustStorePassword("password_for_truststore"), but in this case options.setBypassSslCertCheck( true ) cannot be used.
             String url = "https://your_server_ip_or_FQDN:8082/gpudb-0";
    
             GPUdb.Options options = new GPUdb.Options();
             options.setUsername("user");
             options.setPassword("password");
             options.setBypassSslCertCheck( true );
    
             GPUdb gpudb = new GPUdb( url, options );
     
    C) This setup will enforce checking any security related configurations and will proceed to set up a secured connection only if the server has SSL set up and a certificate from a well-known CA is available. In this case, the Java runtime makes sure that the server certificate is validated without the user having to specify anything.
             String url = "https://your_server_ip_or_FQDN:8082/gpudb-0";
    
             GPUdb.Options options = new GPUdb.Options();
             options.setUsername("user");
             options.setPassword("password");
    
             GPUdb gpudb = new GPUdb( url, options );
     
    See Also:
    GPUdbBase.Options, GPUdbBase.Options.setBypassSslCertCheck(boolean)
    • Method Detail

      • getApiVersion

        public static String getApiVersion()
        Gets the version number of the GPUdb Java API.
        Returns:
        the version number
      • list

        @SafeVarargs
        public static <T> List<T> list​(T... values)
        A utility method for creating a list of objects inline. Can be used with certain GPUdb requests for specifying lists of strings or other objects.
        Type Parameters:
        T - the type of objects in the list
        Parameters:
        values - the objects to be added to the list
        Returns:
        the list
      • options

        public static Map<String,​String> options​(String... values)
        A utility method for creating a map of strings to strings} inline. Can be used with certain GPUdb requests for specifying additional named parameters. An even number of string values must be specified; the first in each pair is the key for a map entry, and the second is the value.
        Parameters:
        values - an even number of string values
        Returns:
        the map
        Throws:
        IllegalArgumentException - if an odd number of values is specified
      • finalize

        protected void finalize()
                         throws Throwable
        Clean up resources--namely, the HTTPClient object(s).
        Overrides:
        finalize in class Object
        Throws:
        Throwable
      • removeProtectedHttpHeaders

        protected void removeProtectedHttpHeaders()
      • createAuthorizationHeader

        protected String createAuthorizationHeader()
        Choose and return the authentication mode based on the presence of options in this connection's options map. Authentication scheme: 1. Choose OAuth2 authentication if oauthToken option is set 2. Choose basic authentication if username/password options is set 3. Choose no authentication
      • getAuthorizationFromHttpHeaders

        protected void getAuthorizationFromHttpHeaders()
      • getURLs

        public List<URL> getURLs()
        Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server. At any given time, one URL will be active and used for all GPUdb calls (call getURL to determine which one), but in the event of failure, the other URLs will be tried in a randomized order, and if a working one is found it will become the new active URL.
        Returns:
        the list of URLs
      • getFailoverURLs

        public List<URL> getFailoverURLs()
        Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server. At any given time, one URL will be active and used for all GPUdb calls (call getURL to determine which one), but in the event of failure, the other URLs will be tried in order, and if a working one is found it will become the new active URL.
        Returns:
        the list of URLs
      • getHmURLs

        public List<URL> getHmURLs()
        Gets the list of URLs for the GPUdb host manager. At any given time, one URL will be active and used for all GPUdb calls (call getHmURL to determine which one), but in the event of failure, the other URLs will be tried in order, and if a working one is found it will become the new active URL.
        Returns:
        the list of URLs
      • getSystemProperties

        public Map<String,​String> getSystemProperties()
        Gets the active cluster's system properties mapping. If this cluster was created without a system properties map, load it now.
        Returns:
        Map of system property settings
      • getURL

        public URL getURL()
        Gets the active URL of the GPUdb server.
        Returns:
        the URL
      • getHmURL

        public URL getHmURL()
        Gets the active URL of the GPUdb host manager.
        Returns:
        the URL
      • getPrimaryUrl

        public URL getPrimaryUrl()
        Gets the URL of the head node of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.
        Returns:
        the primary URL hostname or IP address if there is a primary cluster, null otherwise.
      • getPrimaryHostname

        public String getPrimaryHostname()
        Gets the hostname of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.
        Returns:
        the primary URL hostname or IP address if there is a primary cluster, empty string otherwise.
      • getServerVersion

        public GPUdbBase.GPUdbVersion getServerVersion()
        Gets the version of the database server that this client is connected to. If the server version was not successfully saved, then returns null.
        Returns:
        the server version GPUdbBase.GPUdbVersion, or null.
      • getUseSnappy

        public boolean getUseSnappy()
        Gets the value of the flag indicating whether Snappy compression will be used for certain GPUdb requests that potentially submit large amounts of data. Will be false if not overridden using the GPUdb constructor via GPUdbBase.Options.
        Returns:
        the value of the Snappy compression flag
        See Also:
        GPUdbBase.Options.setUseSnappy(boolean)
      • isAutoDiscoveryEnabled

        public boolean isAutoDiscoveryEnabled()
        Gets whether auto-discovery is enabled or not on the current connection.
        Returns:
        true if auto-discovery is enabled; false otherwise
      • getTimeout

        public int getTimeout()
        Gets the timeout value, in milliseconds, after which a lack of response from the GPUdb server will result in requests being aborted. A timeout of zero is interpreted as an infinite timeout. Note that this applies independently to various stages of communication, so overall a request may run for longer than this without being aborted.
        Returns:
        the timeout value
        See Also:
        GPUdbBase.Options.setTimeout(int)
      • getHARingInfo

        public List<GPUdbBase.ClusterAddressInfo> getHARingInfo()
        Gets a copy of the list of ClusterAddressInfo objects that contain information about the Kinetica ring of clusters that this GPUdb object is connected to.
        Returns:
        the size of the HA cluster
      • getHARingSize

        public int getHARingSize()
        Gets the size of the high availability ring (i.e. how many clusters are in it).
        Returns:
        the size of the HA cluster
      • getBypassSslCertCheck

        public boolean getBypassSslCertCheck()
      • addHttpHeader

        public void addHttpHeader​(String header,
                                  String value)
                           throws GPUdbException
        Adds an HTTP header to the map of additional HTTP headers to send to GPUdb with each request. If the header is already in the map, its value is replaced with the specified value. The user is not allowed to modify the following headers:
        • Authorization
        • ha_sync_mode
        • Content-type
        Parameters:
        header - the HTTP header (cannot be null)
        value - the value of the HTTP header (cannot be null)
        Throws:
        GPUdbException
        See Also:
        getHttpHeaders(), removeHttpHeader(String)
      • removeHttpHeader

        public void removeHttpHeader​(String header)
                              throws GPUdbException
        Removes the given HTTP header from the map of additional HTTP headers to send to GPUdb with each request. The user is not allowed to remove the following headers:
        • Authorization
        • ha_sync_mode
        • Content-type
        Parameters:
        header - the HTTP header (cannot be null)
        Throws:
        GPUdbException
        See Also:
        getHttpHeaders(), addHttpHeader(String, String)
      • setHASyncMode

        public void setHASyncMode​(GPUdbBase.HASynchronicityMode syncMode)
        Sets the current high availability synchronicity override mode. Until it is changed, all subsequent endpoint calls made to the server will maintain the given synchronicity across all clusters in the high availability ring. When set to GPUdbBase.HASynchronicityMode.DEFAULT, normal operation will resume (where the high availability process determines which endpoints will be synchronous and which ones will be asynchronous).
        Parameters:
        syncMode - the ha synchronicity override mode
      • setHostManagerPort

        @Deprecated(since="7.1.0",
                    forRemoval=true)
        public GPUdbBase setHostManagerPort​(int value)
                                     throws IllegalArgumentException
        Deprecated, for removal: This API element is subject to removal in a future version.
        As of version 7.1.0.0, this method will no longer be functional. This method will be a no-op, not changing host manager port. The method will be removed in version 7.2.0.0.
        Parameters:
        value - the host manager port number
        Returns:
        the current GPUdbBase instance
        Throws:
        IllegalArgumentException
      • getNumClusterSwitches

        protected int getNumClusterSwitches()
        Gets the number of times the client has switched to a different cluster amongst the high availability ring.
      • incrementNumClusterSwitches

        protected void incrementNumClusterSwitches()
        Gets the number of times the client has switched to a different cluster amongst the high availability ring.
      • selectNextCluster

        protected void selectNextCluster()
        Select the next cluster based on the HA failover priority set by the user.
      • switchURL

        protected URL switchURL​(URL oldURL,
                                int oldNumClusterSwitches)
                         throws GPUdbBase.GPUdbFailoverDisabledException,
                                GPUdbBase.GPUdbHAUnavailableException
        Switches the URL of the HA ring cluster. Check if we've circled back to the old URL. If we've circled back to it, then re-shuffle the list of indices so that the next time, we pick up HA clusters in a different random manner and throw an exception.
        Parameters:
        oldURL - the head rank URL in use at the time of the failover that initiated this switch
        oldNumClusterSwitches - the total number of cluster switches that have occurred up to the moment before this thread's switch was initiated; this will be used to determine whether another thread is already trying to fail over to the next cluster and that this thread should stand down
        Returns:
        the next cluster head rank URL to try
        Throws:
        GPUdbBase.GPUdbFailoverDisabledException
        GPUdbBase.GPUdbHAUnavailableException
      • initializeHttpPostRequest

        protected org.apache.hc.client5.http.classic.methods.HttpPost initializeHttpPostRequest​(URL url)
                                                                                         throws Exception
        Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
        Parameters:
        url - the URL to which the connection needs to be made
        Returns:
        the initialized HttpPost connection object
        Throws:
        Exception
      • initializeHttpPostRequest

        protected org.apache.hc.client5.http.classic.methods.HttpPost initializeHttpPostRequest​(URL url,
                                                                                                int responseTimeout)
                                                                                         throws Exception
        Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
        Parameters:
        url - the URL to which the connection needs to be made
        responseTimeout - a positive integer representing the number of milliseconds to use for response timeout
        Returns:
        the initialized HttpPost connection object
        Throws:
        Exception
      • initializeHttpConnection

        protected HttpURLConnection initializeHttpConnection​(URL url)
                                                      throws Exception
        Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
        Parameters:
        url - the URL to which the connection needs to be made
        Returns:
        the initialized HTTP connection object
        Throws:
        Exception
      • initializeHttpConnection

        protected HttpURLConnection initializeHttpConnection​(URL url,
                                                             int connectionTimeout)
                                                      throws Exception
        Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
        Parameters:
        url - the URL to which the connection needs to be made
        connectionTimeout - a positive integer representing the number of milliseconds to use for connection and read timeouts
        Returns:
        the initialized HTTP connection object
        Throws:
        Exception
      • insertRecordsFromJson

        public Map<String,​Object> insertRecordsFromJson​(String jsonRecords,
                                                              String tableName)
                                                       throws GPUdbException
        This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table with all default options
        Parameters:
        jsonRecords - - A single JSON record or an array of records as JSON
        tableName - - the table to insert the records into
        Returns:
        - the JSON response as a Map of String to Object.
        Throws:
        GPUdbException - - in case of an error raised by the underlying endpoint
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve; a value of null will return all columns
        offset - - the offset to start from
        limit - - the maximum number of records
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit,
                                                               List<String> orderByColumns)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve; a value of null will return all columns
        offset - - the offset to start from
        limit - - the maximum number of records
        orderByColumns - - the list of columns to order by
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit,
                                                               String expression)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve; a value of null will return all columns
        offset - - the offset to start from
        limit - - the maximum number of records
        expression - - the filter expression
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit,
                                                               String expression,
                                                               List<String> orderByColumns)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve; a value of null will return all columns
        offset - - the offset to start from
        limit - - the maximum number of records
        expression - - the filter expression
        orderByColumns - - the list of columns to order by
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit,
                                                               String expression,
                                                               String havingClause)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve; a value of null will return all columns
        offset - - the offset to start from
        limit - - the maximum number of records
        expression - - the filter expression
        havingClause - - the having clause
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • getRecordsJson

        public GPUdbBase.GetRecordsJsonResponse getRecordsJson​(String tableName,
                                                               List<String> columnNames,
                                                               long offset,
                                                               long limit,
                                                               String expression,
                                                               List<String> orderByColumns,
                                                               String havingClause)
                                                        throws GPUdbException
        This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the 'tableName'. The rest are all optional with suitable defaults wherever applicable.
        Parameters:
        tableName - - Name of the table
        columnNames - - the columns names to retrieve
        offset - - the offset to start from
        limit - - the maximum number of records
        expression - - the filter expression
        orderByColumns - - the list of columns to order by
        havingClause - - the having clause
        Returns:
        - an instance of GPUdbBase.GetRecordsJsonResponse class
        Throws:
        GPUdbException
      • query

        public <T extends RecordGPUdbSqlIterator<T> query​(String sql,
                                                            Object parameters)
                                                     throws GPUdbException
        This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. See query(String, Object, Map) to execute a SQL statement without reading the resulting data.
        Parameters:
        sql - - The SQL query to execute
        parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
        Returns:
        - an instance of GPUdbSqlIterator class
        Throws:
        GPUdbException
      • query

        public <T extends RecordGPUdbSqlIterator<T> query​(String sql,
                                                            Object parameters,
                                                            Map<String,​String> sqlOptions)
                                                     throws GPUdbException
        This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. See execute(String) to execute a SQL statement without reading the resulting data.
        Parameters:
        sql - - The SQL query to execute
        parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
        sqlOptions - - Optional parameters for the executeSql call. Can be null.
        Returns:
        - an instance of GPUdbSqlIterator class
        Throws:
        GPUdbException
      • execute

        public long execute​(String sql)
                     throws GPUdbException
        This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map)} to execute a SQL query to read the resulting data records.
        Parameters:
        sql - - The SQL query to execute
        Returns:
        - number of rows affected by the execution of statement
        Throws:
        GPUdbException
      • execute

        public long execute​(String sql,
                            Object parameters)
                     throws GPUdbException
        This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map) to execute a SQL query to read the resulting data records.
        Parameters:
        sql - - The SQL query to execute
        parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
        Returns:
        - number of rows affected by the execution of statement
        Throws:
        GPUdbException
      • execute

        public long execute​(String sql,
                            Object parameters,
                            Map<String,​String> sqlOptions)
                     throws GPUdbException
        This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map) to execute a SQL query to read the resulting data records.
        Parameters:
        sql - - The SQL query to execute
        parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
        sqlOptions - - Optional parameters for the executeSql call. Can be null.
        Returns:
        - number of rows affected by the execution of statement
        Throws:
        GPUdbException
      • addKnownType

        public void addKnownType​(String typeId,
                                 Object typeDescriptor)
        Adds a type descriptor for a GPUdb type (excluding types of join tables), identified by a type ID, to the known type list. If that type is subsequently encountered in results from a GPUdb request for which an explicit type descriptor is not provided, the specified type descriptor will be used for decoding.
        Parameters:
        typeId - the type ID of the type in GPUdb (must not be the type of a join table)
        typeDescriptor - the type descriptor to be used for decoding the type
        Throws:
        IllegalArgumentException - if typeDescriptor is not a Schema, Type, TypeObjectMap, or Class that implements IndexedRecord
      • addKnownType

        public <T> void addKnownType​(String typeId,
                                     Class<T> objectClass,
                                     TypeObjectMap<T> typeObjectMap)
        Adds a type object map for the specified class as a type descriptor for a GPUdb type, identified by a type ID, to the known type list, and also adds the type object map to the known type object map list. If either the type or the specified class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, or in its results, the specified type object map will be used for decoding and encoding.
        Type Parameters:
        T - the class
        Parameters:
        typeId - the type ID of the type in GPUdb
        objectClass - the class
        typeObjectMap - the type object map to be used for encoding and decoding
      • addKnownTypeFromTable

        public void addKnownTypeFromTable​(String tableName,
                                          Object typeDescriptor)
                                   throws GPUdbException
        Adds a type descriptor for the GPUdb type stored in the specified table to the known type list. If that type is subsequently encountered in results from a GPUdb request for which an explicit type descriptor is not provided, the specified type descriptor will be used for decoding. Note that this method makes a request to GPUdb to obtain table information.
        Parameters:
        tableName - the name of the table in GPUdb
        typeDescriptor - the type descriptor to be used for decoding the type
        Throws:
        IllegalArgumentException - if typeDescriptor is not a Schema, Type, TypeObjectMap, or Class that implements IndexedRecord
        GPUdbException - if the table does not exist or is not homogeneous, or if an error occurs during the request for table information
      • addKnownTypeFromTable

        public <T> void addKnownTypeFromTable​(String tableName,
                                              Class<T> objectClass,
                                              TypeObjectMap<T> typeObjectMap)
                                       throws GPUdbException
        Adds a type object map for the specified class as a type descriptor for the GPUdb type stored in the specified table to the known type list, and also adds the type object map to the known type object map list. If either the type or the specified class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, or in its results, the specified type object map will be used for decoding and encoding. Note that this method makes a request to GPUdb to obtain table information.
        Type Parameters:
        T - the class
        Parameters:
        tableName - the name of the table in GPUdb
        objectClass - the class
        typeObjectMap - the type object map to be used for encoding and decoding
        Throws:
        GPUdbException - if the table does not exist or is not homogeneous, or if an error occurs during the request for information
      • addKnownTypeObjectMap

        public <T> void addKnownTypeObjectMap​(Class<T> objectClass,
                                              TypeObjectMap<T> typeObjectMap)
        Adds a type object map for the specified class to the known type object map list. If that class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, the specified type object map will be used for encoding.
        Type Parameters:
        T - the class
        Parameters:
        objectClass - the class
        typeObjectMap - the type object map to be used for encoding
      • submitRequest

        public String submitRequest​(String endpoint,
                                    boolean enableCompression)
                             throws GPUdbBase.SubmitException,
                                    GPUdbException
        Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method's primary use is in support of getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
        Parameters:
        endpoint - the GPUdb endpoint to send the request to
        enableCompression - whether to compress the request
        Returns:
        the response object (same as response parameter)
        Throws:
        GPUdbBase.SubmitException - if an error occurs while submitting the request
        GPUdbException
      • submitRequestToHM

        public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestToHM​(String endpoint,
                                                                                     org.apache.avro.generic.IndexedRecord request,
                                                                                     T response)
                                                                              throws GPUdbBase.SubmitException,
                                                                                     GPUdbException
        Submits an arbitrary request to the GPUdb host manager and saves the response into a pre-created response object. The request and response objects must implement the Avro IndexedRecord interface.
        Type Parameters:
        T - the type of the response object
        Parameters:
        endpoint - the GPUdb endpoint to send the request to
        request - the request object
        response - the response object
        Returns:
        the response object (same as response parameter)
        Throws:
        GPUdbBase.SubmitException - if an error occurs while submitting the request
        GPUdbException
      • submitRequestToHM

        public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestToHM​(String endpoint,
                                                                                     org.apache.avro.generic.IndexedRecord request,
                                                                                     T response,
                                                                                     boolean enableCompression)
                                                                              throws GPUdbBase.SubmitException,
                                                                                     GPUdbException
        Submits an arbitrary request to the GPUdb host manager and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true.
        Type Parameters:
        T - the type of the response object
        Parameters:
        endpoint - the GPUdb endpoint to send the request to
        request - the request object
        response - the response object
        enableCompression - whether to compress the request
        Returns:
        the response object (same as response parameter)
        Throws:
        GPUdbBase.SubmitException - if an error occurs while submitting the request
        GPUdbException
      • ping

        public void ping()
                  throws GPUdbException
        Verifies that GPUdb is running on the server. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
        Throws:
        GPUdbException - if an error occurs and/or GPUdb is not running on the server
      • ping

        public String ping​(URL url)
        Pings the given URL and returns the response. If no response, returns an empty string. Use the timeout of this GPUdb class.
        Returns:
        the ping response, or an empty string if it fails.
      • ping

        public String ping​(URL url,
                           int connectionTimeout)
        Pings the given URL and returns the response. If no response, returns an empty string.
        Parameters:
        url - the URL to which the connection needs to be made
        connectionTimeout - a positive integer representing the number of milliseconds to use for connection and read timeouts
        Returns:
        the ping response, or an empty string if it fails.
      • isKineticaRunning

        public boolean isKineticaRunning​(URL url)
        Verifies that GPUdb is running at the given URL (does not do any HA failover). Use a very short timeout so that we don't wait for a long time if the server at the given URL is not accessible.
        Returns:
        true if Kinetica is running, false otherwise.