@ConfigurationProperties(prefix="cassandra", ignoreUnknownFields=false) public class CassandraProperties extends Object implements InitializingBean
Configuration properties that provide the configuration for the
CassandraProvider
. This object is injected with properties having the
cassandra.*
prefix.
The following properties are supported by this configuration object:
cassandra.hosts
(see getHosts()
)cassandra.port
(see getPort()
,
setPort(int)
)cassandra.username
(see getUsername()
,
setUsername(String)
)cassandra.password
(see getPassword()
,
setPassword(String)
)cassandra.keyspace
(see getKeyspace()
,
setKeyspace(String)
)cassandra.useLocalConsistencyLevel
(see
isUseLocalConsistencyLevel()
,
setUseLocalConsistencyLevel(boolean)
)Instances of this class are safe for concurrent read access but are not safe for concurrent write access. Typically, this should not be a problem because an instance of this class is initialized once at application startup and then only used for read access.
Constructor and Description |
---|
CassandraProperties()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
List<String> |
getHosts()
Returns the list of hosts that are uses to discover the cluster topology
when initially connecting to the Cassandra cluster.
|
String |
getKeyspace()
Returns the name of the keyspace that is used by the Cassandra PV
Archiver.
|
String |
getPassword()
Returns the password that is used in combination with the username in
order to authenticate with the Cassandra cluster.
|
int |
getPort()
Returns the port number on which the Cassandra database servers listen.
|
String |
getUsername()
Returns the username used in combination with the password in order to
authenticate with the Cassandra cluster.
|
boolean |
isUseLocalConsistencyLevel()
Tells whether the
LOCAL_ variants of the consistency levels
shall be used. |
void |
setKeyspace(String keyspace)
Sets the name of the keyspace that is used by the Cassandra PV Archiver.
|
void |
setPassword(String password)
Sets the password that is used in combination with the username in order
to authenticate with the Cassandra cluster.
|
void |
setPort(int port)
Sets the port number on which the Cassandra database servers listen.
|
void |
setUseLocalConsistencyLevel(boolean useLocalConsistencyLevel)
Defines whether the
LOCAL_ variants of the consistency
levels shall be used. |
void |
setUsername(String username)
Sets the username used in combination with the password in order to
authenticate with the Cassandra cluster.
|
public CassandraProperties()
useLocalConsistencyLevel
to false
.public List<String> getHosts()
Returns the list of hosts that are uses to discover the cluster topology when initially connecting to the Cassandra cluster. Once the topology has been discovered, all servers in the cluster are used. However, it still makes sense to specify several servers so that the connection with the cluster can be established when one of the servers is down.
After initialization is complete ( afterPropertiesSet()
has been
called), the list returned by this method is read-only and attempts to
modify it will result in an UnsupportedOperationException
. Before
that, the list can be modified so that the property injection mechanism
provided by Spring can work.
This method never returns null
. After
afterPropertiesSet()
has been called, the list is guaranteed to
not contain any null
elements. If null elements have been
added to the list, afterPropertiesSet()
will throw a
NullPointerException
.
public String getKeyspace()
public void setKeyspace(String keyspace)
keyspace
- name of the keyspace that shall be used.NullPointerException
- if keyspace
is null
).public boolean isUseLocalConsistencyLevel()
LOCAL_
variants of the consistency levels
shall be used. One might want to use these variants if all archiver nodes
are operating in the same datacenter, but the Cassandra cluster has a
second datacenter that is used for replication (read-only). In this case,
the archiver can continue operation when the connection to the second
datacenter is interrupted. The default is false
.true
if the LOCAL_
variants of the
consistency levels should be used (e.g. LOCAL_QUORUM
instead of QUORUM
), false
if the
regular (global) consistency levels should be used.public void setUseLocalConsistencyLevel(boolean useLocalConsistencyLevel)
LOCAL_
variants of the consistency
levels shall be used. One might want to use these variants if all
archiver nodes are operating in the same datacenter, but the Cassandra
cluster has a second datacenter that is used for replication (read-only).
In this case, the archiver can continue operation when the connection to
the second datacenter is interrupted. The default is false
.useLocalConsistencyLevel
- true
if the LOCAL_
variants of the
consistency levels should be used (e.g.
LOCAL_QUORUM
instead of QUORUM
),
false
if the regular (global) consistency levels
should be used.public String getPassword()
null
(or the
empty string) if no password has been set.getUsername()
public void setPassword(String password)
password
- password used for authentication (or null
or the
empty string if no password is required).setUsername(String)
public int getPort()
public void setPort(int port)
port
- port number of the Cassandra database server(s).IllegalArgumentException
- if port
is less than 1 or greater than 65535.public String getUsername()
null
,
no authentication attempt is made and anonymous access is used. The
default is null
.null
(or the
empty string) if anonymous access shall be used.getPassword()
public void setUsername(String username)
null
,
no authentication attempt is made and anonymous access is used. The
default is null
.username
- username used for authentication or null
(or the
empty string) if anonymous access shall be used.setPassword(String)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
Copyright © 2011–2017 aquenos GmbH. All rights reserved.