public class QueryOptions extends Object
Modifier and Type | Field and Description |
---|---|
static ConsistencyLevel |
DEFAULT_CONSISTENCY_LEVEL
The default consistency level for queries:
ConsistencyLevel.LOCAL_ONE . |
static int |
DEFAULT_FETCH_SIZE
The default fetch size for SELECT queries: 5000.
|
static boolean |
DEFAULT_IDEMPOTENCE
The default value for
getDefaultIdempotence() : false . |
static int |
DEFAULT_MAX_PENDING_REFRESH_NODE_LIST_REQUESTS |
static int |
DEFAULT_MAX_PENDING_REFRESH_NODE_REQUESTS |
static int |
DEFAULT_MAX_PENDING_REFRESH_SCHEMA_REQUESTS |
static int |
DEFAULT_REFRESH_NODE_INTERVAL_MILLIS |
static int |
DEFAULT_REFRESH_NODE_LIST_INTERVAL_MILLIS |
static int |
DEFAULT_REFRESH_SCHEMA_INTERVAL_MILLIS |
static ConsistencyLevel |
DEFAULT_SERIAL_CONSISTENCY_LEVEL
The default serial consistency level for conditional updates:
ConsistencyLevel.SERIAL . |
Constructor and Description |
---|
QueryOptions()
Creates a new
QueryOptions instance using the DEFAULT_CONSISTENCY_LEVEL ,
DEFAULT_SERIAL_CONSISTENCY_LEVEL and DEFAULT_FETCH_SIZE . |
Modifier and Type | Method and Description |
---|---|
ConsistencyLevel |
getConsistencyLevel()
The default consistency level used by queries.
|
boolean |
getDefaultIdempotence()
The default idempotence for queries.
|
int |
getFetchSize()
The default fetch size used by queries.
|
int |
getMaxPendingRefreshNodeListRequests()
Sets the maximum number of node list refresh requests that the control connection can accumulate
before executing them.
|
int |
getMaxPendingRefreshNodeRequests()
The maximum number of node refresh requests that the control connection can accumulate
before executing them.
|
int |
getMaxPendingRefreshSchemaRequests()
The maximum number of schema refresh requests that the control connection can accumulate
before executing them.
|
int |
getRefreshNodeIntervalMillis()
The default window size in milliseconds used to debounce node refresh requests.
|
int |
getRefreshNodeListIntervalMillis()
The default window size in milliseconds used to debounce node list refresh requests.
|
int |
getRefreshSchemaIntervalMillis()
The default window size in milliseconds used to debounce schema refresh requests.
|
ConsistencyLevel |
getSerialConsistencyLevel()
The default serial consistency level used by queries.
|
boolean |
isMetadataEnabled()
Whether client-side token and schema metadata is enabled.
|
boolean |
isPrepareOnAllHosts()
Returns whether the driver should prepare statements on all hosts in the cluster.
|
boolean |
isReprepareOnUp()
Whether the driver should re-prepare all cached prepared statements on a host
when its marks that host back up.
|
QueryOptions |
setConsistencyLevel(ConsistencyLevel consistencyLevel)
Sets the default consistency level to use for queries.
|
QueryOptions |
setDefaultIdempotence(boolean defaultIdempotence)
Sets the default idempotence for queries.
|
QueryOptions |
setFetchSize(int fetchSize)
Sets the default fetch size to use for SELECT queries.
|
QueryOptions |
setMaxPendingRefreshNodeListRequests(int maxPendingRefreshNodeListRequests)
Sets the maximum number of node list refresh requests that the control connection can accumulate
before executing them.
|
QueryOptions |
setMaxPendingRefreshNodeRequests(int maxPendingRefreshNodeRequests)
Sets the maximum number of node refresh requests that the control connection can accumulate
before executing them.
|
QueryOptions |
setMaxPendingRefreshSchemaRequests(int maxPendingRefreshSchemaRequests)
Sets the maximum number of schema refresh requests that the control connection can accumulate
before executing them.
|
QueryOptions |
setMetadataEnabled(boolean enabled)
Toggle client-side token and schema metadata.
|
QueryOptions |
setPrepareOnAllHosts(boolean prepareOnAllHosts)
Set whether the driver should prepare statements on all hosts in the cluster.
|
QueryOptions |
setRefreshNodeIntervalMillis(int refreshNodeIntervalMillis)
Sets the default window size in milliseconds used to debounce node refresh requests.
|
QueryOptions |
setRefreshNodeListIntervalMillis(int refreshNodeListIntervalMillis)
Sets the default window size in milliseconds used to debounce node list refresh requests.
|
QueryOptions |
setRefreshSchemaIntervalMillis(int refreshSchemaIntervalMillis)
Sets the default window size in milliseconds used to debounce node list refresh requests.
|
QueryOptions |
setReprepareOnUp(boolean reprepareOnUp)
Set whether the driver should re-prepare all cached prepared statements on a host
when it marks it back up.
|
QueryOptions |
setSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel)
Sets the default serial consistency level to use for queries.
|
public static final ConsistencyLevel DEFAULT_CONSISTENCY_LEVEL
ConsistencyLevel.LOCAL_ONE
.public static final ConsistencyLevel DEFAULT_SERIAL_CONSISTENCY_LEVEL
ConsistencyLevel.SERIAL
.public static final int DEFAULT_FETCH_SIZE
public static final boolean DEFAULT_IDEMPOTENCE
getDefaultIdempotence()
: false
.public static final int DEFAULT_MAX_PENDING_REFRESH_NODE_LIST_REQUESTS
public static final int DEFAULT_MAX_PENDING_REFRESH_NODE_REQUESTS
public static final int DEFAULT_MAX_PENDING_REFRESH_SCHEMA_REQUESTS
public static final int DEFAULT_REFRESH_NODE_LIST_INTERVAL_MILLIS
public static final int DEFAULT_REFRESH_NODE_INTERVAL_MILLIS
public static final int DEFAULT_REFRESH_SCHEMA_INTERVAL_MILLIS
public QueryOptions()
QueryOptions
instance using the DEFAULT_CONSISTENCY_LEVEL
,
DEFAULT_SERIAL_CONSISTENCY_LEVEL
and DEFAULT_FETCH_SIZE
.public QueryOptions setConsistencyLevel(ConsistencyLevel consistencyLevel)
Statement.getConsistencyLevel()
returns null
.consistencyLevel
- the new consistency level to set as default.QueryOptions
instance.public ConsistencyLevel getConsistencyLevel()
public QueryOptions setSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel)
Statement.getSerialConsistencyLevel()
returns null
.serialConsistencyLevel
- the new serial consistency level to set as default.QueryOptions
instance.public ConsistencyLevel getSerialConsistencyLevel()
public QueryOptions setFetchSize(int fetchSize)
Statement.getFetchSize()
is less or equal to 0.fetchSize
- the new fetch size to set as default. It must be
strictly positive but you can use Integer.MAX_VALUE
to disable
paging.QueryOptions
instance.IllegalArgumentException
- if fetchSize <e; 0
.UnsupportedFeatureException
- if version 1 of the native protocol is in
use and fetchSize != Integer.MAX_VALUE
as paging is not supported by
version 1 of the protocol. See Cluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)
for more details on protocol versions.public int getFetchSize()
public QueryOptions setDefaultIdempotence(boolean defaultIdempotence)
Statement.isIdempotent()
returns null
.defaultIdempotence
- the new value to set as default idempotence.QueryOptions
instance.public boolean getDefaultIdempotence()
DEFAULT_IDEMPOTENCE
.public QueryOptions setPrepareOnAllHosts(boolean prepareOnAllHosts)
prepareOnAllHosts
- the new value to set to indicate whether to prepare
statements once or on all nodes.QueryOptions
instance.public boolean isPrepareOnAllHosts()
setPrepareOnAllHosts(boolean)
public QueryOptions setReprepareOnUp(boolean reprepareOnUp)
reprepareOnUp
- whether the driver should re-prepare when marking a node up.QueryOptions
instance.public boolean isReprepareOnUp()
setReprepareOnUp(boolean)
public QueryOptions setMetadataEnabled(boolean enabled)
Metadata
will return stale
or null/empty results (see the javadoc of each method for details);Metadata.newToken(String)
and
Metadata.newTokenRange(Token, Token)
will throw an exception if metadata
was disabled before startup;TokenAwarePolicy
will always delegate
to its child policy. Otherwise, it might not pick the best coordinator (i.e. chose
a host that is not a replica for the statement's routing key). In addition, statements
prepared while the metadata was disabled might also be sent to a non-optimal coordinator,
even if metadata was re-enabled later.enabled
- whether metadata is enabled.QueryOptions
instance.public boolean isMetadataEnabled()
setMetadataEnabled(boolean)
public QueryOptions setRefreshSchemaIntervalMillis(int refreshSchemaIntervalMillis)
refreshSchemaIntervalMillis
- The default window size in milliseconds used to debounce schema refresh requests.public int getRefreshSchemaIntervalMillis()
public QueryOptions setMaxPendingRefreshSchemaRequests(int maxPendingRefreshSchemaRequests)
maxPendingRefreshSchemaRequests
- The maximum number of schema refresh requests that the control connection can accumulate
before executing them.public int getMaxPendingRefreshSchemaRequests()
public QueryOptions setRefreshNodeListIntervalMillis(int refreshNodeListIntervalMillis)
refreshNodeListIntervalMillis
- The default window size in milliseconds used to debounce node list refresh requests.public int getRefreshNodeListIntervalMillis()
public QueryOptions setMaxPendingRefreshNodeListRequests(int maxPendingRefreshNodeListRequests)
maxPendingRefreshNodeListRequests
- The maximum number of node list refresh requests that the control connection can accumulate
before executing them.public int getMaxPendingRefreshNodeListRequests()
public QueryOptions setRefreshNodeIntervalMillis(int refreshNodeIntervalMillis)
refreshNodeIntervalMillis
- The default window size in milliseconds used to debounce node refresh requests.public int getRefreshNodeIntervalMillis()
public QueryOptions setMaxPendingRefreshNodeRequests(int maxPendingRefreshNodeRequests)
maxPendingRefreshNodeRequests
- The maximum number of node refresh requests that the control connection can accumulate
before executing them.public int getMaxPendingRefreshNodeRequests()