Commit Graph

129 Commits

Author SHA1 Message Date
Mark Paluch
9679506278 DATACASS-439 - Polishing.
Refactor static converter instances to enum types with a single instance.
2017-04-26 13:59:35 +02:00
Mark Paluch
69e4ddd3cc DATACASS-439 - Remove deprecated types and members.
Removal of deprecated and obsolete types and members. Listeners became obsolete by providing AsynCqlTemplate/AsyncCassandraTemplate as async operations return futures that allow synchronization. Other types are not used anymore.
2017-04-26 13:45:08 +02:00
Mark Paluch
b5763bc696 DATACASS-434 - Remove own ConsistencyLevel and RetryPolicy types.
Remove own ConsistencyLevel and RetryPolicy types in favor of driver types.
2017-04-26 13:30:38 +02:00
Mark Paluch
41dc6e739f DATACASS-430 - Polishing.
Move off deprecated API usage in tests.
2017-04-19 14:25:16 +02:00
Mark Paluch
dd697dff26 DATACASS-430 - Adopt changed Mono and Flux error handling API.
Replace Flux/Mono.onErrorResumeWith(…) with Flux/Mono.onErrorMap(…) and turn translateException into a method returning a mapping function instead of a Mono emitting the mapped exception.
2017-04-19 14:25:16 +02:00
Mark Paluch
352dfd6879 DATACASS-431 - Disable tests for ALTER TYPE support on Apache Cassandra 3.10.
Apache Cassandra does not allow altering column/field types since version 3.10. We don't run these tests anymore for version 3.10 and later.
2017-04-19 14:24:59 +02:00
Mark Paluch
0ff0f2348b DATACASS-429 - Assert compatibility with Duration type.
We now test compatibility with Apache Cassandra's duration type (introduced with Apache Cassandra 3.10). Duration requires a driver version >= 3.2.0 so we drop build profiles against earlier driver versions and use Apache Cassandra 3.10 for integration tests.
2017-04-19 14:24:59 +02:00
Mark Paluch
dfc53b635a DATACASS-424 - Upgrade to Cassandra driver 3.2.0.
Enforce frozen user types in collection types when creating tables and frozen user types when referencing a user type from another type. Previously, the driver returned frozen user-types and no interaction from our side was required. Move user-type specifics to UserTypeUtil.

Introduce compatibility code within the tests to build against different driver versions.
2017-04-19 14:24:59 +02:00
Mark Paluch
6c9c65e04d DATACASS-427 - Upgrade to Reactor 3.1.0.
Migrate off removed Mono.then(…)/Mono.flatMap(…) methods to Mono.flatMap(…)/flatMapMany(…).
2017-04-12 08:50:07 +02:00
Mark Paluch
455d3f82fc DATACASS-419 - Remove unused dependency declarations.
Remove el-api and cdi-api from Spring CQL. Remove jsr250-api, el-api, validation-api and hibernate-validator from Spring Data Cassandra.
2017-03-24 14:56:34 +01:00
Mark Paluch
acbb3ba5f9 DATACASS-368 - Migrate reactive tests from TestSubscriber to StepVerifier.
Replace TestSubscriber and .block() calls in test with StepVerifier.
2017-03-24 14:38:56 +01:00
Mark Paluch
8597589ce3 DATACASS-389 - Reformat and reorganize imports. 2017-03-24 09:18:40 +01:00
Oliver Gierke
01e0372905 DATACASS-389 - Adapt to API changes after Mockito 2.7 upgrade. 2017-03-24 09:18:40 +01:00
Mark Paluch
49bbd872d5 DATACASS-389 - Java 8 cleanup.
Add deprecations. Remove unused classes. Replace explicit type arguments with diamond operator. Replace imperative for-loops with stream/forEach (functional approach). Replace anonymous inner classes with lambdas. Replace <code>…</code> with {@code}.
2017-03-24 09:18:39 +01:00
Mark Paluch
e69a17e6d6 DATACASS-389 - Adopt Spring Data Commons changes. 2017-03-24 09:18:39 +01:00
Mark Paluch
dc866df2d2 DATACASS-417 - Allow configuration of cql-template-ref for cassandra:template elements.
We now support configuration of a CqlTemplate reference when creating CassandraTemplate via XML namespace configuration. Configuring a reference allows reusing an existing CqlOperations instance via CassandraTemplateFactoryBean. Additionally, CassandraTemplateFactoryBean now supports setting a SessionFactory.

	<cql:template id="my-cql-template" />
	<cassandra:template cql-template-ref="my-cql-template"/>
