public class CassandraBuilder extends Object
Cassandra.
This class is not thread safe and should not be shared across different threads!
build(),
CassandraBuilderConfigurator| Modifier and Type | Field and Description |
|---|---|
static Version |
DEFAULT_VERSION
Default Cassandra version.
|
| Constructor and Description |
|---|
CassandraBuilder() |
| Modifier and Type | Method and Description |
|---|---|
CassandraBuilder |
addConfigProperties(Map<String,?> configProperties)
Puts Cassandra config properties, that should be merged with properties from cassandra.yaml.
|
CassandraBuilder |
addConfigProperty(String name,
Object value)
Puts Cassandra config property, that should be merged with a property from cassandra.yaml.
|
CassandraBuilder |
addEnvironmentVariable(String name,
Object value)
Puts Cassandra environment variable.
|
CassandraBuilder |
addEnvironmentVariables(Map<String,?> environmentVariables)
Puts Cassandra environment variables.
|
CassandraBuilder |
addJvmOptions(Collection<String> jvmOptions)
Adds Cassandra native Java Virtual Machine (JVM) Options.
|
CassandraBuilder |
addJvmOptions(String... jvmOptions)
Adds Cassandra native Java Virtual Machine (JVM) Options.
|
CassandraBuilder |
addSystemProperties(Map<String,?> systemProperties)
Puts Cassandra native Java Virtual Machine (JVM) system parameters.
|
CassandraBuilder |
addSystemProperty(String name,
Object value)
Puts Cassandra native Java Virtual Machine (JVM) system parameter, For example:
|
CassandraBuilder |
addWorkingDirectoryCustomizers(Collection<? extends WorkingDirectoryCustomizer> workingDirectoryCustomizers)
Adds the
WorkingDirectoryCustomizer. |
CassandraBuilder |
addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer... workingDirectoryCustomizers)
Adds the
WorkingDirectoryCustomizer. |
CassandraBuilder |
addWorkingDirectoryResource(Resource resource,
String path)
Copy a resource to a target path within the working directory.
|
Cassandra |
build()
Build a new
Cassandra instance. |
CassandraBuilder |
configFile(Resource configFile)
Sets the Cassandra configuration file.
|
CassandraBuilder |
configProperties(Map<String,?> configProperties)
Sets Cassandra config properties, that should be merged with properties from cassandra.yaml.
|
CassandraBuilder |
configure(CassandraBuilderConfigurator configurator)
Applies the provided configurator to this builder.
|
CassandraBuilder |
environmentVariables(Map<String,?> environmentVariables)
Sets Cassandra environment variables.
|
String |
getName()
Gets current configured Cassandra instance name.
|
Version |
getVersion()
Gets current configured Cassandra version or
DEFAULT_VERSION. |
CassandraBuilder |
jvmOptions(Collection<String> jvmOptions)
Sets Cassandra native Java Virtual Machine (JVM) Options.
|
CassandraBuilder |
jvmOptions(String... jvmOptions)
Sets Cassandra native Java Virtual Machine (JVM) Options.
|
CassandraBuilder |
logger(Logger logger)
Sets the Cassandra logger.
|
CassandraBuilder |
name(String name)
Sets the Cassandra instance name.
|
CassandraBuilder |
registerShutdownHook(boolean registerShutdownHook)
Sets if the created
Cassandra should have a shutdown hook registered. |
CassandraBuilder |
startupTimeout(Duration startupTimeout)
Sets the startup timeout.
|
CassandraBuilder |
systemProperties(Map<String,?> systemProperties)
Sets Cassandra native Java Virtual Machine (JVM) system parameters.
|
CassandraBuilder |
version(String version)
Sets the Cassandra version.
|
CassandraBuilder |
version(Version version)
Sets the Cassandra version.
|
CassandraBuilder |
workingDirectory(IOSupplier<? extends Path> workingDirectorySupplier)
Set the
Supplier of the working directory that should be called each time when build() is
called. |
CassandraBuilder |
workingDirectoryCustomizers(Collection<? extends WorkingDirectoryCustomizer> workingDirectoryCustomizers)
Sets the
WorkingDirectoryCustomizer. |
CassandraBuilder |
workingDirectoryCustomizers(WorkingDirectoryCustomizer... workingDirectoryCustomizers)
Sets the
WorkingDirectoryCustomizer. |
CassandraBuilder |
workingDirectoryDestroyer(WorkingDirectoryDestroyer workingDirectoryDestroyer)
Sets the
WorkingDirectoryDestroyer. |
CassandraBuilder |
workingDirectoryInitializer(WorkingDirectoryInitializer workingDirectoryInitializer)
Sets the
WorkingDirectoryInitializer. |
public static final Version DEFAULT_VERSION
public CassandraBuilder name(String name)
Defaults to cassandra-0, cassandra-1, and so on.
name - the Cassandra namepublic String getName()
nullpublic CassandraBuilder version(String version)
Defaults to DEFAULT_VERSION
version - the Cassandra versionpublic CassandraBuilder version(Version version)
Defaults to DEFAULT_VERSION
version - the Cassandra versionpublic Version getVersion()
DEFAULT_VERSION.nullpublic CassandraBuilder logger(Logger logger)
Defaults to Logger.get(Cassandra.class)
logger - the Cassandra loggerpublic CassandraBuilder registerShutdownHook(boolean registerShutdownHook)
Cassandra should have a shutdown hook registered.
Defaults to true.
registerShutdownHook - true if shutdown hook should be registered, otherwise falsepublic CassandraBuilder startupTimeout(Duration startupTimeout)
Defaults to 2 minutes.
startupTimeout - the startup timeoutpublic CassandraBuilder configFile(Resource configFile)
Equal to:
addSystemProperty("cassandra.config", configFile);
configFile - the config filepublic CassandraBuilder workingDirectory(IOSupplier<? extends Path> workingDirectorySupplier)
Supplier of the working directory that should be called each time when build() is
called.
The supplied directory will be initialized by WorkingDirectoryInitializer and used as Cassandra home directory.
In the end, provided working directory may be deleted or partly deleted by WorkingDirectoryDestroyer.
Defaults to Files.createTempDirectory("")
workingDirectorySupplier - the working directory supplierIOSupplier.wrap(Supplier)public CassandraBuilder workingDirectoryInitializer(WorkingDirectoryInitializer workingDirectoryInitializer)
WorkingDirectoryInitializer.
Defaults to DefaultWorkingDirectoryInitializer with the
underlying WebCassandraDirectoryProvider.
workingDirectoryInitializer - the working directory initializerDefaultWorkingDirectoryInitializerpublic CassandraBuilder workingDirectoryDestroyer(WorkingDirectoryDestroyer workingDirectoryDestroyer)
WorkingDirectoryDestroyer.
Defaults to
WorkingDirectoryDestroyer.deleteOnly("bin", "pylib", "lib", "tools", "doc", "javadoc", "interface")
workingDirectoryDestroyer - the working directory destroyerWorkingDirectoryDestroyer.doNothing(),
WorkingDirectoryDestroyer.deleteOnly(String...),
WorkingDirectoryDestroyer.deleteAll()public CassandraBuilder workingDirectoryCustomizers(WorkingDirectoryCustomizer... workingDirectoryCustomizers)
WorkingDirectoryCustomizer. Setting this value will replace any previously configured
customizers.workingDirectoryCustomizers - the working directory customizers to setWorkingDirectoryCustomizer.addResource(Resource, String),
workingDirectoryCustomizers(Collection),
addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer...),
addWorkingDirectoryCustomizers(Collection)public CassandraBuilder workingDirectoryCustomizers(Collection<? extends WorkingDirectoryCustomizer> workingDirectoryCustomizers)
WorkingDirectoryCustomizer. Setting this value will replace any previously configured
customizers.workingDirectoryCustomizers - the working directory customizers to setWorkingDirectoryCustomizer.addResource(Resource, String),
workingDirectoryCustomizers(WorkingDirectoryCustomizer...),
addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer...),
addWorkingDirectoryCustomizers(Collection)public CassandraBuilder addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer... workingDirectoryCustomizers)
WorkingDirectoryCustomizer.workingDirectoryCustomizers - the working directory customizers to addWorkingDirectoryCustomizer.addResource(Resource, String),
addWorkingDirectoryCustomizers(Collection),
workingDirectoryCustomizers(WorkingDirectoryCustomizer...),
workingDirectoryCustomizers(Collection)public CassandraBuilder addWorkingDirectoryCustomizers(Collection<? extends WorkingDirectoryCustomizer> workingDirectoryCustomizers)
WorkingDirectoryCustomizer.workingDirectoryCustomizers - the working directory customizers to addWorkingDirectoryCustomizer.addResource(Resource, String),
addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer...),
workingDirectoryCustomizers(WorkingDirectoryCustomizer...),
workingDirectoryCustomizers(Collection)public CassandraBuilder environmentVariables(Map<String,?> environmentVariables)
Map<String,Object> environmentVariables = new LinkedHashMap<>();
environmentVariables.put("TZ", "Europe/London");
builder.environmentVariables(environmentVariables);
environmentVariables - Cassandra environment variablesaddEnvironmentVariable(String, Object),
addEnvironmentVariables(Map)public CassandraBuilder addEnvironmentVariable(String name, Object value)
builder.addEnvironmentVariable("TZ", "Europe/London");
name - Cassandra environment variable namevalue - Cassandra environment variable valueaddEnvironmentVariables(Map),
environmentVariables(Map)public CassandraBuilder addEnvironmentVariables(Map<String,?> environmentVariables)
Map<String,Object> environmentVariables = new LinkedHashMap<>();
environmentVariables.put("TZ", "Europe/London");
builder.addEnvironmentVariables(environmentVariables);
environmentVariables - Cassandra environment variablesaddEnvironmentVariable(String, Object),
environmentVariables(Map)public CassandraBuilder systemProperties(Map<String,?> systemProperties)
Map<String,Object> systemProperties = new LinkedHashMap<>();
systemProperties.put("cassandra.config", new ClassPathResource("cassandra.yaml"));
systemProperties.put("cassandra.native_transport_port", 9042);
systemProperties.put("cassandra.jmx.local.port", 7199);
builder.systemProperties(systemProperties);
systemProperties - Cassandra system parametersaddSystemProperty(String, Object)public CassandraBuilder addSystemProperty(String name, Object value)
addSystemProperty("cassandra.config",new ClassPathResource("cassandra.yaml"))
addSystemProperty("user.timezone","Europe/London").
name - Cassandra system parameter namevalue - Cassandra system parameter valueaddSystemProperties(Map)public CassandraBuilder addSystemProperties(Map<String,?> systemProperties)
Map<String,Object> systemProperties = new LinkedHashMap<>();
systemProperties.put("cassandra.config", new ClassPathResource("cassandra.yaml"));
systemProperties.put("cassandra.native_transport_port", 9042);
systemProperties.put("cassandra.jmx.local.port", 7199);
builder.addSystemProperties(systemProperties);
systemProperties - Cassandra system parametersaddSystemProperty(String, Object)public CassandraBuilder jvmOptions(String... jvmOptions)
jvmOptions - the JVM options to setjvmOptions(Collection),
addJvmOptions(Collection),
addJvmOptions(String...)public CassandraBuilder jvmOptions(Collection<String> jvmOptions)
jvmOptions - the JVM options to setjvmOptions(Collection),
addJvmOptions(Collection),
addJvmOptions(String...)public CassandraBuilder addJvmOptions(String... jvmOptions)
jvmOptions - the JVM options to addaddJvmOptions(Collection),
jvmOptions(Collection),
jvmOptions(String...)public CassandraBuilder addJvmOptions(Collection<String> jvmOptions)
jvmOptions - the JVM options to addaddJvmOptions(String...),
jvmOptions(Collection),
jvmOptions(String...)public CassandraBuilder configProperties(Map<String,?> configProperties)
Map<String,Object> properties = new LinkedHashMap<>();
properties.put("client_encryption_options.enabled", true);
properties.put("cluster_name", "MyCluster");
builder.configProperties(properties);
Output Yaml:
...
cluster_name: "MyCluster"
client_encryption_options:
enabled: true
...
...
configProperties - Cassandra config propertiesaddConfigProperty(String, Object),
addConfigProperties(Map)public CassandraBuilder addConfigProperty(String name, Object value)
builder.configProperty("client_encryption_options.enabled",true)
.configProperty("cluster_name","MyCluster")
Output Yaml:
...
cluster_name: "MyCluster"
client_encryption_options:
enabled: true
...
...
name - config property name (e.g. native_transport_port, client_encryption_options.enabled)value - config property valueaddConfigProperties(Map),
configProperties(Map)public CassandraBuilder addConfigProperties(Map<String,?> configProperties)
Map<String,Object> properties = new LinkedHashMap<>();
properties.put("client_encryption_options.enabled", true);
properties.put("cluster_name", "MyCluster");
builder.configProperties(properties);
Output Yaml:
...
cluster_name: "MyCluster"
client_encryption_options:
enabled: true
...
...
configProperties - Cassandra config propertiesaddConfigProperty(String, Object),
configProperties(Map)public CassandraBuilder addWorkingDirectoryResource(Resource resource, String path)
Equal to:
addWorkingDirectoryCustomizers(WorkingDirectoryCustomizer.addResource(resource, path));
path - path (file only) within the working directory (e.g conf/cassandra.yaml)resource - the resourceWorkingDirectoryCustomizer.addResource(Resource, String)public CassandraBuilder configure(CassandraBuilderConfigurator configurator)
configurator - configurator to useSimpleSeedProviderConfiguratorCopyright © 2023. All rights reserved.