public class CassandraResourceManager extends TestContainerResourceManager<GenericContainer<?>> implements org.apache.beam.it.common.ResourceManager
The class supports one database and multiple collections per database object. A database is created when the first collection is created if one has not been created already.
The database name is formed using testId. The database name will be "{testId}-{ISO8601 time, microsecond precision}", with additional formatting.
The class is thread-safe.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
CassandraResourceManager.Builder
Builder for  
CassandraResourceManager. | 
HOST_IP, port| Modifier and Type | Method and Description | 
|---|---|
static CassandraResourceManager.Builder | 
builder(java.lang.String testId)  | 
void | 
cleanupAll()
Deletes all created resources (VM's, etc.) and stops the container, making the manager object
 unusable. 
 | 
com.datastax.oss.driver.api.core.cql.ResultSet | 
executeStatement(java.lang.String statement)
Execute the given statement on the managed keyspace. 
 | 
java.lang.String | 
getKeyspaceName()
Returns the name of the Database that this Cassandra manager will operate in. 
 | 
int | 
getPort()
Returns the port to connect to the Cassandra Database. 
 | 
boolean | 
insertDocument(java.lang.String tableName,
              java.util.Map<java.lang.String,java.lang.Object> document)
Inserts the given Document into a table. 
 | 
boolean | 
insertDocuments(java.lang.String tableName,
               java.util.List<java.util.Map<java.lang.String,java.lang.Object>> documents)
Inserts the given Documents into a collection. 
 | 
java.lang.Iterable<com.datastax.oss.driver.api.core.cql.Row> | 
readTable(java.lang.String tableName)
Reads all the Documents in a collection. 
 | 
getDockerImageName, getHost, getPortpublic static CassandraResourceManager.Builder builder(java.lang.String testId)
public int getPort()
public java.lang.String getKeyspaceName()
public com.datastax.oss.driver.api.core.cql.ResultSet executeStatement(java.lang.String statement)
statement - The statement to execute.public boolean insertDocument(java.lang.String tableName,
                              java.util.Map<java.lang.String,java.lang.Object> document)
A database will be created here, if one does not already exist.
tableName - The name of the table to insert the document into.document - The document to insert into the table.public boolean insertDocuments(java.lang.String tableName,
                               java.util.List<java.util.Map<java.lang.String,java.lang.Object>> documents)
                        throws CassandraResourceManagerException
Note: Implementations may do collection creation here, if one does not already exist.
tableName - The name of the collection to insert the documents into.documents - A list of documents to insert into the collection.CassandraResourceManagerException - if there is an error inserting the documents.public java.lang.Iterable<com.datastax.oss.driver.api.core.cql.Row> readTable(java.lang.String tableName)
                                                                       throws CassandraResourceManagerException
tableName - The name of the collection to read from.CassandraResourceManagerException - if there is an error reading the collection.public void cleanupAll()
TestContainerResourceManagercleanupAll in interface org.apache.beam.it.common.ResourceManagercleanupAll in class TestContainerResourceManager<GenericContainer<?>>