2017-03-15 14:23:01 +01:00
Mark Paluch
690ebe5c99 DATACASS-402 - Extend exception translation for exceptions that map currently to CassandraUncategorizedException.
We now provide a more fine-grained exception translation for exceptions that previously mapped to CassandraUncategorizedException. Existing translation to more specific exception does not change. The following translation rules are introduced by this change:

* OverloadedException and BootstrappingException map to TransientDataAccessResourceException
* NoHostAvailableException, BusyPoolException, ConnectionException, BusyConnectionException map to CassandraConnectionFailureException
* QueryConsistencyException, FunctionExecutionException map to DataAccessResourceFailureException
2017-02-28 15:21:38 +01:00
John Blum
d0982dc119 DATACASS-330 - Review and apply additional polish. 2017-02-06 19:04:32 -08:00
Mark Paluch
4df8fd1fce DATACASS-330 - Polishing.
Move Reactive Session support to session package. Reorder fields according their visibility.
2017-02-06 19:04:25 -08:00
Mark Paluch
22e6e9ae9f DATACASS-330 - Add Session routing.
We now support Session routing with AbstractRoutingSessionFactory. Session routing is based on a map, keyed by a lookup key that is supplied by an implementing class upon Session lookup.

Extend JavaConfig to configure a SessionFactory bean and configure CqlTemplate and CassandraAdminTemplate accordingly.
2017-02-06 19:04:18 -08:00
Mark Paluch
68d61461cd DATACASS-330 - Add SessionFactory to CqlTemplate and AsyncCqlTemplate.
We now support SessionFactory to obtain Cassandra Session's on a per-request basis. CassandraAccessor is configured primarily with a SessionFactory now, the existing initialization configures a DefaultSessionFactory that returns the initially given Session instance.

Sessions should not be acquired directly by getSession but inside a callback-block so it's guaranteed to operate on the same session within a particular operation. That's especially relevant when preparing and executing prepared statements.

PreparedStatementCallback was changed in a breaking way as it now accepts additionally a Session to retain the session context.

Related ticket: DATACASS-32
2017-02-06 19:04:09 -08:00
Mark Paluch
7e33bf3bcf DATACASS-393 - Polishing.
Add override comments. Fix JavaDoc. Reformat code.
2017-02-01 11:54:12 +01:00
Mark Paluch
bc5262d633 DATACASS-393 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message.

Related ticket: SPR-15196.
2017-02-01 11:44:02 +01:00
Mark Paluch
fff664393e DATACASS-290 - Polishing.
Align declared type of CassandraCqlTemplateFactoryBean to CqlTemplate and the type of CassandraTemplateFactoryBean to CassandraTemplate to report consistent bean types. Add JavaDoc.

Original pull request: #76.
2017-01-25 10:28:17 +01:00
Mark Paluch
48c6240c9f DATACASS-388 - Improve JavaDoc for configuration classes. 2017-01-20 11:02:29 +01:00
Mark Paluch
7563e9b27e DATACASS-381 - Improve integration test stability.
Reuse Thread pools during integration test runs to not recreate and dispose Threads multiple times. Increase build and Cassandra memory. Use an external Cassandra instance for TravisCI build jobs.
2017-01-20 09:43:40 +01:00
Mark Paluch
b247181a34 DATACASS-385 - Migrate ticket references in test code to Spring Framework style. 2017-01-11 12:06:50 +01:00
Mark Paluch
cc00fe735b DATACASS-379 - Add package documentation. 2017-01-03 09:18:55 +01:00
John Blum
8ec905c442 DATACASS-360 - Polish. 2016-11-29 20:15:20 -08:00
Mark Paluch
3b717be06a DATACASS-351 - Revert Spring Data Cassandra 1.5 changes in 1.0 schema files.
Revert added features in version 1.0 schema files in favor of version 1.5 schema files. Remove license header. Remove TODOs and fix documentation source names.
2016-11-28 15:30:00 +01:00
John Blum
542ce24173 DATACASS-292 - Polish. 2016-11-22 21:59:58 -08:00
Mark Paluch
8af23880e9 DATACASS-292 - Provide revised synchronous and asynchronous CQL and Cassandra templates.
We now provide revised CQL and Cassandra templates as central classes to interact with CQL and Cassandra with object mapping. Previously, synchronous and asynchronous methods were exposed inside the same interfaces that made it hard to chose the right method.

