Package org.codehaus.mojo.cassandra
Class AbstractCassandraMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.cassandra.AbstractCassandraMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractCqlExecMojo
,AbstractSchemaCassandraMojo
,CleanupCassandraMojo
,CompactCassandraMojo
,FlushCassandraMojo
,RepairCassandraMojo
,TruncateCassandraMojo
public abstract class AbstractCassandraMojo extends org.apache.maven.plugin.AbstractMojo
Base class for all the Cassandra Maven Plugin goals.- Author:
- stephenc
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
addMainClasspath
Adds the main classpath to cassandra (for example you could use this when you have a custom comparator on your main classpath.protected boolean
addTestClasspath
Adds the test classpath to cassandra (for example you could use this when you have a custom comparator on your test classpath.protected File
cassandraDir
The directory to hold cassandra's database.protected int
jmxPort
Port to listen to for the JMX interface.protected String
keyspace
The keyspace against which individual operations will be executedprotected String
listenAddress
Address to bind to and tell other Cassandra nodes to connect to.protected String
logLevel
Log level of cassandra process.protected int
maxMemory
Number of megabytes to limit the cassandra JVM to.protected int
nativeTransportPort
Port on which the CQL native transport listens for clients.protected org.apache.maven.project.MavenProject
project
The enclosing project.protected String
rpcAddress
Address to use for the RPC interface.protected org.apache.maven.execution.MavenSession
session
The current build session instance.protected boolean
skip
Skip the execution.protected boolean
startNativeTransport
Enable or disable the native transport server.protected String
stopKey
Key to be provided when stopping cassandraprotected int
stopPort
Port to listen to for receiving the stop command overprotected int
storagePort
Port to listen to for the Storage interface.protected Map<String,String>
systemPropertyVariables
List of System properties to pass to the JUnit tests.
-
Constructor Summary
Constructors Constructor Description AbstractCassandraMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createCassandraHome()
Creates the cassandra home directory.protected void
createCassandraHome(File cassandraDir, String listenAddress, String rpcAddress, BigInteger initialToken, String[] seeds)
Creates the cassandra home directory.protected void
createCassandraJar(File jarFile, String mainClass)
Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all classpath elements.protected void
createCassandraJar(File jarFile, String mainClass, File cassandraDir)
Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all classpath elements.protected Map<String,String>
createEnvironmentVars()
Creates the environment required when launching Cassandra or the CLI tools.protected org.apache.maven.toolchain.Toolchain
getToolchain()
Gets the Java toolchain.protected org.apache.commons.exec.CommandLine
newJavaCommandLine()
Create aCommandLine
to launch Java.protected org.apache.commons.exec.CommandLine
newNodetoolCommandLine(String... args)
Creates the command line to launch thenodetool
utility.protected org.apache.commons.exec.CommandLine
newServiceCommandLine()
Creates the command line to launch the cassandra server.protected org.apache.commons.exec.CommandLine
newServiceCommandLine(File cassandraDir, String listenAddress, String rpcAddress, BigInteger initialToken, String[] seeds, boolean jmxRemoteEnabled, int jmxPort)
Creates the command line to launch the cassandra server.protected boolean
useJdk11Options()
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
cassandraDir
@Parameter(defaultValue="${project.build.directory}/cassandra") protected File cassandraDir
The directory to hold cassandra's database.
-
project
@Parameter(readonly=true) protected org.apache.maven.project.MavenProject project
The enclosing project.
-
addTestClasspath
@Parameter(defaultValue="false") protected boolean addTestClasspath
Adds the test classpath to cassandra (for example you could use this when you have a custom comparator on your test classpath.
-
addMainClasspath
@Parameter(defaultValue="false") protected boolean addMainClasspath
Adds the main classpath to cassandra (for example you could use this when you have a custom comparator on your main classpath.
-
skip
@Parameter(property="cassandra.skip", defaultValue="false") protected boolean skip
Skip the execution.
-
session
@Parameter(defaultValue="${session}", required=true, readonly=true) protected org.apache.maven.execution.MavenSession session
The current build session instance. This is used for toolchain manager API calls.
-
rpcAddress
@Parameter(defaultValue="127.0.0.1", required=true) protected String rpcAddress
Address to use for the RPC interface. Do not change this unless you really know what you are doing.
-
jmxPort
@Parameter(property="cassandra.jmxPort", defaultValue="7199") protected int jmxPort
Port to listen to for the JMX interface.
-
nativeTransportPort
@Parameter(property="cassandra.nativeTransportPort", defaultValue="9042") protected int nativeTransportPort
Port on which the CQL native transport listens for clients.- Since:
- 2.0.0-1
-
startNativeTransport
@Parameter(property="cassandra.startNativeTransport", defaultValue="true") protected boolean startNativeTransport
Enable or disable the native transport server. Currently, only the Thrift server is started by default because the native transport is considered beta.- Since:
- 2.0.0-1
-
listenAddress
@Parameter(defaultValue="127.0.0.1") protected String listenAddress
Address to bind to and tell other Cassandra nodes to connect to. You must change this if you want multiple nodes to be able to communicate!
Leaving it blank leaves it up to InetAddress.getLocalHost(). This will always do the Right Thing if the node is properly configured (hostname, name resolution, etc), and the Right Thing is to use the address associated with the hostname (it might not be).
Setting this to 0.0.0.0 is always wrong. Do not change this unless you really know what you are doing.
-
storagePort
@Parameter(property="cassandra.storagePort", defaultValue="7000") protected int storagePort
Port to listen to for the Storage interface.
-
stopPort
@Parameter(property="cassandra.stopPort", defaultValue="8081") protected int stopPort
Port to listen to for receiving the stop command over
-
stopKey
@Parameter(property="cassandra.stopKey", defaultValue="cassandra-maven-plugin") protected String stopKey
Key to be provided when stopping cassandra
-
maxMemory
@Parameter(property="cassandra.maxMemory", defaultValue="512") protected int maxMemory
Number of megabytes to limit the cassandra JVM to.
-
keyspace
@Parameter(property="cassandra.keyspace") protected String keyspace
The keyspace against which individual operations will be executed
-
systemPropertyVariables
@Parameter protected Map<String,String> systemPropertyVariables
List of System properties to pass to the JUnit tests.- Since:
- 1.2.1-2
-
logLevel
@Parameter(defaultValue="ERROR") protected String logLevel
Log level of cassandra process. Logging is performed via log4j2.- Since:
- 3.5
-
-
Method Detail
-
createCassandraJar
protected void createCassandraJar(File jarFile, String mainClass) throws IOException
Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all classpath elements. Copied from surefire (ForkConfiguration#createJar())- Parameters:
jarFile
- The jar file to create/updatemainClass
- The main class to run.- Throws:
IOException
- if something went wrong.
-
useJdk11Options
protected boolean useJdk11Options()
-
createCassandraJar
protected void createCassandraJar(File jarFile, String mainClass, File cassandraDir) throws IOException
Create a jar with just a manifest containing a Main-Class entry for SurefireBooter and a Class-Path entry for all classpath elements. Copied from surefire (ForkConfiguration#createJar())- Parameters:
jarFile
- The jar file to create/updatemainClass
- The main class to run.- Throws:
IOException
- if something went wrong.
-
createCassandraHome
protected void createCassandraHome() throws IOException
Creates the cassandra home directory.- Throws:
IOException
- if something goes wrong.
-
createCassandraHome
protected void createCassandraHome(File cassandraDir, String listenAddress, String rpcAddress, BigInteger initialToken, String[] seeds) throws IOException
Creates the cassandra home directory.- Parameters:
cassandraDir
- the cassandra home directory.- Throws:
IOException
- if something goes wrong.
-
getToolchain
protected org.apache.maven.toolchain.Toolchain getToolchain()
Gets the Java toolchain.- Returns:
- the Java toolchain.
-
newJavaCommandLine
protected org.apache.commons.exec.CommandLine newJavaCommandLine()
Create aCommandLine
to launch Java.- Returns:
- a
CommandLine
to launch Java.
-
createEnvironmentVars
protected Map<String,String> createEnvironmentVars()
Creates the environment required when launching Cassandra or the CLI tools.- Returns:
- the environment required when launching Cassandra or the CLI tools.
-
newServiceCommandLine
protected org.apache.commons.exec.CommandLine newServiceCommandLine() throws IOException
Creates the command line to launch the cassandra server.- Returns:
- the command line to launch the cassandra server.
- Throws:
IOException
- if there are issues creating the cassandra home directory.
-
newServiceCommandLine
protected org.apache.commons.exec.CommandLine newServiceCommandLine(File cassandraDir, String listenAddress, String rpcAddress, BigInteger initialToken, String[] seeds, boolean jmxRemoteEnabled, int jmxPort) throws IOException
Creates the command line to launch the cassandra server.- Returns:
- the command line to launch the cassandra server.
- Throws:
IOException
- if there are issues creating the cassandra home directory.
-
newNodetoolCommandLine
protected org.apache.commons.exec.CommandLine newNodetoolCommandLine(String... args) throws IOException
Creates the command line to launch thenodetool
utility.- Parameters:
args
- the command line arguments to pass to thenodetool
utility.- Returns:
- the
CommandLine
to launchnodetool
with the supplied arguments. - Throws:
IOException
- if there are issues creating the cassandra home directory.
-
-