Package com.gpudb
Class GPUdbBase
- java.lang.Object
-
- com.gpudb.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 theGPUdbclass. Usage patterns: 1. Unsecured setupString 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 Ifoptions.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 foundString 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. ifoptions.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 setoptions.setTrustStoreFilePath("/path/to/truststore.jks")andoptions.setTrustStorePassword("password_for_truststore"), but in this caseoptions.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 );
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGPUdbBase.ClusterAddressInfoHelper class which contains all possible address related information for a given Kinetica cluster.static classGPUdbBase.FailbackOptionsstatic classGPUdbBase.GetRecordsJsonResponseThis class models the response returned by the methodgetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)The default constructor is used to create instance whenever there is an error encountered by the methodgetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long).static classGPUdbBase.GPUdbExitExceptionA special exception indicating the server is shutting downstatic classGPUdbBase.GPUdbFailoverDisabledExceptionstatic classGPUdbBase.GPUdbHAUnavailableExceptionstatic classGPUdbBase.GPUdbHostnameRegexFailureExceptionstatic classGPUdbBase.GPUdbUnauthorizedAccessExceptionIndicates that there is an authorization-related problem occurred.static classGPUdbBase.GPUdbVersionContains the version of the client API or the GPUdb server.static classGPUdbBase.HAFailoverOrderA enumeration of high-availability (inter-cluster) failover order.static classGPUdbBase.HASynchronicityModeA enumeration of high-availability synchronicity override modes.static classGPUdbBase.InsertRecordsJsonRequeststatic classGPUdbBase.JsonOptionsThis class provides options to control JSON ingest usingBulkInserter.static classGPUdbBase.OptionsA set of configurable options for the GPUdb API.static classGPUdbBase.SubmitExceptionAn exception that occurred during the submission of a request to GPUdb.
-
Field Summary
Fields Modifier and Type Field Description static longEND_OF_SETConstant used with certain requests to indicate that the maximum allowed number of results should be returned.protected static StringHEADER_AUTHORIZATIONprotected static StringHEADER_CONTENT_TYPEprotected static StringHEADER_HA_SYNC_MODEprotected static String[]PROTECTED_HEADERSprotected static StringSslErrorMessageFormat
-
Constructor Summary
Constructors Modifier Constructor Description protectedGPUdbBase(String url, GPUdbBase.Options options)protectedGPUdbBase(URL url, GPUdbBase.Options options)protectedGPUdbBase(List<URL> urls, GPUdbBase.Options options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddHttpHeader(String header, String value)Adds an HTTP header to the map of additional HTTP headers to send to GPUdb with each request.<T> voidaddKnownType(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.voidaddKnownType(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.<T> voidaddKnownTypeFromTable(String tableName, Class<T> objectClass, TypeObjectMap<T> typeObjectMap)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.voidaddKnownTypeFromTable(String tableName, Object typeDescriptor)Adds a type descriptor for the GPUdb type stored in the specified table to the known type list.<T> voidaddKnownTypeObjectMap(Class<T> objectClass, TypeObjectMap<T> typeObjectMap)Adds a type object map for the specified class to the known type object map list.protected StringcreateAuthorizationHeader()Choose and return the authentication mode based on the presence of options in this connection's options map.protected GPUdbBase.HASynchronicityModecreateHASyncModeHeader()protected <T> List<T>decode(Object typeDescriptor, List<ByteBuffer> data)protected <T> List<T>decode(String typeId, List<ByteBuffer> data)protected <T> List<T>decode(List<String> typeIds, List<ByteBuffer> data)protected <T> List<List<T>>decodeMultiple(Object typeDescriptor, List<List<ByteBuffer>> data)protected <T> List<List<T>>decodeMultiple(List<String> typeIds, List<List<ByteBuffer>> data)protected <T> List<ByteBuffer>encode(TypeObjectMap<T> typeObjectMap, List<T> data)protected <T> List<ByteBuffer>encode(List<T> data)longexecute(String sql)This method is used to execute a SQL statement (e.g., DML, DDL).longexecute(String sql, Object parameters)This method is used to execute a SQL statement (e.g., DML, DDL).longexecute(String sql, Object parameters, Map<String,String> sqlOptions)This method is used to execute a SQL statement (e.g., DML, DDL).protected voidfinalize()Clean up resources--namely, the HTTPClient object(s).static StringgetApiVersion()Gets the version number of the GPUdb Java API.protected voidgetAuthorizationFromHttpHeaders()booleangetBypassSslCertCheck()GPUdbBase.ClusterAddressInfogetClusterInfo()Gets the active cluster's information object.ExecutorServicegetExecutor()Gets theexecutor serviceused for managing threads during data encoding and decoding operations.List<URL>getFailoverURLs()Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server.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.intgetHARingSize()Gets the size of the high availability ring (i.e. how many clusters are in it).GPUdbBase.HASynchronicityModegetHASyncMode()Gets the current high availability synchronicity override mode.URLgetHmURL()Gets the active URL of the GPUdb host manager.List<URL>getHmURLs()Gets the list of URLs for the GPUdb host manager.List<GPUdbBase.ClusterAddressInfo>getHostAddresses()Map<String,String>getHttpHeaders()Gets the map of additional HTTP headers that will be sent to GPUdb with each request.protected intgetNumClusterSwitches()Gets the number of times the client has switched to a different cluster amongst the high availability ring.StringgetPassword()Gets the password used for authentication to GPUdb.StringgetPrimaryHostname()Gets the hostname of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.URLgetPrimaryUrl()Gets the URL of the head node of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, String havingClause)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, List<String> orderByColumns)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, List<String> orderByColumns, String havingClause)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GetRecordsJsonResponsegetRecordsJson(String tableName, List<String> columnNames, long offset, long limit, List<String> orderByColumns)This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified).GPUdbBase.GPUdbVersiongetServerVersion()Gets the version of the database server that this client is connected to.Map<String,String>getSystemProperties()Gets the active cluster's system properties mapping.intgetThreadCount()Gets the number of threads used during data encoding and decoding operations.intgetTimeout()Gets the timeout value, in milliseconds, after which a lack of response from the GPUdb server will result in requests being aborted.protected ObjectgetTypeDescriptor(String typeId)protected <T> TypeObjectMap<T>getTypeObjectMap(Class<T> objectClass)URLgetURL()Gets the active URL of the GPUdb server.List<URL>getURLs()Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server.StringgetUsername()Gets the username used for authentication to GPUdb.booleangetUseSnappy()Gets the value of the flag indicating whether Snappy compression will be used for certain GPUdb requests that potentially submit large amounts of data.protected voidincrementNumClusterSwitches()Gets the number of times the client has switched to a different cluster amongst the high availability ring.protected HttpURLConnectioninitializeHttpConnection(URL url)Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.protected HttpURLConnectioninitializeHttpConnection(URL url, int connectionTimeout)Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.protected org.apache.hc.client5.http.classic.methods.HttpPostinitializeHttpPostRequest(URL url)Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.protected org.apache.hc.client5.http.classic.methods.HttpPostinitializeHttpPostRequest(URL url, int responseTimeout)Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.Map<String,Object>insertRecordsFromJson(GPUdbBase.InsertRecordsJsonRequest insertRecordsJsonRequest, GPUdbBase.JsonOptions jsonOptions)This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica tableMap<String,Object>insertRecordsFromJson(String jsonRecords, String tableName)This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table with all default optionsMap<String,Object>insertRecordsFromJson(String jsonRecords, String tableName, GPUdbBase.JsonOptions jsonOptions, Map<String,String> createTableOptions, Map<String,String> insertRecordsOptions)This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica tablebooleanisAutoDiscoveryEnabled()Gets whether auto-discovery is enabled or not on the current connection.booleanisKineticaRunning(URL url)Verifies that GPUdb is running at the given URL (does not do any HA failover).static <T> List<T>list(T... values)A utility method for creating a list of objects inline.static Map<String,String>options(String... values)A utility method for creating a map of strings to strings} inline.voidping()Verifies that GPUdb is running on the server.Stringping(URL url)Pings the given URL and returns the response.Stringping(URL url, int connectionTimeout)Pings the given URL and returns the response.<T extends Record>
GPUdbSqlIterator<T>query(String sql)This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object.<T extends Record>
GPUdbSqlIterator<T>query(String sql, Object parameters)This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object.<T extends Record>
GPUdbSqlIterator<T>query(String sql, Object parameters, Map<String,String> sqlOptions)This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object.voidremoveHttpHeader(String header)Removes the given HTTP header from the map of additional HTTP headers to send to GPUdb with each request.protected voidremoveProtectedHttpHeaders()protected voidselectNextCluster()Select the next cluster based on the HA failover priority set by the user.voidsetHASyncMode(GPUdbBase.HASynchronicityMode syncMode)Sets the current high availability synchronicity override mode.GPUdbBasesetHostManagerPort(int value)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.protected voidsetTypeDescriptorIfMissing(String typeId, String label, String typeSchema, Map<String,List<String>> properties)StringsubmitRequest(String endpoint, boolean enableCompression)Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending.Map<String,Object>submitRequest(String endpoint, String payload, boolean enableCompression)Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response)Submits an arbitrary request to GPUdb and saves the response into a pre-created response object.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression)Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending.StringsubmitRequest(URL url, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.Map<String,Object>submitRequest(URL url, String payload, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.StringsubmitRequestRaw(URL url, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.StringsubmitRequestRaw(URL url, boolean enableCompression, int responseTimeout)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.Map<String,Object>submitRequestRaw(URL url, String payload, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.Map<String,Object>submitRequestRaw(URL url, String payload, boolean enableCompression, int responseTimeout)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout)Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequestToHM(String endpoint, org.apache.avro.generic.IndexedRecord request, T response)Submits an arbitrary request to the GPUdb host manager and saves the response into a pre-created response object.<T extends org.apache.avro.generic.IndexedRecord>
TsubmitRequestToHM(String endpoint, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression)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.protected URLswitchURL(URL oldURL, int oldNumClusterSwitches)Switches the URL of the HA ring cluster.
-
-
-
Field Detail
-
END_OF_SET
public static final long END_OF_SET
Constant used with certain requests to indicate that the maximum allowed number of results should be returned.- See Also:
- Constant Field Values
-
HEADER_HA_SYNC_MODE
protected static final String HEADER_HA_SYNC_MODE
- See Also:
- Constant Field Values
-
HEADER_AUTHORIZATION
protected static final String HEADER_AUTHORIZATION
- See Also:
- Constant Field Values
-
HEADER_CONTENT_TYPE
protected static final String HEADER_CONTENT_TYPE
- See Also:
- Constant Field Values
-
PROTECTED_HEADERS
protected static final String[] PROTECTED_HEADERS
-
SslErrorMessageFormat
protected static final String SslErrorMessageFormat
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GPUdbBase
protected GPUdbBase(String url, GPUdbBase.Options options) throws GPUdbException
- Throws:
GPUdbException
-
GPUdbBase
protected GPUdbBase(URL url, GPUdbBase.Options options) throws GPUdbException
- Throws:
GPUdbException
-
GPUdbBase
protected GPUdbBase(List<URL> urls, GPUdbBase.Options options) throws GPUdbException
- Throws:
GPUdbException
-
-
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 ThrowableClean up resources--namely, the HTTPClient object(s).
-
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()
-
createHASyncModeHeader
protected GPUdbBase.HASynchronicityMode createHASyncModeHeader()
-
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 (callgetURLto 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 (callgetURLto 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 (callgetHmURLto 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
-
getClusterInfo
public GPUdbBase.ClusterAddressInfo getClusterInfo()
Gets the active cluster's information object.- Returns:
GPUdbBase.ClusterAddressInfofor the active cluster.
-
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:
Mapof 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.
-
getHASyncMode
public GPUdbBase.HASynchronicityMode getHASyncMode()
Gets the current high availability synchronicity override mode.- Returns:
- the ha synchronicity override mode
- See Also:
setHASyncMode(HASynchronicityMode)
-
getUsername
public String getUsername()
Gets the username used for authentication to GPUdb. Will be an empty string if none was provided to theGPUdb constructorviaGPUdbBase.Options.- Returns:
- the username
- See Also:
GPUdbBase.Options.setUsername(String)
-
getPassword
public String getPassword()
Gets the password used for authentication to GPUdb. Will be an empty string if none was provided to theGPUdb constructorviaGPUdbBase.Options.- Returns:
- the password
- See Also:
GPUdbBase.Options.setPassword(String)
-
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 befalseif not overridden using theGPUdb constructorviaGPUdbBase.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
-
getThreadCount
public int getThreadCount()
Gets the number of threads used during data encoding and decoding operations. Will be one if not overridden using theGPUdb constructorviaGPUdbBase.Options.- Returns:
- the number of threads
- See Also:
GPUdbBase.Options.setThreadCount(int)
-
getExecutor
public ExecutorService getExecutor()
Gets theexecutor serviceused for managing threads during data encoding and decoding operations. Will benullif none was provided to theGPUdb constructorviaGPUdbBase.Options.- Returns:
- the executor service
- See Also:
GPUdbBase.Options.setExecutor(ExecutorService)
-
getHttpHeaders
public Map<String,String> getHttpHeaders()
Gets the map of additional HTTP headers that will be sent to GPUdb with each request. Will be empty if none were provided to theGPUdb constructorviaGPUdbBase.Options.- Returns:
- the map
- See Also:
GPUdbBase.Options.addHttpHeader(String, String),GPUdbBase.Options.setHttpHeaders(Map)
-
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 toGPUdbBase.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
GPUdbBaseinstance - 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.
-
getHostAddresses
public List<GPUdbBase.ClusterAddressInfo> getHostAddresses()
-
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 switcholdNumClusterSwitches- 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
URLto try - Throws:
GPUdbBase.GPUdbFailoverDisabledExceptionGPUdbBase.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 maderesponseTimeout- 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 madeconnectionTimeout- 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(GPUdbBase.InsertRecordsJsonRequest insertRecordsJsonRequest, GPUdbBase.JsonOptions jsonOptions) throws GPUdbException
This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table- Parameters:
insertRecordsJsonRequest- - an instance ofGPUdbBase.InsertRecordsJsonRequestclass- Returns:
- - the JSON response as a Map of String to Object.
- Throws:
GPUdbException- - in case of an error raised by the underlying endpoint
-
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 JSONtableName- - 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
-
insertRecordsFromJson
public Map<String,Object> insertRecordsFromJson(String jsonRecords, String tableName, GPUdbBase.JsonOptions jsonOptions, Map<String,String> createTableOptions, Map<String,String> insertRecordsOptions) throws GPUdbException
This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table- Parameters:
jsonRecords- - A single JSON record or an array of records as JSONtableName- - the table to insert the records intojsonOptions- - Indicates whether Snappy compression is to be set on or notcreateTableOptions- - an instance of the classInsertRecordsJsonRequest.CreateTableOptionsinsertRecordsOptions- - an instance of the classInsertRecordsJsonRequest.Options- 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 tablecolumnNames- - the columns names to retrieve; a value of null will return all columnsoffset- - the offset to start fromlimit- - the maximum number of records- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - 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 tablecolumnNames- - the columns names to retrieve; a value of null will return all columnsoffset- - the offset to start fromlimit- - the maximum number of recordsorderByColumns- - the list of columns to order by- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - 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 tablecolumnNames- - the columns names to retrieve; a value of null will return all columnsoffset- - the offset to start fromlimit- - the maximum number of recordsexpression- - the filter expression- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - 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 tablecolumnNames- - the columns names to retrieve; a value of null will return all columnsoffset- - the offset to start fromlimit- - the maximum number of recordsexpression- - the filter expressionorderByColumns- - the list of columns to order by- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - 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 tablecolumnNames- - the columns names to retrieve; a value of null will return all columnsoffset- - the offset to start fromlimit- - the maximum number of recordsexpression- - the filter expressionhavingClause- - the having clause- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - 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 tablecolumnNames- - the columns names to retrieveoffset- - the offset to start fromlimit- - the maximum number of recordsexpression- - the filter expressionorderByColumns- - the list of columns to order byhavingClause- - the having clause- Returns:
- - an instance of
GPUdbBase.GetRecordsJsonResponseclass - Throws:
GPUdbException
-
query
public <T extends Record> GPUdbSqlIterator<T> query(String sql) throws GPUdbException
This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. Seequery(String, Object, Map)to execute a SQL statement without reading the resulting data.- Parameters:
sql- - The SQL query to execute- Returns:
- - an instance of
GPUdbSqlIteratorclass - Throws:
GPUdbException
-
query
public <T extends Record> GPUdbSqlIterator<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. Seequery(String, Object, Map)to execute a SQL statement without reading the resulting data.- Parameters:
sql- - The SQL query to executeparameters- - Query parameters for the SQL query. Can be null or a String, String[] or List. - Returns:
- - an instance of
GPUdbSqlIteratorclass - Throws:
GPUdbException
-
query
public <T extends Record> GPUdbSqlIterator<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. Seeexecute(String)to execute a SQL statement without reading the resulting data.- Parameters:
sql- - The SQL query to executeparameters- - 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
GPUdbSqlIteratorclass - 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. Seequery(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. Seequery(String, Object, Map)to execute a SQL query to read the resulting data records.- Parameters:
sql- - The SQL query to executeparameters- - 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. Seequery(String, Object, Map)to execute a SQL query to read the resulting data records.- Parameters:
sql- - The SQL query to executeparameters- - 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- iftypeDescriptoris not aSchema,Type,TypeObjectMap, orClassthat implementsIndexedRecord
-
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 GPUdbobjectClass- the classtypeObjectMap- 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 GPUdbtypeDescriptor- the type descriptor to be used for decoding the type- Throws:
IllegalArgumentException- iftypeDescriptoris not aSchema,Type,TypeObjectMap, orClassthat implementsIndexedRecordGPUdbException- 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 GPUdbobjectClass- the classtypeObjectMap- 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 classtypeObjectMap- the type object map to be used for encoding
-
decode
protected <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> data) throws GPUdbException
- Throws:
GPUdbException
-
decode
protected <T> List<T> decode(String typeId, List<ByteBuffer> data) throws GPUdbException
- Throws:
GPUdbException
-
decode
protected <T> List<T> decode(List<String> typeIds, List<ByteBuffer> data) throws GPUdbException
- Throws:
GPUdbException
-
decodeMultiple
protected <T> List<List<T>> decodeMultiple(Object typeDescriptor, List<List<ByteBuffer>> data) throws GPUdbException
- Throws:
GPUdbException
-
decodeMultiple
protected <T> List<List<T>> decodeMultiple(List<String> typeIds, List<List<ByteBuffer>> data) throws GPUdbException
- Throws:
GPUdbException
-
encode
protected <T> List<ByteBuffer> encode(List<T> data) throws GPUdbException
- Throws:
GPUdbException
-
encode
protected <T> List<ByteBuffer> encode(TypeObjectMap<T> typeObjectMap, List<T> data) throws GPUdbException
- Throws:
GPUdbException
-
getTypeDescriptor
protected Object getTypeDescriptor(String typeId) throws GPUdbException
- Throws:
GPUdbException
-
getTypeObjectMap
protected <T> TypeObjectMap<T> getTypeObjectMap(Class<T> objectClass) throws GPUdbException
- Throws:
GPUdbException
-
setTypeDescriptorIfMissing
protected void setTypeDescriptorIfMissing(String typeId, String label, String typeSchema, Map<String,List<String>> properties)
-
submitRequest
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response) throws GPUdbBase.SubmitException, GPUdbException
Submits an arbitrary request to GPUdb and saves the response into a pre-created response object. The request and response objects must implement the AvroIndexedRecordinterface. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
endpoint- the GPUdb endpoint to send the request torequest- the request objectresponse- the response object- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
submitRequest
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response, 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 AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
endpoint- the GPUdb endpoint to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
submitRequest
public Map<String,Object> submitRequest(String endpoint, String payload, 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 AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)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 topayload- the payload as a JSON StringenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
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 AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofgetRecordsJson(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 toenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
submitRequest
public String submitRequest(URL url, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofgetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request toenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequest
public Map<String,Object> submitRequest(URL url, String payload, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request topayload- the payload as a JSON StringenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
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 AvroIndexedRecordinterface.- Type Parameters:
T- the type of the response object- Parameters:
endpoint- the GPUdb endpoint to send the request torequest- the request objectresponse- the response object- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
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 AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue.- Type Parameters:
T- the type of the response object- Parameters:
endpoint- the GPUdb endpoint to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbException
-
submitRequest
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
url- the URL to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequest
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. Optionally, the timeout period can be set in milliseconds. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
url- the URL to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the requestresponseTimeout- a positive integer representing the number of milliseconds to use for response timeout- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
url- the URL to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public Map<String,Object> submitRequestRaw(URL url, String payload, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request topayload- the payload as a JSON StringenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public String submitRequestRaw(URL url, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofgetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request toenableCompression- whether to compress the request- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support of requests other thangetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants andinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Type Parameters:
T- the type of the response object- Parameters:
url- the URL to send the request torequest- the request objectresponse- the response objectenableCompression- whether to compress the requestresponseTimeout- a positive integer representing the number of milliseconds to use for response timeout- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public Map<String,Object> submitRequestRaw(URL url, String payload, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofinsertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request topayload- the payload as a JSON StringenableCompression- whether to compress the requestresponseTimeout- a positive integer representing the number of milliseconds to use for response timeout- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
submitRequestRaw
public String submitRequestRaw(URL url, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the AvroIndexedRecordinterface. The request will only be compressed ifenableCompressionistrueand theGPUdb constructorwas called with theSnappy compression flagset totrue. NOTE: This method's primary use is in support ofgetRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long)and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.- Parameters:
url- the URL to send the request toenableCompression- whether to compress the requestresponseTimeout- a positive integer representing the number of milliseconds to use for connection timeout- Returns:
- the response object (same as
responseparameter) - Throws:
GPUdbBase.SubmitException- if an error occurs while submitting the requestGPUdbBase.GPUdbExitExceptionGPUdbException
-
ping
public void ping() throws GPUdbExceptionVerifies 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 madeconnectionTimeout- 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.
-
-