diff --git a/src/main/java/com/uci/dao/config/CassandraConfig.java b/src/main/java/com/uci/dao/config/CassandraConfig.java index fb96a2d..b62f73d 100644 --- a/src/main/java/com/uci/dao/config/CassandraConfig.java +++ b/src/main/java/com/uci/dao/config/CassandraConfig.java @@ -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; @@ -73,6 +78,17 @@ protected List 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 @@ -85,6 +101,10 @@ protected List 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){ @@ -126,6 +146,7 @@ protected List 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 ) ) ");