use of com.github.nosan.embedded.cassandra.Version in project embedded-cassandra by nosan.
the class CassandraExamples method workingDirectoryInitializer.
// end::start-shared-cassandra[]
private void workingDirectoryInitializer() {
// tag::working-directory-initializer[]
new CassandraBuilder().workingDirectoryInitializer(new WorkingDirectoryInitializer() {
@Override
public void init(Path workingDirectory, Version version) throws IOException {
// Custom logic
}
}).build();
// end::working-directory-initializer[]
// tag::working-directory-initializer-skip-existing[]
new CassandraBuilder().workingDirectoryInitializer(new DefaultWorkingDirectoryInitializer(new WebCassandraDirectoryProvider(), DefaultWorkingDirectoryInitializer.CopyStrategy.SKIP_EXISTING)).build();
// end::working-directory-initializer-skip-existing[]
}
use of com.github.nosan.embedded.cassandra.Version in project embedded-cassandra-spring-boot-starter by nosan.
the class EmbeddedCassandraAutoConfigurationTests method configureProperties.
@Test
void configureProperties() {
this.runner.withUserConfiguration(ExcludeCassandraBeanDefinitionRegistryPostProcessor.class).withPropertyValues("cassandra.embedded.config-file=classpath:cassandra.yaml", "cassandra.embedded.config-properties.start_rpc=true", "cassandra.embedded.environment-variables.JVM_OPTS=-Xmx512m", "cassandra.embedded.jvm-options=-Xmx256m", "cassandra.embedded.logger=MyLogger", "cassandra.embedded.version=3.11.3", "cassandra.embedded.name=MyCassandra", "cassandra.embedded.register-shutdown-hook=false", "cassandra.embedded.system-properties.cassandra.start_rpc=true", "cassandra.embedded.startup-timeout=1m", "cassandra.embedded.working-directory-resources.[conf/cassandra.yaml]=classpath:cassandra.yaml", "cassandra.embedded.working-directory=target/embeddedCassandra").withBean(CassandraBuilderConfigurator.class, () -> (builder) -> builder.addJvmOptions("-Xmx1024m")).run(context -> {
assertThat(context).hasSingleBean(CassandraBuilder.class);
Cassandra cassandra = context.getBean(CassandraBuilder.class).build();
assertThat(cassandra).hasFieldOrPropertyWithValue("databaseFactory.jvmOptions", new LinkedHashSet<>(Arrays.asList("-Xmx256m", "-Xmx1024m")));
assertThat(cassandra).hasFieldOrPropertyWithValue("logger", Logger.get("MyLogger"));
assertThat(cassandra).hasFieldOrPropertyWithValue("name", "MyCassandra");
assertThat(cassandra).hasFieldOrPropertyWithValue("version", Version.parse("3.11.3"));
assertThat(cassandra).hasFieldOrPropertyWithValue("registerShutdownHook", false);
assertThat(cassandra).hasFieldOrPropertyWithValue("startupTimeout", Duration.ofMinutes(1));
assertThat(cassandra).hasFieldOrPropertyWithValue("workingDirectory", Paths.get("target/embeddedCassandra").toAbsolutePath());
assertThat(cassandra).hasFieldOrPropertyWithValue("databaseFactory.environmentVariables", Collections.singletonMap("JVM_OPTS", "-Xmx512m"));
Map<String, Object> systemProperties = new LinkedHashMap<>();
systemProperties.put("cassandra.start_rpc", "true");
systemProperties.put("cassandra.config", new UrlResource(new ClassPathResource("cassandra.yaml").getURL()));
assertThat(cassandra).hasFieldOrPropertyWithValue("databaseFactory.systemProperties", systemProperties);
assertThat((Collection<?>) ReflectionTestUtils.getField(cassandra, "workingDirectoryCustomizers")).hasSize(1);
});
}
use of com.github.nosan.embedded.cassandra.Version in project esop by instaclustr.
the class AbstractBackupTest method inPlaceBackupRestoreTest.
public void inPlaceBackupRestoreTest(final String[][] arguments) throws Exception {
Cassandra cassandra = null;
try {
cassandra = getCassandra(cassandraDir, CASSANDRA_VERSION);
cassandra.start();
List<Long> insertionTimes;
try (CqlSession session = CqlSession.builder().build()) {
insertionTimes = populateDatabaseWithBackup(session, arguments);
assertEquals(insertionTimes.size(), NUMBER_OF_INSERTED_ROWS);
}
logger.info("Executing backup of commit logs {}", asList(arguments[3]));
Esop.mainWithoutExit(arguments[3]);
cassandra.stop();
// RESTORE VERIFICATION
cassandra = getCassandra(cassandraRestoredDir, CASSANDRA_VERSION, (workingDirectory, version) -> {
try {
FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data"));
FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data2"));
FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data3"));
} catch (final Exception ex) {
// ignore
}
restoreOnStoppedNode(insertionTimes, arguments);
});
cassandra.start();
waitForCql();
try (CqlSession session = CqlSession.builder().build()) {
dumpTableAndAssertRowCount(session, KEYSPACE, TABLE, NUMBER_OF_ROWS_AFTER_RESTORATION);
}
} finally {
if (cassandra != null) {
cassandra.stop();
}
deleteDirectory(Paths.get(target("commitlog_download_dir")));
FileUtils.deleteDirectory(cassandraDir);
FileUtils.deleteDirectory(cassandraRestoredDir);
}
}
Aggregations