DATACASS-271 - Upgrade to Cassandra 3.0.

This commit adds support for Cassandra 3.x with upgrading to Datastax Driver 3.0.0. Data type deserialization is performed using the CodecRegistry.

Original pull request: #52.
Related ticket: DATACASS-169.
This commit is contained in:
Antoine Toulme
2016-04-27 23:57:09 -07:00
committed by John Blum
parent 27019f3218
commit a920b530df
18 changed files with 99 additions and 71 deletions

View File

@@ -193,7 +193,7 @@ class EmbeddedCassandraServerHelper {
CommitLog commitLog = CommitLog.instance;
commitLog.getContext(); // wait for commit log allocator instantiation to avoid hanging on a race condition
commitLog.resetUnsafe(); // cleanup screws w/ CommitLog, this brings it back to safe state
commitLog.resetUnsafe(true); // cleanup screws w/ CommitLog, this brings it back to safe state
}
private static void cleanup() throws IOException {

View File

@@ -47,11 +47,11 @@ public class CassandraCqlClusterFactoryBeanIntegrationTests extends AbstractEmbe
@Test
public void configuredProtocolVersionShouldBeSet() throws Exception {
cassandraCqlClusterFactoryBean.setProtocolVersion(ProtocolVersion.V2);
cassandraCqlClusterFactoryBean.setProtocolVersion(ProtocolVersion.V4);
cassandraCqlClusterFactoryBean.setPort(cassandraEnvironment.getPort());
cassandraCqlClusterFactoryBean.afterPropertiesSet();
assertEquals(ProtocolVersion.V2, getProtocolVersionEnum(cassandraCqlClusterFactoryBean));
assertEquals(ProtocolVersion.V4, getProtocolVersionEnum(cassandraCqlClusterFactoryBean));
}
@Test
@@ -68,6 +68,6 @@ public class CassandraCqlClusterFactoryBeanIntegrationTests extends AbstractEmbe
// initialize connection factory
cassandraCqlClusterFactoryBean.getObject().init();
return cassandraCqlClusterFactoryBean.getObject().getConfiguration().getProtocolOptions().getProtocolVersionEnum();
return cassandraCqlClusterFactoryBean.getObject().getConfiguration().getProtocolOptions().getProtocolVersion();
}
}

View File

@@ -18,6 +18,7 @@ package org.springframework.cassandra.test.integration.config.xml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Host.StateListener;
@@ -49,8 +50,13 @@ public class TestHostStateListener implements StateListener {
}
@Override
public void onSuspected(Host host) {
log.info("Host Suspected: " + host.getAddress());
public void onRegister(Cluster cluster) {
log.info("Cluster registered: " + cluster.getClusterName());
}
@Override
public void onUnregister(Cluster cluster) {
log.info("Cluster unregistered: " + cluster.getClusterName());
}
}

View File

@@ -18,6 +18,7 @@ package org.springframework.cassandra.test.integration.config.xml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.LatencyTracker;
import com.datastax.driver.core.Statement;
@@ -34,5 +35,13 @@ public class TestLatencyTracker implements LatencyTracker {
public void update(Host host, Statement statement, Exception exception, long newLatencyNanos) {
LOG.info("Latency Tracker: " + host.getAddress() + ", " + newLatencyNanos + " nanoseconds.");
}
@Override
public void onRegister(Cluster cluster) {
}
@Override
public void onUnregister(Cluster cluster) {
}
}

View File

@@ -19,8 +19,9 @@ import static org.junit.Assert.*;
import org.springframework.cassandra.core.keyspace.IndexDescriptor;
import com.datastax.driver.core.ColumnMetadata.IndexMetadata;
import com.datastax.driver.core.IndexMetadata;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.TableMetadata;
/**
* @author David Webb
@@ -29,15 +30,19 @@ import com.datastax.driver.core.Session;
public class CqlIndexSpecificationAssertions {
public static void assertIndex(IndexDescriptor expected, String keyspace, Session session) {
IndexMetadata imd = session.getCluster().getMetadata().getKeyspace(keyspace.toLowerCase())
.getTable(expected.getTableName().toCql()).getColumn(expected.getColumnName().toCql()).getIndex();
TableMetadata tableMetadata = session.getCluster().getMetadata().getKeyspace(keyspace.toLowerCase())
.getTable(expected.getTableName().toCql());
IndexMetadata imd = tableMetadata.getIndex(expected.getName().toCql());
assertEquals(expected.getName(), imd.getName());
assertEquals(expected.getName(), imd == null ? null : imd.getName());
}
public static void assertNoIndex(IndexDescriptor expected, String keyspace, Session session) {
IndexMetadata imd = session.getCluster().getMetadata().getKeyspace(keyspace.toLowerCase())
.getTable(expected.getTableName().toCql()).getColumn(expected.getColumnName().toCql()).getIndex();
TableMetadata tableMetadata = session.getCluster().getMetadata().getKeyspace(keyspace.toLowerCase())
.getTable(expected.getTableName().toCql());
IndexMetadata imd = tableMetadata.getIndex(expected.getName().toCql());
assertNull(imd);
}

View File

@@ -31,7 +31,7 @@ import org.springframework.cassandra.core.keyspace.TableOption;
import com.datastax.driver.core.ColumnMetadata;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.TableMetadata.Options;
import com.datastax.driver.core.TableOptionsMetadata;
/**
* @author Matthew T. Adams
@@ -70,7 +70,7 @@ public class CqlTableSpecificationAssertions {
assertColumns(expected.getPrimaryKeyColumns(), actual.getPrimaryKey());
}
public static void assertOptions(Map<String, Object> expected, Options actual) {
public static void assertOptions(Map<String, Object> expected, TableOptionsMetadata actual) {
for (String key : expected.keySet()) {
@@ -143,7 +143,7 @@ public class CqlTableSpecificationAssertions {
}
@SuppressWarnings("unchecked")
public static <T> T getOptionFor(TableOption option, Class<?> type, Options options) {
public static <T> T getOptionFor(TableOption option, Class<?> type, TableOptionsMetadata options) {
switch (option) {
case BLOOM_FILTER_FP_CHANCE:
return (T) (Double) options.getBloomFilterFalsePositiveChance();