The revised Template API consists of:

* CqlTemplate
* AsyncCqlTemplate
* CassandraTemplate
* AsyncCassandraTemplate

CassandraTemplate and AsyncCassandraTemplate reuse CqlTemplate and AsyncCqlTemplate instead of extending from these. This is, to not mix methods using conversion/object mapping with lower level CQL execution methods.

AsyncCqlTemplate and AsyncCassandraTemplate are all new and benefit from ListenableFuture as synchronization aid. They no longer rely on various callback-interfaces.

CassandraTemplate and AsyncCassandraTemplate no longer provide insert/update/delete methods accepting a collection of items. Use CassandraBatchOperations for atomic batches to group operations.
2016-11-22 21:59:47 -08:00
John Blum
1c7413bf1f DATACASS-335 - Polish. 2016-11-11 04:45:23 -08:00
Mark Paluch
e0741a8691 DATACASS-335 - Adopt changes in Spring Data Commons.
- Remove version placeholders for reactor and rxjava
- Adopt type migration of ReactiveWrappers
- Adopt RxJava to RxJava1 repository interface renaming
- Use ReactiveQueryMethod in ReactiveMongoQuery.
- Remove trailing whitespaces.
- Use ReflectionUtils for method iteration in ReactiveType.
2016-11-11 04:45:23 -08:00
Mark Paluch
52f4f570a9 DATACASS-335 - Add support for reactive data access.
We now support reactive data access with Spring Data Cassandra by adopting Datastax' asynchronous driver.

ReactiveCqlTemplate and ReactiveCassandraTemplate use Project Reactor wrapper types Mono and Flux to implement Template API and repository support. Reactive template supports common operations such as:

* Query/Execution methods for static CQL and prepared statements
* Insert/Save/Update/Delete methods
* Exists and Count projections
* Reactive Callback methods

Person person = new Person("Dave", 25);

template.insert(person) //
    .flatMap(p -> template.update(new Person("Sven", 25))) //
    .flatMap(p -> template.selectOneById(person.getId(), Person.class)) //
    .subscribeWith(TestSubscriber.create()) //
    .await() //
    .assertValuesWith(result -> {
        assertThat(result.getFirstName(), is(equalTo("Sven")));
    });

Reactive Repository support is built on top of ReactiveCassandraTemplate using ReactiveCassandraRepository as the store-specific base repository. Reactive repositories are enabled by using @EnableReactiveCassandraRepositories on a @Configuration class to opt-in for reactive support. Reactive repositories can be composed of a reactive base interface such as

* ReactiveCrudRepository
* ReactiveSortingRepository
* RxJava1CrudRepository
* RxJava1SortingRepository

and are identified as reactive repository if one method uses a reactive wrapper type (such as Flux or Observable). If a reactive repository is discovered, it's not implemented by the blocking repository support but with the reactive repository factory. Blocking methods are not (yet) synchronized when using a reactive repository so each repository method must use a reactive wrapper result type. Reactive repository support with Spring Data allows using RxJava1 and Project Reactor types to declare repository methods. Reactive wrapper types are internally converted so the composition library choice on repository level is left up to the user.

There's feature parity between Reactive Cassandra repository support and blocking repository support.

Feature overview:

* Query Methods using String queries and Query Derivation
* Projections

@Configuration
@EnableReactiveCassandraRepositories
class ApplicationConfig extends AbstractReactiveCassandraConfiguration {

  @Override
  protected String getKeyspaceName() {
    return "mykeyspace";
  }

  @Override
  protected String getEntityBasePackages() {
    return new String[] {"com.springdata.cassandra"};
  }
}

public interface PersonRepository extends ReactiveSortingRepository<Person, String> {

  Flux<Person> findByFirstname(String firstname);

  Flux<Person> findByFirstname(Publisher<String> firstname);

  Mono<Person> findByFirstnameAndLastname(String firstname, String lastname);
}

public interface PersonRepository extends RxJava1SortingRepository<Person, String> {

  Observable<Person> findByFirstname(String firstname);

  Observable<Person> findByFirstname(Single<String> firstname);

