OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ai.heavy.jdbc.HeavyAIConnection.Connection_properties Class Reference
+ Inheritance diagram for ai.heavy.jdbc.HeavyAIConnection.Connection_properties:
+ Collaboration diagram for ai.heavy.jdbc.HeavyAIConnection.Connection_properties:

Public Member Functions

 Connection_properties (String connection_url, Properties baseProperties) throws SQLException
 

Package Functions

boolean isHttpProtocol ()
 
boolean isHttpsProtocol_insecure ()
 
boolean isHttpsProtocol ()
 
boolean isBinary ()
 
boolean isBinary_tls ()
 
boolean containsTrustStore ()
 

Private Member Functions

String extract_and_remove_query_components (String connection_url, Properties query_props) throws SQLException
 
void validate_params () throws SQLException
 

Detailed Description

Definition at line 144 of file HeavyAIConnection.java.

Constructor & Destructor Documentation

ai.heavy.jdbc.HeavyAIConnection.Connection_properties.Connection_properties ( String  connection_url,
Properties  baseProperties 
) throws SQLException
inline

Definition at line 201 of file HeavyAIConnection.java.

References ai.heavy.jdbc.HeavyAIConnection.Connection_properties.extract_and_remove_query_components(), ai.heavy.jdbc.Options.option_order, and ai.heavy.jdbc.HeavyAIConnection.Connection_properties.validate_params().

202  {
203  connection_url = extract_and_remove_query_components(connection_url, this);
204  String[] url_values = connection_url.split(":");
205  // add 2 for the default jdbc:heavy.ai at the start of the url.
206  if (url_values.length > Options.option_order.length + 2) {
207  // would be nice to print the url at this stage, but the user may have added
208  // their
209  // password into the list.
210  throw new SQLException("Invalid number of arguments provided in url ["
211  + url_values.length + "]. Maximum allowed ["
212  + (Options.option_order.length + 2) + "]");
213  }
214  for (int i = 2; i < url_values.length; i++) {
215  // the offest of 2 is caused by the 2 lables 'jdbc:heavyai' at the start if the
216  // URL
217  String existingValue = getProperty(Options.option_order[i - 2]);
218  if (existingValue != null && !existingValue.equals((url_values[i]))) {
219  logger.warn("Connection property [" + Options.option_order[i - 2]
220  + "] has been provided with different values in the URL and query component of the url. Defaulting to the URL value");
221  }
222  setProperty(Options.option_order[i - 2], url_values[i]);
223  }
224 
225  for (String key : baseProperties.stringPropertyNames()) {
226  String existingValue = getProperty(key);
227  if (existingValue != null
228  && !existingValue.equals(baseProperties.getProperty(key))) {
229  logger.warn("Connection property " + key
230  + "] has been provided with different values in the properties object and the url. Defaulting to the URL value");
231  } else {
232  setProperty(key, baseProperties.getProperty(key));
233  }
234  }
235 
236  validate_params();
237  }
String extract_and_remove_query_components(String connection_url, Properties query_props)

+ Here is the call graph for this function:

Member Function Documentation

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.containsTrustStore ( )
inlinepackage

Definition at line 325 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.server_trust_store.

325  {
326  return this.containsKey(Options.server_trust_store);
327  }
static String server_trust_store
String ai.heavy.jdbc.HeavyAIConnection.Connection_properties.extract_and_remove_query_components ( String  connection_url,
Properties  query_props 
) throws SQLException
inlineprivate

Definition at line 172 of file HeavyAIConnection.java.

Referenced by ai.heavy.jdbc.HeavyAIConnection.Connection_properties.Connection_properties().

173  {
174  // The heavy.ai version of the connection_url is a ':' separated list
175  // with an optional 'query component' at the end (see example above).
176  // The query component starts with the first '?' in the string.
177  // Its is made up of key=value pairs separated by the '&' character.
178  //
179  // The query component is terminated by the end of the string and is
180  // assumed to be at the end of the URL
181 
182  String[] url_components = connection_url.split("\\?");
183  if (url_components.length == 2) {
184  // Query component are separated by an '&' - replace each with a '\n'
185  // will allow Properties.load method to build a properties obj
186  StringReader reader = new StringReader(url_components[1].replace('&', '\n'));
187  try {
188  query_props.load(reader);
189  } catch (IOException iex) {
190  throw new SQLException(iex.toString());
191  }
192  } else if (url_components.length > 2) {
193  throw new SQLException(
194  "Invalid connection string. Multiple query components included ["
195  + connection_url + "]");
196  }
197  // return the url with out any query component
198  return url_components[0];
199  }

+ Here is the caller graph for this function:

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.isBinary ( )
inlinepackage

Definition at line 315 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.protocol.

