Package uk.sky.cqlmigrate
Interface CqlMigrator
-
public interface CqlMigratorInterface for managing application schema changes in a synchronized fashion. The implementation classes are expected to implement some locking mechanism so that there are no concurrent schema modifications when multiple threads attempt to make the schema changes on the same cassandra keyspace.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclean(com.datastax.driver.core.Session session, java.lang.String keyspace)Drops keyspace if it existsvoidclean(java.lang.String[] hosts, int port, java.lang.String username, java.lang.String password, java.lang.String keyspace)Drops keyspace if it existsvoidmigrate(com.datastax.driver.core.Session session, java.lang.String keyspace, java.util.Collection<java.nio.file.Path> directories)If all nodes are up and a lock can be acquired this runs migration starting with bootstrap.cql and then the rest in alphabetical order.voidmigrate(java.lang.String[] hosts, int port, java.lang.String username, java.lang.String password, java.lang.String keyspace, java.util.Collection<java.nio.file.Path> directories)If all nodes are up and a lock can be acquired this runs migration starting with bootstrap.cql and then the rest in alphabetical order.
-
-
-
Method Detail
-
migrate
void migrate(java.lang.String[] hosts, int port, java.lang.String username, java.lang.String password, java.lang.String keyspace, java.util.Collection<java.nio.file.Path> directories)If all nodes are up and a lock can be acquired this runs migration starting with bootstrap.cql and then the rest in alphabetical order. If the migration fails for any reason, the lock will not be released and manual intervention is required to cleanup and fix the issue.- Parameters:
hosts- Comma separated list of cassandra hostsport- Native transport port for the above cassandra nodesusername- Username for Cassandra's internal authentication using PasswordAuthenticator (if using AllowAllAuthenticator, can be set to any value)password- Password for Cassandra's internal authentication using PasswordAuthenticator (if using AllowAllAuthenticator, can be set to any value)keyspace- Keyspace name for which the schema migration needs to be applieddirectories- Comma separated list of directory paths containing the cql statements for the schema change- Throws:
ClusterUnhealthyException- if any nodes are down or the schema is not in agreement before running migrationCannotAcquireLockException- if any of the queries to acquire lock fail orCassandraLockConfig.CassandraLockConfigBuilder.withTimeout(Duration)is reached before lock can be acquired.CannotReleaseLockException- if any of the queries to release lock failjava.lang.IllegalArgumentException- if any file types other than .cql are foundjava.lang.IllegalStateException- if cql file has changed after migration has been runcom.datastax.driver.core.exceptions.DriverException- if any of the migration queries fails
-
migrate
void migrate(com.datastax.driver.core.Session session, java.lang.String keyspace, java.util.Collection<java.nio.file.Path> directories)If all nodes are up and a lock can be acquired this runs migration starting with bootstrap.cql and then the rest in alphabetical order. If the migration fails for any reason, the lock will not be released and manual intervention is required to cleanup and fix the issue.- Parameters:
session- Session to a cassandra clusterkeyspace- Keyspace name for which the schema migration needs to be applieddirectories- Comma separated list of directory paths containing the cql statements for the schema change- Throws:
ClusterUnhealthyException- if any nodes are down or the schema is not in agreement before running migrationCannotAcquireLockException- if any of the queries to acquire lock fail orCassandraLockConfig.CassandraLockConfigBuilder.withTimeout(Duration)is reached before lock can be acquired.CannotReleaseLockException- if any of the queries to release lock failjava.lang.IllegalArgumentException- if any file types other than .cql are foundjava.lang.IllegalStateException- if cql file has changed after migration has been runcom.datastax.driver.core.exceptions.DriverException- if any of the migration queries fails
-
clean
void clean(java.lang.String[] hosts, int port, java.lang.String username, java.lang.String password, java.lang.String keyspace)Drops keyspace if it exists- Parameters:
hosts- Comma separated list of cassandra hostsport- Native transport port for the above cassandra nodesusername- Username for Cassandra's internal authentication using PasswordAuthenticator (if using AllowAllAuthenticator, can be set to any value)password- Password for Cassandra's internal authentication using PasswordAuthenticator (if using AllowAllAuthenticator, can be set to any value)keyspace- Keyspace name for which the schema migration needs to be applied- Throws:
com.datastax.driver.core.exceptions.DriverException- if query fails
-
clean
void clean(com.datastax.driver.core.Session session, java.lang.String keyspace)Drops keyspace if it exists- Parameters:
session- Session to a cassandra clusterkeyspace- Keyspace name for which the schema migration needs to be applied- Throws:
com.datastax.driver.core.exceptions.DriverException- if query fails
-
-