Package net.quasardb.qdb
Class Session
java.lang.Object
net.quasardb.qdb.Session
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder implementation for sessions.static enumCompression mode representationstatic classOptional configuration for establishing a secure connection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Session.Builderbuilder()Create a builder instance.voidclose()protected voidfinalize()longReturns the current input buffer size (in bytes).longReturns the current connection limit per qdbd host.longReturns the current input buffer size (in bytes).longReturns the maximum load of a single execution batch per thread.Returns information about the current memory usage.longhandle()booleanisClosed()voidLogs memory usage information through SLF4J facade with DEBUG log level.voidpurgeAll(int timeoutMillis) Purge all data from cluster.voidsetClientMaxParallelism(long threadCount) Set maximum client parallelism for this session.voidsetInputBufferSize(long size) Set input buffer size for this session.longsetSoftMemoryLimit(long limit) Sets the soft memory limit of the client.voidsetTimeout(int timeoutMillis) Set network timeout for this session.voidlongCleans up memory allocator and purged any unused cache.voidwaitForStabilization(int timeoutMillis) Wait for all nodes of the cluster to be stabilized.
-
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
Create a builder instance. Use this function to create new session objects and connect to the cluster. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public boolean isClosed() -
throwIfClosed
- Throws:
ClusterClosedException
-
finalize
-
handle
public long handle() -
setTimeout
Set network timeout for this session.- Parameters:
timeoutMillis- The timeout of the operation, in milliseconds- Throws:
ClusterClosedException- If QdbCluster.close() has been called.
-
setInputBufferSize
Set input buffer size for this session. Increase this if you encounterInputBufferTooSmallExceptionwhile 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
Returns the current input buffer size (in bytes).- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
setClientMaxParallelism
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
Returns the current input buffer size (in bytes).- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
getConnectionPerAddressSoftLimit
Returns the current connection limit per qdbd host.- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
getMaxBatchLoad
Returns the maximum load of a single execution batch per thread.- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
setSoftMemoryLimit
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
Returns information about the current memory usage.- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
logMemoryInfo
Logs memory usage information through SLF4J facade with DEBUG log level.- Throws:
ClusterClosedException- If the connection to the cluster is currently closed.
-
tidyMemory
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
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
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.
-