  Single<Person> findByFirstnameAndLastname(String firstname, String lastname);
}
2016-11-11 04:45:22 -08:00
John Blum
dcc34a284a DATACASS-172 - Polish. 2016-11-11 03:17:09 -08:00
Mark Paluch
cfa8a6177f DATACASS-172 - Support for UDTs.
We now support Cassandra User-defined types. UDTs can be created using CQL generators and used inside of mapped domain classes. User-defined types can be used either raw as UDTValue that is passed through or as mapped object. Mapped UDTs must be annotated with @UserDefinedType. Types are included into schema generation so known and defined UDTs are created before any tables are created. UDTs can be used with set and list collection types and in primary keys. UDTs can also be used in repository query methods as query predicates.
Updating UDTs will update the whole UDT.

@UserDefinedType
public class Address {
  String city;
  String country;
}

@Table
public class Person {

  @Id String id;
  Address address;
  UDTValue genericUdt;
}

The XML namespace support was extended with new schema versions to support provide a User Type resolver so UDTs can be resolved:

<cassandra:mapping>
  <cassandra:user-type-resolver keyspace-name="${cassandra.keyspace}" />
</cassandra:mapping>
2016-11-11 03:16:43 -08:00
Mark Paluch
84f680ee3e DATACASS-172 - Polishing.
Add tests. Add validations to Cql generators. Enhance JavaDoc. Create FieldSpecification for UDT fields.
2016-11-11 03:13:41 -08:00
Fabio Mendes
ac868d2f0a DATACASS-172 - Add CQL specifications/generators and UserDefinedType annotation. 2016-11-11 03:13:32 -08:00
Mark Paluch
8ff1f0e3fc DATACASS-333 - Switch tests to AssertJ. 2016-10-25 09:37:13 +02:00
Mark Paluch
6b683f4346 DATACASS-350 - Add since version to existing deprecations. 2016-10-24 12:17:20 +02:00
Mark Paluch
24ffba5d2f DATACASS-276 - Use Row.getObject(…) instead of deserialization with CodecRegistry and ProtocolVersion.
We now rely on Row.getObject(…) to retrieve data from a Cassandra Column. CodecRegistry and ProtocolVersion are configured on Cluster so there's no need to use a static configured CodecRegistry and ProtocolVersion that might not fit the configured values.
2016-10-12 14:42:06 +02:00
Mark Paluch
54c7ab6928 DATACASS-335 - Reuse Cluster connection resources during tests where possible.
High client churn seems to affect Cassandra in a negative way (connection timeouts, driver considers hosts as down). Almost all integration tests bootstrap their own Cluster instance and dispose it once the tests has finished. Identify tests where reuse of a global Cluster instance provided by CassandraRule is possible and switch from context bootstrapping to reuse. This helps to prevent integration test failures.
2016-10-12 14:11:51 +02:00
Mark Paluch
add4cab01b DATACASS-347 - Support NettyOptions configuration in XML-based configuration.
We now support `NettyOptions` bean references in XML-based configuration.

<bean id="nettyOptions" class="…" />

<cass:cluster contact-points="…" netty-options-ref="nettyOptions" />
2016-10-12 14:11:50 +02:00
Mark Paluch
45d77ff73e DATACASS-344 - Polishing.
Switch heartbeatIntervalSeconds, idleTimeoutSeconds and poolTimeoutMilliseconds to primitive integers and compare values against defaults to decide whether to set these properties on PoolingOptions.
2016-10-12 14:11:50 +02:00
Mark Paluch
071c101c28 DATACASS-344 - Upgrade Cassandra Driver to 3.1.1.
We are now compatible with Datastax’ Cassandra Driver 3.1.1 and support the newly introduced configuration options MaxQueueSize for PoolingOptions.

This change also removes test assertions for PoolTimeoutMillis as this option was deprecated and made unusable with 3.1.1.
2016-10-12 14:11:47 +02:00
Mark Paluch
b07c708c7c DATACASS-346 - Upgrade embedded Cassandra to 3.9. 2016-10-12 12:25:45 +02:00
John Blum
f293516ecd DATACASS-217 - Polish.
Original pull request: #82.
2016-08-29 16:10:19 -07:00
Mark Paluch
23cb654b18 DATACASS-217 - Add support for LZ4 compression.
Original pull request: #82.
2016-08-29 16:10:11 -07:00
John Blum
c407aad8cf DATACASS-328 - Polish.
Original pull request: #81.
2016-08-09 14:59:39 -07:00