Skip to content

Commit

Permalink
cassandra config minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhi-mahawar committed Aug 24, 2022
1 parent 18e75c1 commit 67952ad
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/uci/dao/config/CassandraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.QueryLogger;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.AbstractReactiveCassandraConfiguration;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.config.SessionBuilderConfigurer;
import org.springframework.data.cassandra.core.cql.keyspace.CreateKeyspaceSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.DropKeyspaceSpecification;
import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceOption;
import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -73,6 +78,17 @@ protected List<CreateKeyspaceSpecification> getKeyspaceCreations() {
return Collections.singletonList(specification);
}

// @Override
// protected SessionBuilderConfigurer getSessionBuilderConfigurer() {
// return new SessionBuilderConfigurer() {
// @Override
// public CqlSessionBuilder configure(CqlSessionBuilder cqlSessionBuilder) {
// return cqlSessionBuilder
// .withConfigLoader(DriverConfigLoader.programmaticBuilder().withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(15000)).build());
// }
// };
// }

/**
* Get list of scripts run on startup
* @return
Expand All @@ -85,6 +101,10 @@ protected List<String> getStartupScripts() {
if (migrationCount > 0) {
count = migrationCount;
}
if(migrationCount > all.size()) {
count = all.size();
}
System.out.println("Count: "+count+", migrationCount: "+migrationCount);
} catch(NumberFormatException ex){
System.out.println("NumberFormatException: " + ex.getMessage());
} catch(Exception ex){
Expand Down Expand Up @@ -126,6 +146,7 @@ protected List<String> getMigrationScripts() {
allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD ownerId text;");
allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD botUuid uuid;");


// allScripts.add("CREATE INDEX IF NOT EXISTS message_state_index\n" +
// "ON "+keyspace
// +".XMessage ( KEYS ( messageState ) ) ");
Expand Down

0 comments on commit 67952ad

Please sign in to comment.