Class CommonSettings

java.lang.Object
com.clickhouse.client.api.internal.CommonSettings

public class CommonSettings extends Object
Class representing very common logic across all setting objects like setting database, getting option
  • Field Details

  • Constructor Details

    • CommonSettings

      public CommonSettings()
  • Method Details

    • getOption

      public Object getOption(String option)
      Gets a configuration option.
      Parameters:
      option - - configuration option name
      Returns:
      configuration option value
    • getOption

      public Object getOption(String option, Object defaultValue)
      Gets a configuration option. If not set then defaultValue is returned.
      Parameters:
      option - - config option key
      defaultValue - - default option to return when option is not set
      Returns:
      configuration option value
    • hasOption

      public boolean hasOption(String option)
    • setOption

      public CommonSettings setOption(String option, Object value)
      Sets a configuration option. This method can be used to set any configuration option. There is no specific validation is done on the key or value.
      Parameters:
      option - - configuration option name
      value - - configuration option value
    • resetOption

      public CommonSettings resetOption(String option)
    • getAllSettings

      public Map<String,Object> getAllSettings()
      Get all settings as an unmodifiable map.
      Returns:
      all settings
    • getQueryId

      public String getQueryId()
    • setQueryId

      public CommonSettings setQueryId(String queryId)
      Sets the query id. This id will be sent to the server and can be used to identify the query.
    • getOperationId

      public String getOperationId()
      Operation id. Used internally to register new operation. Should not be called directly.
    • setOperationId

      public CommonSettings setOperationId(String operationId)
      Operation id. Used internally to register new operation. Should not be called directly.
      Parameters:
      operationId - - operation id
    • setDatabase

      public CommonSettings setDatabase(String database)
      Sets database to be used for a request.
    • getDatabase

      public String getDatabase()
    • httpHeader

      public CommonSettings httpHeader(String key, String value)
      Defines list of headers that should be sent with current request. The Client will use a header value defined in headers instead of any other.
      Parameters:
      key - - header name.
      value - - header value.
      Returns:
      same instance of the builder
      See Also:
    • httpHeader

      public CommonSettings httpHeader(String key, Collection<String> values)
      but for multiple values.
      Parameters:
      key - - name of the header
      values - - collection of values
      Returns:
      same instance of the builder
    • httpHeaders

      public CommonSettings httpHeaders(Map<String,String> headers)
      but for multiple headers.
      Parameters:
      headers - - map of headers
      Returns:
      same instance of the builder
    • serverSetting

      public CommonSettings serverSetting(String name, String value)
      Defines list of server settings that should be sent with each request. The Client will use a setting value defined in settings instead of any other. Operation settings may override these values.
      Parameters:
      name - - name of the setting
      value - - value of the setting
      Returns:
      same instance of the builder
      See Also:
    • serverSetting

      public CommonSettings serverSetting(String name, Collection<String> values)
      but for multiple values.
      Parameters:
      name - - name of the setting without special prefix
      values - - collection of values
      Returns:
      same instance of the builder
    • setDBRoles

      public CommonSettings setDBRoles(Collection<String> dbRoles)
      Sets DB roles for an operation. Roles that were set by Client.setDBRoles(Collection) will be overridden.
      Parameters:
      dbRoles -
    • getDBRoles

      public Collection<String> getDBRoles()
      Gets DB roles for an operation.
      Returns:
      list of DB roles
    • logComment

      public CommonSettings logComment(String logComment)
      Sets the comment that will be added to the query log record associated with the query.
      Parameters:
      logComment - - comment to be added to the log
      Returns:
      same instance of the builder
    • getLogComment

      public String getLogComment()
    • setNetworkTimeout

      public void setNetworkTimeout(long timeout, ChronoUnit unit)
      Sets a network operation timeout.
      Parameters:
      timeout -
      unit -
    • getNetworkTimeout

      public Long getNetworkTimeout()
      Returns network timeout. Zero value is returned if no timeout is set.
      Returns:
      timeout in ms.
    • copyAndMerge

      public CommonSettings copyAndMerge(CommonSettings override)