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 class
Builder implementation for sessions.static enum
Compression mode representationstatic class
Optional configuration for establishing a secure connection. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Session.Builder
builder()
Create a builder instance.void
close()
protected void
finalize()
long
Returns the current input buffer size (in bytes).long
Returns the current connection limit per qdbd host.long
Returns the current input buffer size (in bytes).long
Returns the maximum load of a single execution batch per thread.Returns information about the current memory usage.long
handle()
boolean
isClosed()
void
Logs memory usage information through SLF4J facade with DEBUG log level.void
purgeAll
(int timeoutMillis) Purge all data from cluster.void
setClientMaxParallelism
(long threadCount) Set maximum client parallelism for this session.void
setInputBufferSize
(long size) Set input buffer size for this session.long
setSoftMemoryLimit
(long limit) Sets the soft memory limit of the client.void
setTimeout
(int timeoutMillis) Set network timeout for this session.void
long
Cleans up memory allocator and purged any unused cache.void
waitForStabilization
(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:
close
in 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 encounterInputBufferTooSmallException
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
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.
-