Referenced by ai.heavy.jdbc.HeavyAIConnection.manageConnection().

315  {
316  return (this.containsKey(Options.protocol)
317  && this.getProperty(Options.protocol).equals("binary"));
318  }

+ Here is the caller graph for this function:

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.isBinary_tls ( )
inlinepackage

Definition at line 320 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.protocol.

Referenced by ai.heavy.jdbc.HeavyAIConnection.manageConnection().

320  {
321  return (this.containsKey(Options.protocol)
322  && this.getProperty(Options.protocol).equals("binary_tls"));
323  }

+ Here is the caller graph for this function:

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.isHttpProtocol ( )
inlinepackage

Definition at line 300 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.protocol.

Referenced by ai.heavy.jdbc.HeavyAIConnection.manageConnection().

300  {
301  return (this.containsKey(Options.protocol)
302  && this.getProperty(Options.protocol).equals("http"));
303  }

+ Here is the caller graph for this function:

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.isHttpsProtocol ( )
inlinepackage

Definition at line 310 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.protocol.

Referenced by ai.heavy.jdbc.HeavyAIConnection.manageConnection().

310  {
311  return (this.containsKey(Options.protocol)
312  && this.getProperty(Options.protocol).equals("https"));
313  }

+ Here is the caller graph for this function:

boolean ai.heavy.jdbc.HeavyAIConnection.Connection_properties.isHttpsProtocol_insecure ( )
inlinepackage

Definition at line 305 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.protocol.

305  {
306  return (this.containsKey(Options.protocol)
307  && this.getProperty(Options.protocol).equals("https_insecure"));
308  }
void ai.heavy.jdbc.HeavyAIConnection.Connection_properties.validate_params ( ) throws SQLException
inlineprivate

Definition at line 239 of file HeavyAIConnection.java.

References ai.heavy.jdbc.Options.host_name, ai.heavy.jdbc.Options.max_rows, ai.heavy.jdbc.Options.option_order, ai.heavy.jdbc.Options.password, ai.heavy.jdbc.Options.port_num, ai.heavy.jdbc.Options.protocol, ai.heavy.jdbc.HeavyAIConnection.protocol_set, ai.heavy.jdbc.Options.server_trust_store, ai.heavy.jdbc.Options.server_trust_store_pwd, and ai.heavy.jdbc.Options.user.

Referenced by ai.heavy.jdbc.HeavyAIConnection.Connection_properties.Connection_properties().

239  {
240  // Warn if config values with invalid keys have been used.
241  for (String key : this.stringPropertyNames()) {
242  if (key != Options.user && key != Options.password
243  && !Arrays.asList(Options.option_order).contains(key)) {
244  logger.warn("Unsupported configuration key" + key + " used.");
245  }
246  }
247  // if present remove "//" from front of hostname
248  if (containsKey(Options.host_name)) {
249  String hN = this.getProperty(Options.host_name);
250  if (hN.startsWith("//")) {
251  this.setProperty(Options.host_name, hN.substring(2));
252  }
253  }
254 
255  // Default to binary if no protocol specified
256  String protocol = "binary";
257  if (this.containsKey(Options.protocol)) {
258  protocol = this.getProperty(Options.protocol);
259  protocol.toLowerCase();
260  if (!protocol_set.contains(protocol)) {
261  logger.warn("Incorrect protcol [" + protocol
262  + "] supplied. Possible values are [" + protocol_set.toString()
263  + "]. Using binary as default");
264  protocol = "binary";
265  }
266  }
267  this.setProperty(Options.protocol, protocol);
268 
269  if (this.containsKey(Options.port_num)) {
270  try {
271  Integer.parseInt(getProperty(Options.port_num));
272  } catch (NumberFormatException nfe) {
273  throw new SQLException(
274  "Invalid port number supplied" + getProperty(Options.port_num));
275  }
276  }
277 
278  if (this.containsKey(Options.server_trust_store)
279  && !this.containsKey(Options.server_trust_store_pwd)) {
280  logger.warn("server trust store ["
281  + (String) this.getProperty(Options.server_trust_store)
282  + " specfied without a password");
283  }
284  if (this.containsKey(Options.server_trust_store_pwd)
285  && !this.containsKey(Options.server_trust_store)) {
286  logger.warn("server trust store password specified without a keystore file");
287  }
288  if (!this.containsKey(Options.max_rows)) {
289  this.setProperty(Options.max_rows, "100000");
290  } else {
291  try {
292  Integer.parseInt(getProperty(Options.max_rows));
293  } catch (NumberFormatException nfe) {
294  throw new SQLException(
295  "Invalid value supplied for max rows " + getProperty(Options.max_rows));
296  }
297  }
298  }
static String server_trust_store

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: