public class CassandraCqlClusterFactoryBean extends Object implements FactoryBean<com.datastax.driver.core.Cluster>, InitializingBean, DisposableBean, BeanNameAware, PersistenceExceptionTranslator
FactoryBean for configuring a Cassandra Cluster.InitializingBean,
DisposableBean,
FactoryBean,
Cluster| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONTACT_POINTS |
static boolean |
DEFAULT_JMX_REPORTING_ENABLED |
static int |
DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS |
static boolean |
DEFAULT_METRICS_ENABLED |
static int |
DEFAULT_PORT |
static boolean |
DEFAULT_SSL_ENABLED |
protected static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
CassandraCqlClusterFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
destroy() |
protected void |
executeSpecsAndScripts(List<? extends KeyspaceActionSpecification<?>> kepspaceActionSpecifications,
List<String> scripts) |
List<CreateKeyspaceSpecification> |
getKeyspaceCreations() |
List<DropKeyspaceSpecification> |
getKeyspaceDrops() |
Set<KeyspaceActionSpecification<?>> |
getKeyspaceSpecifications() |
com.datastax.driver.core.Cluster |
getObject() |
Class<? extends com.datastax.driver.core.Cluster> |
getObjectType() |
List<String> |
getShutdownScripts() |
List<String> |
getStartupScripts() |
boolean |
isSingleton() |
void |
setAddressTranslator(com.datastax.driver.core.policies.AddressTranslator addressTranslator)
Configures the address translator used by the new cluster to translate IP addresses received
from Cassandra nodes into locally query-able addresses.
|
void |
setAuthProvider(com.datastax.driver.core.AuthProvider authProvider)
Set the
AuthProvider. |
void |
setBeanName(String beanName) |
void |
setClusterBuilderConfigurer(ClusterBuilderConfigurer clusterBuilderConfigurer)
Sets the
ClusterBuilderConfigurer used to apply additional configuration logic to the
Cluster.Builder. |
void |
setClusterName(String clusterName)
An optional name for the cluster instance.
|
void |
setCompressionType(CompressionType compressionType)
Set the
CompressionType. |
void |
setContactPoints(String contactPoints)
Set a comma-delimited string of the contact points (hosts) to connect to.
|
void |
setHostStateListener(com.datastax.driver.core.Host.StateListener hostStateListener) |
void |
setJmxReportingEnabled(boolean jmxReportingEnabled)
Set whether to use JMX reporting.
|
void |
setKeyspaceCreations(List<CreateKeyspaceSpecification> specifications)
|
void |
setKeyspaceDrops(List<DropKeyspaceSpecification> specifications)
|
void |
setKeyspaceSpecifications(Set<KeyspaceActionSpecification<?>> keyspaceSpecifications) |
void |
setLatencyTracker(com.datastax.driver.core.LatencyTracker latencyTracker) |
void |
setLoadBalancingPolicy(com.datastax.driver.core.policies.LoadBalancingPolicy loadBalancingPolicy)
Set the
LoadBalancingPolicy that decides which Cassandra hosts to contact for each new query. |
void |
setMaxSchemaAgreementWaitSeconds(int seconds)
Sets the maximum time to wait for schema agreement before returning from a DDL query.
|
void |
setMetricsEnabled(boolean metricsEnabled)
Set whether metrics are enabled.
|
void |
setNettyOptions(com.datastax.driver.core.NettyOptions nettyOptions)
Set the
NettyOptions used by a client to customize the driver's underlying Netty layer. |
void |
setPassword(String password)
Set the username to use with
PlainTextAuthProvider. |
void |
setPoolingOptions(com.datastax.driver.core.PoolingOptions poolingOptions)
Set the
PoolingOptions to configure the connection pooling behavior. |
void |
setPort(int port)
Set the port for the contact points.
|
void |
setProtocolVersion(com.datastax.driver.core.ProtocolVersion protocolVersion)
Set the
ProtocolVersion. |
void |
setQueryOptions(com.datastax.driver.core.QueryOptions queryOptions)
Set the
QueryOptions to tune to defaults for individual queries. |
void |
setReconnectionPolicy(com.datastax.driver.core.policies.ReconnectionPolicy reconnectionPolicy)
Set the
ReconnectionPolicy that decides how often the reconnection to a dead node is attempted. |
void |
setRetryPolicy(com.datastax.driver.core.policies.RetryPolicy retryPolicy)
Set the
RetryPolicy that defines a default behavior to adopt when a request fails. |
void |
setShutdownScripts(List<String> scripts)
|
void |
setSocketOptions(com.datastax.driver.core.SocketOptions socketOptions)
Set the
SocketOptions containing low-level socket options. |
void |
setSpeculativeExecutionPolicy(com.datastax.driver.core.policies.SpeculativeExecutionPolicy speculativeExecutionPolicy)
Configures the speculative execution policy to use for the new cluster.
|
void |
setSslEnabled(boolean sslEnabled)
Set whether to use SSL.
|
void |
setSslOptions(com.datastax.driver.core.SSLOptions sslOptions) |
void |
setStartupScripts(List<String> scripts)
|
void |
setTimestampGenerator(com.datastax.driver.core.TimestampGenerator timestampGenerator)
Configures the generator that will produce the client-side timestamp sent with each query.
|
void |
setUsername(String username)
Set the username to use with
PlainTextAuthProvider. |
DataAccessException |
translateExceptionIfPossible(RuntimeException ex) |
public static final boolean DEFAULT_JMX_REPORTING_ENABLED
public static final boolean DEFAULT_METRICS_ENABLED
public static final boolean DEFAULT_SSL_ENABLED
public static final int DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS
public static final int DEFAULT_PORT
public static final String DEFAULT_CONTACT_POINTS
protected static final org.slf4j.Logger log
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionpublic void destroy()
throws Exception
destroy in interface DisposableBeanExceptionpublic com.datastax.driver.core.Cluster getObject()
getObject in interface FactoryBean<com.datastax.driver.core.Cluster>public Class<? extends com.datastax.driver.core.Cluster> getObjectType()
getObjectType in interface FactoryBean<com.datastax.driver.core.Cluster>public boolean isSingleton()
isSingleton in interface FactoryBean<com.datastax.driver.core.Cluster>public DataAccessException translateExceptionIfPossible(RuntimeException ex)
translateExceptionIfPossible in interface PersistenceExceptionTranslatorprotected void executeSpecsAndScripts(List<? extends KeyspaceActionSpecification<?>> kepspaceActionSpecifications, List<String> scripts)
public void setBeanName(String beanName)
setBeanName in interface BeanNameAwarepublic void setContactPoints(String contactPoints)
localhost;
see DEFAULT_CONTACT_POINTS.contactPoints - the contact points used by the new cluster.public void setPort(int port)
9042, see DEFAULT_PORT.port - the port used by the new cluster.public void setCompressionType(CompressionType compressionType)
CompressionType. Default is uncompressed.compressionType - the CompressionType used by the new cluster.public void setPoolingOptions(com.datastax.driver.core.PoolingOptions poolingOptions)
PoolingOptions to configure the connection pooling behavior.poolingOptions - the PoolingOptions used by the new cluster.public void setProtocolVersion(com.datastax.driver.core.ProtocolVersion protocolVersion)
ProtocolVersion.protocolVersion - the ProtocolVersion used by the new cluster.public void setSocketOptions(com.datastax.driver.core.SocketOptions socketOptions)
SocketOptions containing low-level socket options.socketOptions - the SocketOptions used by the new cluster.public void setQueryOptions(com.datastax.driver.core.QueryOptions queryOptions)
QueryOptions to tune to defaults for individual queries.queryOptions - the QueryOptions used by the new cluster.public void setAuthProvider(com.datastax.driver.core.AuthProvider authProvider)
AuthProvider. Default is unauthenticated.authProvider - the AuthProvider used by the new cluster.public void setNettyOptions(com.datastax.driver.core.NettyOptions nettyOptions)
NettyOptions used by a client to customize the driver's underlying Netty layer.nettyOptions - the NettyOptions used by the new cluster.public void setLoadBalancingPolicy(com.datastax.driver.core.policies.LoadBalancingPolicy loadBalancingPolicy)
LoadBalancingPolicy that decides which Cassandra hosts to contact for each new query.loadBalancingPolicy - the LoadBalancingPolicy used by the new cluster.public void setReconnectionPolicy(com.datastax.driver.core.policies.ReconnectionPolicy reconnectionPolicy)
ReconnectionPolicy that decides how often the reconnection to a dead node is attempted.reconnectionPolicy - the ReconnectionPolicy used by the new cluster.public void setRetryPolicy(com.datastax.driver.core.policies.RetryPolicy retryPolicy)
RetryPolicy that defines a default behavior to adopt when a request fails.retryPolicy - the RetryPolicy used by the new cluster.public void setMetricsEnabled(boolean metricsEnabled)
DEFAULT_METRICS_ENABLED.public void setKeyspaceCreations(List<CreateKeyspaceSpecification> specifications)
List of create keyspace specifications that are executed when
this factory is initialized. Create keyspace
specifications are executed on a system session with no keyspace set, before executing
setStartupScripts(List).specifications - the List of create keyspace specifications.public List<CreateKeyspaceSpecification> getKeyspaceCreations()
List of create keyspace specifications.public void setKeyspaceDrops(List<DropKeyspaceSpecification> specifications)
List of drop keyspace specifications that are executed when this
factory is destroyed. Drop keyspace specifications are
executed on a system session with no keyspace set, before executing setShutdownScripts(List).specifications - the List of drop keyspace specifications.public List<DropKeyspaceSpecification> getKeyspaceDrops()
List of drop keyspace specifications.public void setStartupScripts(List<String> scripts)
List of raw CQL statements that are executed when this factory is
initialized. Scripts are executed on a system session with no keyspace set, after
executing setKeyspaceCreations(List).scripts - the scripts to execute on startuppublic void setShutdownScripts(List<String> scripts)
List of raw CQL statements that are executed when this factory is destroyed. Drop keyspace specifications are executed on a system session with no
keyspace set, after executing setKeyspaceDrops(List).scripts - the scripts to execute on shutdownpublic void setKeyspaceSpecifications(Set<KeyspaceActionSpecification<?>> keyspaceSpecifications)
keyspaceSpecifications - The KeyspaceActionSpecification to set.public Set<KeyspaceActionSpecification<?>> getKeyspaceSpecifications()
KeyspaceActionSpecification associated with this factory.public void setUsername(String username)
PlainTextAuthProvider.username - The username to set.public void setPassword(String password)
PlainTextAuthProvider.password - The password to set.public void setJmxReportingEnabled(boolean jmxReportingEnabled)
DEFAULT_JMX_REPORTING_ENABLED.jmxReportingEnabled - The jmxReportingEnabled to set.public void setSslEnabled(boolean sslEnabled)
DEFAULT_SSL_ENABLED.sslEnabled - The sslEnabled to set.public void setSslOptions(com.datastax.driver.core.SSLOptions sslOptions)
sslOptions - The sslOptions to set.public void setHostStateListener(com.datastax.driver.core.Host.StateListener hostStateListener)
hostStateListener - The hostStateListener to set.public void setLatencyTracker(com.datastax.driver.core.LatencyTracker latencyTracker)
latencyTracker - The latencyTracker to set.public void setAddressTranslator(com.datastax.driver.core.policies.AddressTranslator addressTranslator)
addressTranslator - AddressTranslator used by the new cluster.Cluster.Builder.withAddressTranslator(AddressTranslator),
AddressTranslatorpublic void setClusterBuilderConfigurer(ClusterBuilderConfigurer clusterBuilderConfigurer)
ClusterBuilderConfigurer used to apply additional configuration logic to the
Cluster.Builder. ClusterBuilderConfigurer is invoked after all provided
options are configured. The factory will Cluster.Builder.build() the Cluster after applying
ClusterBuilderConfigurer.clusterBuilderConfigurer - ClusterBuilderConfigurer used to configure the
Cluster.Builder.ClusterBuilderConfigurerpublic void setClusterName(String clusterName)
clusterName - optional name for the cluster.Cluster.Builder.withClusterName(String)public void setMaxSchemaAgreementWaitSeconds(int seconds)
seconds - max schema agreement wait in seconds.Cluster.Builder.withMaxSchemaAgreementWaitSeconds(int)public void setSpeculativeExecutionPolicy(com.datastax.driver.core.policies.SpeculativeExecutionPolicy speculativeExecutionPolicy)
speculativeExecutionPolicy - SpeculativeExecutionPolicy to use with the new cluster.Cluster.Builder.withSpeculativeExecutionPolicy(SpeculativeExecutionPolicy),
SpeculativeExecutionPolicypublic void setTimestampGenerator(com.datastax.driver.core.TimestampGenerator timestampGenerator)
timestampGenerator - TimestampGenerator used to produce a client-side timestamp
sent with each query.Cluster.Builder.withTimestampGenerator(TimestampGenerator),
TimestampGeneratorCopyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.