Class NoSQLHandleConfig

  • All Implemented Interfaces:
    Cloneable

    public class NoSQLHandleConfig
    extends Object
    implements Cloneable
    NoSQLHandleConfig groups parameters used to configure a NoSQLHandle. It also provides a way to default common parameters for use by NoSQLHandle methods. When creating a NoSQLHandle the NoSQLHandleConfig instance is copied so modification operations on the instance have no effect on existing handles which are immutable. Handle state with default values can be overridden in individual operations.

    Most of the configuration parameters are optional and have default values if not specified. The only required configuration is the service endpoint required by the constructor.

    • Constructor Detail

      • NoSQLHandleConfig

        public NoSQLHandleConfig​(String endpoint)
        Specifies an endpoint or region id to use to connect to the Oracle NoSQL Database Cloud Service or, if on-premise, the Oracle NoSQL Database proxy server.

        There is flexibility in how endpoints are specified. A fully specified endpoint is of the format:

            http[s]://host:port
        This interface accepts portions of a fully specified endpoint, including a region id (see Region) string if using the Cloud service.

        A valid endpoint is one of these:

        1. region id string (cloud service only)
        2. a string with the syntax [http[s]://]host[:port]

        For example, these are valid endpoint arguments:

        • us-ashburn-1
        • nosql.us-ashburn-1.oci.oraclecloud.com
        • https://nosql.us-ashburn-1.oci.oraclecloud.com:443
        • localhost:8080
        • https://machine-hosting-proxy:443

        If using the endpoint (vs region id) syntax, if the port is omitted, the endpoint defaults to 443. If the protocol is omitted, the endpoint uses https if the port is 443, and http in all other cases.

        If using the Cloud Service see Region for information on available regions. If using the Cloud Service the constructor, NoSQLHandleConfig(Region,AuthorizationProvider), is available rather than using a Region's id string.

        Parameters:
        endpoint - identifies a region id or server for use by the NoSQLHandle. This is a required parameter.
        Throws:
        IllegalArgumentException - if the endpoint is null or malformed.
      • NoSQLHandleConfig

        public NoSQLHandleConfig​(String endpoint,
                                 AuthorizationProvider provider)
        Specifies an endpoint or region id to use to connect to the Oracle NoSQL Database Cloud Service or, if on-premise, the Oracle NoSQL Database proxy server. In addition an AuthorizationProvider is specified.

        There is flexibility in how endpoints are specified. A fully specified endpoint is of the format:

            http[s]://host:port
        This interface accepts portions of a fully specified endpoint, including a region id (see Region) string if using the Cloud service.

        A valid endpoint is one of these:

        1. region id string (cloud service only)
        2. a string with the syntax [http[s]://]host[:port]

        For example, these are valid endpoint arguments:

        • us-ashburn-1
        • nosql.us-ashburn-1.oci.oraclecloud.com
        • https://nosql.us-ashburn-1.oci.oraclecloud.com:443
        • localhost:8080
        • https://machine-hosting-proxy:443

        If using the endpoint (vs region id) syntax, if the port is omitted, the endpoint defaults to 443. If the protocol is omitted, the endpoint uses https if the port is 443, and http in all other cases.

        If using the Cloud Service see Region for information on available regions. If using the Cloud Service the constructor, NoSQLHandleConfig(Region,AuthorizationProvider), is available rather than using a Region's id string.

        Parameters:
        endpoint - identifies a region id or server for use by the NoSQLHandle. This is a required parameter.
        provider - the AuthorizationProvider to use for the handle
        Throws:
        IllegalArgumentException - if the endpoint is null or malformed.
      • NoSQLHandleConfig

        public NoSQLHandleConfig​(Region region,
                                 AuthorizationProvider provider)
        Cloud service only.

        Specify a region to use to connect to the Oracle NoSQL Database Cloud Service. The service endpoint will be inferred from the given region. This is the recommended constructor for applications using the Oracle NoSQL Database Cloud Service.

        Parameters:
        region - identifies the region will be accessed by the NoSQLHandle.
        provider - the AuthorizationProvider to use for the handle
        Throws:
        IllegalArgumentException - if the region is null or malformed.
      • NoSQLHandleConfig

        public NoSQLHandleConfig​(AuthorizationProvider provider)
        Cloud service only.

        Specify a AuthorizationProvider to use to connect to the Oracle NoSQL Database Cloud Service. The service endpoint will be inferred from the given provider. This is the recommended constructor for applications using the Oracle NoSQL Database Cloud Service.

        Parameters:
        provider - the AuthorizationProvider to use for the handle
        Throws:
        IllegalArgumentException - if the region is null or malformed.
    • Method Detail

      • getLibraryVersion

        public static String getLibraryVersion()
        Returns the version of the driver implemented by this library.
        Returns:
        the version as a string
      • getServiceURL

        public URL getServiceURL()
        Returns the URL to use for the NoSQLHandle connection
        Returns:
        the URL.
      • getRegion

        public Region getRegion()
        Cloud service only.

        Returns the region will be accessed by the NoSQLHandle.

        Returns:
        the region.
      • getRequestTimeout

        public int getRequestTimeout()
        Returns the configured request timeout value, in milliseconds.
        Returns:
        the timeout, in milliseconds, or 0 if it has not been set
      • getDefaultRequestTimeout

        public int getDefaultRequestTimeout()
        Returns the default value for request timeout. If there is no configured timeout or it is configured as 0, a "default" default value of 5000 milliseconds is used.
        Returns:
        the default timeout, in milliseconds
      • getTableRequestTimeout

        public int getTableRequestTimeout()
        Returns the configured table request timeout value, in milliseconds. The table request timeout default can be specified independently to allow it to be larger than a typical data request. If it is not specified the default table request timeout of 10000 is used.
        Returns:
        the timeout, in milliseconds, or 0 if it has not been set
      • getDefaultTableRequestTimeout

        public int getDefaultTableRequestTimeout()
        Returns the default value for a table request timeout. If there is no configured timeout or it is configured as 0, a "default" default value of 10000 milliseconds is used.
        Returns:
        the default timeout, in milliseconds
      • getConsistency

        public Consistency getConsistency()
        Returns the configured default consistency
        Returns:
        the Consistency, or null if it has not been configured
      • getRetryHandler

        public RetryHandler getRetryHandler()
        Returns the RetryHandler configured for the handle, or null if none is set.
        Returns:
        the handler
      • setRequestTimeout

        public NoSQLHandleConfig setRequestTimeout​(int timeout)
        Sets the default request timeout. The default timeout is 5 seconds.
        Parameters:
        timeout - the timeout value, in milliseconds
        Returns:
        this
      • setTableRequestTimeout

        public NoSQLHandleConfig setTableRequestTimeout​(int tableRequestTimeout)
        Sets the default table request timeout. The table request timeout can be specified independently of that specified by setRequestTimeout(int) because table requests can take longer and justify longer timeouts. The default timeout is 10 seconds (10000 milliseconds).
        Parameters:
        tableRequestTimeout - the timeout value, in milliseconds
        Returns:
        this
      • setNumThreads

        public NoSQLHandleConfig setNumThreads​(int numThreads)
        Sets the number of threads to use for handling network traffic. This number affects the performance of concurrent requests in a multithreaded application. If set to 0 or not modified the default is the number of CPUs available * 2
        Parameters:
        numThreads - the number
        Returns:
        this
      • setConnectionPoolSize

        @Deprecated
        public NoSQLHandleConfig setConnectionPoolSize​(int poolSize)
        Deprecated.
        The connection pool no longer supports a size setting. It will expand as needed based on concurrent demand.
        Sets the maximum number of individual connections to use to connect to the service. Each request/response pair uses a connection. The pool exists to allow concurrent requests and will bound the number of concurrent requests. Additional requests will wait for a connection to become available. If requests need to wait for a significant time additional connections may be created regardless of the pool size. The default value if not set is number of available CPUs * 2.
        Parameters:
        poolSize - the pool size
        Returns:
        this
      • setConnectionPoolMinSize

        public NoSQLHandleConfig setConnectionPoolMinSize​(int poolMinSize)
        Sets the minimum number of connections to keep in the connection pool when the connections are inactive. This number is used to generate keep-alive messages that prevent this many connections from timing out in environments that can time out, such as the NoSQL Cloud Service. This setting can reduce the latency required to re-create secure connections after an application goes idle for a while (minutes).

        If this value is 0 (default) the minimum is set to 2. If set to -1 then all connections are allowed to time out. If the number of connections in the pool never reaches this minimum, but the minimum is set, those connections will be kept alive. Additional connections are only created on demand. This setting can be thought of as a low-water mark.

        Parameters:
        poolMinSize - the minimum pool size
        Returns:
        this
        Since:
        5.3.2
      • setPoolMaxPending

        @Deprecated
        public NoSQLHandleConfig setPoolMaxPending​(int poolMaxPending)
        Deprecated.
        The connection pool no longer supports pending requests.
        Sets the maximum number of pending acquire operations allowed on the connection pool. This number is used if the degree of concurrency desired exceeds the size of the connection pool temporarily. The default value is 3.
        Parameters:
        poolMaxPending - the maximum number allowed
        Returns:
        this
      • setMaxContentLength

        public NoSQLHandleConfig setMaxContentLength​(int maxContentLength)
        Sets the maximum size in bytes of request/response payloads. On-premises only. This setting is ignored for cloud operations. If not set, or set to zero, the default value of 32MB is used.
        Parameters:
        maxContentLength - the maximum bytes allowed in requests/responses. Pass zero to use the default.
        Returns:
        this
      • getMaxContentLength

        public int getMaxContentLength()
        Returns the maximum size, in bytes, of a request operation payload. On-premises only. This value is ignored for cloud operations.
        Returns:
        the size
      • getConnectionPoolSize

        @Deprecated
        public int getConnectionPoolSize()
        Deprecated.
        The connection pool no longer supports a size setting. It will expand as needed based on concurrent demand.
        Returns the maximum number of individual connections to use to connect to the service. Each request/response pair uses a connection. The pool exists to allow concurrent requests and will bound the number of concurrent requests. Additional requests will wait for a connection to become available.
        Returns:
        0
      • getConnectionPoolMinSize

        public int getConnectionPoolMinSize()
        Returns the minimum number of connections to keep alive in the connection pool.
        Returns:
        the minimum pool size or 0 if not set
        Since:
        5.3.2
      • getPoolMaxPending

        @Deprecated
        public int getPoolMaxPending()
        Deprecated.
        The connection pool no longer supports pending requests.
        Returns the maximum number of pending acquire operations allowed on the connection pool.
        Returns:
        0
      • getNumThreads

        public int getNumThreads()
        Returns the number of threads to use for handling network traffic.
        Returns:
        the number of threads or 0 if not set
      • setRetryHandler

        public NoSQLHandleConfig setRetryHandler​(RetryHandler retryHandler)
        Sets the RetryHandler to use for the handle. If no handler is configured a default is used. The handler must be safely usable by multiple threads.
        Parameters:
        retryHandler - the handler
        Returns:
        this
      • setRateLimitingEnabled

        public NoSQLHandleConfig setRateLimitingEnabled​(boolean enable)
        Enables internal rate limiting. Cloud service only.
        Parameters:
        enable - If true, enable internal rate limiting. If false, disable internal rate limiting.
        Returns:
        this
      • setDefaultRateLimitingPercentage

        public void setDefaultRateLimitingPercentage​(double percent)
        Sets a default rate limiter use percentage. Cloud service only.

        Sets a default percentage of table limits to use. This may be useful for cases where a client should only use a portion of full table limits. This only applies if rate limiting is enabled using setRateLimitingEnabled(boolean).

        The default for this value is 100.0 (full table limits).

        Parameters:
        percent - the percentage of table limits to use. This value must be positive.
      • configureDefaultRetryHandler

        public NoSQLHandleConfig configureDefaultRetryHandler​(int numRetries,
                                                              int delayMS)
        Sets the RetryHandler using a default retry handler configured with the specified number of retries and a static delay. A delay of 0 means "use the default delay algorithm" which is an incremental backoff algorithm. A non-zero delay will work but is not recommended for production systems as it is not flexible.

        The default retry handler will not retry exceptions of type OperationThrottlingException. The reason is that these operations are long-running, and while technically they can be retried, an immediate retry is unlikely to succeed because of the low rates allowed for these operations.

        Parameters:
        numRetries - the number of retries to perform automatically. This parameter may be 0 for no retries.
        delayMS - the delay, in milliseconds. Pass 0 to use the default delay algorithm.
        Returns:
        this
      • setLogger

        public NoSQLHandleConfig setLogger​(Logger logger)
        Sets the Logger used for the driver.
        Parameters:
        logger - the Logger.
        Returns:
        this
      • getLogger

        public Logger getLogger()
        Returns the Logger, or null if not configured by user.
        Returns:
        the Logger
      • setDefaultCompartment

        public NoSQLHandleConfig setDefaultCompartment​(String compartment)
        Cloud service only. Sets the default compartment to use for requests sent using the handle. Setting the default is optional and if set it is overridden by any compartment specified in a request or table name. If no compartment is set for a request, either using this default or by specification in a request, the behavior varies with how the application is authenticated.
        • If authenticated with a user identity the default is the root compartment of the tenancy
        • If authenticated as an instance principal (see SignatureProvider.createWithInstancePrincipal()) the compartment id (OCID )must be specified by either using this method or in each Request object. If not an exception is thrown
        Parameters:
        compartment - may be either the name of a compartment or the id (OCID) of a compartment.
        Returns:
        this
      • getDefaultCompartment

        public String getDefaultCompartment()
        Cloud service only. Returns the default compartment to use for requests or null if not set. The value may be a compartment name or id, as set by setDefaultCompartment(java.lang.String).
        Returns:
        the compartment
      • setDefaultNamespace

        public NoSQLHandleConfig setDefaultNamespace​(String defaultNamespace)
        Set the default namespace to use for the handle. On-premises only. Sets the default namespace to use for requests sent using the handle. This is an optional convenience method to avoid having to add the namespace to table names in requests and SQL statements. Any non-namespace qualified table name in requests and/or SQL statements will be resolved/qualified to the specified namespace. This value can be overridden on a per-request basis by calling setNamespace() on individual requests.
        Parameters:
        defaultNamespace - the default namespace to use
        Returns:
        this
        Since:
        5.4.10
      • getDefaultNamespace

        public String getDefaultNamespace()
        Get the default namespace. On-premises only. Returns the default namespace to use for requests or null if not set.
        Returns:
        the default namespace
        Since:
        5.4.10
      • getSSLCipherSuites

        public List<String> getSSLCipherSuites()
        Returns the SSL cipher suites to enable.
        Returns:
        cipher suites.
      • getSSLProtocols

        public String[] getSSLProtocols()
        Returns the SSL protocols to enable.
        Returns:
        cipher suites.
      • getSSLSessionTimeout

        public int getSSLSessionTimeout()
        Returns the configured SSLSession objects timeout, in seconds.
        Returns:
        the timeout, in seconds, or 0 if it has not been set
      • getSSLSessionCacheSize

        public int getSSLSessionCacheSize()
        Returns the configured size of cache used to store SSLSession objects.
        Returns:
        the cache size
      • getSSLHandshakeTimeout

        public int getSSLHandshakeTimeout()
        Returns the configured SSL handshake timeout, in milliseconds.
        Returns:
        the timeout, in milliseconds, or 0 if it has not been set
        Since:
        5.3.2
      • setSSLCipherSuites

        public NoSQLHandleConfig setSSLCipherSuites​(String... cipherSuites)
        Set SSL cipher suites to enable, in the order of preference. null to use default cipher suites.
        Parameters:
        cipherSuites - cipher suites list
        Returns:
        this
      • setSSLProtocols

        public NoSQLHandleConfig setSSLProtocols​(String... sslProtocols)
        Set SSL protocols to enable, in the order of preference. null to use default protocols.
        Parameters:
        sslProtocols - SSL protocols list
        Returns:
        this
      • setSSLSessionCacheSize

        public NoSQLHandleConfig setSSLSessionCacheSize​(int cacheSize)
        Sets the size of the cache used for storing SSL session objects, 0 to use the default value, no size limit.
        Parameters:
        cacheSize - the size of SSLSession objects.
        Returns:
        this
      • setSSLSessionTimeout

        public NoSQLHandleConfig setSSLSessionTimeout​(int timeout)
        Sets the timeout for the cached SSL session objects, in seconds. 0 to use the default value, no limit. When the timeout limit is exceeded for a session, the SSLSession object is invalidated and future connections cannot resume or rejoin the session.
        Parameters:
        timeout - the session timeout
        Returns:
        this
      • setSSLHandshakeTimeout

        public NoSQLHandleConfig setSSLHandshakeTimeout​(int timeout)
        Sets the timeout for the SSL handshake, in milliseconds. 0 to use the default value, 3000 milliseconds. In general the default works. This value can be set to help debug suspected SSL issues and force retries within the request timeout period.
        Parameters:
        timeout - the SSL handshake timeout
        Returns:
        this
        Since:
        5.3.2
      • setProxyHost

        public NoSQLHandleConfig setProxyHost​(String proxyHost)
        Sets an HTTP proxy host to be used for the session. If a proxy host is specified a proxy port must also be specified, using setProxyPort(int).
        Parameters:
        proxyHost - the proxy host
        Returns:
        this
      • setProxyUsername

        public NoSQLHandleConfig setProxyUsername​(String proxyUsername)
        Sets an HTTP proxy user name if the configured proxy host requires authentication. If a proxy host is not configured this configuration is ignored. If a proxy user name is configure a proxy password must also be configured, using setProxyPassword(java.lang.String).
        Parameters:
        proxyUsername - the user name
        Returns:
        this
      • setProxyPassword

        public NoSQLHandleConfig setProxyPassword​(String proxyPassword)
        Sets an HTTP proxy password if the configured proxy host requires authentication. If a proxy password is configured a proxy user name must also be configured using setProxyUsername(java.lang.String).
        Parameters:
        proxyPassword - the password
        Returns:
        this
      • setProxyPort

        public NoSQLHandleConfig setProxyPort​(int proxyPort)
        Sets an HTTP proxy port to be used for the session. If a proxy port is specified a proxy host must also be specified, using setProxyHost(java.lang.String).
        Parameters:
        proxyPort - the proxy port
        Returns:
        this
      • setStatsInterval

        public NoSQLHandleConfig setStatsInterval​(int statsInterval)
        Sets interval size in seconds for logging statistics. Default interval is 600 seconds, i.e. 10 min.
        Parameters:
        statsInterval - stats logging interval in seconds
        Returns:
        this
        Since:
        5.2.30
      • getStatsInterval

        public int getStatsInterval()
        Returns the current interval for logging statistics. Default interval is 600 seconds, i.e. 10 min.
        Returns:
        the current interval in seconds
        Since:
        5.2.30
      • setStatsProfile

        public NoSQLHandleConfig setStatsProfile​(StatsControl.Profile statsProfile)
        Set the statistics collection profile. Default profile is NONE.
        Parameters:
        statsProfile - profile to use
        Returns:
        this
        Since:
        5.2.30
      • getStatsProfile

        public StatsControl.Profile getStatsProfile()
        Returns the statistics collection profile. Default profile is NONE.
        Returns:
        the current profile
        Since:
        5.2.30
      • setStatsPrettyPrint

        public NoSQLHandleConfig setStatsPrettyPrint​(boolean statsPrettyPrint)
        Enable JSON pretty print for easier human reading when logging statistics. Default is disabled.
        Parameters:
        statsPrettyPrint - flag to enable JSON pretty print
        Returns:
        this
        Since:
        5.2.30
      • getStatsPrettyPrint

        public boolean getStatsPrettyPrint()
        Returns the current JSON pretty print flag for logging statistics. Default is disabled.
        Returns:
        the current JSON pretty print flag
        Since:
        5.2.30
      • setStatsEnableLog

        public NoSQLHandleConfig setStatsEnableLog​(boolean statsEnableLog)
        When stats are enabled the logging is automatically turned on. Setting this to false avoids turning the log on when enabling stats. Default is on.
        Parameters:
        statsEnableLog - flag to enable JSON pretty print
        Returns:
        this
        Since:
        5.2.30
      • getStatsEnableLog

        public boolean getStatsEnableLog()
        Returns the current value of enabling the log when stats are turned on. Default is enabled.
        Returns:
        the current state of stats enable log flag.
        Since:
        5.2.30
      • setStatsHandler

        public NoSQLHandleConfig setStatsHandler​(StatsControl.StatsHandler statsHandler)
        Registers a handler that is called every time the statistics are logged. Note: setting a stats handler will not affect the stats log entries.
        Parameters:
        statsHandler - User defined StatsHandler.
        Returns:
        this
        Since:
        5.2.30
      • getStatsHandler

        public StatsControl.StatsHandler getStatsHandler()
        Returns the registered statistics handler, otherwise null.
        Returns:
        this
        Since:
        5.2.30
      • getExtensionUserAgent

        public String getExtensionUserAgent()
        Returns the set extension to the user agent http header or null if unset.
        Returns:
        the extension to the user agent http header
        Since:
        5.3.3
      • setExtensionUserAgent

        public void setExtensionUserAgent​(String extensionUserAgent)
        Sets an extension to the user agent http header. Extension can be up to 64 bytes in length.
        Parameters:
        extensionUserAgent - the new extension
        Since:
        5.3.3