Class Session

java.lang.Object
net.quasardb.qdb.Session
All Implemented Interfaces:
AutoCloseable

public class Session extends Object implements AutoCloseable
Represents a session with the QuasarDB cluster. This class is not thread-safe. As instantiations of this class are expensive (especially when secure connections are used), you are encouraged to pool instances of this class are you would do with any other connection pool.
  • Constructor Details

    • Session

      public Session()
      Open a new session. This is the equivalent of opening a socket but not yet connecting to it.
  • Method Details

    • builder

      public static Session.Builder builder()
      Create a builder instance. Use this function to create new session objects and connect to the cluster.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      public boolean isClosed()
    • throwIfClosed

      public void throwIfClosed() throws ClusterClosedException
      Throws:
      ClusterClosedException
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • handle

      public long handle()
    • setTimeout

      public void setTimeout(int timeoutMillis) throws ClusterClosedException
      Set network timeout for this session.
      Parameters:
      timeoutMillis - The timeout of the operation, in milliseconds
      Throws:
      ClusterClosedException - If QdbCluster.close() has been called.
    • setInputBufferSize

      public void setInputBufferSize(long size) throws ClusterClosedException
      Set input buffer size for this session. Increase this if you encounter InputBufferTooSmallException while retrieving data from the server.
      Parameters:
      size - The desired size (in bytes) of the input buffer.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • getInputBufferSize

      public long getInputBufferSize() throws ClusterClosedException
      Returns the current input buffer size (in bytes).
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • setClientMaxParallelism

      public void setClientMaxParallelism(long threadCount) throws ClusterClosedException
      Set maximum client parallelism for this session.
      Parameters:
      threadCount - The desired maximum number of threads to use for query execution, or 0
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • getClientMaxParallelism

      public long getClientMaxParallelism() throws ClusterClosedException
      Returns the current input buffer size (in bytes).
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • getConnectionPerAddressSoftLimit

      public long getConnectionPerAddressSoftLimit() throws ClusterClosedException
      Returns the current connection limit per qdbd host.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • getMaxBatchLoad

      public long getMaxBatchLoad() throws ClusterClosedException
      Returns the maximum load of a single execution batch per thread.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • setSoftMemoryLimit

      public long setSoftMemoryLimit(long limit) throws ClusterClosedException
      Sets the soft memory limit of the client. This sets the desired limit of the off-heap memory buffer the QuasarDB C API will maintain.
      Parameters:
      limit - The desired soft limit (in bytes)
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • getMemoryInfo

      public String getMemoryInfo() throws ClusterClosedException
      Returns information about the current memory usage.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • logMemoryInfo

      public void logMemoryInfo() throws ClusterClosedException
      Logs memory usage information through SLF4J facade with DEBUG log level.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • tidyMemory

      public long tidyMemory() throws ClusterClosedException
      Cleans up memory allocator and purged any unused cache. Acquires a global lock on the memory allocator and temporarily pauses all threads, use with caution.
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • waitForStabilization

      public void waitForStabilization(int timeoutMillis) throws ClusterClosedException
      Wait for all nodes of the cluster to be stabilized.
      Parameters:
      timeoutMillis - The timeout of the operation, in milliseconds
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.
    • purgeAll

      public void purgeAll(int timeoutMillis) throws ClusterClosedException
      Purge all data from cluster. Useful for integration testing.
      Parameters:
      timeoutMillis - The timeout of the operation, in milliseconds
      Throws:
      ClusterClosedException - If the connection to the cluster is currently closed.